Moderator
M
Moderator
|
Spirit of the Forest
Someone requested this certain spell in GUI using Hashtable with the Spirits being clickable and showing HP. Might as well share it in the spell section. Maybe someone can use it or learn from it.
Spell Info:
Has a chance to summon a spirit that will circle around this Hero when attacked. Each spirit summoned decreases all attributes of this Hero by 1. Spirits damages nearby enemy units and self within 200 AoE. Spirits cast a weaker Detonate upon death and has an HP of 300.
Level 1 - 20% chance, 30 DPS, maximum of 6 spirits
Level 2 - 40% chance, 40 DPS, maximum of 8 spirits
Level 3 - 60% chance, 50 DPS, maximum of 10 spirits
CONFIGURABLES:
- The chance to summon Spirits per Level
- Editable to be clickable / not clickable
- Damage per second of the Spirits
- AoE of the Spirit Damage
- Damage to self of the Spirits
- Attribute Effects to the Hero when a spirit is summoned (gain / loss / no effect)
- Speed of Spirit Rotation
- Spirit Radius from the Hero
- Maximum number of Spirits that can circle the hero per level
- HP of the Spirit
Spirit of the Forest Configurables
Events
Map initialization
Conditions
Actions
-------- Spirit of the Forest Attack Type and Damage Type --------
Set SOTF_attackType = Spells
Set SOTF_damageType = Magic
-------- If you want the spinning spirits to be clickable and showing HP bar, set SOTF_clickable = true --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_clickable = False
-------- --------------------------------------------------------------------------------- --------
-------- Special Effect when an enemy unit is damaged by the spirit --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_damagedSpEffect = Abilities\Spells\Undead\DeathandDecay\DeathandDecayTarget.mdl
Set SOTF_spiritSpEffect = Abilities\Weapons\SpiritOfVengeanceMissile\SpiritOfVengeanceMissile.mdl
-------- --------------------------------------------------------------------------------- --------
-------- The Chance for the Spirit of the Forest To Active --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_chanceToActivate[1] = 20
Set SOTF_chanceToActivate[2] = 40
Set SOTF_chanceToActivate[3] = 60
-------- --------------------------------------------------------------------------------- --------
-------- The Spirit Damage to Nearby Units within certain AoE every 0.03 second --------
-------- Formula: SOTF_damage = 0.03 * X damage/second --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_damage[1] = 0.90
Set SOTF_damage[2] = 1.20
Set SOTF_damage[3] = 1.50
-------- --------------------------------------------------------------------------------- --------
-------- The Spirit Damage Area of Effect --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_aoe[1] = 120.00
Set SOTF_aoe[2] = 135.00
Set SOTF_aoe[3] = 150.00
-------- --------------------------------------------------------------------------------- --------
-------- The Spirit Damage to Self. Setting it to 0.3 reduces 10 hp/second. --------
-------- Formula: SOTF_selfDamage = 0.03 * X damage/second --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_selfDamage[1] = 0.90
Set SOTF_selfDamage[2] = 1.20
Set SOTF_selfDamage[3] = 1.50
-------- --------------------------------------------------------------------------------- --------
-------- Maximum number of spirits that can spin around the Hero --------
-------- Values can be from 0 to (Number of Levels in the "SOTF_AttributeEffect" Ability) --------
Set SOTF_maxSpirits[1] = 6
Set SOTF_maxSpirits[2] = 8
Set SOTF_maxSpirits[3] = 10
-------- --------------------------------------------------------------------------------- --------
-------- Distance of the spirits from the Hero --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_spiritDistance = 300.00
-------- --------------------------------------------------------------------------------- --------
-------- An SOTF_speed of 10.8 is equal to 1 revolution per second --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_spiritSpeed = 5.40
-------- --------------------------------------------------------------------------------- --------
-------- Spell Variables --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_buff = Spirit of the Forest
Set SOTF_heroAbility = Spirit of the Forest
Set SOTF_unitType = Spirit of the Forest Unit
Set SOTF_detonateAbility = SOTF Detonate
Set SOTF_attributeEffectAbility = SOTF Attribute Effect
REQUIREMENTS:
A Damage Detection System. In the sample map, I used
Physical Damage Detection for GUI by looking_for_help, but any DDS will do if you prefers to trigger the spell when unit is damaged instead of when attacked.
SPELL TRIGGERS:
OnDamage
Events
Game - PDD_damageEventTrigger becomes Equal to 1.00
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
PDD_damageType Equal to PDD_PHYSICAL
Then - Actions
-------- -------------------------------------- --------
-------- Spirit of the Forest Codes --------
-------- Copy these CODES to your Damage Detection System/Engine --------
-------- -------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(PDD_target has buff SOTF_buff) Equal to True
Then - Actions
Set SOTF_tempInteger = (Random integer number between 1 and 100)
Set SOTF_spiritNum = (Level of SOTF_attributeEffectAbility for PDD_target)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_tempInteger Less than or equal to SOTF_chanceToActivate[(Level of SOTF_heroAbility for PDD_target)]
SOTF_spiritNum Less than SOTF_maxSpirits[(Level of SOTF_heroAbility for PDD_target)]
Then - Actions
Set SOTF_tempInteger = (Level of SOTF_heroAbility for PDD_target)
-------- --------------------------------------------------------------------------------- --------
-------- Positioning of the next Spirit to summon --------
-------- --------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_spiritNum Equal to 0
Then - Actions
-------- The first spirit to spawn has a random location --------
Set SOTF_tempAngle = (Random real number between 0.00 and 359.00)
-------- The Level of the Ability is also used as a storage for how many spirits are currently spinning --------
Unit - Add SOTF_attributeEffectAbility to PDD_target
Else - Actions
-------- Next spirit's location is relative to the previous spirit's location --------
-------- tempReal is the polar distance between spirits --------
Set SOTF_angleIncrement = (360.00 / (Real((SOTF_spiritNum + 1))))
-------- Pick a spirit's current angular position to be used as a reference --------
Set SOTF_tempBoolean = True
Unit Group - Pick every unit in SOTF_unitGroup and do (Actions)
Loop - Actions
Set SOTF_caster = (Load (Key SOTF_Caster) of (Key (Picked unit)) in SOTF_hashtable)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_caster Equal to PDD_target
SOTF_tempBoolean Equal to True
Then - Actions
Set SOTF_tempAngle = (Load (Key SOTF_Angle) of (Key (Picked unit)) from SOTF_hashtable)
-------- Reference angle is determined. Do not pick another unit again --------
Set SOTF_tempBoolean = False
Else - Actions
-------- Move all other spirits relative to the reference --------
Unit Group - Pick every unit in SOTF_unitGroup and do (Actions)
Loop - Actions
Set SOTF_caster = (Load (Key SOTF_Caster) of (Key (Picked unit)) in SOTF_hashtable)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_caster Equal to PDD_target
Then - Actions
Hashtable - Save SOTF_tempAngle as (Key SOTF_Angle) of (Key (Picked unit)) in SOTF_hashtable
Set SOTF_tempAngle = (SOTF_tempAngle + SOTF_angleIncrement)
Else - Actions
-------- The Level of the Ability is also used as a storage for how many spirits are currently spinning --------
Unit - Increase level of SOTF_attributeEffectAbility for PDD_target
-------- --------------------------------------------------------------------------------- --------
-------- ------------- Summoned Spirit Codes ---------------- --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_tempLoc = (Position of PDD_target)
Set SOTF_tempLoc2 = (SOTF_tempLoc offset by SOTF_spiritDistance towards SOTF_tempAngle degrees)
Unit - Create 1 SOTF_unitType for (Owner of PDD_target) at SOTF_tempLoc2 facing 0.00 degrees
Set SOTF_tempUnit = (Last created unit)
Special Effect - Create a special effect attached to the origin of SOTF_tempUnit using SOTF_spiritSpEffect
Set SOTF_effect = (Last created special effect)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_clickable Equal to False
Then - Actions
Custom script: call UnitAddAbility(udg_SOTF_tempUnit, 'Aloc')
Else - Actions
Unit - Turn collision for SOTF_tempUnit Off
Hashtable - Save Handle OfSOTF_effect as (Key SOTF_effect) of (Key (Last created unit)) in SOTF_hashtable
Hashtable - Save SOTF_tempAngle as (Key SOTF_Angle) of (Key (Last created unit)) in SOTF_hashtable
Hashtable - Save Handle OfPDD_target as (Key SOTF_Caster) of (Key (Last created unit)) in SOTF_hashtable
Custom script: if (FirstOfGroup(udg_SOTF_unitGroup) == null) then
Trigger - Turn on Spirit of the Forest Loop <gen>
Custom script: endif
Unit Group - Add SOTF_tempUnit to SOTF_unitGroup
Custom script: call RemoveLocation(udg_SOTF_tempLoc)
Custom script: call RemoveLocation(udg_SOTF_tempLoc2)
Else - Actions
Else - Actions
Else - Actions
Spirit of the Forest Loop
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
Unit Group - Pick every unit in SOTF_unitGroup and do (Actions)
Loop - Actions
-------- --------------------------------------------------------------------------------- --------
-------- ------------- SOTF_tempUnit refers to Spirit -------------------------- --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_tempUnit = (Picked unit)
-------- --------------------------------------------------------------------------------- --------
-------- The Polar Angle of the Spirit relative to the Hero --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_tempAngle = ((Load (Key SOTF_Angle) of (Key (Picked unit)) from SOTF_hashtable) + SOTF_spiritSpeed)
-------- --------------------------------------------------------------------------------- --------
-------- SOTF_caster refers to the Hero --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_caster = (Load (Key SOTF_Caster) of (Key (Picked unit)) in SOTF_hashtable)
Set SOTF_tempInteger = (Level of SOTF_heroAbility for SOTF_caster)
Set SOTF_tempLoc = (Position of SOTF_caster)
Set SOTF_tempLoc2 = (SOTF_tempLoc offset by SOTF_spiritDistance towards SOTF_tempAngle degrees)
Unit - Move SOTF_tempUnit instantly to SOTF_tempLoc2
Hashtable - Save SOTF_tempAngle as (Key SOTF_Angle) of (Key (Picked unit)) in SOTF_hashtable
-------- --------------------------------------------------------------------------------------------------- --------
-------- -------------------- Damages Nearby Enemy Units ----------------------------- --------
-------- --------------------------------------------------------------------------------------------------- --------
Set SOTF_tempGroup = (Units within SOTF_aoe[SOTF_tempInteger] of SOTF_tempLoc2)
Unit Group - Pick every unit in SOTF_tempGroup and do (Actions)
Loop - Actions
-------- -------------------- Damages Nearby Enemy Units ----------------------------- --------
Set SOTF_tempUnit = (Picked unit)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(SOTF_tempUnit is alive) Equal to True
(SOTF_tempUnit belongs to an enemy of (Owner of SOTF_caster)) Equal to True
((Unit-type of SOTF_tempUnit) is A structure) Equal to False
Then - Actions
Unit - Cause SOTF_caster to damage SOTF_tempUnit, dealing SOTF_damage[SOTF_tempInteger] damage of attack type SOTF_attackType and damage type SOTF_damageType
Special Effect - Create a special effect attached to the origin of SOTF_tempUnit using SOTF_damagedSpEffect
Special Effect - Destroy (Last created special effect)
Else - Actions
Set SOTF_tempUnit = (Picked unit)
Custom script: call DestroyGroup(udg_SOTF_tempGroup)
-------- --------------------------------------------------------------------------------- --------
-------- -------------------- Decrease Spirit Life ----------------------------- --------
-------- --------------------------------------------------------------------------------- --------
Custom script: call SetWidgetLife(udg_SOTF_tempUnit, GetWidgetLife(udg_SOTF_tempUnit) - udg_SOTF_selfDamage[udg_SOTF_tempInteger])
-------- --------------------------------------------------------------------------------- --------
-------- Cast the weaker Detonate before dying --------
-------- --------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Life of SOTF_tempUnit) Less than or equal to SOTF_selfDamage[SOTF_tempInteger]
Then - Actions
-------- Destroy the Attached Effect on the Spirit before killing it --------
Set SOTF_effect = (Load (Key SOTF_effect) of (Key (Picked unit)) in SOTF_hashtable)
Special Effect - Destroy SOTF_effect
-------- --------------------------------------------------------------------------------------- --------
Unit - Order SOTF_tempUnit to Night Elf Wisp - Detonate SOTF_tempLoc2
Unit Group - Remove SOTF_tempUnit from SOTF_unitGroup
-------- --------------------------------------------------------------------------------- --------
-------- Attribute Effect to the Hero. The Level of the Ability is also used as a storage for how many spirits are currently spinning --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_spiritNum = (Level of SOTF_attributeEffectAbility for SOTF_caster)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_spiritNum Equal to 1
Then - Actions
Unit - Remove SOTF_attributeEffectAbility from SOTF_caster
Else - Actions
Unit - Decrease level of SOTF_attributeEffectAbility for SOTF_caster
Hashtable - Clear all child hashtables of child (Key (Picked unit)) in SOTF_hashtable
-------- If SOTF_unitGroup is empty, turn off this trigger --------
Custom script: if (FirstOfGroup(udg_SOTF_unitGroup) == null) then
Trigger - Turn off Spirit of the Forest Loop <gen>
Custom script: endif
Else - Actions
Custom script: call RemoveLocation(udg_SOTF_tempLoc)
Custom script: call RemoveLocation(udg_SOTF_tempLoc2)
IMPLEMENTATION
1) Make sure you check the "Automatically create unknown variables while pasting trigger data" in File->Preferences of World Editor.
2) Copy the 1 Custom Buff named Spirit of the Forest.
3) Copy SOTF Attribute Effect, SOTF Detonate, and the Spirit of the Forest Hero Ability
4) Copy the 'Spirit of the Forest' Unit.
5) Copy the whole "Spells" Trigger folder & paste in map.
6) If you are using your own DDS, copy this part to your own DDS, otherwise copy the "Damage Library" Trigger folder.
-------- -------------------------------------- --------
-------- Spirit of the Forest Codes --------
-------- Copy these CODES to your Damage Detection System/Engine --------
-------- -------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(PDD_target has buff SOTF_buff) Equal to True
Then - Actions
Set SOTF_tempInteger = (Random integer number between 1 and 100)
Set SOTF_spiritNum = (Level of SOTF_attributeEffectAbility for PDD_target)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_tempInteger Less than or equal to SOTF_chanceToActivate[(Level of SOTF_heroAbility for PDD_target)]
SOTF_spiritNum Less than SOTF_maxSpirits[(Level of SOTF_heroAbility for PDD_target)]
Then - Actions
Set SOTF_tempInteger = (Level of SOTF_heroAbility for PDD_target)
-------- --------------------------------------------------------------------------------- --------
-------- Positioning of the next Spirit to summon --------
-------- --------------------------------------------------------------------------------- --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_spiritNum Equal to 0
Then - Actions
-------- The first spirit to spawn has a random location --------
Set SOTF_tempAngle = (Random real number between 0.00 and 359.00)
-------- The Level of the Ability is also used as a storage for how many spirits are currently spinning --------
Unit - Add SOTF_attributeEffectAbility to PDD_target
Else - Actions
-------- Next spirit's location is relative to the previous spirit's location --------
-------- tempReal is the polar distance between spirits --------
Set SOTF_angleIncrement = (360.00 / (Real((SOTF_spiritNum + 1))))
-------- Pick a spirit's current angular position to be used as a reference --------
Set SOTF_tempBoolean = True
Unit Group - Pick every unit in SOTF_unitGroup and do (Actions)
Loop - Actions
Set SOTF_caster = (Load (Key SOTF_Caster) of (Key (Picked unit)) in SOTF_hashtable)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_caster Equal to PDD_target
SOTF_tempBoolean Equal to True
Then - Actions
Set SOTF_tempAngle = (Load (Key SOTF_Angle) of (Key (Picked unit)) from SOTF_hashtable)
-------- Reference angle is determined. Do not pick another unit again --------
Set SOTF_tempBoolean = False
Else - Actions
-------- Move all other spirits relative to the reference --------
Unit Group - Pick every unit in SOTF_unitGroup and do (Actions)
Loop - Actions
Set SOTF_caster = (Load (Key SOTF_Caster) of (Key (Picked unit)) in SOTF_hashtable)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_caster Equal to PDD_target
Then - Actions
Hashtable - Save SOTF_tempAngle as (Key SOTF_Angle) of (Key (Picked unit)) in SOTF_hashtable
Set SOTF_tempAngle = (SOTF_tempAngle + SOTF_angleIncrement)
Else - Actions
-------- The Level of the Ability is also used as a storage for how many spirits are currently spinning --------
Unit - Increase level of SOTF_attributeEffectAbility for PDD_target
-------- --------------------------------------------------------------------------------- --------
-------- ------------- Summoned Spirit Codes ---------------- --------
-------- --------------------------------------------------------------------------------- --------
Set SOTF_tempLoc = (Position of PDD_target)
Set SOTF_tempLoc2 = (SOTF_tempLoc offset by SOTF_spiritDistance towards SOTF_tempAngle degrees)
Unit - Create 1 SOTF_unitType for (Owner of PDD_target) at SOTF_tempLoc2 facing 0.00 degrees
Set SOTF_tempUnit = (Last created unit)
Special Effect - Create a special effect attached to the origin of SOTF_tempUnit using SOTF_spiritSpEffect
Set SOTF_effect = (Last created special effect)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
SOTF_clickable Equal to False
Then - Actions
Custom script: call UnitAddAbility(udg_SOTF_tempUnit, 'Aloc')
Else - Actions
Unit - Turn collision for SOTF_tempUnit Off
Hashtable - Save Handle OfSOTF_effect as (Key SOTF_effect) of (Key (Last created unit)) in SOTF_hashtable
Hashtable - Save SOTF_tempAngle as (Key SOTF_Angle) of (Key (Last created unit)) in SOTF_hashtable
Hashtable - Save Handle OfPDD_target as (Key SOTF_Caster) of (Key (Last created unit)) in SOTF_hashtable
Custom script: if (FirstOfGroup(udg_SOTF_unitGroup) == null) then
Trigger - Turn on Spirit of the Forest Loop <gen>
Custom script: endif
Unit Group - Add SOTF_tempUnit to SOTF_unitGroup
Custom script: call RemoveLocation(udg_SOTF_tempLoc)
Custom script: call RemoveLocation(udg_SOTF_tempLoc2)
Else - Actions
Else - Actions
7) If you are using the same Damage Detection Engine, copy the 2 abilities 'DAMAGE_TYPE_DETECTOR and SET_MAX_LIFE'.
8) Test the map