How do I make equipment increase more than 1 of a stat? Provide passives?

GC2
24 Apr 2020, 21:01

Under Wearable and then under Advanced features, there's a section where you can type in attributes to increase, but it only increases that attribute by 1.

How do I get it to increase by more than 1?

Also, how do I give equipment passives?
For example: lifesteal all damage dealt


Pykrete
24 Apr 2020, 21:13

I personally ignore that bit entirely.

You can set scripts for when an item is worn, and when it is removed. Use those.

Rather than directly affecting the attribute, I personally have everything that could affect an attribute given an attribute of its own; for example, I have Strength, Strength Weapon, Strength Armour, Strength Accessory, and Strength Bonus (Bonus being temporary buffs/debuffs in battles which resets to 0 at the end of a fight.)

So, on wear, player.strength armour = 2. Or, player.strength weapon = 3, etc.

I then have a turnscript running which updates these attributes into 'Strength Total', which is what I actually use for calculations in battle, calling on for 'can I lift this rock', etc. (Literally, just;
player.strength total = player.strength + player.strength weapon + player.strength armour (etc
)

This turnscript running probably isn't very sensible, though. You could get the same affect with a good Change script, though I've not personally fiddled with them.

On remove, player.strength weapon/armour/whatever = 0.

As for giving equipment passives... same thing. On wear, set a flag. Player.lifesteal.

This, of course, is assuming these passives come from one source. If lifesteal can only come from weapons, then this is fine. If lifesteal could come from, say, accessories too, then you'd need to figure out a way of making it so that if the player puts on a lifesteal sword and a lifesteal ring, they don't deactivate lifesteal when removing either one while the other remains. You could, in that instance, turn it into a variable instead, and rather than checking to see if the player has 'lifesteal' as a flag, check to see if player.lifesteal > 0. With two items, it would be 2, with one removed, it would go down to 1. With neither, it would be 0, effectively the same as turning off a flag.


mrangel
24 Apr 2020, 22:12

How do I get it to increase by more than 1?

You can enter something like strength+4 in that field. Or strength+2;speed-1 if you want to affect multiple attributes.

Also, how do I give equipment passives?
For example: lifesteal all damage dealt

In the script that handles the player dealing damage to something else, you would have to check if they're wearing an item with that attribute, and handle it appropriately.

I'd probably implement it by creating a dictionary of different passive abilities. Your damage-dealing script can do something like:

foreach (garment, FilterByAttribute(ScopeInventory(), "worn", true)) {
  if (HasAttribute (garment, "passive")) {
    if (DictionaryContains (garment.passive, "lifesteal")) {
      player.health = player.health + damage
    }
  }
}

(just as an example. The details will depend on how you're handling combat)

Using a dictionary rather than a list can mean that you can give it a value, which some passive abilities might need. (For example, if a ring gives you an elemental resistance, you could use the value to store which element).


Forgewright
25 Apr 2020, 07:17

Using a dictionary rather than a list can mean that you can give it a value, which some passive abilities might need. (For example, if a ring gives you an elemental resistance, you could use the value to store which element).

Mrangel , as soon as you mentioned the dictionary, I was lost. Could you give an example of what you mean by:

if a ring gives you an elemental resistance, you could use the value to store which element?

Why is it necessary to use a dictionary?