Difference between revisions of "Templates"

From Legends of Aria Admin and Modding Wiki
Jump to: navigation, search
(Properties you can define in templates)
(Properties you can define in templates)
 
(31 intermediate revisions by the same user not shown)
Line 101: Line 101:
 
Data types are referenced by (type), e.g. (string), (number), (bool) or (XML tags)
 
Data types are referenced by (type), e.g. (string), (number), (bool) or (XML tags)
 
<br>They are NOT part of the final XML template.
 
<br>They are NOT part of the final XML template.
<br>Variable data you have to provide is referenced in angular brackets &lang:&rang; with example data inside.
+
<br>Variable data you have to provide is written in italics
<br>The angular brackets are NOT part of the final XML template.
+
<br>The pipe charcter "|" inside example data separates allowed values.
<br>The pipe charcter "|" inside the curly brackets separates allowed values.
+
<br>Tags which can have child tags are marked in <tt>'''bold''</tt>
 +
<br>The namespace (first line of the example file below) and the xmlns:xsi and xmlns:xsd attributes of the root tag are proper xml, but not needed for the function of the template.
  
{|class="wikitable" | style="width: 80%"
+
{|class="wikitable" | style="width: 90%"
! Property !! xml tag !! attributes !! content !! Parent Tag
+
! Property !! xml tag !! attributes !! content !! Parent Tag !! Reapeatable<br>within Parent Tag
 
|-
 
|-
| Root Tag || <ObjectTemplate> || xmlns:xsi = "http://www.w3.org/2001/XMLSchema-instance"<br>xmlns:xsd = "http://www.w3.org/2001/XMLSchema" || The entire template XML tree || none
+
| Root Tag || <tt>'''<ObjectTemplate>'''</tt> || <tt>xmlns:xsi =<br>"<nowiki>http://www.w3.org/2001/XMLSchema-instance</nowiki>"<br>xmlns:xsd =<br>"<nowiki>http://www.w3.org/2001/XMLSchema</nowiki>"</tt> || The entire template XML tree || none || -
 
|-
 
|-
| Client Id || <ClientId> || none || (number) &lang;1&rang; || <ObjectTemplate>
+
| Client Id || <tt><ClientId></tt> || none || (number) ''209'' || <tt><ObjectTemplate></tt>|| no
 
|-
 
|-
| Name || <Name> || none || (string) &lang;Orville the Mayor&rang; || <ObjectTemplate>
+
| Name || <tt><Name></tt> || none || (string) ''Orville the Mayor'' || <tt><ObjectTemplate></tt> || no
 
|-
 
|-
| Hue  || <Hue> || none || (string) &lang;0xFFFFFFFF&rang; or &lang;FFFFFF&rang;|| <ObjectTemplate>
+
| Scale Modifier: A scalar<br>modifier for uniform X,Y,Z scaling || <tt><ScaleModifier></tt> || none || (number) ''1.5'' || <tt><ObjectTemplate></tt> || no
 
|-
 
|-
| Mobile Component || <MobileComponent> || none || (XML tags)&lang;Mobile Component child tags&rang; || <ObjectTemplate>  
+
| Hue || <tt><Hue></tt> || none || (string) ''0xFFFFFFFF'' or ''FFFFFF'' || <tt><ObjectTemplate></tt> || no
 
|-
 
|-
| Base Run Speed || <BaseRunSpeed> || none || (number) &lang;1&rang; || <MobileComponent>
+
| Shared Object Property: see also<br><tt>\\build\base\ObjectTagDefinitions.xml</tt> || <tt><SharedStateEntry></tt> || <tt>name="''Weight''" type="''<nowiki>int|bool|string</nowiki>''" value="''-1''"</tt> || none || <tt><ObjectTemplate></tt>  || yes
 
|-
 
|-
| Mobile Type || <MobileType> || none || (string)&lang; Friendly{{!}}Animal&brvbar;Monster&brvbar;Player &rang; || <MobileComponent>
+
| Mobile Component  || <tt>'''<MobileComponent>'''</tt> || none || (XML tags)''Mobile Component child tags'' || <tt><ObjectTemplate></tt> || no
 
|-
 
|-
| Object Variable Component || <ObjectVariableComponent> || (XML tags)&lang;Object Variable tags&rang; || <ObjectTemplate>  
+
| Base Run Speed || <tt><BaseRunSpeed></tt> || none || (number) ''0.5'' || <tt><MobileComponent></tt> || no
 
|-
 
|-
| String Variable || <StringVariable> || Name="&lang;MyText&rang;" || (string) &lang;Always look at the bright side of life&rang; || <ObjectVariableComponent>
+
| Mobile Type || <tt><MobileType></tt> || none || (string)''<nowiki>Friendly|Animal|Monster|Player</nowiki>'' || <tt><MobileComponent></tt> || no
 
|-
 
|-
| Number Variable || <DoubleVariable> || Name="&lang;MyValue&rang;" || (number) &lang;3.1415926535&rang; || <ObjectVariableComponent>
+
| Object Variable Component || <tt>'''<ObjectVariableComponent>'''</tt> || none || (XML tags)''Object Variable tags'' || <tt><ObjectTemplate></tt> || no
 
|-
 
|-
| Boolean Variable || <BoolVariable> || Name="&lang;MyTruth&rang;" || (Bool) &lang;true|false&rang; || <ObjectVariableComponent>
+
| String Variable || <tt><StringVariable></tt> || <tt>Name="</tt>''MyText''<tt>"</tt> || (string) ''Always look at the bright side of life'' || <tt><ObjectVariableComponent></tt> || yes
 
|-
 
|-
| Vector Variable || <LocVariable> || Name="&lang;MyLocation&rang;" || (string) &lang;1.5,0,23&rang; || <ObjectVariableComponent>
+
| Number Variable || <tt><DoubleVariable></tt> || <tt>Name="</tt>''MyValue''<tt>"</tt> || (number) ''3.1415926535'' || <tt><ObjectVariableComponent></tt> || yes
 
|-
 
|-
| Script Engine Component || <ScriptEngineComponent> || none || (XML tags) &lang;Lua script tags&rang; || <ObjectTemplate>  
+
| Boolean Variable || <tt><BoolVariable></tt> || <tt>Name="</tt>''MyTruth''<tt>"</tt> || (Bool) ''<nowiki>true|false</nowiki>'' || <tt><ObjectVariableComponent></tt> || yes
 
|-
 
|-
| Attached Lua Script || <LuaModule> || Name="&lang;cel_mayor&rang;" || (LuaTable) &lang;Optional Initializer Tag&rang; ||<ScriptEngineComponent>
+
| Vector Variable || <tt><LocVariable></tt> || <tt>Name="</tt>''MyLocation''<tt>"</tt> || (string) ''1.5,0,23'' || <tt><ObjectVariableComponent></tt> || yes
 
|-
 
|-
| Initializer Data || <Initializer> || none || (LuaTable)&lang;{InitStr = "Shrubbery", InitVal = 42}&rang; || <LuaModule>
+
| Script Engine Component || <tt>'''<ScriptEngineComponent>'''</tt> || none || (XML tags) ''Lua script tags'' || <tt><ObjectTemplate></tt> || no
 
|-
 
|-
|
+
| Attached Lua Script || <tt>'''<LuaModule>'''</tt> || <tt>Name="</tt>''cel_mayor''<tt>"</tt> || (LuaTable) ''Optional Initializer Tag'' || <tt><ScriptEngineComponent></tt> || yes
 
|-
 
|-
|
+
| Initializer Data<br>Accessible in the script as "initializer"<br>e.g. <tt>initializer.InitStr</tt> || <tt><Initializer></tt> || none || (LuaTable)''<tt><br>{ InitStr = "Shrubbery",<br>&nbsp;&nbsp;InitVal = 42<br>}<br></tt>'' || <tt><LuaModule></tt> || no
|-
 
|
 
|-
 
|
 
|-
 
|
 
|-
 
|
 
|-
 
|
 
 
|}
 
|}
 +
 +
Example template with everything in it:
 +
<syntaxhighlight lang="xml">
 +
<?xml version="1.0" encoding="utf-8"?>
 +
<ObjectTemplate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 +
<ClientId>1</ClientId>
 +
<Hue>0xFFFFFFFF</Hue>
 +
<Name>Ceo Laer, Mayor of Aberfan</Name>
 +
<ScaleModifier>1.1<ScaleModifier>
 +
<MobileComponent>
 +
<BaseRunSpeed>1</BaseRunSpeed>
 +
<MobileType>Friendly</MobileType>
 +
</MobileComponent>
 +
<ObjectVariableComponent>
 +
<BoolVariable  Name="AI-CanConverse">false</BoolVariable>
 +
<BoolVariable  Name="AI-StationedLeash">true</BoolVariable>
 +
<BoolVariable  Name="ImportantNPC">True</BoolVariable>
 +
<BoolVariable  Name="noloot">True</BoolVariable>
 +
<DoubleVariable Name="BaseHealth">250</DoubleVariable>
 +
<StringVariable Name="MobileTeamType">Villagers</StringVariable>
 +
<StringVariable Name="QuestName">KillMayorQuest</StringVariable>
 +
<StringVariable Name="QuestRequiredTask">SlayMayor</StringVariable>
 +
<StringVariable Name="QuestTask">ReturnForReward</StringVariable>
 +
<StringVariable Name="WanderRegion">MayorHouse</StringVariable>
 +
</ObjectVariableComponent>
 +
<ScriptEngineComponent>
 +
    <LuaModule Name="quest_monster"/>
 +
<LuaModule Name="guard_protect"/>
 +
<LuaModule Name="ai_npc_mayor">
 +
<Initializer>
 +
{
 +
Stats = { Str=10, Agi=120, Int=120 },
 +
Skills = { Melee = 100, Slashing = 100, Bashing = 100, Piercing = 100, Endurance = 100, Regeneration = 100, Blocking = 90 },
 +
EquipTable = {
 +
BodyPartHead = { "head_merchant" },
 +
BodyPartHair = { {"hair_merchant", "0xFF999999"} },
 +
Chest        = { "merchant_clothing_chest" },
 +
            Legs        = { "merchant_clothing_legs" },
 +
Backpack    = { "backpack" }
 +
},
 +
}
 +
</Initializer>
 +
</LuaModule>
 +
</ScriptEngineComponent>
 +
</ObjectTemplate>
 +
</syntaxhighlight>
 +
 +
  
 
[[Category:Drafts]]
 
[[Category:Drafts]]

Latest revision as of 02:49, 5 November 2016

Basics

  • Templates are files which describe properties of objects to be created in the world.
  • A template is the building plan, the blueprint for an object
  • You can create as many instances of these objects as your server allows:
    1000 rabbits, if you wish from a single rabbit template, or cultists or whatever.
  • Templates are described in files, one template per file only, so there are many.
  • These file live in a special directory called "templates" inside your mods directory.
  • The basic file format is XML, so you have the rules for XML tags and attributes.
  • Do not use special characters in the names for your templates, it can cause weird bugs
    Forbidden characters in template names: "&"

Template Properties

Templates describe GameObjects to be created, so a fundamental understanding of GameObjects is necessary: GameObj

Templates and Default Properties

Example of a very simple template:

<ObjectTemplate>
	<ClientId>461</ClientId>
	<Name>[FF9500]Green Book[-]</Name>
	<SharedStateEntry name="Weight" type="int" value="1"/>
	<Hue>0xFFFFFFFF</Hue>
</ObjectTemplate>

All templates MUST have the opening and closing tags:

<ObjectTemplate>
</ObjectTemplate>

The ClientId tag also is mandatory:

<ObjectTemplate>
    <ClientId>2</ClientId>
</ObjectTemplate>

I saved that as MostDumbTemplateEver.xml in my templates folder.
The example above probably is the most primitive template possible.
The ClientId tells that the invisible NoDraw object is to be displayed.
Apart from that it has no properties, scripts or anything declared.

A reference of possible ClientIds can be found in the file:

\\build\base\ClientIdReference.txt

After creation in the world this object already has some default properties:

Basic:

  • Name: "" (Empty String)
  • Hue:"FFFFFF" (white)
  • Position: Loc(166.34,0.00,-135.43) - that's where I placed it
  • Rotation: Loc(0,0,0)
  • Scale: Loc(1,1,1)
  • template: "MostDumbTemplateEver" (That's how I named the template when I saved it)

Shared Object Properties

  • DefaultInteraction: "Use" (When we click it)
  • NoInteract: false (Default Interaction is on)
  • TooltipString: "" (Empty String)
  • Weight: -1 (Cannot be picked up normally)

Just for the fun of it and for better understanding I created another template:

<ObjectTemplate>
    <ClientId>1</ClientId>
</ObjectTemplate>

I saved it as MostDumbMaleEver.xml in my templates folder.
Inspecting it gave me the following properties, which are different from the NoDraw above, so we learn one thing:
The basic properties of a created object depend on the ClientId it is created from and are hardcoded in the engine.

Basic:

  • Name: "" (Empty String)
  • Hue:"FFFFFF" (white)
  • Position: Loc(166.12,0.00,-135.32) - that's where I placed it
  • Rotation: Loc(0,0,0)
  • Scale: Loc(1,1,1)
  • template: "MostDumbMaleEver" (That's how I named the template when I saved it)

Shared Object Properties

  • AudioIdentifierOverride: "" (Empty String)
  • BodyOffset: 0.8
  • CanEquipArmor: true
  • CanEquipWeapon: true
  • Capacity: 2000
  • CombatMode: false
  • CombatStance: Passive
  • DefaultInteraction: Interact (When we click it)
  • DisplayName: "" (Empty String)
  • Faction: None
  • FriendlyFactions: "" (Empty String)
  • IsDead: false
  • IsFlying: false
  • IsJumping: false
  • NoInteract: false (Default Interaction is on)
  • Pose: Standing
  • Title: "" (Empty String)
  • TooltipString: "" (Empty String)
  • Weight: -1 (Cannot be picked up normally)

A reference of which Shared Properties are available for which ClientId can be found in the non-moddable file (never ever edit it !!!)

\\build\base\ObjectTagDefinitions.xml

Properties you can define in templates

Data types are referenced by (type), e.g. (string), (number), (bool) or (XML tags)
They are NOT part of the final XML template.
Variable data you have to provide is written in italics
The pipe charcter "|" inside example data separates allowed values.
Tags which can have child tags are marked in 'bold
The namespace (first line of the example file below) and the xmlns:xsi and xmlns:xsd attributes of the root tag are proper xml, but not needed for the function of the template.

Property xml tag attributes content Parent Tag Reapeatable
within Parent Tag
Root Tag <ObjectTemplate> xmlns:xsi =
"http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd =
"http://www.w3.org/2001/XMLSchema"
The entire template XML tree none -
Client Id <ClientId> none (number) 209 <ObjectTemplate> no
Name <Name> none (string) Orville the Mayor <ObjectTemplate> no
Scale Modifier: A scalar
modifier for uniform X,Y,Z scaling
<ScaleModifier> none (number) 1.5 <ObjectTemplate> no
Hue <Hue> none (string) 0xFFFFFFFF or FFFFFF <ObjectTemplate> no
Shared Object Property: see also
\\build\base\ObjectTagDefinitions.xml
<SharedStateEntry> name="Weight" type="int|bool|string" value="-1" none <ObjectTemplate> yes
Mobile Component <MobileComponent> none (XML tags)Mobile Component child tags <ObjectTemplate> no
Base Run Speed <BaseRunSpeed> none (number) 0.5 <MobileComponent> no
Mobile Type <MobileType> none (string)Friendly|Animal|Monster|Player <MobileComponent> no
Object Variable Component <ObjectVariableComponent> none (XML tags)Object Variable tags <ObjectTemplate> no
String Variable <StringVariable> Name="MyText" (string) Always look at the bright side of life <ObjectVariableComponent> yes
Number Variable <DoubleVariable> Name="MyValue" (number) 3.1415926535 <ObjectVariableComponent> yes
Boolean Variable <BoolVariable> Name="MyTruth" (Bool) true|false <ObjectVariableComponent> yes
Vector Variable <LocVariable> Name="MyLocation" (string) 1.5,0,23 <ObjectVariableComponent> yes
Script Engine Component <ScriptEngineComponent> none (XML tags) Lua script tags <ObjectTemplate> no
Attached Lua Script <LuaModule> Name="cel_mayor" (LuaTable) Optional Initializer Tag <ScriptEngineComponent> yes
Initializer Data
Accessible in the script as "initializer"
e.g. initializer.InitStr
<Initializer> none (LuaTable)
{ InitStr = "Shrubbery",
  InitVal = 42
}
<LuaModule> no

Example template with everything in it:

<?xml version="1.0" encoding="utf-8"?>
<ObjectTemplate xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<ClientId>1</ClientId>
	<Hue>0xFFFFFFFF</Hue>
	<Name>Ceo Laer, Mayor of Aberfan</Name>
	<ScaleModifier>1.1<ScaleModifier>
	<MobileComponent>
		<BaseRunSpeed>1</BaseRunSpeed>
		<MobileType>Friendly</MobileType>
	</MobileComponent>			
	<ObjectVariableComponent>
		<BoolVariable   Name="AI-CanConverse">false</BoolVariable>
		<BoolVariable   Name="AI-StationedLeash">true</BoolVariable>
		<BoolVariable   Name="ImportantNPC">True</BoolVariable>
		<BoolVariable   Name="noloot">True</BoolVariable>
		<DoubleVariable Name="BaseHealth">250</DoubleVariable>
		<StringVariable Name="MobileTeamType">Villagers</StringVariable>
		<StringVariable Name="QuestName">KillMayorQuest</StringVariable>
		<StringVariable Name="QuestRequiredTask">SlayMayor</StringVariable>
		<StringVariable Name="QuestTask">ReturnForReward</StringVariable>
		<StringVariable Name="WanderRegion">MayorHouse</StringVariable>
	</ObjectVariableComponent>			
	<ScriptEngineComponent>
    	<LuaModule Name="quest_monster"/>
		<LuaModule Name="guard_protect"/>
		<LuaModule Name="ai_npc_mayor">
			<Initializer>
				{
					Stats = { Str=10, Agi=120, Int=120 },
					Skills = { Melee = 100, Slashing = 100, Bashing = 100, Piercing = 100, Endurance = 100, Regeneration = 100, Blocking = 90 },
					EquipTable = {
						BodyPartHead = { "head_merchant" },
						BodyPartHair = { {"hair_merchant", "0xFF999999"} },
						Chest        = { "merchant_clothing_chest" },
			            Legs         = { "merchant_clothing_legs" }, 
						Backpack     = { "backpack" }			
					},
				}
			</Initializer>
		</LuaModule>
	</ScriptEngineComponent>
</ObjectTemplate>