Help with Weep's damage detection system

hazylwp

Member
Reaction score
0
I am trying to trigger an ability using weep's DD system which detects damage taken from a unit until it reaches a certain amount eg. 100 damage then it is saved and counted as one stack until it reaches X amount of stacks. It's something like Dota's Death Knight's "Aphotic Shield", for those of you who don't know it is a targeted ability which gives the unit a buff and that unit will not take any damage until the damage threshold is reached then the buff is removed. How would i have to trigger this using weep's DD system?
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
Is it supposed to be MUI or MPI?
Because MPI would be rather easy.
You have an "integer" array for the stacks and a "real" array for the damage.
When damage is taken you add the damage to the real array at the owning players player id.
Then you check if the cumulative value is greater then or equal to 100.
If so you set the value in the array to be the current alue modulo 100 and add to the integer array at the owning players player id the current value divided by 100.
 

hazylwp

Member
Reaction score
0
i want it to be MUI i tried triggering for MUI before but it doesnt count individual damage dealt for individual units and stacks for different units with the same ability thus making it not MUI. Is there any way to this using unit arrays or custom values?
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
You need to save 2 individual pieces of data for every unit; number of stacks AND the current damage taken mod 100.
You can not really use custom value for that since it only allows to save one value. (unless you try some kind of crazy code)

Best solution would involve using a hashtable to save these data for each unit if you really need it to be MUI.
 

hazylwp

Member
Reaction score
0
@accname problem is i dont understand hastables and how use them it's confusing xD like you said making it MPI is easier to trigger
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
Well, complicated abilities need complicated tools. You either have to make the ability more simple to be able to implement it without hashtables or you have to learn how to use them.
They are actually very simple.

A hashtable is (more or less) like an array. But instead of having an integer number to access each element you can use any kind of object. And they can save different types of data and not just one.

It works by connecting a key value to a data value.
Code looks like this:
Trigger:
  • Hashtable - Save SomeReal as (Key "DamageTaken") of (Key (Triggering unit)) in SomeHashTable

This way you could save the value of the variable "SomeReal" in the hashtable. And the key for this data would be the combination of the String "DamageTaken" and the triggering unit.

So this variable was saved for the triggering unit under the label "DamageTaken" and with this combination you can always access it.
Trigger:
  • Set SomeReal = (Load (Key "DamageTaken") of (Key (Triggering unit)) from SomeHashTable)
 

hazylwp

Member
Reaction score
0
Yeah true enough i think i have some idea about hastables, let me give you an example. Say I wanna have stacks for each damage threshold reach for each unit so

Events
GDD_Event becomes equal to 0.00
Conditions
Level of (Assumption) for (GDD_DamagedUnit) greater than 0
Owner of GDD_DamagedUnit belongs to an enemy of owner of GDD_DamageSource
Actions
Set ASdamagetaken = ASdamagetaken + Damage Taken
Hastable - save ASdamagetaken as (Key("Damage taken") of (Key(GDD_DamagedUnit)) in hastable
If - conditions
ASdamagetaken greater than or equal to (100.00 x Level of Assumption for GDD_DamagedUnit)
Then - actions
Set ASstacks = ASstacks + 1
Hastable - Save ASstacks as (Key(???)) of (Key(GDD_DamagedUnit)) in Hastable
Set ASdamagetaken = 0

Will this be MUI and work?
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
What is the variable ASdamagetaken used for? As far as I see right now you use it globally for all units.

In pseudo-code your trigger should look somewhat like this:

Code:
Event:
 A unit takes damage
Conditions
 ... something...
Actions
 Damage-Taken-So-Far = hashtable - load "damageTaken" for (DamagedUnit)
 Damage-Stacks = hashtable - load "DamageStacks" for (DamagedUnit)
 Damage-Taken-So-Far += New-Damage-Taken
 Damage-Stacks += Damage-Taken-So-Far / 100
 Damage-Taken-So-Far = Damage-Taken-So-Far mod 100
 Hashtable - Save Damage-Taken-So-Far as "damageTaken" for (DamagedUnit)
 Hashtable - Save Damage-Stacks as "damageStacks" for (DamagedUnit)
 

hazylwp

Member
Reaction score
0
Erm to calculate the damage when the unit is attacked and if it reaches 100 i will increase the stacks by 1?correct me if my method is wrong. Just wondering is your "damage taken" an event response or a variable?
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
Just look at this example map. It uses the pseudo code from above.
But it does not use Weeps Damage Detection system. You have to connect these two by your own, but it shouldnt be that hard.
 

Attachments

  • DamageStacks MUI (with Hashtables).w3x
    20.2 KB · Views: 221

hazylwp

Member
Reaction score
0
Assumption Detect1
Events
Game - GDD_Event becomes Equal to 0.00
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Assumption for GDD_DamagedUnit) Greater than 0
Then - Actions
Cinematic - Clear the screen of text messages for (All players)
Set ASS_DamageTaken = (Load (Key damage taken) of (Key (Triggering unit)) from Hashtable)
Set ASS_Stacks = (Load (Key damage stacks) of (Key (Triggering unit)) from Hashtable)
Set ASS_DamageTaken = (ASS_DamageTaken + (Damage taken))
Set ASS_Stacks = (ASS_Stacks + (Integer((ASS_DamageTaken / 120.00))))
Set ASS_DamageTaken = (ASS_DamageTaken mod 120.00)
Hashtable - Save ASS_DamageTaken as (Key damage taken) of (Key (Triggering unit)) in Hashtable
Hashtable - Save ASS_Stacks as (Key damage stacks) of (Key (Triggering unit)) in Hashtable
Game - Display to (All players) the text: (Stacks: + (String(ASS_Stacks)))
Game - Display to (All players) the text: (Damage Taken: + (String((Damage taken))))
Game - Display to (All players) the text: (Damage Total: + (String(ASS_DamageTaken)))
Else - Actions

Assumption Learn
Events
Unit - A unit Learns a skill
Conditions
(Learned Hero Skill) Equal to Assumption
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Level of Assumption for (Learning Hero)) Equal to 1
Then - Actions
Unit - Add Assumption Spell Book to (Learning Hero)
Player - Disable Assumption Spell Book for (Owner of (Learning Hero))
Hashtable - Save 0.00 as (Key damage taken) of (Key (Learning Hero)) in Hashtable
Else - Actions
Unit - Set level of Assumption (Magic Resistance) for (Learning Hero) to (Level of Assumption for (Learning Hero))
My trigger doesnt seem to calculate the damage taken, correct me if my trigger is wrong
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top