Confirmedusers, Bureaucrats, editor, Administrators
1,778
edits
CreativeMD (talk | contribs) No edit summary |
(→Result) |
||
(11 intermediate revisions by 3 users not shown) | |||
Line 47: | Line 47: | ||
=== Client === | === Client === | ||
The client type has different properties for client and server. This will cover the client side | The client type has different properties for client and server. This will cover the client side (rendering, shape, texture) | ||
(please note that // comments are actually not a valid json syntax, so if you want to use this json code in your projects, you'd have to remove these first) | |||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
"client": { | "client": { | ||
"renderer": "Shape", // | "renderer": "Shape", // How the entity will be rendered, "Shape" is the right one in almost all cases. | ||
"shape": { "base": "entity/land/littlefigure" }, // a path to our shape | "shape": { "base": "entity/land/littlefigure" }, // a path to our shape | ||
"texture": { "base": "game:block/wood/planks/birch1" }, // the figure should have the texture of birch wood. Therefore the prefix "game" is needed | "texture": { "base": "game:block/wood/planks/birch1" }, // the figure should have the texture of birch wood. Therefore the prefix "game" is needed | ||
Line 57: | Line 59: | ||
{ "code": "repulseagents" }, | { "code": "repulseagents" }, | ||
{ | { | ||
"code": "controlledphysics", | "code": "controlledphysics", // Adds physics to the entity | ||
"stepHeight": 0.2 | "stepHeight": 0.2 | ||
}, | }, | ||
{ | { | ||
"code": "floatupwhenstuck", | "code": "floatupwhenstuck", // Fixes corpse get stuck in ground | ||
"onlyWhenDead": true | "onlyWhenDead": true | ||
}, | }, | ||
{ "code": "interpolateposition" } | { "code": "interpolateposition" } // Smooths out movement of entity | ||
], | ], | ||
"animations": [ | "animations": [ // Animations which have to be implemented by the shape as well | ||
{ | { | ||
"code": "hurt", | "code": "hurt", | ||
Line 87: | Line 89: | ||
=== Server === | === Server === | ||
The server side handles the "brain" of the entity. | |||
<syntaxhighlight lang="c#"> | |||
"server": { | "server": { | ||
"behaviors": [ | "behaviors": [ | ||
{ "code": "repulseagents" }, | { "code": "repulseagents" }, | ||
{ | { | ||
"code": "controlledphysics", | "code": "controlledphysics", // Adds physic interaction | ||
"stepHeight": 0.2 | "stepHeight": 0.2 | ||
}, | }, | ||
{ | { | ||
"code": "health", | "code": "health", // Adds a health bar to the entity | ||
"currenthealth": 4, | "currenthealth": 4, | ||
"maxhealth": 4 | "maxhealth": 4 | ||
}, | }, | ||
{ | { | ||
"code": "deaddecay", | "code": "deaddecay", // Makes the dead entity stay for one hour | ||
"hoursToDecay": 1 | "hoursToDecay": 1 | ||
}, | }, | ||
{ | { | ||
"code": "floatupwhenstuck", | "code": "floatupwhenstuck", // Fixes corpse get stuck in ground | ||
"onlyWhenDead": true | "onlyWhenDead": true | ||
}, | }, | ||
{ | { | ||
"code": "despawn", | "code": "despawn", // Makes the entity despawn if there is no player within 48 blocks | ||
"minPlayerDistance": 48, | "minPlayerDistance": 48, | ||
"minSeconds": 5 | "minSeconds": 5 | ||
}, | }, | ||
{ | { | ||
"code": "emotionstates", | "code": "emotionstates", // Adds different emotion states | ||
"states": [ | "states": [ | ||
{ | { | ||
"code": "fleeondamage", | "code": "fleeondamage", // After the entity is hit it will try to flee for 10 seconds | ||
"duration": 10, | "duration": 10, | ||
"chance": 0.2, | "chance": 0.2, | ||
"slot": 0, | "slot": 0, | ||
" | "priority": 1, | ||
"accumType": "max" | "accumType": "max" | ||
} | } | ||
Line 126: | Line 131: | ||
}, | }, | ||
{ | { | ||
"code": "taskai", | "code": "taskai", // Handles what the entity does, a task will be processed one at a time | ||
"aitasks": [ | "aitasks": [ | ||
{ | { | ||
"code": "idle", | "code": "idle", // the figure will stand still and think | ||
"priority": 1.2, | "priority": 1.2, | ||
"priorityForCancel": 1.35, | "priorityForCancel": 1.35, | ||
Line 143: | Line 148: | ||
}, | }, | ||
{ | { | ||
"code": "wander", | "code": "wander", // The entity will walk around | ||
"priority": 1.0, | "priority": 1.0, | ||
"movespeed": 0.008, | "movespeed": 0.008, | ||
Line 151: | Line 156: | ||
}, | }, | ||
{ | { | ||
"code": "lookaround", | "code": "lookaround", // The entity will look around | ||
"priority": 0.5 | "priority": 0.5 | ||
} | } | ||
Line 158: | Line 163: | ||
] | ] | ||
}, | }, | ||
</syntaxhighlight> | |||
=== Result === | === Result === | ||
If we put everything together it should look like this: | |||
<syntaxhighlight lang="c#"> | <syntaxhighlight lang="c#"> | ||
Line 241: | Line 249: | ||
"chance": 0.2, | "chance": 0.2, | ||
"slot": 0, | "slot": 0, | ||
" | "priority": 1, | ||
"accumType": "max" | "accumType": "max" | ||
} | } | ||
Line 289: | Line 297: | ||
== Shape == | == Shape == | ||
== | If you want to know how to create the shape for the entity I suggest you checkout [[VS Model Creator]]. | ||
== Item == | |||
In order to spawn the entity we can create an item to do so: | |||
<syntaxhighlight lang="c#"> | |||
{ | |||
"code": "creature", | |||
"class": "ItemCreature", | |||
"maxstacksize": 64, | |||
"variantgroups": [ | |||
{ | |||
"code": "type", | |||
"states": [ "figure:littlefigure" ] | |||
} | |||
], | |||
"shape": { | |||
"base": "figure:entity/land/littlefigure" | |||
}, | |||
"texture": { "base": "game:block/wood/planks/birch1" }, | |||
"creativeinventory": { | |||
"general": [ "*" ], | |||
"items": [ "*" ], | |||
"creatures": [ "*" ] | |||
}, | |||
"materialDensity": 600, | |||
"guiTransform": { | |||
"rotation": { | |||
"x": 0, | |||
"y": -90, | |||
"z": -180 | |||
}, | |||
"origin": { | |||
"x": 0.5, | |||
"y": 0.15, | |||
"z": 0.5 | |||
}, | |||
"scale": 6 | |||
}, | |||
"fpHandTransform": { | |||
"rotation": { | |||
"x": 0, | |||
"y": -90, | |||
"z": 0 | |||
}, | |||
"origin": { | |||
"x": 0.5, | |||
"y": 0.15, | |||
"z": 0.5 | |||
}, | |||
"scale": 6 | |||
}, | |||
"groundTransform": { | |||
"translation": { | |||
"x": 0, | |||
"y": 0.15, | |||
"z": 0 | |||
}, | |||
"rotation": { | |||
"x": 0, | |||
"y": -90, | |||
"z": 0 | |||
}, | |||
"origin": { | |||
"x": 0.5, | |||
"y": 0.15, | |||
"z": 0.5 | |||
}, | |||
"scale": 6 | |||
} | |||
} | |||
</syntaxhighlight> | |||
== Testing/ Distribution == | == Testing/ Distribution == | ||
<youtube>Ci9CB0fnK7U</youtube> | |||
Download [https://wiki.vintagestory.at/images/d/d8/Figure_v1.0.0.zip Figure v1.0.0] for VintageStory 1.8 | |||
{{Navbox/modding|Vintage Story}} |