damage detection,

Status
Not open for further replies.
Level 7
Joined
Jun 15, 2010
Messages
218
There are all kinds of damage detections system, but i need to know what will be the best for my map. It must have the following reqruirements:

-I only want it to work for psycal damage, not spells!

-I must be costumizeble with GUI

-Leakless, bugs and lag free.

-I need it for the following thing:
When a [unit1*] attack [target1*] then do actions:
-Play [sound(playernumber (owner of triggering unit))] at [target1*] position


I use it for my map with lots of different weapon attachments.


-It also would be cool if there would be a floating text above units with the text "blocked" when the damage is under 3 or so.



Also i use evasion in my map. would be cool if there would be played a missed sound (only if possible)


So what would fit the best for me?



(* = expample)
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
There are all kinds of damage detections system, but i need to know what will be the best for my map. It must have the following reqruirements:

-I only want it to work for psycal damage, not spells!

-I must be costumizeble with GUI

-Leakless, bugs and lag free.

-I need it for the following thing:
When a [unit1*] attack [target1*] then do actions:
-Play [sound(playernumber (owner of triggering unit))] at [target1*] position


I use it for my map with lots of different weapon attachments.

Also i use evasion in my map. would be cool if there would be played a missed sound (only if possible)


So what would fit the best for me?



(* = expample)

would this system work? ;)
it is created in jass but can be used with gui to access. (If you want to fully change every aspect of the system you'll have to have a little jass knowledge. It's not that hard, just change some variables ^^)

JASS:
// GUI-Friendly Damage Detection -- v1.2.1 -- by Weep
//    http:// [url]www.thehelper.net/forums/showthread.php?t=137957[/url]
//
//    Requires: only this trigger and its variables.
//
// -- What? --
//    This snippet provides a leak-free, GUI-friendly implementation of an "any unit takes
//    damage" event.  It requires no JASS knowledge to use.
//
//    It uses the Game - Value Of Real Variable event as its method of activating other
//    triggers, and passes the event responses through a few globals.
//
// -- Why? --
//    The traditional GUI method of setting up a trigger than runs when any unit is damaged
//    leaks trigger events.  This snippet is easy to implement and removes the need to do
//    you own GUI damage detection setup.
//
// -- How To Implement --
//    0. Before you copy triggers that use GDD into a new map, you need to copy over GDD
//       with its GDD Variable Creator trigger, or there will be a problem: the variables
//       won't be automatically created correctly.
//
//    1. Be sure "Automatically create unknown variables while pasting trigger data" is
//       enabled in the World Editor general preferences.
//    2. Copy this trigger category ("GDD") and paste it into your map.
//       (Alternately: create the variables listed in the globals block below, create a
//       trigger named "GUI Friendly Damage Detection", and paste in this entire text.)
//    3. Create your damage triggers using Game - Value Of Real Variable as the event,
//       select GDD_Event as the variable, and leave the rest of the settings to the default
//       "becomes Equal to 0.00".
//       The event responses are the following variables:
//          GDD_Damage is the amount of damage, replacing Event Response - Damage Taken.
//          GDD_DamagedUnit is the damaged unit, replacing Event Response - Triggering Unit.
//              Triggering Unit can still be used, if you need to use waits.
//              Read the -- Notes -- section below for more info.
//          GDD_DamageSource is the damaging unit, replacing Event Response - Damage Source.
//
// -- Notes --
//    GDD's event response variables are not wait-safe; you can't use them after a wait in
//    a trigger.  If you need to use waits, Triggering Unit (a.k.a. GetTriggerUnit()) can
//    be used in place of GDD_DamageSource.  There is no usable wait-safe equivalent to
//    Event Damage or Damage Source; you'll need to save the values yourself.
//
//    Don't write any values to the variables used as the event responses, or it will mess
//    up any other triggers using this snippet for their triggering.  Only use their values.
//
//    This uses arrays, so can detect damage for a maximum of 8190 units at a time, and
//    cleans up data at a rate of 33.33 per second, by default.  This should be enough for
//    most maps, but if you want to change the rate, change the value returned in the
//    GDD_RecycleRate function at the top of the code, below.
//
//    By default, GDD will not register units that have Locust at the moment of their
//    entering the game, and will not recognize when they take damage (which can only
//    happen if the Locust ability is later removed from the unit.)  To allow a unit to have
//    Locust yet still cause GDD damage events if Locust is removed, you can either design
//    the unit to not have Locust by default and add it via triggers after creation, or
//    edit the GDD_Filter function at the top of the code, below.
//
// -- Credits --
//    Captain Griffin on wc3c.net for the research and concept of GroupRefresh.
//
//    Credit in your map not needed, but please include this README.
//
// -- Version History --
//    1.2.1: Minor code cleaning.  Added configuration functions.  Updated documentation.
//    1.2.0: Made this snippet work properly with recursive damage.
//    1.1.1: Added a check in order to not index units with the Locust ability (dummy units).
//           If you wish to check for damage taken by a unit that is unselectable, do not
//           give the unit-type Locust in the object editor; instead, add the Locust ability
//           'Aloc' via a trigger after its creation, then remove it.
//    1.1.0: Added a check in case a unit gets moved out of the map and back.
//    1.0.0: First release.


//===================================================================
// Configurables.
function GDD_RecycleRate takes nothing returns real //The rate at which the system checks units to see if they've been removed from the game
    return 0.03
endfunction

function GDD_Filter takes unit u returns boolean //The condition a unit has to pass to have it registered for damage detection
    return GetUnitAbilityLevel(u, 'Aloc') == 0 //By default, the system ignores Locust units, because they normally can't take damage anyway
endfunction

//===================================================================
// This is just for reference.
// If you use JassHelper, you could uncomment this section instead of creating the variables in the trigger editor.

// globals
//  real udg_GDD_Event = 0.
//  real udg_GDD_Damage = 0.
//  unit udg_GDD_DamagedUnit
//  unit udg_GDD_DamageSource
//  trigger array udg_GDD__TriggerArray
//  integer array udg_GDD__Integers
//  unit array udg_GDD__UnitArray
//  group udg_GDD__LeftMapGroup = CreateGroup()
// endglobals

//===================================================================
// System code follows.  Don't touch!
function GDD_Event takes nothing returns boolean
    local unit damagedcache = udg_GDD_DamagedUnit
    local unit damagingcache = udg_GDD_DamageSource
    local real damagecache = udg_GDD_Damage
    set udg_GDD_DamagedUnit = GetTriggerUnit()
    set udg_GDD_DamageSource = GetEventDamageSource()
    set udg_GDD_Damage = GetEventDamage()
    set udg_GDD_Event = 1.
    set udg_GDD_Event = 0.
    set udg_GDD_DamagedUnit = damagedcache
    set udg_GDD_DamageSource = damagingcache
    set udg_GDD_Damage = damagecache
    set damagedcache = null
    set damagingcache = null
    return false
endfunction

function GDD_AddDetection takes nothing returns boolean
//  if(udg_GDD__Integers[0] > 8190) then
//      call BJDebugMsg("GDD: Too many damage events!  Decrease number of units present in the map or increase recycle rate.")
//      ***Recycle rate is specified in the GDD_RecycleRate function at the top of the code.  Smaller is faster.***
//      return
//  endif
    if(IsUnitInGroup(GetFilterUnit(), udg_GDD__LeftMapGroup)) then
        call GroupRemoveUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
    elseif(GDD_Filter(GetFilterUnit())) then
        set udg_GDD__Integers[0] = udg_GDD__Integers[0]+1
        set udg_GDD__UnitArray[udg_GDD__Integers[0]] = GetFilterUnit()
        set udg_GDD__TriggerArray[udg_GDD__Integers[0]] = CreateTrigger()
        call TriggerRegisterUnitEvent(udg_GDD__TriggerArray[udg_GDD__Integers[0]], udg_GDD__UnitArray[udg_GDD__Integers[0]], EVENT_UNIT_DAMAGED)
        call TriggerAddCondition(udg_GDD__TriggerArray[udg_GDD__Integers[0]], Condition(function GDD_Event))
    endif
    return false
endfunction

function GDD_PreplacedDetection takes nothing returns nothing
    local group g = CreateGroup()
    local integer i = 0
    loop
        call GroupEnumUnitsOfPlayer(g, Player(i), Condition(function GDD_AddDetection))
        set i = i+1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    call DestroyGroup(g)
    set g = null
endfunction

function GDD_GroupRefresh takes nothing returns nothing
// Based on GroupRefresh by Captain Griffen on wc3c.net
    if (bj_slotControlUsed[5063] == true) then
        call GroupClear(udg_GDD__LeftMapGroup)
        set bj_slotControlUsed[5063] = false
    endif
    call GroupAddUnit(udg_GDD__LeftMapGroup, GetEnumUnit())
endfunction

function GDD_Recycle takes nothing returns nothing
    if(udg_GDD__Integers[0] <= 0) then
        return
    elseif(udg_GDD__Integers[1] <= 0) then
        set udg_GDD__Integers[1] = udg_GDD__Integers[0]
    endif
    if(GetUnitTypeId(udg_GDD__UnitArray[udg_GDD__Integers[1]]) == 0) then
        call DestroyTrigger(udg_GDD__TriggerArray[udg_GDD__Integers[1]])
        set udg_GDD__TriggerArray[udg_GDD__Integers[1]] = null
        set udg_GDD__TriggerArray[udg_GDD__Integers[1]] = udg_GDD__TriggerArray[udg_GDD__Integers[0]]
        set udg_GDD__UnitArray[udg_GDD__Integers[1]] = udg_GDD__UnitArray[udg_GDD__Integers[0]]
        set udg_GDD__UnitArray[udg_GDD__Integers[0]] = null
        set udg_GDD__Integers[0] = udg_GDD__Integers[0]-1
    endif
    set udg_GDD__Integers[1] = udg_GDD__Integers[1]-1
endfunction

function GDD_LeaveMap takes nothing returns boolean
    local boolean cached = bj_slotControlUsed[5063]
    if(udg_GDD__Integers[2] < 64) then
        set udg_GDD__Integers[2] = udg_GDD__Integers[2]+1
    else
        set bj_slotControlUsed[5063] = true
        call ForGroup(udg_GDD__LeftMapGroup, function GDD_GroupRefresh)
        set udg_GDD__Integers[2] = 0
    endif
    call GroupAddUnit(udg_GDD__LeftMapGroup, GetFilterUnit())
    set bj_slotControlUsed[5063] = cached
    return false
endfunction

// ===========================================================================
function InitTrig_GUI_Friendly_Damage_Detection takes nothing returns nothing
    local region r = CreateRegion()
    call RegionAddRect(r, GetWorldBounds())
    call TriggerRegisterEnterRegion(CreateTrigger(), r, Condition(function GDD_AddDetection))
    call TriggerRegisterLeaveRegion(CreateTrigger(), r, Condition(function GDD_LeaveMap))
    call GDD_PreplacedDetection()
    call TimerStart(CreateTimer(), GDD_RecycleRate(), true, function GDD_Recycle)
    set r = null
endfunction

create a trigger, convert it to custom text remove all the codes, paste this in it and be sure to read the manual at the top on how to implement and use it ;)
 
Level 7
Joined
Jun 15, 2010
Messages
218
Weep's damage detection system doesent realy work for me because it will also go off when a unit deals damage with an spell. I realy need it to work for normal attacks only
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Weep's damage detection system doesent realy work for me because it will also go off when a unit deals damage with an spell. I realy need it to work for normal attacks only

try this system instead: http://www.wc3c.net/showthread.php?t=100618

but only use it if you triggered the spells you use, else this will not work.
There has not been any solution to this yet (being gui friendly) if I recall correctly...

So I'm sorry but this definitly requires jass experience
 
Level 7
Joined
Jun 15, 2010
Messages
218
damn. is there an dmg detection system with easy Jass that wont be to hard to use and maybe even combined with GUI?
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
there are still people out here who can implement it in your map though... *cough*

the question is: are all your spells trigger based ^^?

damn. is there an dmg detection system with easy Jass that wont be to hard to use and maybe even combined with GUI?

Let me rephrase this:

Is there a inituitive damage detection system that can detect damage types AND is GUI friendly or easilly written and configurable in jass?

(I don't think so, but I might be wrong. Can someone PLEASE correct me that I'm wrong, I'd love to have it too :p)
 
Level 7
Joined
Jun 15, 2010
Messages
218
no not all my spells are trigger based, Ive looked at the system and its not what im looking for. pure Jass and spell-trigger- reqruierd. The system of weep would be so damn perfect if it would only work for normal attacks:p
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
no not all my spells are trigger based, Ive looked at the system and its not what im looking for. pure Jass and spell-trigger- reqruierd. The system of weep would be so damn perfect if it would only work for normal attacks:p

if you want to use GDD with damage types, I suggest you to create trigger based damage for the types that you want to be filtered out the system, this way you can adjust the system in a way that it also contains damage type detection.

That would be a solution for now.
(Untill there has been a alternative solution that detects spell damage that are not trigger based)
 
Level 7
Joined
Jun 15, 2010
Messages
218
I hope you can do it:D nice that you try though!

all we need is a physical (normal attack) type detection planted in weep's system i think. lol thats sounds easy but i quess its not that simple:p
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
I hope you can do it:D nice that you try though!

all we need is a physical (normal attack) type detection planted in weep's system i think. lol thats sounds easy but i quess its not that simple:p

I'm sorry for now I can't find a other solution then triggering the spell damage that you want filtered out of the system. So to use his sytem with damage type detection you'll have to trigger your spells :(

(Untill there has been a alternative solution that detects spell damage that are not trigger based)

I remember Nestharus was working on something similar. I don't know what happened to that though :S http://www.hiveworkshop.com/forums/world-editor-help-zone-98/damage-detection-possible-186810/
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
if you have any orbs in your map, youll have to scrap them. Its very hard to trigger those correctly in GUI (and you have to since detecting physical attacks depends on placing a buff on the attacked unit). Maybe it can be done, but noone's tried it, for all i know.

Yeah thats true but we have already seen lots of systems that are capable of doing that.

The problem is, he wants to use GUI compatible systems to detect damage, damage types and ofcourse orb stacks.

We have already found systems like GDD by Weep.
But that system does not support the usage of damage types in a way that chasin255 would like to do.
Since lots of systems check the spell damage type by looking through spells created by triggers,
he wanted something that would do that a other way since he didn't want to recreate his spells in triggers.
Now there are a few systems capable of doing such things including Nestharus's one which uses buffs to detect the damage type.

The problem is, this is written in vJass and can not be compatible with GUI.
 
Actually, you can register events in something like AdvDamageEvent by passing the trigger in, but you might have to do the registration via vjass (pretty simple, you can do the rest of the code or w/e in GUI).

A trigger is formatted like this- gg_trg_Untitled_Trigger_001

That would be Untitled Trigger 001.

So just put _ for the spaces and put a gg_trg_ in front of it, pass that in. For AdvDamageEvent, it'd be like

DamageEvent.PHYSICAL.registerTrigger(gg_trg_Untitled_Trigger_001).

Then you read the DamageEvent fields.

Here is a little template you can use
JASS:
/*
        //readonly static integer targetId
        //readonly static integer sourceId
        //readonly static unit target
        //readonly static unit source
        //readonly static real amount
*/
scope GUIDamageEvent
    private module Globals
        //global variables
        set udg_target = DamageEvent.target
        set udg_source = DamageEvent.source
        set udg_amount = DamageEvent.amount
        set udg_damageType = DamageEvent.type
    endmodule

    private module Register
        //register GUI here
        call DamageEvent.PHYSICAL.registerTrigger(gg_trg_Untitled_Trigger_001)
    endmodule

    private module Init
        private static method update takes nothing returns boolean
            implement Globals
            return false
        endmethod
        private static method onInit takes nothing returns nothing
            //required
            call DamageEvent.SPELL.register(Condition(function thistype.update))
            call DamageEvent.JASS.register(Condition(function thistype.update))
            call DamageEvent.PHYSICAL.register(Condition(function thistype.update))

            implement Register
        endmethod
    endmodule

    private struct Inits extends array
        implement Init
    endstruct
endscope
 
2 upper modules are for easy modification and the bottom one is for proper initialization. You almost always use a module to initialize :\. 99.99% of systems running on library/scope initializers are bad.


And this is all assuming you can install all of the lua resources and other systems required ;P. Also, I don't use the ANY registration because that fires after SPELL, JASS, and PHYSICAL :\.


I must note that AdvDamageEvent does have 2 issues, one being that 0 units will explode and the other being one relating to a wc3 bug with expiring attacks (would happen whether AdvDamageEvent was in there or not).


The explosion issue is still being worked on, hence why it's still in submissions ;P. It works perfectly, and if you don't use exploding at all, you won't have any issues =).
 
My bad, fixed. Was initially a library, but forgot to change end block to scope ;P.

I coded that in a post in like <1 minute ;D, I need to get back to a show. Off I go : D.

edit
The GUI version will have bad readings on the GUI vars for recursive events. For example, if you damage a unit within a damage event, the readings will be wrong. Reading the vjass values will still give the right values.

This means that you won't be able to use Damage natives within a damage event. The regular vjass variables will still be fine though, and you can modify damage using SetWidgetLife without screwing up the GUI variables.

Do custom script and read these for 100% accurate values if you really want to use a Damage native within a damage event and are doing GUI-
JASS:
DamageEvent.target
DamageEvent.source
DamageEvent.amount
DamageEvent.type

You can learn more about the causes of this in my Custom Event Data Tutorial


edit
There is no surefire way to detect evasion.
 
Last edited:
Level 14
Joined
Nov 18, 2007
Messages
816
There is no surefire way to detect evasion.
You mean, other than scripting the whole attacking yourself?
Yeah thats true but we have already seen lots of systems that are capable of doing that.
Capable of doing what exactly? Stacking orbs using GUI?
The problem is, he wants to use GUI compatible systems to detect damage, damage types and ofcourse orb stacks.
Theres no system out there that does this.
Now there are a few systems capable of doing such things including Nestharus's one which uses buffs to detect the damage type.
And detecting physical attacks using buffs forces you to implement all orbs in triggers. I dont think you know the extent to which one must go to replicate Blizzards orbs in all their glory.
 
Level 7
Joined
Jun 15, 2010
Messages
218
man this will get so hard for me.
How do other maps change the sound of attacks when a units gets another weapon?
 
Level 7
Joined
Jun 15, 2010
Messages
218
chaos gives so much bugs. already tried before. and effect looping sounds doesent play:( thanks for the info yesterday btw:)

or is there an ability that plays sound everytime a unit attacks?
 
Level 7
Joined
Jun 15, 2010
Messages
218
I havent triggerd all of my spells. I think il try the evnemoment spears thing:D that should work. to bad the sound wont change if unit has different armor but its ok.

When i aply chaos on a hero then his stats will do some wierd stuff. else choas would be perfect for much more.
 
Status
Not open for further replies.
Top