HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Healing+Event

02-20-2009, 03:04 PM#1
Seshiro
Healing+Event

HealingEvent is for healing units nicer(only triggered), because it improves the Syntax and makes a simple one lined heal, which triggers a selfmade 'Event' called Healing-Event.

It triggers only on triggered healing not in Spellcasts!
Documentation inside :D

Collapse Healing Event:
library HealingEvent initializer init uses Table
//*********************************************************************************
//**
//**            --HEALING EVENT--
//**              ~~by Seshiro
//**                ~v1.5(1.24b++)
//**
//**    The healing event is a script used to simulate real healing events, as they
//**    would exist.
//**    It works similar to the DamageTarget Event, but it doesn't use
//**    healing-types but that could come if wanted :D
//**    
//**    The event works only with triggered-'healing' made with this script,
//**    because it's only for making more comfortable code!
//**
//**    The functions:
//**        function GetHealingUnit takes nothing returns unit
//**        ~returns the Healer of the heal(whichunit)
//**
//**        function GetHealedUnit takes nothing returns unit
//**        ~returns the target of the heal(target)
//**
//**        function GetHealedLife takes nothing returns real
//**        ~returns the amount of the healed life(amount)
//**        
//**        function TriggerRegisterHealingEvent takes trigger t returns nothing
//**        ~registers a trigger to the 'healing-event'
//**        
//**        function RemoveHealingEvent takes trigger t returns nothing
//**        ~unregisters a trigger from the event
//**
//**        function HealTarget takes unit whichunit, unit target, real amount returns boolean
//**        ~Heals the unit target by the amount of amount
//**        ~returns wether the heal was succesfull or not
//**        ~whichunit is the 'healing'-unit
//**
//**
//**
//*********************************************************************************
    globals
        private unit Healer
        private unit Healed
        private real Amount = 0
    endglobals
    
    function GetHealingUnit takes nothing returns unit
        return Healer // Returns the Healing unit
                      // Not possible to use GetTriggerUnit!
    endfunction
    
    function GetHealedUnit takes nothing returns unit
        return Healed // returns the Healed unit
    endfunction
    
    function GetHealedLife takes nothing returns real
        return Amount // Returns the Amonut of the healed life
    endfunction
    
    // This is the module which is used to simulate the healing events!
    // REMEMBER: The event works only with the function Healunit, not with spells, which are healing!
    
    // <!---DON'T CHANGE BELOW---!>
    globals
        private trigger array Trigs
        private integer N = 0
        //private integer array table
        private HandleTable table
        private HandleTable Stat
        
    endglobals
    
    
    function TriggerRegisterHealingEvent takes trigger t returns boolean
        if ( (N >8190) or (Stat[t] == 1) ) then
            return false
        endif
        set N = N + 1
        set Trigs[N] = t
        set Stat[t]  = 1
        set table[t] = N
        return true
    endfunction
        
    function RemoveHealingEvent takes trigger t returns boolean
        local integer i = N
        local integer p = table[t]
        local integer stat = Stat[t]
        
        if t == null then
            debug call BJDebugMsg(SCOPE_PREFIX+" Error: Tried to realease a null trigger")
            return false
        elseif stat == 0 then
            debug call BJDebugMsg(SCOPE_PREFIX+" Error: Trigger was not registered")
            return false
        elseif stat == 2 then
            debug call BJDebugMsg(SCOPE_PREFIX+" Error: Tried to unresgister a trigger multilpy")
            return false
        endif
        
        set Stat[t] = 2
        set Trigs[p] = Trigs[N]
        set table[Trigs[p]] = p
        set N = N - 1
        return true
    endfunction
    
    function HealTarget takes unit whichunit, unit target, real amount returns boolean
        local integer i = N
        local trigger t
        // This is the Healfunction
        if GetWidgetLife(target) > .405 and GetWidgetLife(whichunit) > .405 and (amount > 0) then
            call SetWidgetLife(target,GetWidgetLife(target)+amount)
            //~'Heals' the unit
            set Healer = whichunit
            set Healed = target
            set Amount = amount
            loop
                exitwhen i <= 0
                set t = Trigs[i]//locals are faster than globals :)
                if ( (t != null) and (IsTriggerEnabled(t)) and (Stat[t] == 1) and (TriggerEvaluate(t)) ) then
                    call TriggerExecute(t)
                endif 
                set i = i - 1
            endloop
            return true
        endif
        return false
    endfunction
    
    private function init takes nothing returns nothing
        set table = HandleTable.create()
        set Stat = HandleTable.create()
    endfunction
endlibrary

Here are two example spells, i dont want to create a testmap sorry :D

Example spell for Healunit
Expand JASS:

Example spell for Healing Event
Expand JASS:

In the preview Screen you can see my Paladin using Calming Kiss, which triggered Glistening Lights :)


Needed is the Jasshelper found in the JNGP
and it uses Table.

Please Give Credits to Seshiro

If there are things to improve, or to change, tell me, I will accept many forms of ctitcism!

Greez
Attached Images
File type: jpgHealingEvent_Logo.jpg (37.5 KB)
02-20-2009, 05:58 PM#2
darkwulfv
Seems a bit silly, since healing is usually done on your own (via a couple lines of code) and wouldn't need to be detected (and any other time it could be detected by spell cast). However if you can explain a use that isn't already covered by basic methods of healing and spell detection, please do so.
02-21-2009, 03:08 PM#3
Seshiro
The problem is, that in many cases you don't know the healed value vià OE Healingspell, when you use this system, you can make triggered healing like 20*lvl+30+GetHeroInt(u)*5 as this wouldn't be possible with OE spells or you could make a HoT.

You can create a texttag system for shownig healed values thats really cool, Im using it in my current map :D
Or you could create spells which are firing on heal, like a hex, which makes the unit unhealable vià SetWidgetLife(GetHealedUnit(),GetWidgetLife(GetHealedUnit())-GetHealedAmount()) That couldn't be done as easy with OE spells!

Greez
02-21-2009, 03:42 PM#4
darkwulfv
I suppose that's true, but I could do all of that without a system; just making a small function called "HealUnit" that applies instant life w/ an effect. Then it can be a triggered spell, and if I want texttags I would make them directly in the spell's code.

It's true this has more functionality than OE spells, but I'm not so sure this needs its own system. But I'll leave that decision to a code-god.
02-24-2009, 03:42 PM#5
C2H3NaO2
please check if the trigger are enabled before checking conditions and call them.

I would btw suggest to use Tables for the unregistered stuff. I think the current solution will break if you unregister a trigger you never registered.

I think this is pretty cool. We are able to make "critical healing" ^^
02-25-2009, 05:12 AM#6
Pyrogasm
I think this can be useful and interesting, so I think it can be approved, pending you fix some things and nobody else has major issues with this system.

I'd like to see you change the name of the library to "HealingEvents" or something of that sort; "Healing" is a bit bland/could easily cause conflicts.
  • As C2H3NaO2 suggested, use Table to store whether or not a trigger has been registered with the system previously, both in the Register function (to prevent multiple registers for the same trigger) and in the Unregister function (so it doesn't try to remove a trigger that isn't there).
  • In the ExecuteEvent function, check to make sure the trigger is enabled before calling TriggerEvaluate and TriggerExecute (as C2H3NaO2 also suggested).
  • In the Execute Event function, perform one additional check (before all others) to see if Trigs[i] == null, and if so you know that trigger has been destroyed, so you can treat it as if that trigger was just unregistered.

Aside from that, it actually looks pretty good.
02-25-2009, 10:08 AM#7
Seshiro
UPDATE: V1.3
  • Added saftey protection(copied from GroupUtisl) :=
  • Execute Event is now Inlined
I'm now not using table, but an array :)


Greez
02-26-2009, 10:03 PM#8
Seshiro
So, Here is a version using table, plz tell me if this is better or not as good as the arrayed one:

Expand Table Version:

Usage is the same, but this one is more saftey, because of the high trigger handle Ids.


Greez
02-26-2009, 11:37 PM#9
Pyrogasm
I much prefer the table version, personally.

Also, this is bunk: //locals are faster than globals :) Many different tests have been show that one is better than the other while an equal number of other tests have shown the reverse. Anyway, it doesn't really matter here; there's no way the difference could be noticed at all.

That being said, the way you have it is fine.


Everything seems in order here, so update your first post with the new version and I'll approve this! It'd be cool if you could get an image to use as the thread image, too, but that's not necessary.
02-27-2009, 10:52 AM#10
Seshiro
Just Released V 1.4:
  • Now uses table for more saftey, because of high handle Ids
  • Edited a bit the Doc :)
Greez
02-27-2009, 12:13 PM#11
moyack
A question: can we heal by setting a negative damage with UnitDamageTarget?

If it's possible... a damage detection can do this in a more simple way and manage more properly the events.
02-27-2009, 12:27 PM#12
Seshiro
I dont think so, but test it!


Greez
02-27-2009, 12:50 PM#13
Tyrande_ma3x
> A question: can we heal by setting a negative damage with UnitDamageTarget?
I just tested it and negative damage heals the unit. Though, I don't know if it is detected by damage detection systems... Give me 10 minutes and I'll see.

EDIT: No, negative damage cannot be detected.
03-01-2009, 08:09 AM#14
Pyrogasm
In that case, this system has a purpose and I shall approve it.

:D
03-01-2009, 10:28 AM#15
Troll-Brain
Quote:
Originally Posted by Tyrande_ma3x
> A question: can we heal by setting a negative damage with UnitDamageTarget?
I just tested it and negative damage heals the unit. Though, I don't know if it is detected by damage detection systems... Give me 10 minutes and I'll see.

EDIT: No, negative damage cannot be detected.

Wait ...
It's just because damage detections filter the damages under or equal to 0.
They can easily be edited to manage negative damages.