Custom Event Responses

This is where all discussion of WC3 mapmaking should be held. This forum exists particularly for mapmaking needs. If you have a question on how something works or have need for some code review, this is the place to put it.
Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Custom Event Responses

Post by Greenspawn » Fri Jul 02, 2010 11:50 am

Is there a way to do something like this?

Code: Select all

    call TriggerRegisterUnitEvent(sometrigger, someunit, EVENT_UNIT_RECEIVES_BUFF_BLAH)
or this:

Code: Select all

    call TriggerRegisterUnitEvent(sometrigger, someunit, EVENT_UNIT_LOSES_BUFF_BLAH)
I'm designing a buff system with hashtables, and I want to store triggers in the hashtable which run when the above events occurs.
Last edited by Greenspawn on Fri Jul 02, 2010 1:54 pm, edited 1 time in total.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Custom Event Responses

Post by Fledermaus » Fri Jul 02, 2010 1:16 pm

Look at how dusk did his damage events.

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Custom Event Responses

Post by Greenspawn » Fri Jul 02, 2010 1:51 pm

I did, but he used EVENT_UNIT_DAMAGED, which is a Blizzard constant.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Custom Event Responses

Post by Fledermaus » Sat Jul 03, 2010 12:44 am

I meant the other stuff:

Code: Select all

    private          integer       Count               = 0
    private          Table         TrigTable           = 0
    private          Table         RegiTable           = 0
    private          boolean       IgnPrior            = false
and

Code: Select all

    loop
        exitwhen i > Count or IgnPrior
        //Ensure all variables are correct for nesting
        set Damage            = r
        set DamageBase        = b
        set DamageTarget      = t
        set DamageSource      = s
        set DamageType        = d
        set DamageId          = id
        set NewDamage[id]     = 0.
        set NewDamageType[id] = -1
        if IsTriggerEnabled(Trg[i]) and TriggerEvaluate(Trg[i]) then
            call TriggerExecute(Trg[i])
        endif
        if NewDamage[id] > 0. then
            //Update damage if it was changed
            set r = NewDamage[id]
        endif
        if NewDamageType[id] >= 0 then
            //Update damagetype if it was changed
            set d = NewDamageType[id]
        endif
        set i = i + 1
    endloop
(and obviously all the trigger registering stuff too).

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Custom Event Responses

Post by Greenspawn » Sat Jul 03, 2010 10:13 am

Ok I see. Here's what I came up with. It's a function that registers the specific buff events with a trigger. So:

Code: Select all

function TriggerRegisterBuffEvent takes trigger trig, integer BuffEvent returns boolean
    call SaveInteger(Hashtable, GetHandleId(trig), StringHash(I2S(BuffEvent)), Count)
endfunction
Well, it'd do more than that, but you get the idea. Then if one of those events ran, I would just call the triggers registered with that event, evaluate them, and if they evaluate, then execute (because the buff is applied through triggers, so I would know if the event occurred).

Count is just an integer that keeps track of registrations.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Custom Event Responses

Post by Fledermaus » Sat Jul 03, 2010 11:44 pm

Err, I gave you a lot of missing code in that last post :p

Check this out

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Custom Event Responses

Post by Greenspawn » Sun Jul 04, 2010 1:48 pm

I've actually got a prototype worked out. It doesn't work, but I was wondering if someone wanted to review it to suggest what the problem might be.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Custom Event Responses

Post by Fledermaus » Sun Jul 04, 2010 6:05 pm

If you post your code within the next hour, I might be able to give it a read. Otherwise I'm gone for 2 weeks.

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Custom Event Responses

Post by Greenspawn » Mon Jul 12, 2010 9:06 pm

Well after debugging it I managed to get it to work for the most part. One little hiccup is that the buffs aren't being applied correctly. For instance, I'll have the code:

Code: Select all

set dummy = CreateUnit(GetOwningPlayer(source), Buff1DummyId, GetUnitX(target), GetUnitY(target), Atan2(GetUnitY(target),GetUnitX(target))*bj_DEGTORAD - 180)
call IssueTargetOrder(dummy, Buff1AbilityOrder, target)
but it won't be applied. It creates the unit for sure, but I don't know why it wouldn't cast the ability. I'm almost positive the ability order is correct.

The Buff1DummyId is a constant for the system, so I don't have to keep looking up the Id of the unit, and Buff1AbilityOrder (also a constant) is the order used to cast the spell.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Custom Event Responses

Post by Fledermaus » Tue Jul 13, 2010 2:49 am

Does the dummy unit have enough mana to cast the spell?
Is it all buff spells that aren't applying or only a few?
Are there any requirements on the buff spells?
Does the dummy unit have the buff spells already? (I don't see any UnitAddAbility)

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Custom Event Responses

Post by Greenspawn » Tue Jul 13, 2010 12:16 pm

The spells don't cost any mana, no spells work (not even the Blizzard spells), there aren't any requirements, and the dummy has the spells already. Could it be because it's being created by a function which is called from another trigger?
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Custom Event Responses

Post by Fledermaus » Tue Jul 13, 2010 7:06 pm

I don't get what you're asking.

If the unit's being created and all that other stuff is correct, it is probably the wrong order being issued, can you give me an example of a spell you're using and the order string?

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Custom Event Responses

Post by Greenspawn » Tue Jul 13, 2010 10:29 pm

One of the base spells is Acid Bomb, with all the damage stuff set to 0, as well as the mana cost. It is only used for the buff. The order string I'm using is "acidbomb".
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

User avatar
Fledermaus
Keeper of the Keys
Posts: 354
Joined: Fri Feb 01, 2008 9:55 am
Location: New Zealand
Contact:

Re: Custom Event Responses

Post by Fledermaus » Wed Jul 14, 2010 11:01 am

Are you trying to apply it to an ally or enemy? Are the targeting fields correct? If it's an ally, try using a different spell (say, Unholy Frenzy) to see if Acidbomb is hard coded to not allow ally targeting.

Greenspawn
Keeper of the Keys
Posts: 434
Joined: Fri Jan 18, 2008 4:50 pm
Location: Massachusetts

Re: Custom Event Responses

Post by Greenspawn » Wed Jul 14, 2010 2:52 pm

It's supposed to be able to apply to both an ally and an enemy. It works if I order it manually, but not through triggers.
Math is # |e^iπ|
"I can't imagine getting hit by a giant rock and not being maimed or crippled or ruined" -Dusk

Logue: Please replace the toilet paper when you use it all. For some reason my 5 year old son believes if it's not there he does not have to wipe.

Post Reply

Return to “Custom Map Creation”