• 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.

Strange damage issue; need help or clarification

Status
Not open for further replies.
Level 7
Joined
Aug 11, 2010
Messages
270
Well, I haven't got to many ideas what could be causing this; though -- it seems to be a relatively big issue. After-all, I can't just allow enemy units to just 'heal' units with damaging spells. I get this feeling that it has something to do with the damage detection engine I use.

For an example; take Fireball. This spell does 75 damage and stuns the target for .65 second(s). Well; instead of DEALING 75 damage it occasionally HEALS 75 damage instead (but it doesn't always HEAL)

I am currently using Physical Damage Detection v1.1.0.0 GUI by Looking_for_help for my map's damage detection system. I'm also using these damage modification triggers:


Description: upon dealing damage the system deciphers if the damage is spell damage or physical damage and shows the damage text. In addition, it activates any of the on-damage effects.
  • M Damage Display
    • Events
      • Game - damageEventTrigger becomes Equal to 1.00
    • Conditions
    • Actions
      • -------- ----- --------
      • -------- Start Running Scripts --------
      • -------- ----- --------
      • -------- Item Effects --------
      • Trigger - Run RIR Kingstone Scepter Effect <gen> (checking conditions)
      • Trigger - Run RIE Eye of the Infinite Nexus Effect <gen> (checking conditions)
      • Trigger - Run RIL Mindstaff Aura Effect <gen> (checking conditions)
      • Trigger - Run RIL Cloak of Flames Effect <gen> (checking conditions)
      • Trigger - Run RIE Harvest Bounty Effect <gen> (checking conditions)
      • -------- Hero Abilities --------
      • Trigger - Run HEW Shatter Effect <gen> (checking conditions)
      • Trigger - Run HDS Calculated Shot Effect <gen> (checking conditions)
      • Trigger - Run HIJ Repel Strikes Effect <gen> (checking conditions)
      • Trigger - Run HIJ Intervene Effect <gen> (checking conditions)
      • Trigger - Run HRB Ferocious Charge Effect <gen> (checking conditions)
      • Trigger - Run HRB Razored Flank Effect <gen> (checking conditions)
      • Trigger - Run HRB Spirit of Agamaggan Effect <gen> (checking conditions)
      • Trigger - Run HNI Reflective Strike Effect <gen> (checking conditions)
      • -------- Creep Abilities --------
      • Trigger - Run CWCI Critical Strike <gen> (checking conditions)
      • Trigger - Run CWCI Piercing Javelins <gen> (checking conditions)
      • Trigger - Run CWCI Firebolt AI <gen> (checking conditions)
      • Trigger - Run CWCI Battle Shout AI <gen> (checking conditions)
      • Trigger - Run CWCI War Stomp AI <gen> (checking conditions)
      • -------- ----- --------
      • -------- Stop Running Scripts --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • amount Greater than or equal to 0.00
          • damageType Equal to PHYSICAL
        • Then - Actions
          • Set TempReal = amount
          • Set TempInteger = (Integer(TempReal))
          • Floating Text - Create floating text that reads (String(TempInteger)) above target with Z offset 0.00, using font size 8.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Set TempFloatingText = (Last created floating text)
          • Floating Text - Set the velocity of TempFloatingText to 64.00 towards 90.00 degrees
          • Floating Text - Change TempFloatingText: Disable permanence
          • Floating Text - Change the lifespan of TempFloatingText to 1.50 seconds
          • Floating Text - Change the fading age of TempFloatingText to 0.75 seconds
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • damageType Equal to SPELL
            • Then - Actions
              • Set TempReal = amount
              • Set TempInteger = (Integer(TempReal))
              • Floating Text - Create floating text that reads (String(TempInteger)) above target with Z offset 0.00, using font size 12.00, color (25.00%, 25.00%, 100.00%), and 0.00% transparency
              • Set TempFloatingText = (Last created floating text)
              • Floating Text - Set the velocity of TempFloatingText to 64.00 towards 90.00 degrees
              • Floating Text - Change TempFloatingText: Disable permanence
              • Floating Text - Change the lifespan of TempFloatingText to 1.50 seconds
              • Floating Text - Change the fading age of TempFloatingText to 0.75 seconds
            • Else - Actions
Description: When the Hero has the item 'Kingstone Scepter' his spell damage is increased by an amount.
  • RIR Kingstone Scepter Effect
    • Events
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • damageType Equal to SPELL
          • (PlayerHeroes[(Player number of (Owner of source))] has an item of type |cff0080ffKingstone Scepter|r) Equal to True
    • Actions
      • Set base_amount = amount
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Item carried by PlayerHeroes[(Player number of (Owner of source))] in slot (Integer A))) Equal to |cff0080ffKingstone Scepter|r
            • Then - Actions
              • Set TempReal = (base_amount x 0.12)
              • Set amount = (amount + TempReal)
              • Set TempInteger = (Integer(amount))
            • Else - Actions
Description: When the Hero has the item 'Harvest Bounty' his physical damage deals an additional amount based on agility and intelligence.
  • RIE Harvest Bounty Effect
    • Events
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • damageType Equal to PHYSICAL
          • (source has an item of type |cffb048f8Harvest Bounty|r) Equal to True
    • Actions
      • Set TempReal = ((0.20 x (Real((Agility of source (Include bonuses))))) + (0.20 x (Real((Intelligence of source (Include bonuses))))))
      • Set amount = (amount + TempReal)
Description: Basically has the same effect as 'RIR Kingstone Scepter Effect,' except this effect is significantly stronger.
  • RIE Eye of the Infinite Nexus Effect
    • Events
    • Conditions
      • And - All (Conditions) are true
        • Conditions
          • damageType Equal to SPELL
          • (source has an item of type |cffb048f8Eye of the Infinite Nexus|r) Equal to True
          • (PlayerHeroes[(Player number of (Owner of source))] has an item of type |cffb048f8Eye of the Infinite Nexus|r) Equal to True
    • Actions
      • Set base_amount = amount
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Item-type of (Item carried by PlayerHeroes[(Player number of (Owner of source))] in slot (Integer A))) Equal to |cffb048f8Eye of the Infinite Nexus|r
            • Then - Actions
              • Set TempReal = (base_amount x 0.22)
              • Set amount = (amount + TempReal)
              • Set TempInteger = (Integer(amount))
            • Else - Actions

Any help at all would be greatly appreciated, would really like to get this issue sorted out.
 

EdgeOfChaos

E

EdgeOfChaos

The idea of the system is quite simple. Every unit on the map gets a modified ability of runed bracers with 200% damage reduction from spells. Because the damage reduction is bigger than 100%, all spell damage is negativ. Now by simply checking the sign of the damage, it is possible to identify if the damage was physical of not.
Maybe a glitch with this causes it (from DDS thread) but he says he fixed it, so idk.

Try just reversing sign of damage if it does the same for all spells.
 

EdgeOfChaos

E

EdgeOfChaos

if(SpellDamage < 0) then
call DamageTarget(source,target,SpellDamage * -2, blah blah)
endif

That's a workaround. I don't believe things like Holy Light or any heals will trigger DDS so it should be safe. Only problem is it may kill units at higher HP than they would normally die from. This could be solved with some work though.
 
Level 7
Joined
Aug 11, 2010
Messages
270
@EdgeofChaos

I'm not sure. I'll experiment with it; though if I can't solve the issue with units dying too early I'll need to disable it; there is a few waves in this Hero Defense where that could be a very very severe unbalance for both the Heroes and the actual creep waves themselves.


This kind of bugs usually come from thread crashes(invalid calls/dividing with zero) or turning the system off.

I'll be honest, I have absolutely no idea what thread crashes are; are they possible in GUI? Every trigger I have (Except the ACTUAL damage detection engine itself) is in GUI. It is possible that it could happen when the system is turned off -- though, from what I seen; even when I disabled the function it still happened. It's a bit difficult to test -- unfortunately, since I don't know what triggers it -- it seems entirely at random. Even vanilla non-edited spells seem to provoke it's wrath.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
thread crash happens when you pass certain point in execution weigth. Every time new thread spawns(Trigger is commanded to evaluate, execute, ExecuteFunc, after TriggerSleepAction, timer callback, callback from multiple natives like group enumerations) it is assigned a value 0. Every time you perform something in the Jass(either GUI or jass, doesnt matter), the value increases by certain amount. If this value goes beyond 300,000, the current thread of execution will stop. This is put in there by Blizzard to stop infinite loops or deadlocked code from freezing the map, even tho you can still freeze the map rather easily.

Example:

JASS:
function f takes nothing returns nothing
    local integer i = 0
    loop
        call BJDebugMsg(i)
        set i = i + 1
    endloop
endfunction

will only print up to few thousand, even tho from logical point of view, this should keep running until you close the map

This can be caused by multiple other reasons too, if you try to read uninitialized variables like so:

JASS:
function example takes nothing returns nothing
    local integer i
    call BJDebugMsg(I2S(i))
endfunction

will cause the current execution to stop. Also division by 0(local real r = 1 / 0) will have the same effect
 

EdgeOfChaos

E

EdgeOfChaos

@EdgeofChaos

I'm not sure. I'll experiment with it; though if I can't solve the issue with units dying too early I'll need to disable it; there is a few waves in this Hero Defense where that could be a very very severe unbalance for both the Heroes and the actual creep waves themselves.




I'll be honest, I have absolutely no idea what thread crashes are; are they possible in GUI? Every trigger I have (Except the ACTUAL damage detection engine itself) is in GUI. It is possible that it could happen when the system is turned off -- though, from what I seen; even when I disabled the function it still happened. It's a bit difficult to test -- unfortunately, since I don't know what triggers it -- it seems entirely at random. Even vanilla non-edited spells seem to provoke it's wrath.

Here's a way to do it. I have to go in 1 min so basic text

If unit is below/equal to (spelldamage x -2) - Set HP to 1
Else cause damage equal to (spelldamage x -2)
Again, confirm that spelldamage is negative before doing this.
 
Level 7
Joined
Aug 11, 2010
Messages
270
thread crash happens when you pass certain point in execution weigth. Every time new thread spawns(Trigger is commanded to evaluate, execute, ExecuteFunc, after TriggerSleepAction, timer callback, callback from multiple natives like group enumerations) it is assigned a value 0. Every time you perform something in the Jass(either GUI or jass, doesnt matter), the value increases by certain amount. If this value goes beyond 300,000, the current thread of execution will stop. This is put in there by Blizzard to stop infinite loops or deadlocked code from freezing the map, even tho you can still freeze the map rather easily.

Example:

JASS:
function f takes nothing returns nothing
    local integer i = 0
    loop
        call BJDebugMsg(i)
        set i = i + 1
    endloop
endfunction

will only print up to few thousand, even tho from logical point of view, this should keep running until you close the map

This can be caused by multiple other reasons too, if you try to read uninitialized variables like so:

JASS:
function example takes nothing returns nothing
    local integer i
    call BJDebugMsg(I2S(i))
endfunction

will cause the current execution to stop. Also division by 0(local real r = 1 / 0) will have the same effect

Ahh... I see, I see. Well I just looked my map over for cases of that, I don't believe I seen any. I don't use waits -at all-, I do use alot of Run XYZ triggers, but it would by no means be more than 100k

Also incase it helps any (I am not sure if it does) I use JNGP editor as opposed to the regular vanilla one.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
It's hard to know if you have thread crashes just by looking at the code.
The best way is putting debug messages in various parts of the code. If the debug message didn't show, then something before it crashed the thread.

Also, this damage detection system should never be turned off, because this breaks the magic damage reversal. By default all units are healed by magic damage with this system, so the system deals extra damage after the event to make sure that the amount of health lost is right.
 

EdgeOfChaos

E

EdgeOfChaos

Try to find a pattern for when it breaks. What happens before it breaks every time? When does it revert to normal?

Or PM the code to someone you trust and they can probably fix it.
 
Level 7
Joined
Aug 11, 2010
Messages
270
@EdgeofChaos

That's the irritating thing, I can't seem to figure out what triggers it; despite numerous play throughs. It happens with any spells; any heroes; and (seemingly) any item. Strangely enough though it seems to happen FAR more frequently with spell damage items, although -- from what i've seen in my tests they're also possible without spell damage items.

It's hard to know if you have thread crashes just by looking at the code.
The best way is putting debug messages in various parts of the code. If the debug message didn't show, then something before it crashed the thread.

Also, this damage detection system should never be turned off, because this breaks the magic damage reversal. By default all units are healed by magic damage with this system, so the system deals extra damage after the event to make sure that the amount of health lost is right.

That... Might be the problem then. A few of my functions shut off the DDS trigger; if you want -- I can link the scripts that do this to you. Do you truly believe this is what causes it? Because if you do -- that seems like a fairly easy fix... Admittedly, it won't be a pretty one since I can't seem to figure out how to make the system detect 'scripted' damage properly in the damage text. But that's absolutely fine; it shouldn't be too difficult to fix with a fair bit of tinkering.
 
Last edited:

EdgeOfChaos

E

EdgeOfChaos

Oh.. yes, that is 100% surely the problem.

The system uses a 200% runic bracer, which turns all spelldamage negative; this is then sign reversed, and differentiated from physical based on it being negative. Don't disable it. (Also, look at what I quoted in my first post)
 
Level 7
Joined
Aug 11, 2010
Messages
270
Oh wait a minute. No; nevermind. I never disabled the system. My bad, guys. What I disabled was the trigger named 'M Damage Display'. My apologies, I got a bit confused there initially.

Any other ideas on how to fix the problem? I doubt turning off 'M Damage Display' is the problem considering the fact it doesn't do anything except display the damage when you deal it; it also runs some hero spells for procced events.
 
Level 7
Joined
Aug 11, 2010
Messages
270
Turn off all triggers that might be causing the issue. Then enable them one by one. If the issue is reproducible at all, then you will see which trigger causes it.

As mentioned prior. I cannot reproduce the issue on a whim; since I don't know what triggers it and I can't seem to find a connection to anything in particular as a culprit. It takes me about 30 or 40 minutes of testing to get it to happen, typically. And sometimes it happens on specific units; other times -- it doesn't. You could hit a Peon with a spell and then hit a nearby peon and that peon; unlike the first peon you hit -- would not heal.
 
Last edited:
Level 7
Joined
Aug 11, 2010
Messages
270
Oh... What? I'm a bit confused... You can't use damage actions; even the ones that are provided by the system? (I.E. "Damage Detection Event becomes equal to 1")?

Stuff such as this
  • HEW Shatter Effect
    • Events
    • Conditions
      • (Level of Shatter (Earth Warden) for target) Greater than 0
      • damageType Equal to PHYSICAL
    • Actions
      • -------- ----- --------
      • -------- Level 1 --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Shatter (Earth Warden) for target) Equal to 1
          • (Random integer number between 1 and 100) Less than or equal to 5
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set TempPoint = (Position of target)
          • Set TempGroup = (Units within 400.00 of TempPoint matching ((((Owner of target) is an enemy of (Owner of (Matching unit))) Equal to True) and ((source is alive) Equal to True)))
          • Unit - Create 1 Shard of Azinnok (Level 1) for (Owner of target) at TempPoint facing Default building facing degrees
          • Floating Text - Create floating text that reads Shatter! above target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TempFloatingText = (Last created floating text)
          • Floating Text - Set the velocity of TempFloatingText to 64.00 towards 90.00 degrees
          • Floating Text - Change TempFloatingText: Disable permanence
          • Floating Text - Change the lifespan of TempFloatingText to 1.50 seconds
          • Floating Text - Change the fading age of TempFloatingText to 0.75 seconds
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Cause target to damage (Picked unit), dealing 25.00 damage of attack type Normal and damage type Normal
          • Custom script: call DestroyGroup (udg_TempGroup)
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Trigger - Run HEW Shatter SFX <gen> (ignoring conditions)
          • Trigger - Run HEW Shatter Cooldown <gen> (ignoring conditions)
        • Else - Actions
      • -------- ----- --------
      • -------- Level 2 --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Shatter (Earth Warden) for target) Equal to 2
          • (Random integer number between 1 and 100) Less than or equal to 7
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set TempPoint = (Position of target)
          • Set TempGroup = (Units within 400.00 of TempPoint matching ((((Owner of target) is an enemy of (Owner of (Matching unit))) Equal to True) and ((source is alive) Equal to True)))
          • Unit - Create 1 Shard of Azinnok (Level 2) for (Owner of target) at TempPoint facing Default building facing degrees
          • Floating Text - Create floating text that reads Shatter! above target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TempFloatingText = (Last created floating text)
          • Floating Text - Set the velocity of TempFloatingText to 64.00 towards 90.00 degrees
          • Floating Text - Change TempFloatingText: Disable permanence
          • Floating Text - Change the lifespan of TempFloatingText to 1.50 seconds
          • Floating Text - Change the fading age of TempFloatingText to 0.75 seconds
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Cause target to damage (Picked unit), dealing 40.00 damage of attack type Normal and damage type Normal
          • Custom script: call DestroyGroup (udg_TempGroup)
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Trigger - Run HEW Shatter SFX <gen> (ignoring conditions)
          • Trigger - Run HEW Shatter Cooldown <gen> (ignoring conditions)
        • Else - Actions
      • -------- ----- --------
      • -------- Level 3 --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Shatter (Earth Warden) for target) Equal to 3
          • (Random integer number between 1 and 100) Less than or equal to 9
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set TempPoint = (Position of target)
          • Set TempGroup = (Units within 400.00 of TempPoint matching ((((Owner of target) is an enemy of (Owner of (Matching unit))) Equal to True) and ((source is alive) Equal to True)))
          • Unit - Create 1 Shard of Azinnok (Level 3) for (Owner of target) at TempPoint facing Default building facing degrees
          • Floating Text - Create floating text that reads Shatter! above target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TempFloatingText = (Last created floating text)
          • Floating Text - Set the velocity of TempFloatingText to 64.00 towards 90.00 degrees
          • Floating Text - Change TempFloatingText: Disable permanence
          • Floating Text - Change the lifespan of TempFloatingText to 1.50 seconds
          • Floating Text - Change the fading age of TempFloatingText to 0.75 seconds
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Cause target to damage (Picked unit), dealing 55.00 damage of attack type Normal and damage type Normal
          • Custom script: call DestroyGroup (udg_TempGroup)
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Trigger - Run HEW Shatter SFX <gen> (ignoring conditions)
          • Trigger - Run HEW Shatter Cooldown <gen> (ignoring conditions)
        • Else - Actions
      • -------- ----- --------
      • -------- Level 4 --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Shatter (Earth Warden) for target) Equal to 4
          • (Random integer number between 1 and 100) Less than or equal to 11
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set TempPoint = (Position of target)
          • Set TempGroup = (Units within 400.00 of TempPoint matching ((((Owner of target) is an enemy of (Owner of (Matching unit))) Equal to True) and ((source is alive) Equal to True)))
          • Unit - Create 1 Shard of Azinnok (Level 4) for (Owner of target) at TempPoint facing Default building facing degrees
          • Floating Text - Create floating text that reads Shatter! above target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TempFloatingText = (Last created floating text)
          • Floating Text - Set the velocity of TempFloatingText to 64.00 towards 90.00 degrees
          • Floating Text - Change TempFloatingText: Disable permanence
          • Floating Text - Change the lifespan of TempFloatingText to 1.50 seconds
          • Floating Text - Change the fading age of TempFloatingText to 0.75 seconds
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Cause target to damage (Picked unit), dealing 70.00 damage of attack type Normal and damage type Normal
          • Custom script: call DestroyGroup (udg_TempGroup)
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Trigger - Run HEW Shatter SFX <gen> (ignoring conditions)
          • Trigger - Run HEW Shatter Cooldown <gen> (ignoring conditions)
        • Else - Actions
      • -------- ----- --------
      • -------- Level 5 --------
      • -------- ----- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Shatter (Earth Warden) for target) Equal to 5
          • (Random integer number between 1 and 100) Less than or equal to 15
        • Then - Actions
          • Trigger - Turn off (This trigger)
          • Set TempPoint = (Position of target)
          • Set TempGroup = (Units within 400.00 of TempPoint matching ((((Owner of target) is an enemy of (Owner of (Matching unit))) Equal to True) and ((source is alive) Equal to True)))
          • Unit - Create 1 Shard of Azinnok (Level 5) for (Owner of target) at TempPoint facing Default building facing degrees
          • Floating Text - Create floating text that reads Shatter! above target with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
          • Set TempFloatingText = (Last created floating text)
          • Floating Text - Set the velocity of TempFloatingText to 64.00 towards 90.00 degrees
          • Floating Text - Change TempFloatingText: Disable permanence
          • Floating Text - Change the lifespan of TempFloatingText to 1.50 seconds
          • Floating Text - Change the fading age of TempFloatingText to 0.75 seconds
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Unit - Cause target to damage (Picked unit), dealing 85.00 damage of attack type Normal and damage type Normal
          • Custom script: call DestroyGroup (udg_TempGroup)
          • Custom script: call RemoveLocation (udg_TempPoint)
          • Trigger - Run HEW Shatter SFX <gen> (ignoring conditions)
          • Trigger - Run HEW Shatter Cooldown <gen> (ignoring conditions)
        • Else - Actions
which is used to give me a flawless damage event (as opposed to A unit is attacked, which will prematurely apply the damage) is unusable?
 
Last edited:
Level 21
Joined
Mar 27, 2012
Messages
3,232
Well yes. The system (at least the vJASS version) assumes that you don't use UnitDamageTarget inside damage events, because it is handled instantly and thus messes up the globals.
In the vJASS version there is a function called UnitDamageTargetEx, that can be used for this same purpose, but doesn't mess up globals.
 
Level 7
Joined
Aug 11, 2010
Messages
270
Well yes. The system (at least the vJASS version) assumes that you don't use UnitDamageTarget inside damage events, because it is handled instantly and thus messes up the globals.
In the vJASS version there is a function called UnitDamageTargetEx, that can be used for this same purpose, but doesn't mess up globals.

Well... That's news to me, I assumed it'd be safe due to the fact it says it's compatible with GUI. Is there a way to call UnitDamageTargetEx with Custom Scripts? If so; how is it laid out? How do I fit a variable in it? Jass isn't particularly my strong point, unfortunately.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
The damage detection system made by looking_for_help responds to usual damage events. This is how damage handlers work.

However, it responds to UnitDamageTarget events instantly, because that's how JASS works. This means that without a thorough workaround any new UnitDamageTarget events will overwrite previous ones.
This is usually not a problem, but if you cause an event while a previous one is being handled, then the new will be handled instantly, after which the previous keeps going from where it was, but with the globals from the new event.

I tried to write an explanation on how to use UnitDamageTargetEx in custom script, but it would have been awfully complicated, because the system was originally designed for vJASS only.

This is the function:
JASS:
call UnitDamageTargetEx(localSource, localTarget, localAmount, attack, ranged, localAttackType, localDamageType, localWeaponType)

Example usage:
JASS:
call UnitDamageTargetEx(udg_MyUnitA, udg_MyUnitB, 500, true, false, ATTACK_TYPE_CHAOS, DAMAGE_TYPE_UNIVERSAL, WEAPON_TYPE_WHOKNOWS)

udg_MyUnitA and udg_MyUnitB are unit variables with the names MyUnitA and MyUnitB.

Amount - How much damage will be done (before reductions)

attack and ranged can be either "true" or "false". They tell the game whether this damage came from an attack (as opposed to damage over time) and whether it was from a ranged unit.

attacktypes are:
ATTACK_TYPE_NORMAL - Not used anywhere afaik
ATTACK_TYPE_MELEE - Called "Normal" in editor. It's what footmen use
ATTACK_TYPE_PIERCE
ATTACK_TYPE_SIEGE
ATTACK_TYPE_MAGIC
ATTACK_TYPE_CHAOS
ATTACK_TYPE_HERO

Damage types define what kind of resistances apply to the damage.
meaningful damage types are:
DAMAGE_TYPE_NORMAL - Modified by armor amount, but not magic resistance.
DAMAGE_TYPE_MAGIC - Modified by magic resistance.
DAMAGE_TYPE_UNIVERSAL - Not modified by armor amount or magic resistance.

Weapon type defines what sound to play (like on normal attacks). I usually don't want that, so I use:
WEAPON_TYPE_WHOKNOWS - Plays no sound at all.
 
Level 7
Joined
Aug 11, 2010
Messages
270
Anyway; after painstakingly rewriting my triggers 30 minutes of testing doesn't seem to yield any results, I don't know if it's just me being unlucky; but it's a good sign. I'll repost if something happens.

+Rep to all you folk, thanks for your help.
 
Level 7
Joined
Aug 11, 2010
Messages
270
Anyway; after painstakingly rewriting my triggers 30 minutes of testing doesn't seem to yield any results, I don't know if it's just me being unlucky; but it's a good sign. I'll repost if something happens.

+Rep to all you folk, thanks for your help.

After further testing I figured out two things.

1) The triggered damage no longer works with increased spell damage (which is a giant problem; since that'd mean some types magical spell damage would be far more significant than others)

2) I got the healing bug to occur once again, too. Again -- I can't quite figure out what's causing it, it just seems to be speriodic and random. It's most unfortunate.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Well, the most commons reasons for me are:
1. Using initialized variables(can't do i = i + 1 if I wasn't set)
2. Invalid calls/Passing invalid parameters to functions(null)
3. Dividing with 0.

I recommend putting debug messages in the code. Then you'll see how far the code reaches and know more precisely where to look.
 
Level 7
Joined
Aug 11, 2010
Messages
270
Interesting that you're having a similar problem, CakeMaster. Have you figured out what causes it? Or is it happening at seemingly random intervals for you, too? It's possible that the system might just simply be broke.

@Xonok The problem with putting debug inside of the code (I'm guessing you mean the DDS); I don't know much about JASS. I probably couldn't even get the script to compile properly -- which is kind of ironic since I've used text-based coding before in different games. I suppose it's what you get used to, really.
 
Level 7
Joined
Aug 11, 2010
Messages
270
Except Blizzard, nobody gets used to the Vanilla Editor when scripting. :p

You can try the Jass New Gen Pack. It has vJASS, and also has a function autocomplete while offering colored text.

Oh, no. I appreciate the suggestion -- though I already use it! Someone said I should learn vJASS instead of regular JASS. Plus I use it for the unlimited doodads feature and the nice limitless tileset feature. (which is necessary for my map since I actually have a few more tiles than allowed in the vanilla editor)
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
You only need one function to debug:

JASS:
call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Stuff")

For the sake of faster writing I've even made a wrapper for this:

JASS:
function Debug takes string s returns nothing
    call DisplayTextToPlayer(GetLocalPlayer(),0,0,s)
endfunction

Which is used like this:

JASS:
call Debug("stuff")
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
or you know, BJDebugMsg takes string s returns nothing :D

Try running it in a loop. It will lag the map A LOT. I didn't expect it initially, but when I created another kinematics system it made a huge difference to use my own function.

JASS:
function BJDebugMsg takes string msg returns nothing
    local integer i = 0
    loop
        call DisplayTimedTextToPlayer(Player(i),0,0,60,msg)
        set i = i + 1
        exitwhen i == bj_MAX_PLAYERS
    endloop
endfunction

It shows 12 messages, has an extra function call and one extra argument. All of those things slow it down.

Xonok, is the duration field not missing?

E: edo, BJDebugMsg lasts a painful 60s. ;_;

There is no duration field for this function. There are only player, x, y and message.
 
Status
Not open for further replies.
Top