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 > Warcraft III Modding > Developer's Corner > Triggers & Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-13-2009, 11:47 AM   #1
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default How to prevent infinite loop when amplifying damage

Hi guys, I am making some sort of inverse crtitical strike with ADamage, in the case, when a unit with a certain buff takes damage, the damage is amplified by a factor, lets say 20%.
Everything was going well, I am using ADamage and xedamage module, however I enter on a infinite loop (obvious...) because I can not tell teh difference between the damage being amplified and the damage taken in combat normally. This way, when a unit takes damage, I amplify the damage by dealing it again, and then the computer takes the amplified damage as normal damages and amplifies it again, this loop until the unit dies or the CPU blows, depends on the one that comes first.

My possible solution would be to use boolean values, but they are useless, the other solution would be to cause the amplified damage as a special damage with xedamage, however I don't know how to do that either.
The code is in my Light SHield thread, if some one is interested, but I really need to figure out a solution for this since I want to make many other amplify damage spells that don't involve shields.

I would appreciate all possible help, thx in advance.
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-13-2009, 12:07 PM   #2
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Use a different type of damage for the amplified damage and then a triggercondition to detect it.
__________________
Rising_Dusk is offline   Reply With Quote
Old 02-13-2009, 12:32 PM   #3
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
Use a different type of damage for the amplified damage and then a triggercondition to detect it.
That what I am asking here ... how can I simulate that with ADamage and xedamage?
I know I have to use xedamage tags, but I make no idea on how to use them and the documentation lacks examples on it =S
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 02-13-2009 at 12:32 PM.
Flame_Phoenix is offline   Reply With Quote
Old 02-13-2009, 12:36 PM   #4
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

option 1 (which I use) is just disabling the trigger before you do the bonus damage, then re-enabling it afterward

option 2 would be to add some dependancy to the trigger that you can manipulate before nad after the damage - for instance, a group within which a unit cannot be for the trigger to fire (adding it before the damage and removing it after allows this to work) - there are several other methods to the same end, but you get it

option 3 (when using something like IDDS) is to just deal the damage of a type that wont fire the trigger,

option 4 - there are probably more but you get the point
__________________
emjlr3 is offline   Reply With Quote
Old 02-13-2009, 01:05 PM   #5
DioD
obey
 
DioD's Avatar
 
Join Date: Feb 2006
Posts: 1,532

Submissions (4)

DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)

Send a message via ICQ to DioD
Default

Use dummy unit(s) who ignored by system.

If you need real damage source, you always can link real unit to dummy.
DioD is offline   Reply With Quote
Old 02-13-2009, 01:14 PM   #6
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Look at my Thornwine Armour spell, it only returns damage when it was non-triggered damage (you could also easily modify it to only ignore some damage tags rather than all triggered damage).
__________________
Anitarf is offline   Reply With Quote
Old 02-13-2009, 01:14 PM   #7
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
option 1 (which I use) is just disabling the trigger before you do the bonus damage, then re-enabling it afterward
The mods would just reject it for not being a good practice or for not being modular ...

Quote:
option 2 would be to add some dependancy to the trigger that you can manipulate before nad after the damage - for instance, a group within which a unit cannot be for the trigger to fire (adding it before the damage and removing it after allows this to work) - there are several other methods to the same end, but you get it
The group idea seems really nice ! Thx I will try it soon!

Quote:
option 3 (when using something like IDDS) is to just deal the damage of a type that wont fire the trigger,
Using ADamage...

Quote:
Use dummy unit(s) who ignored by system.
Now a good idea for my multiboard, that way we wouldn't know the killer.

Quote:
If you need real damage source, you always can link real unit to dummy.
How ?
Quote:
Look at my Thornwine Armour spell, it only returns damage when it was non-triggered damage (you could also easily modify it to only ignore some damage tags rather than all triggered damage).
I had a look on your spells.Afaik, that spell causes damage to the attacker and not to the shielded unit so it is kinda different, but I will look at it again.

Off-topic:
- Having in mind how emjlr3 usually posts in my threads, I want to tank to emjlr3for being nice and helpful this time. Thx m8 =D
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 02-13-2009 at 01:16 PM.
Flame_Phoenix is offline   Reply With Quote
Old 02-13-2009, 01:32 PM   #8
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Flame_Phoenix
I had a look on your spells.Afaik, that spell causes damage to the attacker and not to the shielded unit so it is kinda different, but I will look at it again.
Different? It deals damage in response to detecting damage, so it's the same thing. If both the attacking and the attacked unit had the buff then it would still result in an infinite loop, but it doesn't because the spell is coded properly.
__________________
Anitarf is offline   Reply With Quote
Old 02-13-2009, 01:33 PM
moyack
This message has been deleted by moyack. Reason: double posting :P
Old 02-13-2009, 01:35 PM   #9
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

What thing doesn't trigger a EVENT_UNIT_DAMAGED?? a simulated damage.

Here's my example of a triggered critical strike using my powerful and uber simple damage detection script, you can adapt that function to other DD systems:

Collapse JASS:
scope TriggeredCriticalStrike initializer init 

globals
    private constant integer SpellID = 'A000'
    private constant real    chance  = 0.8 // 80% of chance to do the effect
    private constant real    factor  = 3. // multiplier damage factor
endglobals

private function DoEffect takes nothing returns boolean
    local real d = GetEventDamage()// Damage dealt normally
    local unit u = GetTriggerUnit()// unit that receives the damage
    local real l = GetWidgetLife(u)// unit life
    local unit c = GetEventDamageSource()// unit that deals the damage
    local texttag t = CreateTextTag()
    local real D // the damage bonus value...
    if GetRandomReal(0,1) < chance and GetUnitAbilityLevel(c, SpellID) > 0 and d > 0 then
        set D = d * (factor - 1.)
        if l - (d + D) <= 0.405 then // if the damage is enough to kill the target
            call SetWidgetLife(u, d * 0.9) // sets the life of the target unit in such way that the damage dealt will kill it
        else
            call SetWidgetLife(u, l - D) // Reduce the life of the unit by the damage bonus
        endif
        // the remaining damage will be done after the end of this code...
        // Eyecandy part :)
        call SetTextTagText(t, I2S(R2I(d + D))+"!", 0.024)
        call SetTextTagPos(t, GetUnitX(c), GetUnitY(c), 0.00)
        call SetTextTagColor(t, 255, 0, 0, 255)
        call SetTextTagVelocity(t, 0, 0.04)
        call SetTextTagVisibility(t, true)
        call SetTextTagFadepoint(t, 2)
        call SetTextTagLifespan(t, 5)
        call SetTextTagPermanent(t, false)
    else
        call DestroyTextTag(t)
    endif
    set t = null
    set u = null
    set c = null
    return false
endfunction

private function init takes nothing returns nothing
    call AddDamageCondition(Condition(function DoEffect))
endfunction

endscope
moyack is offline   Reply With Quote
Old 02-13-2009, 01:50 PM   #10
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Quote:
Different? It deals damage in response to detecting damage, so it's the same thing. If both the attacking and the attacked unit had the buff then it would still result in an infinite loop, but it doesn't because the spell is coded properly.
I don't get it, if I wanted to cause damage in response to an attack I would just use the Undead shield on ABuff template. My problem here is that the unit with the shield will be, attacked again every time it is attacked.
On the other hand, I am totally not following/understanding your idea =S sorry

Quote:
What thing doesn't trigger a EVENT_UNIT_DAMAGED?? a simulated damage.
Moyack, your posts are always a pleasure to read.
To be honest I already had that idea, but not your way ... I am amazed, you sure that thing runs well? Like, it I see you never kill the unit, you just make it weaker!
This may be th perfect solution. Thx !
As far as I am concerned, it beats emil group solution =P
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition

Last edited by Flame_Phoenix : 02-13-2009 at 01:51 PM.
Flame_Phoenix is offline   Reply With Quote
Old 02-13-2009, 02:14 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

Of course it works, and it has been tested. Remember that the EVENT_UNIT_DAMAGED happens just just just before deal the damage, when the code ends, the damage is actually dealt.
moyack is offline   Reply With Quote
Old 02-13-2009, 02:31 PM   #12
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Ha thx to all ! Problem fixed !
Here is the code of my Light Shield spell (for those who are curious. Yes, this is the wrong thread, but it is just for people who really are curious).
I will update the Light SHield spell a little bit saying the good news to the people, and will wait for suggestions a few more hours (not more than 48). Then if no suggestions are made, I will submit the spell!
And I am sure it will be approved, this is the most modular thing I have ever done without Ani or Dusk getting mad at me for not being modular (lol).

Expand JASS:
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 02-13-2009, 03:24 PM   #13
DioD
obey
 
DioD's Avatar
 
Join Date: Feb 2006
Posts: 1,532

Submissions (4)

DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)DioD is a jewel in the rough (220)

Send a message via ICQ to DioD
Default

Use 'hook' function.
This is not easy, you cant "fix" natives, but you always can replace functions inside your code.

Collapse JASS:
function GetEventDamageSourceEX takes nothing returns unit

if GetUnitTypeId(GetEventDamageSource()) == 'dummy' then
return GetUnitUserData(GetEventDamageSource())
endif
return GetEventDamageSource()
endfunction

NOTE: may contain functions misstypes.

Replace GetEventDamageSource() with GetEventDamageSourceEX() in code, then paste function to map header.

Such modifications allow you to ajust "natives".
This "native" will return real damage source ever if damage done by dummy.
Just store data inside custom value.
DioD is offline   Reply With Quote
Old 02-13-2009, 03:33 PM   #14
Flame_Phoenix
retired coder | real ilfe
 
Flame_Phoenix's Avatar
 
Join Date: Mar 2007
Posts: 2,208

Submissions (10)

Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)Flame_Phoenix has a spectacular aura about (90)

Send a message via MSN to Flame_Phoenix
Default

Mmmm, I don't like the sound of UnitUserData and I think you are treating xedamage like IDDS.
Anyway the problem was fixed, you can all visit this thread if you have cool ideas:
http://www.wc3campaigns.net/showthread.php?t=104575

Anyway, +rep to all =D
(only if wc3c doesn't block.)
__________________
Check out my tutorials at:
1-Creating a Hero Tavern
2-Complete Icon Tutorial - ALL about Icons
3-Making a spell in vJass - Practice Session 1
Check out all my current spells at here
Finally, check my project:
Castle vs Castle Flame Edition
Flame_Phoenix is offline   Reply With Quote
Old 02-13-2009, 04:41 PM   #15
emjlr3
Rehabbing
 
emjlr3's Avatar
 
Join Date: Jun 2005
Posts: 1,386

Submissions (14)

emjlr3 is a jewel in the rough (151)emjlr3 is a jewel in the rough (151)

Mapping Contest First Place

Send a message via AIM to emjlr3 Send a message via MSN to emjlr3
Default

Quote:
The mods would just reject it for not being a good practice or for not being modular ...

ok, that really doesn't make sense but whatever - not sure why one would consider this bad practice (it works), and whats all this about modularity?

Quote:
Having in mind how emjlr3 usually posts in my threads, I want to tank to emjlr3for being nice and helpful this time. Thx m8 =D

the only real difference being that you weren't acting like a child, so I didn't answer you as such
__________________
emjlr3 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 01:07 PM.


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