Assigning damage based on the weapon

by LadylexUK (May 2015)
Copied from ProjectSpark.com

Scenario: You have a range of weapons. Each weapon inflicts a different amount of damage when used.

In each of the weapon brains. Add the following to the standard brain.

Code:

WHEN [equipped] DO [numvar:damage][=][10] // the number being the amount of damage this weapon inflicts

In the player brain

Code:

WHEN [equipment]
…WHEN [it][is melee weapon] DO [numvar:melee damage][=][it][numvar:damage]
…/…WHEN [else]
…/…/…WHEN DO [numvar:melee damage][=][5] //the default damage with no weapons
…WHEN [it][is ranged weapon] DO [numvar:ranged damage][=][it][numvar:damage]
…/…WHEN [else]
…/…/…WHEN DO [numvar:ranged damage][=][5] //the default damage with no weapons
…WHEN [else] //when there is no equipment
…/…WHEN DO [numvar:melee damage][=][5]
…/…WHEN DO [numvar:ranged damage][=][5]

WHEN [Y][pressed] DO [shoot][with damage][numvar:ranged damage]
WHEN [X][pressed] DO [attack][with damage][numvar:melee damage]

So when a weapon is equipped it changes the damage the player can inflict, when it is unequipped you get the default.

This was previously posted as a response to a question in Koding Konversation by Biohazzard14

If you want to add damage with the weapon rather than change it then use the same method in the weapon brain with the additional value, but add

WHEN [equipment]
…WHEN [it][is melee weapon] DO [numvar:melee damage][=][numvar:melee damage][+][it][numvar:damage]

etc.

You also need to remove the damage from the [numvar:melee damage] when the item is unequipped

In weapon brain

WHEN [equipped] DO [numvar:damage][=][10]
…WHEN [objvar:my owner][=][owner]
WHEN [started to][unequipped] DO [objvar:my owner][numvar:melee damage][=][numvar:melee damage][-][10]

Comments are closed.

Powered by WordPress.com.

Up ↑

%d bloggers like this: