HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Can someone help me improve this trigger?

08-07-2006, 04:31 PM#1
Sardius
Basicly when you stand in the region for 12 seconds, your hero is suppose to be selected. The problem with this trigger is that when you leave the region the trigger is still running, so but occasionally if you re-enter the region after you've already done so once, your hero will be instantly chosen or not chosen at all no matter how long you stand there. Basicly I want the trigger to hault and reset when you leave the region, but removing it from the trigger que doesn't seem to do anything. I know its because the count down timer is still running after you leave the region, but can you make it so as soon as you leave the region the trigger stops or the wait timer resets?


Trigger:
Necromancer
Collapse Events
Unit - A unit enters Region 010 <gen>
Collapse Conditions
(Triggering unit) Equal to Perin 0010 <gen>
Collapse Actions
Special Effect - Create a special effect at (Position of Nazgrel 0015 <gen>) using Objects\Spawnmodels\Undead\UCancelDeath\UCancelDeath.mdl
Wait 1.00 seconds
Unit - Unhide Nazgrel 0015 <gen>
Quest - Display to (All players) the Hint message: |cffffcc00Nazgrel t...
Wait 12.00 seconds
If ((Region 010 <gen> contains Perin 0010 <gen>) Equal to True) then do (Do nothing) else do (Skip remaining actions)
Unit - Replace Perin 0010 <gen> with a Nazgrel using The new unit's max life and mana
08-07-2006, 05:40 PM#2
The_AwaKening
Try creating a loop with a 1 second polled wait and set it to end at 12 counts. Check every 1 second to see if the unit is still in the region. If not, then exit the loop. Sorry I don't have WE on this laptop so I cant make it in gui for you, but it would be something like this. I'll be home in 3 hours and then I can type it up for you if you can't figure it out.
08-07-2006, 07:15 PM#3
Alevice
Don't use waits, use a timer.

Trigger:
Necromancer
Collapse Events
Unit - A unit enters Region 010 <gen>
Collapse Conditions
(Triggering unit) Equal to Perin 0010 <gen>
Collapse Actions
Special Effect - Create a special effect at (Position of Nazgrel 0015 <gen>) using Objects\Spawnmodels\Undead\UCancelDeath\UCancelDeath.mdl
Wait 1.00 seconds
Unit - Unhide Nazgrel 0015 <gen>
Quest - Display to (All players) the Hint message: |cffffcc00Nazgrel t...
Countdown Timer - Start tempTimer as a One-shot timer that will expire in 12.00 seconds

Trigger:
SelectHero
Collapse Events
Time - tempTimer expires
Conditions
Collapse Actions
Unit - Replace Perin 0010 <gen> with a Nazgrel using The new unit's max life and mana

Trigger:
PauseTempTimer
Collapse Events
Unit - A unit leaves Region 010 <gen>
Collapse Conditions
(Remaining time for tempTimer) Greater than 0.00
Collapse Actions
Countdown Timer - Pause tempTimer
08-08-2006, 12:32 AM#4
The_AwaKening
--edited to add trigger

You can make it using Timers and a loop all in one trigger. I can't do well in GUI, so here is the JASS version. You should be able to copy this right over and only have to set your units ID's where I specifiied.

Collapse JASS:
function Necromancer_Actions takes nothing returns nothing
 local timer t = CreateTimer()
 local unit u = GetTriggerUnit()
 local real x = GetUnitX(gg_unit_YOURUNITID)        // set this to your unit Nazgrel
 local real y = GetUnitY(gg_unit_YOURUNITID)        // set this to your unit Nazgrel
 local boolean b = true
    call DestroyEffect(AddSpecialEffect("Objects\Spawnmodels\Undead\UCancelDeath\UCancelDeath.mdl",x,y)
    call TriggerSleepAction(1)
    call ShowUnit(gg_unit_YOURUNITID,true)        // set this to your unit Nazgrel
    call DisplayTimedTextToForce(GetPlayersAll(), 0, 0, bj_TEXT_DELAY_HINT, " "))
    call DisplayTextToForce(GetPlayersAll(), bj_TEXT_DELAY_HINT, "message")        // set your message
    call StartSound(bj_questHintSound)
    call TimerStart(t,12,false,null)
    loop
        exitwhen TimerGetRemaining(t) <= 0
        if RectContainsUnit(gg_rct_Region_010,u)==false then
            set b = false
            exitwhen true
        endif
        call TriggerSleepAction(1)
    endloop
    call PauseTimer(t)
    call DestroyTimer(t)
    if b==true then
        call ShowUnit(u,false)
        call CreateUnit(GetOwningPlayer(u),'YourUnitId',GetUnitX(u),GetUnitY(u),bj_UNIT_FACING)    // be sure to set your unit's Id you want to create
        call RemoveUnit(u)
    endif
 set t=null
 set u=null
endfunction

//===========================================================================
function Necromancer_Conditions takes nothing returns boolean
    return GetTriggerUnit() == gg_unit_Hpal_0000    // change this to your unit
endfunction

function InitTrig_Necromancer takes nothing returns nothing
    set gg_trg_Necromancer = CreateTrigger(  )
    call TriggerRegisterEnterRectSimple( gg_trg_Necromancer, gg_rct_Region_010 )
    call TriggerAddCondition( gg_trg_Necromancer, Condition( function Necromancer_Conditions ) )
    call TriggerAddAction( gg_trg_Necromancer, function Necromancer_Actions )
endfunction
08-08-2006, 06:53 AM#5
Wyvernoid
Quote:
Originally Posted by Alevice
Don't use waits, use a timer.
Trigger:
SelectHero
Collapse Events
Time - tempTimer expires
Conditions
Collapse Actions
Unit - Replace Perin 0010 <gen> with a Nazgrel using The new unit's max life and mana
If I remembered correctly, you said you want it execute only once... Why not add a "Trigger - Turn off (This Trigger)" to the trigger above?
And my suggestion is.... to use Alevice's triggers, 'cause I think there are some errors in Awakening's jass (also you forgot a ")" in line 7) Another reason is that I use GUI myself ^_^
08-08-2006, 04:31 PM#6
The_AwaKening
Fixed line 7, thanks. Tell me what problem you see with my code. It works with 1 trigger and it stops the timer if he leaves the region; therefore making him have to start the timer over if he re-enters. Sounded to me like that is what he wants. Also, turning the trigger off won't stop the actions. He would still have the original bug he is trying to fix.
08-08-2006, 07:05 PM#7
Sardius
Yah can you make the timer reset rather then pause?
So he has to stand in the region for 12 seconds without leaving?
08-08-2006, 07:22 PM#8
Captain Griffen
That's already what it does.
08-09-2006, 02:50 AM#9
Wyvernoid
@Awakening: Sorry it was my fault, your jass was quite right, I thought that it wouldn't trigger the function again.
But to the "Turn-off": in fact, when I look at the trigger again, I found the right thing: the timer was an ONE-SHOT one, so even if you do not turn it off, it will only execute once.