wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-20-2009, 03:04 PM   #1
Seshiro
User
 
Seshiro's Avatar
 
Join Date: Aug 2008
Posts: 158

Submissions (1)

Seshiro is on a distinguished road (20)

Default Healing+Event

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: jpg HealingEvent_Logo.jpg (37.5 KB, 135 views)

Last edited by Seshiro : 12-20-2009 at 04:14 PM. Reason: V 1.4
Seshiro is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-20-2009, 05:58 PM   #2
darkwulfv
Alpha Male of Wc3c
 
darkwulfv's Avatar


Official Map Reviewer
 
Join Date: Mar 2006
Posts: 3,646

Submissions (6)

darkwulfv is just really nice (270)darkwulfv is just really nice (270)

Send a message via AIM to darkwulfv
Default

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.
__________________
The Spell Request Thread
Quote:
Originally Posted by Joe-Black-5
a dota like map but with unique stuff
(There was no map attached, and that was all the thread said.)
Spells I've Made

Darkwulfv's Lightning Grapple || Tritanis' Lazy Bolt


Last edited by darkwulfv : 02-20-2009 at 05:59 PM.
darkwulfv is offline   Reply With Quote
Old 02-21-2009, 03:08 PM   #3
Seshiro
User
 
Seshiro's Avatar
 
Join Date: Aug 2008
Posts: 158

Submissions (1)

Seshiro is on a distinguished road (20)

Default

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
Seshiro is offline   Reply With Quote
Old 02-21-2009, 03:42 PM   #4
darkwulfv
Alpha Male of Wc3c
 
darkwulfv's Avatar


Official Map Reviewer
 
Join Date: Mar 2006
Posts: 3,646

Submissions (6)

darkwulfv is just really nice (270)darkwulfv is just really nice (270)

Send a message via AIM to darkwulfv
Default

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.
__________________
The Spell Request Thread
Quote:
Originally Posted by Joe-Black-5
a dota like map but with unique stuff
(There was no map attached, and that was all the thread said.)
Spells I've Made

Darkwulfv's Lightning Grapple || Tritanis' Lazy Bolt

darkwulfv is offline   Reply With Quote
Old 02-24-2009, 03:42 PM   #5
C2H3NaO2
User
 
Join Date: May 2008
Posts: 80

C2H3NaO2 is on a distinguished road (17)

Default

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" ^^
C2H3NaO2 is offline   Reply With Quote
Old 02-25-2009, 05:12 AM   #6
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

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.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request ThreadDone for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 02-25-2009, 10:08 AM   #7
Seshiro
User
 
Seshiro's Avatar
 
Join Date: Aug 2008
Posts: 158

Submissions (1)

Seshiro is on a distinguished road (20)

Default Update

UPDATE: V1.3
  • Added saftey protection(copied from GroupUtisl) :=
  • Execute Event is now Inlined
I'm now not using table, but an array :)


Greez
Seshiro is offline   Reply With Quote
Old 02-26-2009, 10:03 PM   #8
Seshiro
User
 
Seshiro's Avatar
 
Join Date: Aug 2008
Posts: 158

Submissions (1)

Seshiro is on a distinguished road (20)

Exclamation Tabled Version

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
Seshiro is offline   Reply With Quote
Old 02-26-2009, 11:37 PM   #9
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

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.
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request ThreadDone for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 02-27-2009, 10:52 AM   #10
Seshiro
User
 
Seshiro's Avatar
 
Join Date: Aug 2008
Posts: 158

Submissions (1)

Seshiro is on a distinguished road (20)

Default

Just Released V 1.4:
  • Now uses table for more saftey, because of high handle Ids
  • Edited a bit the Doc :)
Greez
Seshiro is offline   Reply With Quote
Old 02-27-2009, 12:13 PM   #11
moyack
Evil Emoticon
 
moyack's Avatar


Respected User
Project Leader: PoC
 
Join Date: Jan 2006
Posts: 3,279

Submissions (17)

moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)moyack is a splendid one to behold (666)

AI Tournament #2 - 2nd PlaceHero Contest - Second place

Send a message via MSN to moyack
Default

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.

Last edited by moyack : 02-27-2009 at 12:14 PM.
moyack is offline   Reply With Quote
Old 02-27-2009, 12:27 PM   #12
Seshiro
User
 
Seshiro's Avatar
 
Join Date: Aug 2008
Posts: 158

Submissions (1)

Seshiro is on a distinguished road (20)

Default

I dont think so, but test it!


Greez
Seshiro is offline   Reply With Quote
Old 02-27-2009, 12:50 PM   #13
Tyrande_ma3x
User
 
Tyrande_ma3x's Avatar
 
Join Date: Feb 2009
Posts: 185

Submissions (1)

Tyrande_ma3x is on a distinguished road (12)

Default

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

Last edited by Tyrande_ma3x : 02-27-2009 at 12:58 PM.
Tyrande_ma3x is offline   Reply With Quote
Old 03-01-2009, 08:09 AM   #14
Pyrogasm
Lackadaisically Absent.
 
Pyrogasm's Avatar


Respected User
 
Join Date: Sep 2006
Posts: 4,523

Submissions (9)

Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)Pyrogasm is a splendid one to behold (638)

Hero Contest - Fourth place

Send a message via ICQ to Pyrogasm Send a message via AIM to Pyrogasm Send a message via MSN to Pyrogasm Send a message via Yahoo to Pyrogasm
Default

In that case, this system has a purpose and I shall approve it.

:D
__________________
Quote:
Originally posted by Rising_Dusk
Your spells are mostly ignored because they are not very cool so we aren't very excited to review/approve them, but you are incredibly persistent and won't give us an excuse to graveyard it. That is generally what results in a resource being ignored for a long time.

The Spell Request ThreadDone for, unless someone else wants to revive it...
It lasted a damn long time.

Please; Ask for Help Appropriately














Quote:
Originally posted by Kyrbi0
Huh. Almost makes me wish I had a girlfriend, to take advantage of today (wait, no, that's not what I meant... I mean, take advantage of the fact that it is international women's day... gah, never mind).
Quote:
Originally posted by Pyrogasm
Rome may not have been built in a day, but the Romans sure as hell didn't say "look at this great city we built guys!" when they had nothing more than a bit of stone and some cottages.
Pyrogasm is offline   Reply With Quote
Old 03-01-2009, 10:28 AM   #15
Troll-Brain
User
 
Join Date: Oct 2006
Posts: 1,490

Submissions (1)

Troll-Brain has a spectacular aura about (134)

Default

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.
Troll-Brain is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:19 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services