Line 243: | Line 243: | ||
Object name: FooBar#Baz<br> | Object name: FooBar#Baz<br> | ||
Rotation: 90 | Rotation: 90 | ||
Use tiled to mark the area of the trigger. | <br><br> | ||
Use tiled to mark the area of the trigger. To have a 0,0 trigger '''set the "trigger" property to "true"'''. | |||
{| class="wikitable" border="1" | {| class="wikitable" border="1" | ||
Line 249: | Line 250: | ||
! Property | ! Property | ||
! Value | ! Value | ||
|- | |- | ||
| debug | | debug | ||
Line 263: | Line 261: | ||
|} | |} | ||
Gives: <pre> | Gives in Hercules: <pre> | ||
009-1,25,25,3 script FooBar#Baz 161,2,4,{ | |||
end; | |||
OnTouch: | |||
callfunc "Qux", "FooBar", 25, 25; | |||
end; | |||
OnInit: | |||
if(DEBUG) end; | |||
disablenpc "FooBar#Baz"; | |||
end; | |||
} | |||
</pre> | |||
<br> | |||
Gives in TMWA: <pre> | |||
009-1,25,25,3|script|FooBar#Baz|161,2,4 | 009-1,25,25,3|script|FooBar#Baz|161,2,4 | ||
{ | { | ||
end; | end; | ||
OnTouch | OnTouch; | ||
set @npcname$, "FooBar"; | |||
set @npcloc, 25, 25; | |||
callfunc "Qux"; | |||
end; | end; | ||
OnInit: | OnInit: |
Revision as of 18:46, 28 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 "shop" instead of "callfunc".
Shop npc [RC]
Object type: shop
Object name: FooBar#Baz
Property | Value |
---|---|
items | Item,Item:*2,Item,Item:9 |
Gives in Hercules:
009-1,25,25,0 shop FooBar#Baz 32767,Item:*1,Item:*2,Item:*1,Item:9
Gives in TMWA:
009-1,25,25,0|shop|FooBar#Baz|32767,Item:*1,Item:*2,Item:*1,Item:9
Anonymous npc
if you do not care what name your npc has you can set its name to # to get an auto-generated name. This is particularly useful for npcs that only activate when you walk over them.
Object type: npc
Object name: #
Property | Value |
---|---|
callfunc | Qux |
Gives in Hercules:
009-1,25,25,0 script #009-1_anon0 32767,{ callfunc "Qux", "", 25, 25; end; }
Gives in TMWA:
009-1,25,25,0|script|#009-1_anon0|32767 { set @npcname$, ""; setarray @npcloc, 25, 25; callfunc "Qux"; end; }
@wushin: it's up to you to decide the naming convention of anonymous npcs
Semi-anonymous npc
When you have multiple copies of a npc with the same name, you can add # at the end without anything else to append an auto-generated suffix. For example, the barrels would become barrel# instead of barrel#(number). This way you do not have to worry about giving a safe name to a npc.
Object type: npc
Object name: FooBar#
Property | Value |
---|---|
callfunc | Qux |
Gives in Hercules:
009-1,25,25,0 script FooBar#009-1_0 32767,{ callfunc "Qux", "FooBar", 25, 25; end; }
Gives in TMWA:
009-1,25,25,0|script|FooBar#009-1_anon0|32767 { set @npcname$, "FooBar"; setarray @npcloc, 25, 25; callfunc "Qux"; end; }
Named npc
Object type: npc
Object name: FooBar#Baz
Property | Value |
---|---|
callfunc | Qux |
Gives in Hercules:
009-1,25,25,0 script FooBar#Baz 32767,{ callfunc "Qux", "FooBar", 25, 25; end; }
Gives in TMWA:
009-1,25,25,0|script|FooBar#Baz|32767 { set @npcname$, "FooBar"; setarray @npcloc, 25, 25; callfunc "Qux"; end; }
That's nice but this npc is not sent to the client since its ID is 32767. 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 in Hercules:
009-1,25,25,0 script FooBar#Baz 161,{ callfunc "Qux", "FooBar", 25, 25; end; }
Gives in TMWA:
009-1,25,25,0|script|FooBar#Baz|161 { set @npcname$, "FooBar"; setarray @npcloc, 25, 25; callfunc "Qux"; end; }
The "sprite" property is non-mandatory and defaults to 32767 when not set.
Setting the direction
Tiled has a built-in "Rotation" property for objects. To set the direction, set the rotation to any multiple of 90 (or a multiple of 45 if your npc supports all 8 directions). The minimum is -180 and the maximum is 180. For example, 90 is facing west and 180 (or -180) is facing north.
Object type: npc
Object name: FooBar#Baz
Rotation: 90
Property | Value |
---|---|
sprite | 161 |
callfunc | Qux |
Gives in Hercules:
009-1,25,25,3 script FooBar#Baz 161,{ callfunc "Qux", "FooBar", 25, 25; end; }
Gives in TMWA:
009-1,25,25,3|script|FooBar#Baz|161 { set @npcname$, "FooBar"; setarray @npcloc, 25, 25; 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 in Hercules:
009-1,25,25,3 script FooBar#Baz 161,{ callfunc "Qux", "FooBar", 25, 25; end; OnInit: if(DEBUG) end; disablenpc "FooBar#Baz"; end; }
Gives in TMWA:
009-1,25,25,3|script|FooBar#Baz|161 { set @npcname$, "FooBar"; set @npcloc, 25, 25; callfunc "Qux"; end; OnInit: if(DEBUG) end; disablenpc "FooBar#Baz"; end; }
Adding a trigger area
Object type: npc
Object name: FooBar#Baz
Rotation: 90
Use tiled to mark the area of the trigger. To have a 0,0 trigger set the "trigger" property to "true".
Property | Value |
---|---|
debug | true |
sprite | 161 |
callfunc | Qux |
Gives in Hercules:
009-1,25,25,3 script FooBar#Baz 161,2,4,{ end; OnTouch: callfunc "Qux", "FooBar", 25, 25; end; OnInit: if(DEBUG) end; disablenpc "FooBar#Baz"; end; }
Gives in TMWA:
009-1,25,25,3|script|FooBar#Baz|161,2,4 { end; OnTouch; set @npcname$, "FooBar"; set @npcloc, 25, 25; callfunc "Qux"; end; OnInit: if(DEBUG) end; disablenpc "FooBar#Baz"; end; }
Adding a recurring timer
Object type: npc
Object name: FooBar#Baz
Rotation: 90
Property | Value |
---|---|
interval | 10000,Function |
trigger | 2,4 |
debug | true |
sprite | 161 |
callfunc | Qux |
Gives:
009-1,25,25,3|script|FooBar#Baz|161,2,4 { end; OnTouch: callfunc "Qux", "FooBar", 25, 25; end; OnTimer10000: callfunc "Function", "FooBar", 25, 25; initnpctimer; end; OnInit: if(DEBUG >= 2) end; initnpctimer; if(DEBUG) end; disablenpc "FooBar#Baz"; end; }
Passing arguments to the function
Object type: npc
Object name: FooBar#Baz
Rotation: 90
Property | Value |
---|---|
arguments | 19,"ba,z" |
interval | 10000,Function |
trigger | 2,4 |
debug | true |
sprite | 161 |
callfunc | Qux |
Gives:
009-1,25,25,3|script|FooBar#Baz|161,2,4 { end; OnTouch: callfunc "Qux", "FooBar", 25, 25, 19, "ba,z"; end; OnTimer10000: callfunc "Function", "FooBar", 25, 25; initnpctimer; end; OnInit: if(DEBUG >= 2) end; initnpctimer; if(DEBUG) end; disablenpc "FooBar#Baz"; end; }
Automatically added properties
Property | Value |
---|---|
name | Anything that comes before the # (if any) in the object name |
X | the X location of the npc |
Y | the Y location of the npc |
Any custom property is added after the default properties
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 { callfunc "Debug"; end; OnInit: if(DEBUG) end; disablenpc "Debug#3", "Debug", 75, 85; end; }
Banker
Object type: npc
Object name: Richard
Property | Value |
---|---|
sprite | 161 |
callfunc | Banker |
Gives:
009-2,20,99,0|script|Richard|161 { callfunc "Banker", "Richard", 20, 99; end; }