[Trigger] Item Possession Stat Boost

Level 3
Joined
Aug 19, 2016
Messages
18
Howdy folks, so I’m trying to figure out whether or not the following is possible.

I’ve given a specific category of unit an inventory which allows them to carry up to 6 items, but which does NOT allow them to use or benefit from the items directly.

What I’m trying to do is find the right kind of trigger to make it so these units gain +2 armor, +5 damage, +100 health, and +10% attack speed for each item in their inventory, regardless of what those items actually are.

Is there a way to do this in world editor?
 
Level 1
Joined
Aug 23, 2021
Messages
1
Units with the (2 item inventory research) ability do not receive stats from items, you can make this ability have 6 slots and just trigger the stat gain/loss upon picking up/dropping items
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Manually tracking stat gain across all items in the game to undo them is a horribly complicated solution that requires covering a bunch of edge cases involving how stats add together. The behavior you want, @LeCrepe, is easiest achieved with some simple triggers:
  • Events
    • Time - Every 1.00 seconds of game-time //or a faster frequency if you want
  • Conditions
  • Actions
    • Unit Group - Pick every unit in COURIER_UNITS_GROUP and do (Actions)
      • Loop - Actions
        • Set LVL = ((Number of items carried by (Picked Unit)) + 1) //adding 1 because at 0 items this needs to return level 1.
        • For each (Integer A) from 1 to COURIER_ABILITY_COUNT do (Actions)
          • Loop - Actions
            • Unit - Set level of COURIER_ABILITY[(Integer A)] for (Picked Unit) to LVL //Just use 7 ability levels as the range of effects for having 0-6 items
  • Events
    • Unit - A unit enters (Playable map area)
  • Conditions
    • ((Unit-type of (Triggering Unit)) equal to COURIER)
    • ((Triggering Unit) is in COURIER_UNITS_GROUP) equal to False
  • Actions
    • Unit - Add (Triggering Unit) to COURIER_UNITS_GROUP
  • Events
    • Unit - A unit dies
  • Conditions
    • ((Triggering Unit) is in COURIER_UNITS_GROUP) equal to True
  • Actions
    • Unit - Remove (Triggering Unit) from COURIER_UNITS_GROUP
  • Events
    • Time - Elapsed game-time is 0.50 seconds
  • Conditions
  • Actions
    • Set COURIER_UNITS_GROUP = (Units of type COURIER)
    • -------- --------
    • Set COURIER_ABILITY_COUNT = (COURIER_ABILITY_COUNT + 1)
    • Set COURIER_ABILITY[COURIER_ABILITY_COUNT] = SomeArmorAbility
    • Set COURIER_ABILITY_COUNT = (COURIER_ABILITY_COUNT + 1)
    • Set COURIER_ABILITY[COURIER_ABILITY_COUNT] = SomeDamageAbility
    • Set COURIER_ABILITY_COUNT = (COURIER_ABILITY_COUNT + 1)
    • Set COURIER_ABILITY[COURIER_ABILITY_COUNT] = SomeAttackspeedAbility
    • Set COURIER_ABILITY_COUNT = (COURIER_ABILITY_COUNT + 1)
    • Set COURIER_ABILITY[COURIER_ABILITY_COUNT] = SomeHealthAbility
There's an issue with this, which is that HP-granting abilities don't work with multiple levels. If you increase the level it won't add the 'new' correct bonus hp to the target, but when you remove the ability it will remove the hp that should have been added. While weird this did allow BonusMod to work back in the day. The way around that now is just to be aware of it and use some system or bit of code that is supposed to make it easy to manipulate HP this way. You can use N different abilities and then add/remove them properly, which will work.

What should happen if a courier unit with < 100 current HP drops its last remaining item? Die? Have 1 hp? Can't lose item?
 
Level 3
Joined
Aug 19, 2016
Messages
18
Thank you, if I can manage to recreate your example triggers, I think that will work perfectly. 😁
 
Top