• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Custom Damage System

Status
Not open for further replies.
Level 20
Joined
Jul 14, 2011
Messages
3,213
Hi! I started the thread on World Editor zone - http://www.hiveworkshop.com/forums/world-editor-help-zone-98/custom-complex-damage-system-205277/ -, and it already helped me to start with the trigger, but now I need to optimize it, and even know how to use it :p I'm not good at all on JASS or vJASS, but I understand that this kind of stuff is a lot easier JASS.

I'm trying to make a damage system that triggers game damage, so each unit has 6 types o damage, and 5 types of resistances.

Physic Dmg - Physic Resis
Fire Dmg - Fire Res
Water Dmg - Water Res
Wind Dmg - Wind Res
Earth Dmg - Earth Res
Pure Damage <- This one has no resistance.

So, every time a unit deals damage to another unit, the trigger retrieves all the data from the unit (All the Damage data of the Attacking Unit, and All the Resistance Data from the Attacked Unit) and deals the respective damage. Resistances are just a % of reduction of the attacking unit damage.

I'm thinking of making all units in my map deal 1-1 damage and have 0 armor, since all the damage and resistances are going to be triggered.

Adding all the data this way (or a better one) to every Unit Type in the game:

JASS:
globals
    integer array UnitID
    integer array PD         // Physical Damage 
    integer array PR         // Physical Resistance
    integer array FD         // Fire Damage
    integer array FR         // Fire Resist
    integer array WaD         // Water Damage
    integer array WaR         // Water Resistance
    integer array ED         // Earth Damage
    integer array ER         // Earth Resistance
    integer array WiD         // Wind Damage
    integer array WiR         // Wind Resistance
    integer array PD         // Pure Damage
    integer i = 0
endglobals

function UnitEle_Setup takes nothing returns nothing

    //Footman
    set i = i + 1
    set UnitID = 'h000'       
    set PD[i] = 15
    set PR[i] = 15
    set FD[i] = 0
    set FR[i] = 10
    set WaD[i] = 0
    set WaR[i] = 10
    set ED[i] = 20
    set ER[i] = 50
    set WiD[i] = 0
    set WiR[i] = 0
    set PD[i] 0
    
    //Archer
    set i = i + 1
    set UnitID = 'h001'       
    set PD[i] = 5
    set PR[i] = 15
    set FD[i] = 0
    set FR[i] = 0
    set WaD[i] = 15
    set WaR[i] = 50
    set ED[i] = 0
    set ER[i] = 0
    set WiD[i] = 50
    set WiR[i] = 50
    set PD[i] 0
    
//===========================================================================
function InitTrig_ThisTrig takes nothing returns nothing
    set gg_trg_ThisTrig = CreateTrigger(  )
    call TriggerAddAction( gg_trg_ThisTrig, function UnitEle_Setup )
endfunction

This is just an example. Since these are going to be damage amounts, and % of resistance, I think these should be 'real array' instead of 'integer array'. Simply, each damage detection would have 6 actions.

Cause 'DamageSource' deal 'PD[DamageSource] - PR[DamagedUnit]'
Cause 'DamageSource' deal 'FD[DamageSource] - FR[DamagedUnit]'
Cause 'DamageSource' deal 'WaD[DamageSource] - WaR[DamagedUnit]'
Cause 'DamageSource' deal 'WiD[DamageSource] - WiR[DamagedUnit]'
Cause 'DamageSource' deal 'ED[DamageSource] - ER[DamagedUnit]'
Cause 'DamageSource' deal 'PD[DamageSource]'

Any help around to do/improve this? I just need the base sytem... I'm the one that's going to place the data :p

BTW.. if target Unit has 100% resistance, it would deal 0 damage. If It has over 100% resistance, it should deal negative damage, which means heal the target (Hitting a Fire Elemental with a Fire Sword shouldn't damage it)

And I need a way to know if the damage is dealt by Spells or Attacks (I can add a buff to each spell, so the system detects the damage, and if the Unit has the buff, it means that the damage was a spell, remove the buff, and deal the spell damage excluding physical and elemental damage, that should only be done with attacks)
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
So what are you going to code this in, GUI, JASS, vJASS, ZINC, cJASS? Anyway about the system.

Detecting if it's a spell is easier than that, just trigger all spells that deals damage aka all object editor spells that deal damage should be set to 0 and you trigger the damage instead and when the spell is cast, you have a public boolean which is set to true, damage is done and then it's set to false afterwards. Then when the damage detection engine spots the boolean, it will know that it is a spell.

And as resistance, it should be percentage based right? So it will be basically a value between 0 and 1 with more or less if you want that heal option. So you'll just need to do "initialdamage * resistance percentage variable = damage output".

I'll recommend to use arrays and a unit indexing system so you can do O(1) search when you want to retrieve the resistance or the damage.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
So what are you going to code this in, GUI, JASS, vJASS, ZINC, cJASS? Anyway about the system.

I can do things in GUI, but not in JASS or vJASS, these I Just know how to manipulate a bit, but don't know how to do anything from scratch there.

Detecting if it's a spell is easier than that, just trigger all spells that deals damage aka all object editor spells that deal damage should be set to 0 and you trigger the damage instead and when the spell is cast, you have a public boolean which is set to true, damage is done and then it's set to false afterwards. Then when the damage detection engine spots the boolean, it will know that it is a spell.

Better than what I tough... have to play with it a bit anyway to feel comfortable and find the way to work with it.

And as resistance, it should be percentage based right? So it will be basically a value between 0 and 1 with more or less if you want that heal option. So you'll just need to do "initialdamage * resistance percentage variable = damage output".

Hehe, never tough about the resistance that way (0, 0.2, etc.). A lot better than what I was thinking xD

I don't have 'Initial damage' It's 1 (when hits) and 0 (with skills). Every time damage is detected I have to retrieve the attacking unit damage values, and the attacked unit resistance values, do the formulas and then the damage.

I'll recommend to use arrays and a unit indexing system so you can do O(1) search when you want to retrieve the resistance or the damage.

I will always retrieve the damage and resistance data from any unit that gets involved in damage event. Right now, I'm thinking in a way to make the spells deal elemental damage. How would that be?

I don't know how to use indexing systems :$ I'll check later about Bribe's.
EDIT: May sound a bit dumb, but no matter how much I read and read... can't figure out the way to work with indexing system :( *Feel_Like_A_Noob*

Thanks for your answer baassee!
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
I can do things in GUI, but not in JASS or vJASS, these I Just know how to manipulate a bit, but don't know how to do anything from scratch there.

Then it will be a bit time consuming but if you're really up for it then it should not matter.

Better than what I tough... have to play with it a bit anyway to feel comfortable and find the way to work with it.

Basic it's like this with a damage engine and your trigger in this order:

Spell is fired. //your trigger
Boolean = true //your trigger
Deal damage // your trigger
Detects damage // damage engine
boolean == true -> spelldmg // damage engine
boolean = false // your trigger

Hehe, never tough about the resistance that way (0, 0.2, etc.). A lot better than what I was thinking xD

I don't have 'Initial damage' It's 1 (when hits) and 0 (with skills). Every time damage is detected I have to retrieve the attacking unit damage values, and the attacked unit resistance values, do the formulas and then the damage.

Although you'll need a formula to count from variables into percentages aka 1 resistance may be 0.1% but 2 resistance may be 0.15? :p

The meaning with initial damage is what you said, the damage value you saved for this unit.

I will always retrieve the damage and resistance data from any unit that gets involved in damage event.

Right now, I'm thinking in a way to make the spells deal elemental damage. How would that be?

I don't know how to use indexing systems :$ I'll check later about Bribe's.

Then how? With a hashtable?

Make some sort of custom damage functioning in JASS or you make it in gui with lots of variables to define the actual type and damage, example of variables:

fire, water, air, earth etc and then when a spell fires and you want to deal damage and define the type, let's say fire, then you set fire to true and the rest to false (this way is also the worst as if you set two types into true it will get messy if you don't support some kind of mix type of course ;) )

Just read Bribe's documentation. You just have to implement it into your map and done.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
About the percent:
1 would be 100%, 0 would be 0%, just the way warcraft handles rates in the object editor. 50 * 0.1 is the same than the 10% of 50.

About the elemental spell damage:
I just noticed that all damages are of the same kind, are just 'Damage'. What makes them 'Elemental' is the value, and the resistance. Means that If I deal 'Damage' to the unit, retrieving the target 'Water' resistance, that damage would count as 'Water' damage.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
About the percent:
1 would be 100%, 0 would be 0%, just the way warcraft handles rates in the object editor. 50 * 0.1 is the same than the 10% of 50.

Exactly.

About the elemental spell damage:
I just noticed that all damages are of the same kind, are just 'Damage'. What makes them 'Elemental' is the value, and the resistance. Means that If I deal 'Damage' to the unit, retrieving the target 'Water' resistance, that damage would count as 'Water' damage.

Wasn't the damage type important? Like fire against water equals to 0?
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Lets say I cast 'Firebolt', and give it 100 Damage, and I will reduce that damage with the target Fire Resistance. Tooltip and cosmetics will say 'Fire Damage' but it's just 'Damage' for the system. I just give a high fire resistance to water elementals (example), and give over 100% resistance to Fire Elementals (So they get healed). I can just add 90% Fire Resistance to Earth and Water creeps, since enough fire can indeed evaporate water or melt earth.

BTW, I was reading the Bribe's Unit Indexing System, and it works like this
This trigger works in two key phases:

1) During map initialization, enumerate all units of all players to give them an index.
2) Adds a second event to itself to index new units as they enter the map.

As a unit enters the map, check for any old units that may have been removed at some point in order to free their index.

So... how to keep the data of units I kill, if the system removes it? When I Was thinking about this Nestharus suggested me:

use a hashtable to index the unit type ids. On unit index, create a unit and set all of it's stuff to the unit type id stuff (that way the specific unit can be modded later). Done >.>.

And that would be something like the (poor) script I posted before.

So far, I just have an idea on how to do it, but I don't really know how to. I'm not good at all with Hashtables, and I can use JASS or vJASS as long as someone gives me the basic system. I already know it's a lot easier and faster than GUI.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Still you should trigger that damage and anyway if you don't know the damage type, how are you supposed to sort it against the resistance?

What do you mean keep data of units I kill? If they're heroes and supposed to revive you'll just set the array variable when revived into yourvariable[newindex] = yourvariable[oldindex].

If you need to modify them all then Nest's idea is great.

You'll just need to start with a damage detection system. Or you can use the power of Bribe's damage engine.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok, I'm already using Weep's DSS, and I have problems understanding Bribe's Damage Engine.

After all (believe me, I feel near to cry of frustration), I keep liking the Hashtable idea to store unit damage values based on Unit Tipe ID, since my mind doesn't want to understand how to work with the arrays and stuff... (Dumbness - 1, Spartipilo - 0). And still, I have no idea how to.
 
Last edited:
Level 7
Joined
Apr 11, 2011
Messages
173
Here you go.

Also, with spells and magic you can use a simple shield absorb/reduce system.

Anti-Magic Shell
Elunes Grace
Hardened skin for physical/normal
Defend

List continues on, just a few examples of the simple object editor able to do what people spend a lot of time on.
 

Attachments

  • custom damage system of elements.w3x
    19.7 KB · Views: 296
Level 20
Joined
Jul 14, 2011
Messages
3,213
Thanks! Some questions before going to sleep:

1) How's that Bribes Unit Indexer retrieves the data of the unit, if it's not based on Unit Type ID? I mean, if I have 3 bears, with custom values of 8, 15, and 44, I would have 3 units with the same data, but still over 33 data values (11 each). Wouldn't be better to store Unit Type data in HashTable?

2) HandlerCD and HandlerCD Copy looks exactly the same, and why a 'Wait 0.00' action?

3) Shoudln't I use a Damage Detection System (Like Weep's?)

4) Shouldn't be 'Unit Cause Damage' instead of 'Set life of Unit'? if so the hero wouldn't take the kill count.

5)Wouldn't this

  • HandlerCD
    • Events
    • Conditions
    • Actions
      • Wait 0.00 seconds
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • fire[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (fire[(Custom value of (Damage source))] - FireArmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Weapons\FireBallMissile\FireBallMissile.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Wind[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Wind[(Custom value of (Damage source))] - WindArmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Water[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Water[(Custom value of (Damage source))] - Waterarmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Earth[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Earth[(Custom value of (Damage source))] - Eartharmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - pure[(Custom value of (Damage source))])
Work like this (Looks prettier to me :D)

  • HandlerCD
    • Events
    • Conditions
    • Actions
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
      • -------- Pure - - - Pure - - - Pure --------
      • Custom script: if udg_pure[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - pure[(Custom value of (Damage source))])
      • Custom script: endif
      • -------- Fire - - - Fire - - - Fire --------
      • Custom script: if udg_fire[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (fire[(Custom value of (Damage source))] - FireArmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
      • -------- Water - - - Water - - - Water --------
      • Custom script: if udg_Water[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Water[(Custom value of (Damage source))] - Waterarmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
      • -------- Earth - - - Earth - - - Earth --------
      • Custom script: if udg_Earth[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Earth[(Custom value of (Damage source))] - Eartharmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
      • -------- Wind - - - Wind - - - Wind --------
      • Custom script: if udg_Wind[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Wind[(Custom value of (Damage source))] - WindArmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
When using a Damage System all the (Triggering Unit) and else are already into a variable. It already fixes all the 'GetTriggerUnit()' actions.


EDIT: Tried this. I'd like to know if this could work.
  • Damage Set
    • Events
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DamageHash = (Last created hashtable)
      • -------- Physical Damage --------
      • Hashtable - Save 10.00 as 1 of (Key (Units of type Footman)) in DamageHash
      • -------- Physical Resistance --------
      • Hashtable - Save 0.15 as 2 of (Key (Units of type Footman)) in DamageHash
  • Damage Itself
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • Custom script: set Handle1 = GetHandleId(udg_GDD_DamageSource)
      • Custom script: set Handle2 = GetHandleId(udg_GDD_DamagedUnit)
      • Custom script: if R2I(LoadRealBJ(1, Handle1, udg_DamageHash)) > 0 then
      • Unit - Cause GDD_DamageSource to damage GDD_DamagedUnit, dealing ((Load 1 of (Key Handle1) from DamageHash) x (Load 2 of (Key Handle2) from DamageHash)) damage of attack type Hero and damage type Normal
      • Custom script: endif
But it doesn't allow me to use Key (GDD_DamageSource) nor Key (GDD_DamagedUnit) directly, but doing all these functions (GetUnitsOfTypeIdAll(GetUnitTypeId(udg_GDD_DamageSource))))". Could it be (GetunitsTypeID(udg_GDD_DamageSource)) ? Would be in custom script, since the WE doesn't allow that.

BTW:.. I would be loading 5 Damage Values from DamageSource, and 4 Resistance Values from DamagedUnit every time damage is dealt. Wouldn't it be a bit heavy, if there are several units taking dmg?
 
Last edited:
Level 8
Joined
Dec 9, 2009
Messages
397
You can save that unit as a key, but not in JNGP, thoes menus are broken there, You can make the trigger line you want in normal WE,
then save map, open JNGP, open that map, copy the line you want, then open your map and paste it.
Just recreate that variable in the new map.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually, I don't know if that works. This is my first attempt with a Hashtable.

You already told me before the thing about the problem JNPG has with hashtables, that's why I created this one in common WE, and posted here. I just want to be sure that I'm using the best method before working on all the data input.

My main problem with this, is that I don't know how work around this with Heroes, since each player will have his own stats. This may work for creeps just like it's, but I don't know how to handle the player units, like making dummy units doing damage based on the hero stats.
 
Level 8
Joined
Dec 9, 2009
Messages
397
No dummy units are needed, you use

  • Unit - Cause GDD_DamageSource to damage GDD_DamagedUnit, dealing (Real((Strength of GDD_DamageSource (Exclude bonuses)))) damage of attack type Chaos and damage type Normal
use Conversion - Integer to Real to get str as dmg
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Yeah, I know, but I have some hero attacks that simulates 'Ranged' attack (Like Magic Staff, doesn't work like common attacks, but creates a dummy that has the attack). Where the hero plays the Attack animation from a range, but the missile is actually a Dummy.
 
Level 7
Joined
Apr 11, 2011
Messages
173
Thanks! Some questions before going to sleep:

1) How's that Bribes Unit Indexer retrieves the data of the unit, if it's not based on Unit Type ID? I mean, if I have 3 bears, with custom values of 8, 15, and 44, I would have 3 units with the same data, but still over 33 data values (11 each). Wouldn't be better to store Unit Type data in HashTable?

-Hashtables are slower and in this case could be too complex for you and if so then why not do the easier way?

2) HandlerCD and HandlerCD Copy looks exactly the same, and why a 'Wait 0.00' action?

-Two of the same triggers to avoid Event leaking, a wait 0.00 to be able to cancel out a hit when it is near full hitpoints, it is a common issue with damage detection and healing physical damage that was taken, only put this in if you chose not to use Wc3's basic system at all.

3) Shoudln't I use a Damage Detection System (Like Weep's?)

-If you don't know how to avoid event leaking and want to go through more complexity but better looking GUI then sure otherwise it is quite easy to make your own while working pretty good still.

4) Shouldn't be 'Unit Cause Damage' instead of 'Set life of Unit'? if so the hero wouldn't take the kill count.

Try unit cause damage with a negative value and see what happens, I know but you can fix that with a unit group check at damage source.

5)Wouldn't this

  • HandlerCD
    • Events
    • Conditions
    • Actions
      • Wait 0.00 seconds
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • fire[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (fire[(Custom value of (Damage source))] - FireArmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Weapons\FireBallMissile\FireBallMissile.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Wind[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Wind[(Custom value of (Damage source))] - WindArmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Orc\Disenchant\DisenchantSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Water[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Water[(Custom value of (Damage source))] - Waterarmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Earth[(Custom value of (Damage source))] Greater than or equal to 1.00
        • Then - Actions
          • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Earth[(Custom value of (Damage source))] - Eartharmor[(Custom value of (Triggering unit))]))
          • Special Effect - Create a special effect attached to the chest of (Triggering unit) using Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
          • Special Effect - Destroy (Last created special effect)
        • Else - Actions
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - pure[(Custom value of (Damage source))])
Work like this (Looks prettier to me :D)
-Sometimes the prettier way isn't always needed.

  • HandlerCD
    • Events
    • Conditions
    • Actions
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) + (Damage taken))
      • -------- Pure - - - Pure - - - Pure --------
      • Custom script: if udg_pure[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - pure[(Custom value of (Damage source))])
      • Custom script: endif
      • -------- Fire - - - Fire - - - Fire --------
      • Custom script: if udg_fire[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (fire[(Custom value of (Damage source))] - FireArmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
      • -------- Water - - - Water - - - Water --------
      • Custom script: if udg_Water[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Water[(Custom value of (Damage source))] - Waterarmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
      • -------- Earth - - - Earth - - - Earth --------
      • Custom script: if udg_Earth[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Earth[(Custom value of (Damage source))] - Eartharmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
      • -------- Wind - - - Wind - - - Wind --------
      • Custom script: if udg_Wind[GetUnitUserData(GetEventDamageSource())] > 0 then
      • Unit - Set life of (Triggering unit) to ((Life of (Triggering unit)) - (Wind[(Custom value of (Damage source))] - WindArmor[(Custom value of (Triggering unit))]))
      • Custom script: endif
When using a Damage System all the (Triggering Unit) and else are already into a variable. It already fixes all the 'GetTriggerUnit()' actions.
-What?


EDIT: Tried this. I'd like to know if this could work.
  • Damage Set
    • Events
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DamageHash = (Last created hashtable)
      • -------- Physical Damage --------
      • Hashtable - Save 10.00 as 1 of (Key (Units of type Footman)) in DamageHash
      • -------- Physical Resistance --------
      • Hashtable - Save 0.15 as 2 of (Key (Units of type Footman)) in DamageHash
  • Damage Itself
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • Custom script: set Handle1 = GetHandleId(udg_GDD_DamageSource)
      • Custom script: set Handle2 = GetHandleId(udg_GDD_DamagedUnit)
      • Custom script: if R2I(LoadRealBJ(1, Handle1, udg_DamageHash)) > 0 then
      • Unit - Cause GDD_DamageSource to damage GDD_DamagedUnit, dealing ((Load 1 of (Key Handle1) from DamageHash) x (Load 2 of (Key Handle2) from DamageHash)) damage of attack type Hero and damage type Normal
      • Custom script: endif
But it doesn't allow me to use Key (GDD_DamageSource) nor Key (GDD_DamagedUnit) directly, but doing all these functions (GetUnitsOfTypeIdAll(GetUnitTypeId(udg_GDD_DamageSource))))". Could it be (GetunitsTypeID(udg_GDD_DamageSource)) ? Would be in custom script, since the WE doesn't allow that.

BTW:.. I would be loading 5 Damage Values from DamageSource, and 4 Resistance Values from DamagedUnit every time damage is dealt. Wouldn't it be a bit heavy, if there are several units taking dmg?


Why are you using unit types?
Damage source can be accessed through gui... while damagedunit is just triggering unit.
No it shouldn't be too heavy for there is not much leaking going on a massive level...
Should be just fine with 250+ units.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I'm using Unit Types because I'm adding damage/resistance data to unit types, not specific unit. All Bears should have the same damage/resistance data, then it's better to add the data to Unit-Type ID, instead of specific unit. I'll manage an effective system later for Damage/Resistance reduction, and aura effects over this. (Means that I'll wait for Nestharus or Bribe's to come up with something good).

I managed to optimize the trigger a bit with some custom scripts.

  • Damage Itself
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • Custom script: set udg_Handle1 = ConvertUnitType(GetHandleId(udg_GDD_DamageSource))
      • Custom script: set udg_Handle2 = ConvertUnitType(GetHandleId(udg_GDD_DamagedUnit))
      • Custom script: if R2I(LoadRealBJ(1, GetHandleId(udg_Handle1), udg_DamageHash)) > 0 then
      • -------- Physycal Damage --------
      • Custom script: call UnitDamageTarget(udg_GDD_DamageSource, udg_GDD_DamagedUnit, ( LoadRealBJ(1, GetHandleId(udg_Handle1), udg_DamageHash) * LoadRealBJ(2, GetHandleId(udg_Handle2), udg_DamageHash)), true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
      • Custom script: endif
This is the first time I mess with Jasscraft and BJ removal also :p. At least it allows me to save and keep the trigger enabled :p I'm not sure if the 'attack', 'ranged' booleans have an effect, or how to use them. Never found an effective way to remove LoadReajBJ though.

I don't think there's any leak here :p It's just massive data loaded at the same time. I don't think I'll have more than 50 units dealing/taking damage at the same time.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Vehster, at this point I'm not sure about how to interpret your last post. My native language is not English, I'm really sorry if I said something wrong, it was never my intention to insult you or be offensive. I don't even know why you say so... just in case.

1) I said "Nestharus or Bribe" just because I see they keep creating complex systems, and Nestharus said me some days ago that I would be able to use AuraStruct as soon as it's working. I never intended to make you feel 'less' than them.
2) About the leak part, well, it's my opinion. Maybe I'm just too dumb to know if there's a leak somewhere.
3) At least the creep part, yes, I wan't them exact, like SNES Creeps data (Attack, Defense, etc.) is exact from creep to creep. I'm sorry if I didn't said it before with enough clarity.
4) Please, don't think that your work in the map you posted before was in vain. You gave me a really good StartUp point to think about it over and over and reach what (I think) is the best method I've found so far for what want.

I hope you can understand me and pardon me.

EDIT:

No, I have no problem with GUI, but I'm a bit perfectionist, and I'm making a big RPG which involves a lot of everything, and I want to do it the best I can. The thing is actually not with your system... It's with me, since I still don't understand precisely how indexing works, and don't feel comfortable working with a system I don't know how to handle nor manipulate very well. I even think that Hashtables is harder, and I know it's slower, but at least I understand enough of it as to work with it at the level I need so far.

The things about your system are what I have already said before. With index I add the same value list to 100 bears, having 100 lists. Besides, it requires the unit to enter the map to set the values. If a boss casts 30 small spiders at the same time, there will be lag, since the game has to index all the 30 spiders, and add the 11 damage/resistance values, which is 333 data. It may create lag spikes.

Excuse me if I'm too dumb to see that your system is better than using Hashtables or something like that. Though I've been here for some months, there's a lot a bunch of stuff I don't know. As said before many times, this is the first time I'm messing with a complex (for me) system, hashtables, and indexing. Never did before.

EDIT: I found 2 things when tested.


  • Damage Set
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set DamageHash = (Last created hashtable)
      • -------- Physical Damage --------
      • Hashtable - Save 20.00 as 1 of (Key (Units of type Footman)) in DamageHash
      • -------- Physical Resistance --------
      • Hashtable - Save 0.15 as 2 of (Key (Units of type Footman)) in DamageHash
  • Damage Itself
    • Events
      • Game - GDD_Event becomes Equal to 0.00
    • Conditions
    • Actions
      • Custom script: set udg_Handle1 = ConvertUnitType(GetHandleId(udg_GDD_DamageSource))
      • Custom script: set udg_Handle2 = ConvertUnitType(GetHandleId(udg_GDD_DamagedUnit))
      • -------- Physycal Damage --------
      • Custom script: if R2I(LoadRealBJ(1, GetHandleId(udg_Handle1), udg_DamageHash)) > 0 then
      • Custom script: call UnitDamageTarget(udg_GDD_DamageSource, udg_GDD_DamagedUnit, ( LoadRealBJ(1, GetHandleId(udg_Handle1), udg_DamageHash) * LoadRealBJ(2, GetHandleId(udg_Handle2), udg_DamageHash)), true, false, ATTACK_TYPE_HERO, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS )
      • Custom script: endif
Like this, does nothing. If I disable the condition if R2I(LoadRealBJ(1, GetHandleId(udg_Handle1), udg_DamageHash)) > 0 then It crashes.
If I turn off/on the trigger like Weep's suggests, does nothing again.
 
Last edited:
Level 7
Joined
Apr 11, 2011
Messages
173
I am sorry I was offended, I just didn't fully understand how you said that last reply and I took it offensively.... I should of thought ahead.

Sure Bribe and Nestharus create super awesome complex systems but Nesthar does vjass which you'll have a lot of issue's with from what I can see so far while Bribe is better then me he is quite busy same for Nesthar... I do know I am a bit less than them sadly because I am a gui'er more then anything...

Well I can confirm there is no known leak in my system besides one....
So you wouldn't want a chance for something to be a little different then the other thing? It is nice to have to apply your knowledge to different tactics for all monsters instead of the same boring type... just saying.

Well if you need help I am here to help anyone who would use my GUI... Hopefully if you agree I can break your perfectionist attitude :) and show you nothing is truly perfect.

It took me years to understand indexing so I know it is difficult, well MUI that is.
I don't know how you understood hashtables before indexing but nice job on that.
It is quite easier then what you think to add the same value to 100 bears...
I did a poor job in showing you how to apply the system to work with a unit.

Isn't it best for the unit to enter the map to set the value to avoid loading lag and global leaks?
A boss casts 30 spiders at same time the lag would not be from my system but from normal lag like anything else because sure the game/map has to index all 30 spiders but that's a very small and I mean tiny amount of RAM to do so... If you can't handle this then I would advise you to buy a new computer....

The 11 damage/resistance values are kind of object editor so......
You seem to have a wrong understanding of how data is handled, it isn't as bad as you seem to think.
Lag spikes only occur because of the bot or host or some leak in the map usually...

Your not dumb at all, my system might or might not be better then hashtables however for one thing I do know it is much easier...

I hope you can forgive me for being or if I was offensive at all.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Mmmm basassee.. any further info?

If I set fixed values (Load 1 from 1) instead of (Load 1 from (Key(Handle)) it works. So, the problem is in the Handle...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok... I've tried all I have been able to imagine so far, but it doesn't work. I can't find a way to save and store the data correclty. As said before, works if I set fixed values, but not adding the data to the Unit-Type ID. :'(
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Bribe, I'm trying to trigger all the units damage, with 6 damage types and 5 damage resistances, giving each unit these 11 values, and load them all every time damage is dealt (Damage values for DamageSource and Resistance Values for DamagedUnit). I tried to use your system several times but I just see too much stuff and get confused.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Ok... Well, I don't know if you read the whole thread, but I don't think what I want is that hard...

1) A way to add each Unit Type these damage (Physical, Fire, Water, Earth, Wind, Pure) and resitance (Physical, Water, Earth, Wind, Pure) values. In some kind of 'List', and then "intuitively" call those values when damage is dealt.

2) A way to handle and manipulate those values if the unit is the player hero (since I would be increasing/reducing those values with triggers), and also a way to make some dummy units to retrieve the same values the hero has (Some Hero attacks are actually dummy attacks, but should deal the hero damage values).

I should be able to work with some kind of template.
 
Status
Not open for further replies.
Top