Assigning damage by weapon

How to change the amount of damage each weapon inflicts when equipped

Scenario: You have a range of weapons. Each weapon inflicts a different amount of damage when used. So you need to alter how much damage you can inflict in the player brain depending on what is equipped.

Instructions

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

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

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.

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: