From The Mana World
Line 24: Line 24:
009-1,25,25,0|shop|FooBar#Baz|112,Item:*1,Item:*1,Item:9
009-1,25,25,0|shop|FooBar#Baz|112,Item:*1,Item:*1,Item:9
</pre>
</pre>
When using "store" instead of "callfunc" the optional "sprite" and "direction" properties can be used
When using "store" instead of "callfunc" only the optional "sprite" property can be used
<br><br>
<br><br>


Line 42: Line 42:
009-1,25,25,0|script|FooBar#Baz|127
009-1,25,25,0|script|FooBar#Baz|127
{
{
     set @npcname$, "FooBar";
     callfunc "Qux", "FooBar", 25, 25;
    callfunc "Qux";
     end;
     end;
}
}
Line 69: Line 68:
009-1,25,25,0|script|FooBar#Baz|161
009-1,25,25,0|script|FooBar#Baz|161
{
{
     set @npcname$, "FooBar";
     callfunc "Qux", "FooBar", 25, 25;
    callfunc "Qux";
     end;
     end;
}
}
Line 78: Line 76:


== Setting the direction ==
== 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.
Tiled has a built-in "Rotation" property 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>
Line 98: Line 96:
009-1,25,25,3|script|FooBar#Baz|161
009-1,25,25,3|script|FooBar#Baz|161
{
{
     set @npcname$, "FooBar";
     callfunc "Qux", "FooBar", 25, 25;
    callfunc "Qux";
     end;
     end;
}
}
Line 127: Line 124:
009-1,25,25,3|script|FooBar#Baz|161
009-1,25,25,3|script|FooBar#Baz|161
{
{
     set @npcname$, "FooBar";
     callfunc "Qux", "FooBar", 25, 25;
    callfunc "Qux";
     end;
     end;
OnInit:
OnInit:
Line 165: Line 161:
     end;
     end;
OnTouch:
OnTouch:
     set @npcname$, "FooBar";
     callfunc "Qux", "FooBar", 25, 25;
    callfunc "Qux";
     end;
     end;
OnInit:
OnInit:
Line 206: Line 201:
     end;
     end;
OnTouch:
OnTouch:
     set @npcname$, "FooBar";
     callfunc "Qux", "FooBar", 25, 25, 19, "ba,z";
    callfunc "Qux", 19, "ba,z";
     end;
     end;
OnInit:
OnInit:
Line 216: Line 210:
</pre>
</pre>


=== Automatically added variables ===
=== Automatically added properties ===
{| class="wikitable" border="1"
{| class="wikitable" border="1"
|-
|-
! Variable
! Property
! Value
! Value
|-
|-
| @npcname$
| name
| Anything that comes before the # (if any) in the object 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
<br><br>
<br><br>


Line 249: Line 250:
020-1,75,85,0|script|Debug#3|154
020-1,75,85,0|script|Debug#3|154
{
{
    set @npcname$, "Debug";
     callfunc "Debug";
     callfunc "Debug";
     end;
     end;
OnInit:
OnInit:
     if(DEBUG) end;
     if(DEBUG) end;
     disablenpc "Debug#3";
     disablenpc "Debug#3", "Debug", 75, 85;
     end;
     end;
}
}
Line 278: Line 278:
009-2,20,99,0|script|Richard|161
009-2,20,99,0|script|Richard|161
{
{
     set @npcname$, "Richard";
     callfunc "Banker", "Richard", 20, 99;
    callfunc "Banker";
     end;
     end;
}
}
</pre>
</pre>

Revision as of 15:56, 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" only the optional "sprite" property 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
{
    callfunc "Qux", "FooBar", 25, 25;
    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
{
    callfunc "Qux", "FooBar", 25, 25;
    end;
}

The "sprite" property is non-mandatory and defaults to 127 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. 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
{
    callfunc "Qux", "FooBar", 25, 25;
    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
{
    callfunc "Qux", "FooBar", 25, 25;
    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:
    callfunc "Qux", "FooBar", 25, 25;
    end;
OnInit:
    if(DEBUG) end;
    disablenpc "FooBar#Baz";
    end;
}


Passing arguments to the function (hercules)

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

Property Value
arguments 19,"ba,z"
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;
OnInit:
    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;
}