• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[General] Items + trigger editor

Status
Not open for further replies.
Level 2
Joined
Mar 24, 2015
Messages
14
How to make items give u bonuses like having an item that gives u health and armor using trigger editor? Because creating a custom item ability isnt efficient having no original abilities with same bonuses.
 
Level 12
Joined
May 22, 2015
Messages
1,051
How to make items give u bonuses like having an item that gives u health and armor using trigger editor? Because creating a custom item ability isnt efficient having no original abilities with same bonuses.

It basically requires a big setup, but then it will work for every item you add (and even abilities that add bonuses for buffs or just passive bonuses).

Not every stat works the same, but it is something along the lines of:

armor0 - adds 1 armor
armor1 - adds 2 armor
armor2 - adds 4 armor
armor3 - adds 8 armor
armor4 - adds 16 armor
armor5 - adds 32 armor
(continue like this unit you don't need further armor bonuses)

Then you have to keep track of a unit's bonus armor (hashtable or unit indexer is most likely necessary).

When you modify armor, you:
1) remove all of the armor abilities
2) check each armor ability like so:
armor to add = total bonus armor
if armor to add > 32
add the +32 armor ability
reduce armor to add by 32
endif

Repeat this check for each ability always doing the biggest ability before the others (and adjust the numbers).

You can do the same thing with negative values in case you want to be able to reduce below 0 bonus armor.

With that set up of abilities, you can add any amount from 0-63 (it's always the max level bonus x 2 - 1). You can double the max armor bonus by adding one more ability. Very quickly, it becomes unnecessary to add any more abilities.

If you do this for every stat, you can add all the bonuses manually in the triggers rather than in the object editor. It is very handy in the long run, but as I said, this is quite a bit to set up.

________________________________________________

Health works a bit differently. There is a bug with the max health (and max mana) bonus item ability. If you change the level of the ability, it does not update the amount of health the unit gets. However, if you remove the ability, it removes the amount of health the current level of the ability is supposed to add.

To use this to your advantage, set the level 1 amount to 0 health bonus, and set the level 2 amount to -100 (or whatever amount you want). Then, you add the ability, set it to level 2, then remove it, and it will remove -100 health (which adds 100 health). There is no longer an ability attached to it, so this 100 health is permanent.

Unless you go crazy with it, you can probably get by with a -10 and a -100 ability.

_________________________________________________

You can set up triggers to add the stats when you pick up certain items, or you can create a hash table to store the item stat bonuses and apply them when you pick them up and remove them when you drop them. Using a hashtable will make it faster, but it will also require some more setup work.

Remember that these actions are expensive (looping over the abilities to check them) so you do not want to be spamming them. Limiting it to just on the item gain and item loss events is a good way to keep them in check so that they don't slow down your map.

It is a ton of work to set this all up, but there may be systems to do this already built. The result is amazing, though. You can just do anything you want with any stat at any time in the triggers. No need to go through the object editor each time you want to modify some stats.
 
Status
Not open for further replies.
Top