Equipping armour in a game

by LadylexUK (Feb 2015)
Copied from ProjectSpark.com

There is no facility to change the clothing/armour of a player while in game using kode. So here are some workaround methods

Method 1: Design your own
You can make some interesting armour pieces from the prop gallery. Part of the castle such as the tower, the arrow slits and the crenelations can make interesting armour designs.
Dress your character how you want him to appear without armour.
Then attach the armour pieces to shoulders, arms, knees, hip, back etc..(attack front pieces to the back socket as there is no front socket on a villager).

In players brain

Code:

WHEN [once] DO [objset:armour][=][WIP: left arm piece][+][WIP:right arm piece][+] etc…
WHEN [once] DO [boolvar:armour][=][false]
WHEN [left stick button][pressed] DO [toggle][boolvar:armour] //or whatever call to action puts on the armour
WHEN [boolvar:armour][=][true]
…WHEN [for each of][objset:armour] DO [it][visible][=][true]
…WHEN [else]
../..WHEN [for each of][objset:armour] DO [it][visible][=][false]

You can also add Kode that will increase the health of the player while he is wearing the armour, or make him invulnerable. Just remember to turn it back again under the else command.

Method 2: Doppleganger

This method will allow you to create an alternative version of your character. You can use it when levelling, or at a specific point in the game. Because it uses another model, you can also use this to turn your character into a creature, or goblin, or change the color of his skin etc..
This will transfer the inventory from one character to another. If you are using variables in your player brain you will need to transfer them too (and back again).

As before I am using a toggle on the left stick to change his clothes. However if you do not need to change back again, then you can just create your new character and destroy your old one. Page 2 will not be necessary.

Create a copy of your character wearing armour (we will call him armoured me) and make him a template. He should contain all the Kode in the player brain. Apart from what we are about to add.

In your original player

Code:

WHEN [once] DO [boolvar:armour][=][false]
WHEN [left stick button][pressed] DO [toggle][boolvar:armour]
WHEN [boolvar:armour][=][true]
…WHEN [started to] DO [objvar:armoured me][=][create][IWP:Armoured version][at position][position]
…WHEN DO [visible][=][false]
…WHEN DO [collidable][=][false]
…WHEN DO [attackable][=][false]
…WHEN DO [invulnerable][=][true]
…WHEN [for each of] [inventory]DO [give][it][to][objvar:armoured me] // this duplicates any collected items in your player brain to your armoured version
…WHEN [equipment] DO [armoured me][equip it] // this puts any equipped weapon in the armoured version
…WHEN DO [switch page][2]

page 2

WHEN [left stick button][pressed] DO [toggle][boolvar:armour]
WHEN [armour][=][false] DO
…WHEN DO [visible][=][true]
…WHEN DO [collidable][=][true]
…WHEN DO [attackable][=][true]
…WHEN DO [invulnerable][=][false]
…WHEN [for each of] [objvar:armoured me][inventory]DO [give][it][to][me] // this transfers all the collected items back into your player brain
…WHEN [objvar:armoured me] [equipment] DO [equip][it] // this puts any equipped weapon in the armoured version
…WHEN [started to] DO [position][=][objvar:armoured me][position]
…WHEN DO [destroy][objvar:armoured me]
…WHEN DO [switch page][1]

 

Comments are closed.

Website Powered by WordPress.com.

Up ↑

<span>%d</span> bloggers like this: