- Joined
- Jul 14, 2011
- Messages
- 3,213
Hi!
I made this system to trigger my map damage... But right now it's kinda "big" and I'm having some troubles achieving some stuff..
These is the Hashtable data so far.
0 - Spell Damage - > Override the rest of damage data. Boolean
1 - Physical Damage
2 - Physycal Resistance
3 - Fire Damage
4 - Fire Resistance
5 - Wind Damage
6 - Wind Resistance
7 - Earth Damage
8 - Earth Resistance
9 - Water Damage
10 - Water Resistance
11 - Pure Damage
12 - Critical Chance
13 - Critical Rate
14 - Evasion
15 - Bash Chance
16 - Bash Duration
17- Bashed Time
This is how I set the damage based on the unit type ID.
This is how I handle the Hero stats. It's "Player" stat, since it's based on Player Number.
All the "iVariable" are for Skills/Items/Etc. bonuses.
This is how I display the selected units information.
This is how I handle stunned units.
This is my trigger to deal damage.
.
I'd like to know how to improve the overall. Now I noticed that, as it is right now, I can't modify specific unit values, since all the data is taken from "Unit Type" and not specific unit ID.
Also, I want to display the data in a Hashtable for triggering player, rather than doing it with Game text.
Another thing is that I'm having too many variables...
I haven't done the trigger that actually sets the Hero/Player values, since i'm using The Witcher equipment system and gets a bit harder.
I made this system to trigger my map damage... But right now it's kinda "big" and I'm having some troubles achieving some stuff..
These is the Hashtable data so far.
0 - Spell Damage - > Override the rest of damage data. Boolean
1 - Physical Damage
2 - Physycal Resistance
3 - Fire Damage
4 - Fire Resistance
5 - Wind Damage
6 - Wind Resistance
7 - Earth Damage
8 - Earth Resistance
9 - Water Damage
10 - Water Resistance
11 - Pure Damage
12 - Critical Chance
13 - Critical Rate
14 - Evasion
15 - Bash Chance
16 - Bash Duration
17- Bashed Time
This is how I set the damage based on the unit type ID.
-
Damage Set
-
Events
- Time - Elapsed game time is 0.00 seconds
- Conditions
-
Actions
- Hashtable - Create a hashtable
- Set DamageHash = (Last created hashtable)
- -------- Footman --------
- Custom script: set udg_i = 'hfoo'
- Hashtable - Save 7.00 as 1 of i in DamageHash
- Hashtable - Save 0.15 as 2 of i in DamageHash
- Hashtable - Save 1.00 as 12 of i in DamageHash
- Hashtable - Save 1.20 as 13 of i in DamageHash
- Hashtable - Save 0.00 as 14 of i in DamageHash
- Hashtable - Save 1.00 as 15 of i in DamageHash
- Hashtable - Save 10.00 as 16 of i in DamageHash
-
Events
This is how I handle the Hero stats. It's "Player" stat, since it's based on Player Number.
All the "iVariable" are for Skills/Items/Etc. bonuses.
-
Heroes Stats
-
Events
- Unit - A unit enters (Playable map area)
- Unit - A unit Acquires an item
- Unit - A unit Uses an item
- Unit - A unit Loses an item
- Unit - A unit Learns a skill
-
Conditions
- (Unit-type of (Triggering unit)) Equal to Mountain King
-
Actions
- -------- Unit / Owner / Number --------
- Set u = (Triggering unit)
- Set p = (Owner of u)
- Set i = (Player number of p)
- -------- Stats --------
- Set HeroStr[i] = (Real((Strength of u (Include bonuses))))
- Set HeroAgi[i] = (Real((Agility of u (Include bonuses))))
- Set HeroInt[i] = (Real((Intelligence of u (Include bonuses))))
- -------- Physycal Damage --------
- Set PD = (iPD[i] + ((HeroAgi[i] x 0.50) + ((HeroInt[i] x 0.25) + (HeroStr[i] x 1.00))))
- Hashtable - Save PD as 1 of i in DamageHash
- -------- Physycal Resistance --------
- Set PR = (iPD[i] + (HeroStr[i] / 500.00))
- Hashtable - Save PR as 2 of i in DamageHash
- -------- Fire Damage --------
- Hashtable - Save iFD[i] as 3 of i in DamageHash
- -------- Fire Resistance --------
- Hashtable - Save iFR[i] as 4 of i in DamageHash
- -------- Wind Damage --------
- Hashtable - Save iWiD[i] as 5 of i in DamageHash
- -------- Wind Resistance --------
- Hashtable - Save iWiR[i] as 6 of i in DamageHash
- -------- Earth Damage --------
- Hashtable - Save iED[i] as 7 of i in DamageHash
- -------- Earth Resistance --------
- Hashtable - Save iER[i] as 8 of i in DamageHash
- -------- Water Damage --------
- Hashtable - Save iWaD[i] as 9 of i in DamageHash
- -------- Water Resistance --------
- Hashtable - Save iWaR[i] as 10 of i in DamageHash
- -------- Pure Damage --------
- Hashtable - Save iPuD[i] as 11 of i in DamageHash
- -------- Critical Chance --------
- Set CritChance[i] = (iCritChance[i] + (HeroInt[i] / 500.00))
- Hashtable - Save CritChance[i] as 12 of i in DamageHash
- -------- Critical Damage Rate --------
- Set CritRate[i] = (iCritRate[i] + (HeroStr[i] / 500.00))
- Hashtable - Save CritRate[i] as 13 of i in DamageHash
- -------- Evasion --------
- Set EvaChance[i] = (iEvaChance[i] + (HeroAgi[i] / 500.00))
- Hashtable - Save EvaChance[i] as 14 of i in DamageHash
- -------- Bash Chance --------
- Set BashChance_Hero[i] = (iBashChance[i] + (HeroStr[i] / 500.00))
- Hashtable - Save BashChance_Hero[i] as 15 of i in DamageHash
- -------- Bash Duration --------
- Set BashDuration_Hero[i] = (iBashDuration[i] + (HeroStr[i] / 500.00))
- Hashtable - Save BashDuration_Hero[i] as 16 of i in DamageHash
-
Events
This is how I display the selected units information.
-
Stat Display
-
Events
- Player - Player 1 (Red) types a chat message containing -st as An exact match
- Conditions
-
Actions
- Set p = (Triggering player)
- Set TempForce = (Player group(p))
- Set Temp_Group = (Units currently selected by p)
- Set Group2 = (Random 1 units from Temp_Group)
- Custom script: if GetLocalPlayer() == udg_p then
- Custom script: call ClearTextMessages()
- Custom script: endif
-
Unit Group - Pick every unit in Group2 and do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- ((Picked unit) is A Hero) Equal to True
-
Then - Actions
- Custom script: set udg_i = GetConvertedPlayerId(udg_p)
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, GetPlayerName(udg_p) + ":")
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
- Set ii = (Integer((Load 1 of i from DamageHash)))
- Set iii = (Integer(((Load 2 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffffd700Damage:|r " + (I2S(udg_ii) + (" |cffffd700/|r " + (I2S(udg_iii) + "% |cffffd700Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 3 of i from DamageHash)))
- Set iii = (Integer(((Load 4 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffff0000Damage:|r " + (I2S(udg_ii) + (" |cffff0000/|r " + (I2S(udg_iii) + "% |cffff0000Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 5 of i from DamageHash)))
- Set iii = (Integer(((Load 6 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff999999Damage:|r " + (I2S(udg_ii) + (" |cff999999/|r " + (I2S(udg_iii) + "% |cff999999Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 7 of i from DamageHash)))
- Set iii = (Integer(((Load 8 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff552200Damage:|r " + (I2S(udg_ii) + (" |cff552200/|r " + (I2S(udg_iii) + "% |cff552200Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 9 of i from DamageHash)))
- Set iii = (Integer(((Load 10 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff77bbffDamage:|r " + (I2S(udg_ii) + (" |cff77bbff/|r " + (I2S(udg_iii) + "% |cff77bbffResistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 11 of i from DamageHash)))
- Custom script: if udg_ii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff7F0080Damage:|r " + (I2S(udg_ii))))
- Custom script: endif
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
- Set ii = (Integer(((Load 12 of i from DamageHash) x 100.00)))
- Set Real = (Load 13 of i from DamageHash)
- Custom script: if udg_ii > 0 or udg_Real > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Critical: " + ((I2S(udg_ii) + "% x"))) + (R2SW(udg_Real, 1, 1)))
- Custom script: endif
- Set ii = (Integer(((Load 14 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Evasion: " + ((I2S(udg_ii) + "%"))))
- Custom script: endif
- Set ii = (Integer(((Load 15 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Bash Chance: " + ((I2S(udg_ii) + "%"))))
- Custom script: endif
-
Else - Actions
- Set u = (Picked unit)
- Custom script: set udg_i = GetHandleId(udg_u)
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, (GetUnitName(udg_u) + (": |cffffd700Level|r " + I2S(GetUnitLevel(udg_u)))))
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
- Set ii = (Integer((Load 1 of i from DamageHash)))
- Set iii = (Integer(((Load 2 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffffd700Damage:|r " + (I2S(udg_ii) + (" |cffffd700/|r " + (I2S(udg_iii) + "% |cffffd700Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 3 of i from DamageHash)))
- Set iii = (Integer(((Load 4 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cffff0000Damage:|r " + (I2S(udg_ii) + (" |cffff0000/|r " + (I2S(udg_iii) + "% |cffff0000Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 5 of i from DamageHash)))
- Set iii = (Integer(((Load 6 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff999999Damage:|r " + (I2S(udg_ii) + (" |cff999999/|r " + (I2S(udg_iii) + "% |cff999999Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 7 of i from DamageHash)))
- Set iii = (Integer(((Load 8 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff552200Damage:|r " + (I2S(udg_ii) + (" |cff552200/|r " + (I2S(udg_iii) + "% |cff552200Resistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 9 of i from DamageHash)))
- Set iii = (Integer(((Load 10 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 or udg_iii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff77bbffDamage:|r " + (I2S(udg_ii) + (" |cff77bbff/|r " + (I2S(udg_iii) + "% |cff77bbffResistance|r" )))))
- Custom script: endif
- Set ii = (Integer((Load 11 of i from DamageHash)))
- Custom script: if udg_ii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("|cff7F0080Damage:|r " + (I2S(udg_ii))))
- Custom script: endif
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, " ")
- Set ii = (Integer(((Load 12 of i from DamageHash) x 100.00)))
- Set Real = (Load 13 of i from DamageHash)
- Custom script: if udg_ii > 0 or udg_Real > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Critical: " + ((I2S(udg_ii) + "% x"))) + (R2SW(udg_Real, 1, 1)))
- Custom script: endif
- Set ii = (Integer(((Load 14 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Evasion: " + ((I2S(udg_ii) + "%"))))
- Custom script: endif
- Set ii = (Integer(((Load 15 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Bash: " + ((I2S(udg_ii) + "%"))))
- Custom script: endif
- Set ii = (Integer(((Load 16 of i from DamageHash) x 100.00)))
- Custom script: if udg_ii > 0 then
- Custom script: call DisplayTimedTextToForce(udg_TempForce, 20, ("Bash Duration: " + ((I2S(udg_ii))))
- Custom script: endif
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
- Custom script: call DestroyForce(udg_TempForce)
- Custom script: call DestroyGroup(udg_Temp_Group)
- Custom script: call DestroyGroup(udg_Group2)
-
Events
This is how I handle stunned units.
-
StunGroup
-
Events
- Time - Every 0.03 seconds of game time
- Conditions
-
Actions
-
Unit Group - Pick every unit in StunGroup and do (Actions)
-
Loop - Actions
- Custom script: set udg_i = GetHandleId(GetEnumUnit())
- Set BashDur = ((Load 17 of i from DamageHash) - 0.03)
- Hashtable - Save BashDur as 17 of i in DamageHash
- Game - Display to (All players) the text: (String(BashDur))
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- BashDur Less than or equal to 0.00
-
Then - Actions
- Hashtable - Save 0.00 as 17 of i in DamageHash
- Unit - Remove Stunned (Pause) buff from (Picked unit)
- Unit Group - Remove (Picked unit) from StunGroup
- Else - Actions
-
If - Conditions
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (Number of units in StunGroup) Equal to 0
-
Then - Actions
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
-
Unit Group - Pick every unit in StunGroup and do (Actions)
-
Events
This is my trigger to deal damage.
-
Damage Itself
-
Events
- Game - GDD_Event becomes Equal to 0.00
-
Conditions
- (Unit-type of GDD_DamageSource) Not equal to DUMMY
-
Actions
- Set FontSize = 8.00
- -------- DamagedUnit and DamageSource Id's --------
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (GDD_DamagedUnit is A Hero) Equal to True
-
Then - Actions
- Set I_DU = (Player number of (Triggering player))
-
Else - Actions
- Custom script: set udg_I_DU = GetUnitTypeId(udg_GDD_DamagedUnit)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (GDD_DamageSource is A Hero) Equal to True
-
Then - Actions
- Set I_DS = (Player number of (Owner of GDD_DamageSource))
-
Else - Actions
- Custom script: set udg_I_DS = GetUnitTypeId(udg_GDD_DamageSource)
-
If - Conditions
- Custom script: if LoadBooleanBJ(0, udg_I_DS, udg_DamageHash) == true then
- Custom script: return
- Custom script: endif
- -------- Damage Types (Odd) and Resistances (Even) --------
- Set PD = ((Load 1 of I_DS from DamageHash) x (1.00 - (Load 2 of I_DU from DamageHash)))
- Set FD = ((Load 3 of I_DS from DamageHash) x (1.00 - (Load 4 of I_DU from DamageHash)))
- Set WiD = ((Load 5 of I_DS from DamageHash) x (1.00 - (Load 6 of I_DU from DamageHash)))
- Set ED = ((Load 7 of I_DS from DamageHash) x (1.00 - (Load 8 of I_DU from DamageHash)))
- Set WaD = ((Load 9 of I_DS from DamageHash) x (1.00 - (Load 10 of I_DU from DamageHash)))
- Set PuD = (Load 11 of I_DS from DamageHash)
- Set CritChanc = (Load 12 of I_DS from DamageHash)
- Set CriticalRate = (Load 13 of I_DS from DamageHash)
- Set Eva = (Load 14 of I_DU from DamageHash)
- Set BashChance = (Load 15 of I_DS from DamageHash)
- Set BashDuration = (Load 16 of I_DS from DamageHash)
- -------- Total Damage --------
- Custom script: set udg_Dmg = udg_PD + udg_FD + udg_WiD + udg_ED + udg_WaD + udg_PuD
- -------- Evasion --------
- Custom script: if GetRandomReal(0, 1) <= udg_Eva then
- Floating Text - Create floating text that reads miss above GDD_DamageSource with Z offset 0.00, using font size 9.50, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
- Custom script: return
- Custom script: endif
- -------- Critical Hit --------
- Custom script: if udg_CritChanc > 0 and GetRandomReal(0,1) <= udg_CritChanc then
- Custom script: set udg_Dmg = (udg_Dmg * udg_CriticalRate)
- Set FontSize = 13.00
- Custom script: endif
- -------- Bash Chance --------
- Custom script: if udg_BashChance > 0 and GetRandomReal(0,1) <= udg_BashChance then
- Custom script: set udg_i = GetHandleId(udg_GDD_DamagedUnit)
- Set BashDur = ((Load 17 of i from DamageHash) + BashDuration)
- Custom script: if udg_BashDur > 2.5 then
- Custom script: set udg_BashDur = 2.5
- Custom script: endif
- Hashtable - Save BashDur as 17 of i in DamageHash
- Set Point = (Position of GDD_DamagedUnit)
- Unit - Create 1 DUMMY for (Owner of GDD_DamageSource) at Point facing Point
- Unit - Order (Last created unit) to Attack GDD_DamagedUnit
- Unit - Add a 0.20 second Generic expiration timer to (Last created unit)
- Unit Group - Add GDD_DamagedUnit to StunGroup
- Trigger - Turn on StunGroup <gen>
- Custom script: call RemoveLocation(udg_Point)
- Custom script: endif
- -------- Display Red Damage --------
- Custom script: if (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) < GetWidgetLife(udg_GDD_DamagedUnit) then
- Floating Text - Create floating text that reads (String((Integer(Dmg)))) above GDD_DamagedUnit with Z offset 0.00, using font size FontSize, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
- -------- Display Green Heal --------
- Custom script: elseif (GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg ) > GetWidgetLife(udg_GDD_DamagedUnit) then
- Custom script: call SetWidgetLife(udg_GDD_DamagedUnit, GetWidgetLife(udg_GDD_DamagedUnit) - udg_Dmg)
- Floating Text - Create floating text that reads (+ + (String((Integer((Abs(Dmg))))))) above GDD_DamagedUnit with Z offset -2.00, using font size FontSize, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
- Floating Text - Change (Last created floating text): Disable permanence
- Floating Text - Change the lifespan of (Last created floating text) to 2.00 seconds
- Floating Text - Change the fading age of (Last created floating text) to 1.00 seconds
- Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
- Custom script: endif
- -------- Deal Damage if it's > 0 --------
- Trigger - Turn off (This trigger)
- Custom script: if udg_Dmg > 0 then
- Custom script: call UnitDamageTarget(udg_GDD_DamageSource, udg_GDD_DamagedUnit, udg_Dmg, true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, null)
- Custom script: endif
- Trigger - Turn on (This trigger)
-
Events
I'd like to know how to improve the overall. Now I noticed that, as it is right now, I can't modify specific unit values, since all the data is taken from "Unit Type" and not specific unit ID.
Also, I want to display the data in a Hashtable for triggering player, rather than doing it with Game text.
Another thing is that I'm having too many variables...
I haven't done the trigger that actually sets the Hero/Player values, since i'm using The Witcher equipment system and gets a bit harder.