• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Hashtable / Damage Types / Modify values during game

Status
Not open for further replies.
Level 20
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.

  • 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
These are my damage types/resistances

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 (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)
      • -------- 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)
So far, with creeps, it works perfectly, but here are my problems when handling the heroes.

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
... But i'm not sure if this is the best way. iPD is for external values (Like items, auras, or buffs, or skills. I just set iPD = iPD + *BonusEffect*)

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)
 
Level 7
Joined
Apr 1, 2010
Messages
289
you should probably put the turn on/turn off trigger inside of the if, just to make so that they do not run uselessly(for efficiency)


this sets the damage for the heroes right? you could just have it detect the damage the heroes should do when they attack something, or damage something.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
bassee: It's a lot. The same actions if the unit equips an item, or uses an skill, or etc... I can't feel good with that :p

Narogog, I tough about that, but felt like it may be too much work, I don't know. Heroes can deal AoE damage and else, it would be a lot of work for the system on some fights.

After reading your suggestions, I think about doing this:

  • Heroes Stats
    • Events
      • A unit Acquires an Item <- For items that has effects on inventory
      • A unit losses an item <- When drops it
      • A unit learns a skill <- Only skills are Str, Agi, Int, Hp and Mp.
    • Conditions
      • Or (Any conditions are true):
        • Item-Type of Item Being Manipulated is... (Whole list of my items that has an inventory effect)
      • Triggering Unit is A Hero Equal to True
    • Actions
      • Bla bla bla
I use "OnEquip" and "UnEquip" with "GetEquippingUnit()" with The_Witcher Equipment system, so, I can add the bonus of the item (iPD or iPR, etc), and then run this trigger (ignoring conditions) to set the values acordingly.

This would run for all players though... (I don't have the editor here to think about how to do it only for the triggering player)
 
Status
Not open for further replies.
Top