System Quick Damage Detection

RaiJin

New Member
Reaction score
40
Quick Damage Detection

JASS:
library QDD initializer init requires Event

//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//$                     Quick Damage Detection                                 $
//$                          Version 1.05                                      $
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
//$                                                                            $
//$                                                                            $
//$    CREATOR - RaiJin                                                        $
//$                                                                            $
//$    HOW TO IMPORT:                                                          $
//$        Simply make a new trigger rename it to QDD and copy                 $
//$        copy and paste this in                                              $
//$                                                                            $
//$    CREDITS: -Vex for JASS NEWGEN PACK                                      $
//$             - JESUS4LYF for letting me use Event <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite1" alt=":)" title="Smile    :)" loading="lazy" data-shortname=":)" />                        $
//$             - Tom Jones for his help                                       $
//$             - Romek for reminding me to add a function                     $
//$                                                                            $
//$                                                                            $
//$    Version 1.02 has a complete new revamp !!!                              $
//$                                                                            $
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$


globals
    private trigger QDD_Trigger = CreateTrigger()
    private Event QDD_Event
endglobals

function TriggerRegisterAnyUnitDamaged takes trigger t returns nothing
    call QDD_Event.register(t)
endfunction

private function LoopingThrough takes nothing returns boolean
    call QDD_Event.fire()
    return false
endfunction

private function INIT_GROUP takes nothing returns boolean
    call TriggerRegisterUnitEvent(QDD_Trigger, GetFilterUnit(), EVENT_UNIT_DAMAGED)
    return false
endfunction

private function init takes nothing returns nothing
    local group g = CreateGroup()
    local region r = CreateRegion()
    call RegionAddRect(r, bj_mapInitialPlayableArea)
    call TriggerRegisterEnterRegion(CreateTrigger(), r, Condition(function INIT_GROUP))
    call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea, Condition(function INIT_GROUP))
    call TriggerAddCondition(QDD_Trigger, Condition(function LoopingThrough))
    set QDD_Event = Event.create()
    call DestroyGroup(g)
    set g = null
endfunction

endlibrary


Heres a link to Jesus4lyfe's Event system Props to him for making it

http://www.thehelper.net/forums/showthread.php?t=126846


JASS:
function TriggerRegisterAnyUnitDamaged takes trigger t returns nothing // like event
//Use the event responses to get the units
 

Romek

Super Moderator
Reaction score
963
You missed out the most essential function of any damage detection:
TriggerRegisterAnyUnitDamaged (or w/e you want to call it).
 

RaiJin

New Member
Reaction score
40
You missed out the most essential function of any damage detection:
TriggerRegisterAnyUnitDamaged (or w/e you want to call it).

shit i knew i was forgetting something loool ill do that right now :D

@Cohadar: exactly :D
 

Jesus4Lyf

Good Idea™
Reaction score
397
>Vex for JASS NEWGEN PACK
This is wrong and (imo) irrelevant. Vex did not write the NewGen pack, just JassHelper.

Once again, like every other system where the author doesn't use Event so far, the event structure is incorrect and will not actually function in the expected manner. I don't know why you made it only run actions either, as these are generally frowned upon anyway. If you can't stand having requirements for this system, at least embed Event into this, but it is preferred to just require it for the sake of reduced code duplication and any updates or anything.

>function TriggerAddAction(QDD_Trigger, function userfunc)
I'd make it TriggerRegisterAnyUnitDamaged and make it take a trigger. Then you can use dynamic triggers... :thup:
 

RaiJin

New Member
Reaction score
40
>Vex for JASS NEWGEN PACK
This is wrong and (imo) irrelevant. Vex did not write the NewGen pack, just JassHelper.

Once again, like every other system where the author doesn't use Event so far, the event structure is incorrect and will not actually function in the expected manner. I don't know why you made it only run actions either, as these are generally frowned upon anyway. If you can't stand having requirements for this system, at least embed Event into this, but it is preferred to just require it for the sake of reduced code duplication and any updates or anything.

>function TriggerAddAction(QDD_Trigger, function userfunc)
I'd make it TriggerRegisterAnyUnitDamaged and make it take a trigger. Then you can use dynamic triggers... :thup:

Ok ill implement Event in this and

>it looks a bit weird
what do u mean? you can at least tell me what looks "weird"
 

Azlier

Old World Ghost
Reaction score
461
You may want to know that this doesn't work with the latest patch. Blizzard killed H2I.
 

Romek

Super Moderator
Reaction score
963
> WAAAAH REALLY? omg that sucks lol !
No it doesn't.

There's a native H2I, as well as 96 other new natives, and a new handle type.
 

RaiJin

New Member
Reaction score
40
oh interesting lol

> theres a native H2I, as well as 96 other new natives, and a new handle type.
really? so blizzard updated the editor?
 

Romek

Super Moderator
Reaction score
963
See the announcement for more information.
 

Sevion

The DIY Ninja
Reaction score
413
JASS:
function QDD_DisableUnit takes unit whichUnit returns nothing
function QDD_EnableUnit takes unit whichUnit returns nothing


Um. Why?

JASS:
function QDD_ConfigUnit takes unit whichUnit, boolean switch returns nothing
    if whichUnit == null then
        debug call BJDebugMsg(&quot;NULL UNIT !! make sure its not&quot;)
        return
    endif
    set disable[GetUnitValue(whichUnit)] = switch
endfunction
 

Sevion

The DIY Ninja
Reaction score
413
JASS:
function TriggerRegisterAnyUnitDamaged takes trigger t returns nothing
    debug if t == null then
    debug   call BJDebugMsg(&quot;Null trigger passed!!!&quot;)
    debug   return
    debug endif
    set trigger_execute[trigger_count] = t
    set trigger_count = trigger_count + 1
endfunction


Why debug?

You're going to allow them to pass null triggers?

JASS:
function TriggerRegisterAnyUnitDamaged takes trigger t returns nothing
    if t == null then
debug   call BJDebugMsg(&quot;Null trigger passed!!!&quot;)
    return
    endif
    set trigger_execute[trigger_count] = t
    set trigger_count = trigger_count + 1
endfunction
 

RaiJin

New Member
Reaction score
40
JASS:
function TriggerRegisterAnyUnitDamaged takes trigger t returns nothing
    debug if t == null then
    debug   call BJDebugMsg(&quot;Null trigger passed!!!&quot;)
    debug   return
    debug endif
    set trigger_execute[trigger_count] = t
    set trigger_count = trigger_count + 1
endfunction


Why debug?

You're going to allow them to pass null triggers?

JASS:
function TriggerRegisterAnyUnitDamaged takes trigger t returns nothing
    if t == null then
debug   call BJDebugMsg(&quot;Null trigger passed!!!&quot;)
    return
    endif
    set trigger_execute[trigger_count] = t
    set trigger_count = trigger_count + 1
endfunction

who would pass a null trigger in the first place?
 

Artificial

Without Intelligence
Reaction score
326
JASS:
//
    set LastDamagedUnit = GetTriggerUnit()
    set LastDamagingUnit = GetEventDamageSource()
    set LastDamageCount = GetEventDamage()

You know, they could just use the event responses directly. ^_^

I think you should make sure the trigger isn't disabled before evaluating/executing it (otherwise damaging a unit inside an action/condition of a trigger evaluated/executed by this will cause an infinite loop even if you disable the trigger).

And why did you make it not register buildings? o_o Did they offend you? ;o

And IMO this seems to be rather similar to this (dunno if anyone else feels this way, though). x)
 

RaiJin

New Member
Reaction score
40
JASS:
//
    set LastDamagedUnit = GetTriggerUnit()
    set LastDamagingUnit = GetEventDamageSource()
    set LastDamageCount = GetEventDamage()

You know, they could just use the event responses directly. ^_^

I think you should make sure the trigger isn't disabled before evaluating/executing it (otherwise damaging a unit inside an action/condition of a trigger evaluated/executed by this will cause an infinite loop even if you disable the trigger).

And why did you make it not register buildings? o_o Did they offend you? ;o

And IMO this seems to be rather similar to this (dunno if anyone else feels this way, though). x)

WAAAH it actually does loool xD and event responses would still work? ill update it soon then

@sevion then whats the point?
 

Sevion

The DIY Ninja
Reaction score
413
The point is, users can pass null triggers...

And guess what? The last time I checked, that ISN'T good.

Do you follow me?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      • Ghan
        Administrator - Servers are fun

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top