- Joined
- Jul 14, 2011
- Messages
- 3,213
Hi!
Eh... I made a custom damage system to store damage types and resistances in a hash table for every unit-type, but I need to know how to handle the same values for heroes, since it's dinamyc, depends on stats (which vary) and item equip/unequip, etc.
The map is an RPG, every player has 1 hero of the same type. I'm using The_Witcher equipment system.
These are my damage / resistance types (Child value). Unit type ID is the Parent value.
As you can see, hero damage/resistance values are indeed the player values, saved as (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) of (Player Number) in the hashtable.
Since heroes may get bonuses anytime, I think the best would be to set every value attached to the heroes every second, as following.
I still have to add the rest of the damage types and else. This way, whenever the unit levels up, or has some kind of side effect, it would be reflected automatically.
I don't really have an specific question, I'm just not very sure if there's a better way than this. The only one that comes to my mind is setting the values in every event (Unit levels up = set bla bla / Unit learns a skill = set bla bla / Unit equips an item = set bla bla)
Eh... I made a custom damage system to store damage types and resistances in a hash table for every unit-type, but I need to know how to handle the same values for heroes, since it's dinamyc, depends on stats (which vary) and item equip/unequip, etc.
The map is an RPG, every player has 1 hero of the same type. I'm using The_Witcher equipment system.
These are my damage / resistance types (Child value). Unit type ID is the Parent value.
-
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 2.00 as 2 of i in DamageHash
-
Events
JASS:
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
-
Damage Itself
-
Events
- Game - GDD_Event becomes Equal to 0.00
- Conditions
-
Actions
- -------- 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
- -------- 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)
- -------- Total Damage --------
- Custom script: set udg_Dmg = udg_PD + udg_FD + udg_WiD + udg_ED + udg_WaD + udg_PuD
- -------- 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
As you can see, hero damage/resistance values are indeed the player values, saved as (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) of (Player Number) in the hashtable.
Since heroes may get bonuses anytime, I think the best would be to set every value attached to the heroes every second, as following.
-
Heroes Stats
-
Events
- Time - Every 1.00 seconds of game time
- Conditions
-
Actions
- Custom script: set bj_wantDestroyGroup = true
-
Unit Group - Pick every unit in (Units of type Mountain King) and do (Actions)
-
Loop - Actions
- -------- Unit / Owner / Number --------
- Set u = (Picked 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 iPD[i] = iPD[i]
- Set PD = (iPD[i] + ((HeroAgi[i] x 0.50) + ((HeroInt[i] x 0.25) + (HeroStr[i] + 1.00))))
- Hashtable - Save PD as 1 of i in DamageHash
- -------- Physycal Resistance --------
- Set iPR[i] = iPR[i]
- Set PR[i] = (iPD[i] + (HeroStr[i] / 50.00))
- Hashtable - Save PR[i] as 2 of i in DamageHash
-
Loop - Actions
-
Events
I still have to add the rest of the damage types and else. This way, whenever the unit levels up, or has some kind of side effect, it would be reflected automatically.
I don't really have an specific question, I'm just not very sure if there's a better way than this. The only one that comes to my mind is setting the values in every event (Unit levels up = set bla bla / Unit learns a skill = set bla bla / Unit equips an item = set bla bla)