[scripting] endless / infinite loop ?


(aaa3) #1

er…

  1. idk if its really endless or just too much. game exits after warmup is over and map really should start, with “a reliable command cycled out”. and scriptdebug is on so i can see that beforebridge and the called triggers have run many times, at least 40-80, idk…

2)the script contains remarks but just ignore/skip those they re just for me. it is the verbatim copy of my script file, sry for thme making reading hard.

3)the script contains wm_announce stuff at the end of all triggers to see whats happening. only there for helping me the debugging. its helpful and scriptdebug dont make up for it.

4)when i noticed first the “infinite” runs they werent really infinite just about a few ten times. then later as script evolved it reached a state where would run so many times that it kicks from game. first i have inspected the script but didnt notice any semantic error which would cause this. (maybe i didnt noticed). then checked again and again, but when still didnt found anything i decided to add a new accum to dont let beforebridge run more than 1. but omg it also didnt work! very strange however it somehow reduced the loops to such an extent that it dont kick from the game anymore but still 15-20 times it runs. its totally mysterious for me :S

5)so pls help me in a) why this infinite or just too much looping occurs and why even my anti loop dont works; b) i have another problem, disabling and enabling team_ctf_xxxspawns are a complete mess in my script, i guess im doing it totally wrong. how to do it correctly? i.e. how to disable and enable spawning at certain spawn points? i done this after several tutorials n scripting references and examining stock maps and a spawn exchange example map.

edit: additional info. in the map file there is a flagpole but the spawns are NOT LINKED (ctrl-k) to it coz i wanted to manually control the enabling and disabling of the spawns. some fo the spawns are startactive and others are not, it is somewhere in the remarks in the long version which which.


here comes the script, in two version, bottom a simple easy read stripped version, and above it a full version as it is. edit: ok i divide it into 2 posts, simple version is in 2nd post. (10k char limit.)

full script, verbatim copy:
















//==================================================================//
//	AAA - DANUBIUS MAP - MAP SCRIPT FILE                    		    //
//==================================================================//














game_manager
{
  spawn
  {
    wait 512
    //wm_axis_respawntime 5             //a bridge lespawnolása megcsinálja a spawnokat
    //wm_allied_respawntime 5
    wm_set_round_timelimit 35
    wm_number_of_objectives 8 //######meglátjuk a map infót...
    wm_set_defending_team 0 //stopwatch, defending team (0=Axis, 1=Allies)
    wm_setwinner 0 //if timer expired (-1=Nobody)
    //setautospawn "Axis Valley Spawn" 0
    //setautospawn "Allied Mountain Pass Spawn" 1
    wm_objective_status 1 0 0 // <objective team status> 0 default, 1 succd 2 failed
    wm_objective_status 1 1 0 //repair bridge
    wm_objective_status 2 0 0 //hold a bridgehead for 5 min
    wm_objective_status 2 1 0

    accum 0 set 0 //indicates that do allies holding the flag? (1=Allies 0=Axis)(or yes/no:))
    accum 1 set 0 //stores that since how long r they having continuously the flag? (timer)
    //globalacc 0 - indicates that do allies have the bridge built? (yes=1, no=0)
    accum 2 set 1 //indicates if valley twobj allied (-1) or axis (1)? coz of fuking alerting the twobjs must made this new accum :S :( //and later made it use also for ctfrs
    accum 3 set 0 //indicates if bridgehead spawns are active? (1=Yes, 0=No)
    accum 4 set 0 //anti endless loop, temporarily added but dont really work :S
  }

  trigger beforebridge
  {
    globalaccum 0 abort_if_equal 1
    accum 4 abort_if_equal 1
    accum 4 set 1
    wm_axis_respawntime 3
    wm_allied_respawntime 3

    trigger self axis_two_1_makeaxis    //(alert) fukk it was at afterbridge bottom but must made it a separate trigger to make the lots of "abort if equal" stuff nice (and actually possible xD). //setstate axis_two_1 default //ez amúgy se kell a 3adik allied spawn miatt!
    trigger self ctfrs_ena              //alertentity ctfrs_1 //setstate ctfrs_1 default
    setautospawn "Axis Valley Spawn" 0

    setstate allied_two_2 invisible     //######majd ha timer akkor itt hiányok lehetnek...
    trigger self ctfbs2_disa            //alertentity ctfbs_2 //setstate ctfbs_2 invisible
    setautospawn "Allied Mountain Pass Spawn" 1
    //accum 4 set 1
    wm_announce "beforeb"
  }

  trigger afterbridge
  {
    globalaccum 0 abort_if_equal 0

    wm_axis_respawntime 4
    wm_allied_respawntime 4

    trigger self ctfrs_disa  //must preceed makeallied coz of shared accums //alertentity ctfrs_1 //setstate ctfrs_1 invisible //original not working stuff in REMs, if multiple, feeding new to left ...
    trigger self axis_two_1_makeallied  //nn invis... ld beforeb...
    setautospawn "Axis Back Spawn" 0

    setstate allied_two_2 default
    trigger self ctfbs2_ena             //alertentity ctfbs_2 //setstate ctfbs_2 default //coz dont start active, and anyway, uniform solution...
    setautospawn "Allied Bridge-head Spawn" 1
    wm_announce "afterb"
  }

  trigger allied_capture
  {
    globalaccum 0 abort_if_equal 0
    accum 0 abort_if_equal 1

    setstate allied_two_2 default
    trigger self ctfbs2_ena             //alertentity ctfbs_2 //setstate ctfbs_2 default
    setautospawn "Allied Bridge-head Spawn" 1

    wm_axis_respawntime 7
    wm_allied_respawntime 7

    accum 0 inc 1                       //not "set 1" ^^, just because
    wm_announce "Allied forces have set up a bridgehead!"
    wm_announce "al cap"
  }

  trigger axis_capture
  {
    accum 0 abort_if_equal 0
    
    setstate allied_two_2 invisible
    trigger self ctfbs2_disa            //alertentity ctfbs_2 //setstate ctfbs_2 invisible
    //alertentity ctfbs_3 //no need to alert it in ... er... **** :S i cant use this now. must have to set startactive :S :( (coz i dont want they to lost it when getting back "2"...) hope they will not spawn there anyways when shouldnt... //setstate ctfbs_3 default
    trigger self axis_two_1_makeallied  //alertentity axis_two_1 //just for cm flag appearance to change to allied
    setautospawn "Axis Valley Spawn" 1
    
    wm_axis_respawntime 6
    wm_allied_respawntime 6
    
    accum 0 inc -1
    wm_announce "Axis forces have repelled the Allies from the right River bank..."
    wm_announce "ax cap"
  }

//important that ctfrs_1 spawns are starting active (this is set
//at map and bsp) while ctfbs_2s doesnt and bs_3s again does.
//also important the order in which the toggling commands of the redspawns
//and the valley spawn command map icons are executing because
//of the shared accum.

  trigger ctfrs_disa
  {
    accum 2 abort_if_equal -1
    alertentity ctfrs_1
    wm_announce "rs dis"
  }

  trigger ctfrs_ena
  {
    accum 2 abort_if_equal 1
    accum 4 abort_if_equal 1
    alertentity ctfrs_1
    wm_announce "rs en"
  }

  trigger ctfbs2_disa
  {
    accum 3 abort_if_equal 0
    //először a globalaccumhoz akartam kötni de az nagy képtelenség. ennek muszáj külön accum mert sokminden változtathatja nem olyan egyszerű mint a red valley spawnok.
    alertentity ctfbs_2
    accum 3 inc -1
    wm_announce "bs2 dis"
  }

  trigger ctfbs2_ena
  {
    accum 3 abort_if_equal 1
    alertentity ctfbs_2
    accum 3 inc 1
    wm_announce "bs2 en"
  }

  trigger axis_two_1_makeallied
  {
    accum 2 abort_if_equal -1
    alertentity axis_two_1
    accum 2 inc -2
    wm_announce "valley made allied"
  }

  trigger axis_two_1_makeaxis
  {
    accum 2 abort_if_equal 1
    accum 4 abort_if_equal 1
    alertentity axis_two_1
    accum 2 inc 2
    wm_announce "valley made axis"
  }

  trigger checkgame
  {
  //later
  }
}





allied_bridge //based on 2bit's allied constructible prefab
{
  spawn
  {
    wait 512
    globalaccum 0 set 0
    trigger self setup
    constructible_class	3	// 2=Satchel 3=Dyna
    wm_announce "b spawned"
  }

  trigger setup
  {
    setstate allied_bridge_materials default // Crate Models
    setstate allied_bridge_clip default // Clip brushes
    setstate allied_bridge_flag default
    trigger game_manager beforebridge
    wm_announce "b set up"
  }

  built final
  {
    setstate allied_bridge_materials invisible // Crate Models
    setstate allied_bridge_clip invisible	// Clip brushes
    setstate allied_bridge_flag invisible
    wm_objective_status 1 0 2
    wm_objective_status 1 1 1
    globalaccum 0 inc 1
    trigger game_manager afterbridge
    wm_announce "Allied Team have repaired the Bridge."
  }

  decayed final
  {
    trigger self setup
  }

  death
  {
    wm_objective_status 1 0 1
    wm_objective_status 1 1 2
    globalaccum 0 inc -1
    trigger self setup
    wm_announce "Axis Team have destroyed the Bridge." 
  }
}

(aaa3) #2

very simplified version:


game_manager
{
  spawn
  {
    accum 0 set 0 //do allies holding the flag? (1=Allies 0=Axis)(or yes/no:))
    //globalacc 0 - allies have the bridge built? (yes=1, no=0)
    accum 2 set 1 //if valley twobj allied (-1) or axis (1)
    accum 3 set 0 // if bridgehead spawns are active? (1=Yes, 0=No)
    accum 4 set 0 //anti endless loop, temporarily added but dont really work :S
  }

  trigger beforebridge
  {
    globalaccum 0 abort_if_equal 1
    accum 4 abort_if_equal 1
    accum 4 set 1

    trigger self axis_two_1_makeaxis    
    trigger self ctfrs_ena 
    setautospawn "Axis Valley Spawn" 0

    setstate allied_two_2 invisible
    trigger self ctfbs2_disa
    setautospawn "Allied Mountain Pass Spawn" 1
    //accum 4 set 1
  }

  trigger afterbridge
  {
    globalaccum 0 abort_if_equal 0

    wm_axis_respawntime 4
    wm_allied_respawntime 4

    trigger self ctfrs_disa
    trigger self axis_two_1_makeallied
    setautospawn "Axis Back Spawn" 0

    setstate allied_two_2 default
    trigger self ctfbs2_ena
    setautospawn "Allied Bridge-head Spawn" 1
  }

  trigger allied_capture
  {
    globalaccum 0 abort_if_equal 0
    accum 0 abort_if_equal 1

    setstate allied_two_2 default
    trigger self ctfbs2_ena
    setautospawn "Allied Bridge-head Spawn" 1

    accum 0 inc 1
  }

  trigger axis_capture
  {
    accum 0 abort_if_equal 0
    
    setstate allied_two_2 invisible
    trigger self ctfbs2_disa
    trigger self axis_two_1_makeallied
    setautospawn "Axis Valley Spawn" 1

    accum 0 inc -1
  }

  trigger ctfrs_disa
  {
    accum 2 abort_if_equal -1
    alertentity ctfrs_1
  }

  trigger ctfrs_ena
  {
    accum 2 abort_if_equal 1
    accum 4 abort_if_equal 1
    alertentity ctfrs_1
  }

  trigger ctfbs2_disa
  {
    accum 3 abort_if_equal 0
    alertentity ctfbs_2
    accum 3 inc -1
  }

  trigger ctfbs2_ena
  {
    accum 3 abort_if_equal 1
    alertentity ctfbs_2
    accum 3 inc 1
  }

  trigger axis_two_1_makeallied
  {
    accum 2 abort_if_equal -1
    alertentity axis_two_1
    accum 2 inc -2
  }

  trigger axis_two_1_makeaxis
  {
    accum 2 abort_if_equal 1
    accum 4 abort_if_equal 1
    alertentity axis_two_1
    accum 2 inc 2
  }
}





allied_bridge //based on 2bit's allied constructible prefab
{
  spawn
  {
    wait 512
    globalaccum 0 set 0
    trigger self setup
    constructible_class	3	// 2=Satchel 3=Dyna
  }

  trigger setup
  {
    trigger game_manager beforebridge
  }

  built final
  {
    globalaccum 0 inc 1
    trigger game_manager afterbridge
  }

  decayed final
  {
    trigger self setup
  }

  death
  {
    globalaccum 0 inc -1
    trigger self setup
  }
}

another edit, here are the older versions of the script attached. ver numbering is a mess coz it dont tie to *.script but to *.map versions.


(isbowhten) #3

Im afraid i can only help you with point 5b)
disabling, enabling spawns:
perhaps there are better ways but i do it this way…
entites arent linked together;
you could say in the scriptfile “alertentity targetname_of_team_ctf_xxxspawn” toggles the active status…
if you checked the spawnflag “startactive” then alertentity would make it inaktiv.

the wolf_objectives are set to default or invisible if they should be enabled or disabled…

perhaps i can help you with the other problems if you give me a list of your entites…
i had such problems, too but not with spawnexchanges ( i had this when my truck i made myself (with help of this fourm) passed a barrier)


(Igloo) #4

5b)

You can use both - alertentity & setstate targetname invisible/default for spawns and team_WOLF_objective afair.

Greetings,
Igloo


(aaa3) #5

i couldnt use setstate with non-start-active ones so i switched to alerting which would toggle it between on and off. at least, i thought it will. but somehow it dont works for me. t_w_objs are i think moreorless working i have serious problems only with spawns


(-SSF-Sage) #6

Why don’t you set all spawns startactive and toggle it with the setstate… As suggested above. What comes to the other questions, I didn’t read them yet. If I don’t have too bad hang over tomorrow, I will read them tomorrow.


(aaa3) #7

thanx for everybody who tried to help on this;

yeah that would be a good workaround but it should also work in this method, it must be possible to correctly use non-start-active ones too (and without a flagpole automatically enabling one and disabling other team’s ctrl-k connected ctf_xxspawns), and i dont know why it doesnt work and i want to know it :slight_smile:
what i was also thinking about that maybe only this loop thing causes the spawning mess too. in earlier versions after staring the code minutes, i found lots of errors why spawn changigng why doesnt work as i imagined, but correcting one error after another thinking “it should work now” but it still didnt, then found new ones et c, this is my method; but now i cant find any more. i corrected them all, at least i thought it.
but i cant further work on the script until i get solution to this looping stuff =/ …


(isbowhten) #8

it might help if you post your map…
i also have an idea:
trigger x
{
//here you trigger another scriptroutine although it isnt needed
trigger y z
}

y
{
trigger z
{
abort if accum = 1
set accum 1
->commands
}
}
the trigger of the first routine runs more than once => accums do not stop it if it is run again after a too short while or some other reason, i dont really know…
but triggering another script did help me with a wm_Announce command executed too often


(aaa3) #9

here is a console dump. the one without number is when i have the “accum 4 set 1” in beforebridge at the remarked place (bottom of block), and the one with number 2 is when i have “accum 4 set 1” at immediately after abor_if_equal (top of block), as it can be seen in the script. its visible that it runs fewer times, allowing to join the game, but still not only once.
i will post the map soon and edit this post.

isbowthen, ty, it seems u had the same problem with announces and u had managed to solve it. u mean i should put my called triggers into an entirely different script block instead of the same as the one which call it (now both are in game_manager) ? or i have to put little wait commands, e.g. wait 50 ? hmm i will try it anyways, and edit this post about the results. ty : )


EDIT: Yay! Thanx isbow :stuck_out_tongue: all i had had to do is to add a “wait 64” to the first line of the trigger axis_two_1_makeaxis, nothing else had to changed; inspiration was by your post :smiley: [QUOTE=isbowhten;176961]if it is run again after a too short while or some other reason, i dont really know…
but triggering another script did help me with a wm_Announce command executed too often[/QUOTE]

just for being interested, also tried to move it (_makeaxis trigger) to a new routine instead of game_manager, but this time without wait, and it didnt work in this way.


(isbowhten) #10

you’re welcome :wink: