So, some background information. Each item has a number of charges equal to its level. This allows me to easily bar people from picking up higher leveled items without having to add them all to a group via triggers. The following trigger is how I level the abilities on my items. Using an axe as an example. Note that the only thing that bugs here is the HP (or MP). Damage, stats, or pretty much anything else works fine.
Code
Axe Damage
Events
Unit - A unit Acquires an item
Conditions
(Substring((Name of (Item being manipulated)), 1, 3)) Equal to Axe
Actions
Unit - Set level of Axe Damage Bonus for (Triggering unit) to ((Charges remaining in (Item being manipulated)) / 5)
Unit - Set level of Axe Life Bonus for (Triggering unit) to ((Charges remaining in (Item being manipulated)) / 5)
Now. Just because I've brought it up so often. I figure I'll post my stat based spell triggers. This is done in multiple parts.
Code
Spell Setup
Events
Unit - A unit enters (Entire map)
Conditions
Actions
Trigger - Add to Damage display <gen> the event (Unit - (Entering unit) Takes damage)
Trigger - Add to Healing display <gen> the event (Unit - (Entering unit) Takes damage)
-------- 1 THROUGH 20 --------
Trigger - Add to Spell 1x INT <gen> the event (Unit - (Entering unit) Takes damage)
Trigger - Add to Spell 2x INT <gen> the event (Unit - (Entering unit) Takes damage)
Trigger - Add to Spell 3x INT <gen> the event (Unit - (Entering unit) Takes damage)
Trigger - Add to Spell 4x INT <gen> the event (Unit - (Entering unit) Takes damage)
This trigger makes damage detection possible for every unit in the map. It also requires that there be no pre-placed units on the map (or that they be replaced if there are any). The trigger is a lot longer than what's posted here, as you need to add this event to EVERY damage dealing trigger.Added (2012-11-19, 7:05:12 PM)
---------------------------------------------
Next is my damage display.
Code
Damage display
Events
Conditions
(Damage taken) Greater than or equal to 1.01
Actions
Floating Text - Create floating text that reads (String((Integer((Damage taken))))) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the fading age of (Last created floating text) to 0.50 seconds
Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
Pretty self explanatory. Whenever a unit takes damage higher than 1, it will show up as floating red text.
And now the opposite trigger for healing. The same but with negative damage.
Code
Healing display
Events
Conditions
(Damage taken) Less than 0.00
Actions
Floating Text - Create floating text that reads (String(((Integer((Damage taken))) x -1))) above (Triggering unit) with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
Floating Text - Change (Last created floating text): Disable permanence
Floating Text - Change the fading age of (Last created floating text) to 0.50 seconds
Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
Added (2012-11-19, 7:05:36 PM)
---------------------------------------------
Finally you have one of the damage dealing triggers. These work by making the actual ability deal a specific amount of damage below 1 that corresponds to the trigger.
For example
Code
Spell 1x INT
Events
Conditions
(Damage taken) Equal to 0.01
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
((Triggering unit) has buff Banish) Equal to True
Then - Actions
Unit - Cause (Damage source) to damage (Triggering unit), dealing (2.00 x (Real((Intelligence of (Damage source) (Include bonuses))))) damage of attack type Spells and damage type Normal
Else - Actions
Unit - Cause (Damage source) to damage (Triggering unit), dealing (1.00 x (Real((Intelligence of (Damage source) (Include bonuses))))) damage of attack type Spells and damage type Normal
This of course requires that the damage is not altered by armor type. So all armor types must take 100% damage from spells. You can still change the other values if you like. Any item that reduces magic damage will break the trigger as well.Added (2012-11-19, 7:05:47 PM)
---------------------------------------------
The trigger for stat based summons is a lot simpler. You simply have to make every summon a hero (hide its glow, icon, etc) and then this trigger will work.
Code
Water Elementals LVL 1
Events
Unit - A unit Spawns a summoned unit
Conditions
(Unit-type of (Summoned unit)) Equal to Water Elemental (Hero Lvl1)
Actions
Hero - Modify Strength of (Summoned unit): Set to ((Intelligence of (Summoning unit) (Include bonuses)) / 3)
Hero - Modify Agility of (Summoned unit): Set to ((Intelligence of (Summoning unit) (Include bonuses)) / 4)
Hero - Modify Intelligence of (Summoned unit): Set to ((Intelligence of (Summoning unit) (Include bonuses)) / 3)
and this ensures that your summons aren't reviveable at an altar.
Code
Summon cleanup
Events
Unit - A unit Becomes revivable
Conditions
And - All (Conditions) are true
Conditions
((Triggering unit) is A Hero) Equal to True
((Triggering unit) is Summoned) Equal to True
Actions
Unit - Remove (Triggering unit) from the game
So that's about it. Comments?