HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Wierd Bug

02-17-2007, 12:02 AM#1
ClichesAreSt00pid
Okay heres the trigger:
Trigger:
Respawn
Collapse Events
Player - Player 1 (Red) types a chat message containing -revive as An exact match
Conditions
Collapse Actions
Custom script: local location l
Collapse For each (Integer A) from 1 to 11, do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
(Player_Soldier[(Integer A)] is dead) Equal to True
((Player((Integer A))) slot status) Equal to Is playing
Collapse Then - Actions
Custom script: set l=GetRandomLocInRect(gg_rct_Spawn_Area)
Custom script: call CreateNUnitsAtLoc( 1, 'h003', ConvertedPlayer(GetForLoopIndexA()), (l), bj_UNIT_FACING )
Unit - Add a 10.00 second Generic expiration timer to (Last created unit)
Custom script: call PanCameraToTimedLocForPlayer( ConvertedPlayer(GetForLoopIndexA()), (l), 0 )
Camera - Set (Player((Integer A)))'s camera Distance to target to 20000.00 over 0.00 seconds
Camera - Set (Player((Integer A)))'s camera Rotation to 30.00 over 0.00 seconds
Wait 1.00 game-time seconds
Camera - Set (Player((Integer A)))'s camera Distance to target to 100.00 over 10.00 seconds
Wait 9.35 game-time seconds
Custom script: call AddSpecialEffectLocBJ((l), "Units\\Demon\\Infernal\\InfernalBirth.mdl" )
Wait 0.65 game-time seconds
Camera - Reset camera for (Player((Integer A))) to standard game-view over 2.00 seconds
Custom script: call ReviveHeroLoc( udg_Player_Soldier[GetForLoopIndexA()], (l), false )
Else - Actions
Custom script: set l=null
Now when it gets up to the first wait (Wait 1.00 game-time seconds) it does nothing and skips all remaining functions. I dunno whats causing this or how to fix it.
02-17-2007, 12:36 AM#2
Ammorth
don't use a wait with a loop that uses a global variable (Integer A). Also, you understand the wait will make it so each player will have the actions done in turn, instead of at the same time? To fix it, I would recommend that you remove the loop, and use triggering player as the arguments, instead of the loop with the ConvertedPLayerId()
02-17-2007, 12:47 AM#3
The)TideHunter(
Yes, hes right, when you put waits in loops, it does one after another.

Example:

Start Loop
Action1
Wait
Action2
Wait
Action3
Loop 5 times
End Loop


Action1, wait, Action2, wait, Action3, wait, Action1, wait, Action2, wait etc.

Not: Action1 full loop, wait, Action2 full loop, wait, Action3 full loop.

Thats why its not good to have loops in GUI, if you wanted a accurate but time consuming process, you return bug + gamecache and a timer callback function to use as a loop, but thats going to the extreme for a small job, so i dont reccomend.
02-17-2007, 01:15 AM#4
ClichesAreSt00pid
It's not supposed to have any events thats just for testing so I know it works. Other triggers will run it so it's "premade" you know?

For the wait I don't really get what I need to change so it works. I need the loop in there so it does it for all 11 players but I also need the wait functions. I tried converting it to jass and using locals instead of "bjforloopindex" or w/e and when i'd try to use my integer for the index on the "player_soldier" global variable it would crash.
02-17-2007, 02:23 AM#5
Ammorth
Use a playergroup loop instead of an integer loop. I believe player groups will wait properly. The replace all your "Player(Integer A)" with "Picked Player".
02-17-2007, 03:34 AM#6
ClichesAreSt00pid
Quote:
Originally Posted by Ammorth
Use a playergroup loop instead of an integer loop. I believe player groups will wait properly. The replace all your "Player(Integer A)" with "Picked Player".
Okay i'll do that tomorrow. But what about my conditions, too?
02-17-2007, 11:13 AM#7
The)TideHunter(
Yes, ForForce will work, which is Pick all players in Blah.
To use ForForce, you will need to convert GUI to Jass, because you need to make your own function, which will be the actions.
So lets get started.

Make a new trigger, add your event, and call it Respawn and convert it to Jass.
You will now have this:
Collapse JASS:
function Trig_Respawn_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_Respawn takes nothing returns nothing
    set gg_trg_Respawn = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Respawn, Player(0), "-revive", true )
    call TriggerAddAction( gg_trg_Respawn, function Trig_Respawn_Actions )
endfunction

Make a new function above Trig_Respawn_Actions, and call it Trig_Respawn_Loop or something.

So now we have:
Collapse JASS:
function Trig_Respawn_Loop takes nothing returns nothing
endfunction

function Trig_Respawn_Actions takes nothing returns nothing
endfunction

//===========================================================================
function InitTrig_Respawn takes nothing returns nothing
    set gg_trg_Respawn = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Respawn, Player(0), "-revive", true )
    call TriggerAddAction( gg_trg_Respawn, function Trig_Respawn_Actions )
endfunction

Now, we need to loop, as the action, so lets add that in the Actions function.
It was ForForce, and these are the parameters for it:
native ForForce takes force whichForce, code callback returns nothing
First parameter is force whichForce, a force is a player group, so first lets get all players.
For this, we can use bj_FORCE_ALL_PLAYERS, which is a force already made with all players.
And the last parameter is code callback, code is a function pointer, so its asking for us to put a function in there to run, we want our Loop function there, so lets create the ForForce and fill it in, we now have:
Collapse JASS:
function Trig_Respawn_Loop takes nothing returns nothing
endfunction

function Trig_Respawn_Actions takes nothing returns nothing
    call ForForce(bj_FORCE_ALL_PLAYERS, function Trig_Respawn_Loop)
endfunction

//===========================================================================
function InitTrig_Respawn takes nothing returns nothing
    set gg_trg_Respawn = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Respawn, Player(0), "-revive", true )
    call TriggerAddAction( gg_trg_Respawn, function Trig_Respawn_Actions )
endfunction

Now we just need to fill in our top function, which is the loop.
I won't go through this as much because i dont have enough time, but i will just copy all your actions into there.

Heres the finished result:

Collapse JASS:
function Trig_Respawn_Loop takes nothing returns nothing
    local location l
    local unit u
    local integer i = GetPlayerId(GetEnumPlayer())
    if(GetWidgetLife(udg_Player_Solider[i+1]) < 305.) and (GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING) then
        set l=GetRandomLocInRect(gg_rct_Spawn_Area)
        set u = CreateUnit(Player(i), 'h003', GetLocationX(l), GetLocationY(l), bj_UNIT_FACING)
        call UnitApplyTimedLife(u, 'BTLF', 10.)
        call PanCameraToTimedLocForPlayer(Player(i), l, 0.) 
        if(GetLocalPlayer()==Player(i))then
            SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 20000., 0.)
            SetCameraField( CAMERA_FIELD_ROTATION, 30., 0.,)
        endif
        call TriggerSleepAction(1.)
        if(GetLocalPlayer()==Player(i))then
            SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 100., 10.)
        endif
        call TriggerSleepAction(9.35)
        call DestroyEffect(AddSpecialEffectLoc("Units\\Demon\\Infernal\\InfernalBirth.mdl", l))
        call TriggerSleepAction(0.65)
        if(GetLocalPlayer()==Player(i))then
            ResetToGameCamera(2.)
        endif
        call ReviveHeroLoc(udg_Player_Soldier[i+1], l, false)
    endif
    call RemoveLocation(l)
    set l = null
    set u = null
endfunction

function Trig_Respawn_Actions takes nothing returns nothing
    call ForForce(bj_FORCE_ALL_PLAYERS, function Trig_Respawn_Loop)
endfunction

//===========================================================================
function InitTrig_Respawn takes nothing returns nothing
    set gg_trg_Respawn = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Respawn, Player(0), "-revive", true )
    call TriggerAddAction( gg_trg_Respawn, function Trig_Respawn_Actions )
endfunction

If that has any compile errors, just say, i dident check to see if theyre was any errors.
02-17-2007, 06:49 PM#8
ClichesAreSt00pid
It got a few errors but I fixed em' all.

It's still not doing the actions after the first wait function. Heres the trigger:
Collapse JASS:
function Trig_Respawn_Loop takes nothing returns nothing
    local location l
    local unit u
    local integer i = GetPlayerId(GetEnumPlayer())
    if(IsUnitDeadBJ(udg_Player_Soldier[GetConvertedPlayerId(GetEnumPlayer())]) == true ) and (GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING) then
        set l=GetRandomLocInRect(gg_rct_Spawn_Area)
        set u = CreateUnit(Player(i), 'h003', GetLocationX(l), GetLocationY(l), bj_UNIT_FACING)
        call UnitApplyTimedLife(u, 'BTLF', 10.)
        call PanCameraToTimedLocForPlayer(Player(i), l, 0.) 
        call SetCameraFieldForPlayer( GetEnumPlayer(), CAMERA_FIELD_ROTATION, 30.00, 0 )
        call SetCameraFieldForPlayer( GetEnumPlayer(), CAMERA_FIELD_TARGET_DISTANCE, 20000.00, 0.00 )
        call TriggerSleepAction(1.)
        call SetCameraFieldForPlayer(ConvertedPlayer(i), CAMERA_FIELD_TARGET_DISTANCE, 100.00, 10.00 )
        call TriggerSleepAction(9.35)
        call AddSpecialEffectLocBJ((l), "Units\\Demon\\Infernal\\InfernalBirth.mdl" )
        call TriggerSleepAction(0.65)
        call ResetToGameCameraForPlayer(ConvertedPlayer(i), 2.00 )
        call ReviveHeroLoc(udg_Player_Soldier[i], l, false)
    endif
    call RemoveLocation(l)
    set l = null
    set u = null
endfunction

function Trig_Respawn_Actions takes nothing returns nothing
    call ForForce(GetPlayersByMapControl(MAP_CONTROL_USER), function Trig_Respawn_Loop)
endfunction

//===========================================================================
function InitTrig_Respawn takes nothing returns nothing
    set gg_trg_Respawn = CreateTrigger(  )
    call TriggerRegisterPlayerChatEvent( gg_trg_Respawn, Player(0), "-revive", true )
    call TriggerAddAction( gg_trg_Respawn, function Trig_Respawn_Actions )
endfunction
02-17-2007, 10:52 PM#9
The)TideHunter(
Um, why did you change some of it? It should have worked.

To say some stuff about your code:

Where you have the function:
call SetCameraFieldForPlayer( GetEnumPlayer(), CAMERA_FIELD_ROTATION, 30.00, 0 )
I wrote:

Collapse JASS:
        if(GetLocalPlayer()==Player(i))then
            SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 20000., 0.)
            SetCameraField( CAMERA_FIELD_ROTATION, 30., 0.,)
        endif

If you look at what SetCameraFieldForPlayer does, you will find out that it does exactly what i wrote, so calling another function is just useless when you can have it direct.

Collapse JASS:
function SetCameraFieldForPlayer takes player whichPlayer, camerafield whichField, real value, real duration returns nothing
    if (GetLocalPlayer() == whichPlayer) then
        // Use only local code (no net traffic) within this block to avoid desyncs.
        call SetCameraField(whichField, value, duration)
    endif
endfunction

Also, you used call AddSpecialEffectLocBJ((l), "Units\\Demon\\Infernal\\InfernalBirth.mdl" )
Which is a leak, and its a BJ, the function i wrote will play the effect once then destroy it, it was fine how it was -.-.

And finally, when you use arrays, you need a +1 next to the i.
GetPlayerId(GetEnumPlayer()) will returns the players real number, player 1's number is not 1, but 0.

Player 1 = 0
Player 2 = 1
Player 3 = 2
Etc.
Its ok when you use Player(i), because thats what it should be, it is the correct player, but when you use a array, unless your first array starts at 0, which i doubt, i think it will be one because you use the Integer A loop function which returns 1 for player 1.

I'll remove the errors in a few minutes from my original code and repost it.

EDIT: Fixed with no Syntax errors, try this, it should work.
I highlited the things i dident include which were errors.

Collapse JASS:
function Trig_Respawn_Loop takes nothing returns nothing
    local location l
    local unit u
    local integer i = GetPlayerId(GetEnumPlayer())
    if(GetWidgetLife(udg_Player_Soldier[i+1]) < 0.405) and (GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING) then
        set l=GetRandomLocInRect(gg_rct_Spawn_Area)
        set u = CreateUnit(Player(i), 'h003', GetLocationX(l), GetLocationY(l), bj_UNIT_FACING)
        call UnitApplyTimedLife(u, 'BTLF', 10.)
        call PanCameraToTimedLocForPlayer(Player(i), l, 0.) 
        if(GetLocalPlayer()==Player(i)) then
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 20000., 0.)
            call SetCameraField(CAMERA_FIELD_ROTATION, 30., 0.)
        endif
        call TriggerSleepAction(1.)
        if(GetLocalPlayer()==Player(i))then
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 100., 10.)
        endif
        call TriggerSleepAction(9.35)
        call DestroyEffect(AddSpecialEffectLoc("Units\\Demon\\Infernal\\InfernalBirth.mdl", l))
        call TriggerSleepAction(0.65)
        if(GetLocalPlayer()==Player(i))then
            call ResetToGameCamera(2.)
        endif
        call ReviveHeroLoc(udg_Player_Soldier[i+1], l, false)
    endif
    call RemoveLocation(l)
    set l = null
    set u = null
endfunction
02-17-2007, 11:52 PM#10
ClichesAreSt00pid
Oh okay, thanks ^.^. I wish I could rep you a second time...and third and fourth and so on...

Anyways it's still not working though. It still doesn't execute the functions after the first wait (this is pissing me off now >.< work JASS work!).
02-18-2007, 12:15 AM#11
Pyrogasm
Tide, you wrote if(GetWidgetLife(udg_Player_Soldier[i+1]) < 305.), which is incorrect. It should be if(GetWidgetLife(udg_Player_Soldier[i+1]) < 0.406)
A unit with 0.406 life is alive, while a unit with 0.405 life is dead. The way it's set up, as long as the unit has less than 305 (three-hundred and five) life the trigger will not run.

Kind-of a big mistake, is it not?
02-18-2007, 12:48 AM#12
The)TideHunter(
Shit lol, i put the decimal on the wrong side, dumbass mistake.
Oh, and so it is 0.405, always thought it was 0.305.
Thanks, updated the code so its just another CnP.

Oh, and to be clear, CnP the code from the function below, to not get confused in which post iv been updating.
Updated Code

Collapse JASS:
function Trig_Respawn_Loop takes nothing returns nothing
    local location l
    local unit u
    local integer i = GetPlayerId(GetEnumPlayer())
    if(GetWidgetLife(udg_Player_Soldier[i+1]) < 0.405) and (GetPlayerSlotState(Player(i))==PLAYER_SLOT_STATE_PLAYING) then
        set l=GetRandomLocInRect(gg_rct_Spawn_Area)
        set u = CreateUnit(Player(i), 'h003', GetLocationX(l), GetLocationY(l), bj_UNIT_FACING)
        call UnitApplyTimedLife(u, 'BTLF', 10.)
        call PanCameraToTimedLocForPlayer(Player(i), l, 0.) 
        if(GetLocalPlayer()==Player(i)) then
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 20000., 0.)
            call SetCameraField(CAMERA_FIELD_ROTATION, 30., 0.)
        endif
        call TriggerSleepAction(1.)
        if(GetLocalPlayer()==Player(i))then
            call SetCameraField(CAMERA_FIELD_TARGET_DISTANCE, 100., 10.)
        endif
        call TriggerSleepAction(9.35)
        call DestroyEffect(AddSpecialEffectLoc("Units\\Demon\\Infernal\\InfernalBirth.mdl", l))
        call TriggerSleepAction(0.65)
        if(GetLocalPlayer()==Player(i))then
            call ResetToGameCamera(2.)
        endif
        call ReviveHeroLoc(udg_Player_Soldier[i+1], l, false)
    endif
    call RemoveLocation(l)
    set l = null
    set u = null
endfunction



BTW: If thats dosent work: What isent happening? is the effect not being created, is the camera not getting reset, or what?
02-18-2007, 02:21 AM#13
ClichesAreSt00pid
Everything after the very first wait action is not happening. I have no idea why...
02-18-2007, 09:48 AM#14
The)TideHunter(
If ForForce creates a new thread for each player, then the thread will die because its hitting TriggerSleepAction (so i think anyway), try this:
Try removing all the waits, and see whats happens, (it will all happen instantly), but atleast you can justify if its the waits that are causing your problems.
02-18-2007, 02:58 PM#15
ClichesAreSt00pid
I can guarentee it's the waits I just don't know what to do to fix it. Wait functions stop groups (unit, player) I forgot that. We could have different loops each time after a wait.