From The Mana World
Line 4: Line 4:


= Usage =
= Usage =
For the examples below we will use the map 009-1 and position 25, 25. The only mandatory property to make a NPC is "callfunc". To make a store, put "store" instead of "callfunc".
For the examples below we will use the map 009-1 and position 25, 25. The only mandatory property to make a npc is "callfunc". To make a store, put "store" instead of "callfunc".
<br>
<br>
== Store npc ==
== Store npc ==
Object type: NPC<br>
Object type: npc<br>
Object name: FooBar#Baz
Object name: FooBar#Baz
{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 28: Line 28:


== Basic npc ==
== Basic npc ==
Object type: NPC<br>
Object type: npc<br>
Object name: FooBar#Baz
Object name: FooBar#Baz
{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 47: Line 47:
}
}
</pre>
</pre>
That's nice but the NPC does not have a visible sprite, it defaults to 127. Let's add a sprite.
That's nice but the npc does not have a visible sprite, it defaults to 127. Let's add a sprite.
<br><br>'''''@wushin: There is a "end;" instead of a "close;" because not all function send "mes" so "close2;" should be put before "return;" in the functions'''''
<br><br>'''''@wushin: There is a "end;" instead of a "close;" because not all function send "mes" so "close2;" should be put before "return;" in the functions'''''
<br><br>
<br><br>


== Adding a sprite ==
== Adding a sprite ==
Object type: NPC<br>
Object type: npc<br>
Object name: FooBar#Baz
Object name: FooBar#Baz
{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 80: Line 80:
Tiled has a built-in "Rotation" properties for objects. To set the direction, set the rotation to any multiple of 90. For example, 90 is facing west and 180 is facing north.
Tiled has a built-in "Rotation" properties for objects. To set the direction, set the rotation to any multiple of 90. For example, 90 is facing west and 180 is facing north.
<br><br>
<br><br>
Object type: NPC<br>
Object type: npc<br>
Object name: FooBar#Baz<br>
Object name: FooBar#Baz<br>
Rotation: '''90'''
Rotation: '''90'''
Line 106: Line 106:


== Setting as debug npc ==
== Setting as debug npc ==
Object type: NPC<br>
Object type: npc<br>
Object name: FooBar#Baz<br>
Object name: FooBar#Baz<br>
Rotation: 90
Rotation: 90
Line 139: Line 139:


== Adding a trigger area ==
== Adding a trigger area ==
Object type: NPC<br>
Object type: npc<br>
Object name: FooBar#Baz<br>
Object name: FooBar#Baz<br>
Rotation: 90
Rotation: 90
Line 177: Line 177:


== Adding custom variables ==
== Adding custom variables ==
Object type: NPC<br>
Object type: npc<br>
Object name: FooBar#Baz<br>
Object name: FooBar#Baz<br>
Rotation: 90
Rotation: 90
Line 220: Line 220:
}
}
</pre>
</pre>
Any property starting with @ is treated as a custom variable. Variables should be FIXED values (ie. 3), not dynamic values (ie. @foo - 3). Only temporary variables (@) can be set through NPC objects. To set global variables, please manually add a floating NPC.
Any property starting with @ is treated as a custom variable. Variables should be FIXED values (ie. 3), not dynamic values (ie. @foo - 3). Only temporary variables (@) can be set through npc objects. To set global variables, please manually add a floating npc.
<br><br>'''''@wushin: Should variables be cleaned before the "end;" ?'''''
<br><br>'''''@wushin: Should variables be cleaned before the "end;" ?'''''
<br><br>
<br><br>
Line 240: Line 240:
= Examples =
= Examples =
== Debug npc ==
== Debug npc ==
Object type: NPC<br>
Object type: npc<br>
Object name: Debug#3
Object name: Debug#3
{| class="wikitable" border="1"
{| class="wikitable" border="1"
Line 272: Line 272:


== Banker ==
== Banker ==
Object type: NPC<br>
Object type: npc<br>
Object name: Richard
Object name: Richard
{| class="wikitable" border="1"
{| class="wikitable" border="1"

Revision as of 14:15, 25 March 2015

This proposal is to enable npc creation from Tiled. It could even provide a way to add a "npc finder" to manaplus so that players can easily know where a npc is (manaplus would simply have to look at the tmx). Should not be used for floating npcs (no map).

Usage

For the examples below we will use the map 009-1 and position 25, 25. The only mandatory property to make a npc is "callfunc". To make a store, put "store" instead of "callfunc".

Store npc

Object type: npc
Object name: FooBar#Baz

Property Value
sprite 112
store Item:*1,Item:*1,Item:9

Gives:

009-1,25,25,0|shop|FooBar#Baz|112,Item:*1,Item:*1,Item:9

When using "store" instead of "callfunc" the optional "sprite" and "direction" properties can be used

Basic npc

Object type: npc
Object name: FooBar#Baz

Property Value
callfunc Qux

Gives:

009-1,25,25,0|script|FooBar#Baz|127
{
    set @npcname$, "FooBar";
    callfunc "Qux";
    end;
}

That's nice but the npc does not have a visible sprite, it defaults to 127. Let's add a sprite.

@wushin: There is a "end;" instead of a "close;" because not all function send "mes" so "close2;" should be put before "return;" in the functions

Adding a sprite

Object type: npc
Object name: FooBar#Baz

Property Value
sprite 161
callfunc Qux

Gives:

009-1,25,25,0|script|FooBar#Baz|161
{
    set @npcname$, "FooBar";
    callfunc "Qux";
    end;
}

The "sprite" property is non-mandatory and defaults to 127 when not set.

Setting the direction

Tiled has a built-in "Rotation" properties for objects. To set the direction, set the rotation to any multiple of 90. For example, 90 is facing west and 180 is facing north.

Object type: npc
Object name: FooBar#Baz
Rotation: 90

Property Value
sprite 161
callfunc Qux

Gives:

009-1,25,25,3|script|FooBar#Baz|161
{
    set @npcname$, "FooBar";
    callfunc "Qux";
    end;
}


Setting as debug npc

Object type: npc
Object name: FooBar#Baz
Rotation: 90

Property Value
debug true
sprite 161
callfunc Qux

Gives:

009-1,25,25,3|script|FooBar#Baz|161
{
    set @npcname$, "FooBar";
    callfunc "Qux";
    end;
OnInit:
    if(DEBUG) end;
    disablenpc "FooBar#Baz";
    end;
}


Adding a trigger area

Object type: npc
Object name: FooBar#Baz
Rotation: 90

Property Value
trigger 2,4
debug true
sprite 161
callfunc Qux

Gives:

009-1,25,25,3|script|FooBar#Baz|161,2,4
{
    end;
OnTouch:
    set @npcname$, "FooBar";
    callfunc "Qux";
    end;
OnInit:
    if(DEBUG) end;
    disablenpc "FooBar#Baz";
    end;
}


Adding custom variables

Object type: npc
Object name: FooBar#Baz
Rotation: 90

Property Value
@quux 19
@norf$ baz
trigger 2,4
debug true
sprite 161
callfunc Qux

Gives:

009-1,25,25,3|script|FooBar#Baz|161,2,4
{
    end;
OnTouch:
    set @quux, 19;
    set @norf$, "baz";
    set @npcname$, "FooBar";
    callfunc "Qux";
    end;
OnInit:
    if(DEBUG) end;
    disablenpc "FooBar#Baz";
    end;
}

Any property starting with @ is treated as a custom variable. Variables should be FIXED values (ie. 3), not dynamic values (ie. @foo - 3). Only temporary variables (@) can be set through npc objects. To set global variables, please manually add a floating npc.

@wushin: Should variables be cleaned before the "end;" ?

Arrays

To add arrays, simply use : as a separator

Automatically added variables

Variable Value
@npcname$ Anything that comes before the # (if any) in the object name



Examples

Debug npc

Object type: npc
Object name: Debug#3

Property Value
sprite 154
debug true
callfunc Debug

Gives:

020-1,75,85,0|script|Debug#3|154
{
    set @npcname$, "Debug";
    callfunc "Debug";
    end;
OnInit:
    if(DEBUG) end;
    disablenpc "Debug#3";
    end;
}


Banker

Object type: npc
Object name: Richard

Property Value
sprite 161
callfunc Banker

Gives:

009-2,20,99,0|script|Richard|161
{
    set @npcname$, "Richard";
    callfunc "Banker";
    end;
}