Heavy script??


(Flippy) #1

Hey…

in following of a post i made a while back, where i wanted to have a scoreboard count down from 30 to 0, counting down once every 5 seconds for the team that has the flag in the middle captured…

i got this to work now, but everytime a team scores and the scoreboard must be updated, a slight pause in the game is noticable…
this pause is very slightly, but the map is at the moment VERY small, with NOTHING in it except the flag and the scoreboard, and im all alone on my server, so with 20 players blasting about and all kinds of structures in my map im guessing the pause will be much more noticable…

now i think i know why the game is pausing for a moment, it’s because the script has to do many things at the same time…

i was wondering if there was any other way to do this (i ll try to explain it…)

see, everytime a team scores (every 5 serconds of holding the flag) a trigger is called to update that teams scoreboard…

This is part of the script… This part only counts to 25, so you can image how many times more this part of the script is run at the same time…
(ax1_2 means axis scoreboard, 1 = leftside, 2 = number 2)
globalaccum 0 is the axis score)
(trigger self clearaxis triggers the board to clear itself, this means "setstate ax1_0 invisible, setstate ax1_1 invisible, etc etc etc…)


  		trigger self clearaxis 
  		setstate ax1_2 default
  		setstate ax2_9 default
  		globalaccum 0 abort_if_equal 29

  		trigger self clearaxis
  		setstate ax1_2 default
  		setstate ax2_8 default
  		globalaccum 0 abort_if_equal 28 

  		trigger self clearaxis
  		setstate ax1_2 default
  		setstate ax2_7 default
  		globalaccum 0 abort_if_equal 27

		trigger self clearaxis
		setstate ax1_2 default
		setstate ax2_6 default
		globalaccum 0 abort_if_equal 26

		trigger self clearaxis
		setstate ax1_2 default
		setstate ax2_5 default
		globalaccum 0 abort_if_equal 25

As you might be able to see (or not, i know it can be hard to understand a script just by looking at it) i let the script run the trigger to clear the board, and at the same time show the numbers 29. Then the script continues only if globalaccum 0 is not 29 (which means it’s less than 29) so it clears the board again, and shows the 2 values it should show again.
You can image that if the score was for example 4, the script has to run through 26 of these “blocks” of script, and all at the same time…

I hope you understand, and i hope there is an easier way to do this LOL :clap:

EDIT, i just thought of something… would adding a wait 10 everytime after “globalaccum 0 blabla” solve the problem??


(RayBan) #2

are these fixed flags? like just an area that a player has to stand in for 5 seconds to get a score?


(Flippy) #3

just the normal flags used in the game for capturing spawnpoints… except this flag doesnt give you a spawnpoint but it gives you a point (or actually one less point) if you hold it for 5 seconds
(it’s not capture the flag map like quake or UT where you run around with the flag… the flag stays in the middle of the map all game, but when it’s captured by axis (axis flag raised) it gives axis points…)


(nUllSkillZ) #4

In some of the MLB maps are counters / countdowns.
So you could take a look there.


(RayBan) #5

so sort of like a checkpoint type of map… well, you could get rid of that scripting for it, and make more of a script like the one in railgun, where
if a axis player is in it, it gets activated, if they step out, deactivated, same for the allies… and if both team players are in it, it becomes
null and void until one steps out… basicly just will work if one team or the other is in it.

so if a player steps in it, it becomes active, then you could use a func_timer or a target_delay set at 5 seconds to call a script trigger via
the target_script_trigger which will only trigger the point score routine if the player is still in and the opposite team members have not
stepped in during the call… blah blah blah…

there’s a few ways you could do it actually… but it would be less of a headache than some massive script and more precise.


(Flippy) #6

hmm i dont like the fact that more players can step in … it will make the concept of scoring very unclear and itll make it hard to see who is actually scoring at the moment…

and thinking of it… how will that solve my problem with having to go past each accum value untill the actuall value is reached??


(RayBan) #7

maybe i dont understand the concept, here’s what i get from your initial post,

there’s a flag that either team needs to hold for 5 seconds to reduce the count on the scoreboard, when that reaches 0 that team wins…
im hoping thats correct.

the count can always be done if a player is in the holding area and his/her team currently has the flag ( its up the pole ) and if an enemy player is in the flag
area, but his/her team doesnt have the flag… then the null/void is ignored.

either way, i think the scripting is less of a hassle than the route your taking…

but then again… i might not understand the concept properly.


(Flippy) #8

i think the way you think is correct…

ill try to explain again in more detail :stuck_out_tongue:

There’s a flag in the middle of the map. By default no team is “holding” the flag (and with holding i mean having their flag raised). The default score (stored in 2 globalaccums, one for each team) is 30 and is also displayed on a scoreboard.
The scoreboard (axis for example) consists of 2 digit places. In each digit place, there are 10 script_movers, the numbers 0 - 9. Their targetnames/scriptnames are as follows:
ax1_0 untill ax1_9 and ax2_0 untill ax2_9 (ax means axis, 1 means first digit, 2 means second digit)

When axis holds the flag for 5 seconds, their score is lowered with one point (globalaccum 0 inc -1) and the scoreboard is triggered to update the score.

I wanted to do it very easy:
If score = 25, then setstate ax1_2 default and setstate ax2_5 default (and setstate the rest invisible)

However, i saw no other way to do this than letting the game do this in this exact order:

  1. Clearing the scoreboard (setstate invisible to all)
  2. Showing the first possible score (29) (setstate 2 and 9 default)
  3. Letting the script stop if the globalaccum is actually 29 and letting it continue with this same sequence, but now with 28, when it’s not 29.
  4. Clear scoreboard again, show first possible score after 29 (28 ), letting the script stop when globalaccum 0 is 28, and letting it continue to 27 if it’s not.
  5. ETC…

So the scoreboard is essentially running through all possible values between 30 and 0, untill it hits the value of globalaccum 0. If it hits the value of globalaccum 0, it is ordered to abort (abort_if_equal [current score]) this script sequence untill another 5 seconds have passed.

This last sequence, is there ANY other (simpler) way of doing it?

What i first thought of was making a seperate trigger for each score, and letting the script trigger only the appropriate trigger… eg, score is atm 25. The game knows this (globalaccum 0 = 25) Because the games knows the current score, it SHOULD be possible to tell it to skip the first 5 “sequences” of the scoreboard and start with value 24…? shouldnt it?
Well, i have no clue how…


(kamikazee) #9

1 flag in the middle, which needs to be captured for 5 seconds straight to get a point. The team with 30 points wins.

You could try it like this:

[ul][li]Give your team_CTF_checkpoint a scriptname.
[/li][li]Write an allied_capture trigger, and an axis_capture trigger for that scriptblock.
[/li][li]In those triggers, toggle a globalaccum flag to show who is currently holding the flag. Provide a “not captured” flag too. (See comments in script on what I mean)
[/li][li]Make a func_timer with a delay of 5 seconds
[/li][li]Targety it to a target_script_trigger
[/li][li]Let this one call a trigger called “dec”.
[/li][li]If you use the code below as a start, it should decrease the right score.[/ul]
[/li]
This code is not much better in terms of code length, but here’s how I would rewrite your system:


// globalaccum 0 -> bit 0 -> 0 = flag NOT captured, used for start
//		 bit 1 -> team who captured flag, 0 = axis, 1 = allies
targ_scr_trig {
	// Accum 0 is score for axis
	// Accum 1 is score for allies
	spawn {
		wait 100
		accum 0 set 30
		accum 1 set 30
		trigger self ax_thirty
		trigger self al_thirty
	}
	trigger inc {
		// See if the flag has been captured at least once
		globalaccum 0 abort_if_not_bitset 0
		trigger self dec_ax
		trigger self dec_al
	}
	trigger dec_ax {
		// Sure allies got the flag?
		globalaccum 0 abort_if_not_bitset 1
		accum 0 inc -1
		accum 0 trigger_if_equal 0 game_manager axis_lose
		accum 0 trigger_if_equal 1 self  ax_one
		accum 0 trigger_if_equal 2 self  ax_two
		accum 0 trigger_if_equal 3 self  ax_three
		accum 0 trigger_if_equal 4 self  ax_four
		accum 0 trigger_if_equal 5 self  ax_five
		accum 0 trigger_if_equal 6 self  ax_six
		accum 0 trigger_if_equal 7 self  ax_seven
		accum 0 trigger_if_equal 8 self  ax_eight
		accum 0 trigger_if_equal 9 self  ax_nine
		// And so on...
	}
	trigger dec_al {
		// Sure axis got the flag?
		globalaccum 0 abort_if_bitset 1
		accum 1 inc -1
		accum 1 trigger_if_equal 0 game_manager allies_lose
		accum 1 trigger_if_equal 1 self  al_one
		accum 1 trigger_if_equal 2 self  al_two
		accum 1 trigger_if_equal 3 self  al_three
		accum 1 trigger_if_equal 4 self  al_four
		accum 1 trigger_if_equal 5 self  al_five
		accum 1 trigger_if_equal 6 self  al_six
		accum 1 trigger_if_equal 7 self  al_seven
		accum 1 trigger_if_equal 8 self  al_eight
		accum 1 trigger_if_equal 9 self  al_nine
		// And so on...
	}
	trigger al_thirty {
		//Set score to thirty, hide OTHER chars
		setstate al1_0 invisible
		setstate al1_1 invisible
		setstate al1_2 invisible
		setstate al1_3 default
		setstate al1_4 invisible
		setstate al1_5 invisible
		setstate al1_6 invisible
		setstate al1_7 invisible
		setstate al1_8 invisible
		setstate al1_9 invisible

		setstate al2_0 default
		setstate al2_1 invisible
		setstate al2_2 invisible
		setstate al2_3 invisible
		setstate al2_4 invisible
		setstate al2_5 invisible
		setstate al2_6 invisible
		setstate al2_7 invisible
		setstate al2_8 invisible
		setstate al2_9 invisible
	}
	trigger al_twentynine {
		setstate al1_2 default
		setstate al1_3 invisible
		setstate al2_0 invisible
		setstate al2_9 default
	}
	//... and so on
	trigger ax_thirty {
		//Set score to thirty, hide OTHER chars
		setstate ax1_0 invisible
		setstate ax1_1 invisible
		setstate ax1_2 invisible
		setstate ax1_3 default
		setstate ax1_4 invisible
		setstate ax1_5 invisible
		setstate ax1_6 invisible
		setstate ax1_7 invisible
		setstate ax1_8 invisible
		setstate ax1_9 invisible

		setstate ax2_0 default
		setstate ax2_1 invisible
		setstate ax2_2 invisible
		setstate ax2_3 invisible
		setstate ax2_4 invisible
		setstate ax2_5 invisible
		setstate ax2_6 invisible
		setstate ax2_7 invisible
		setstate ax2_8 invisible
		setstate ax2_9 invisible
	}
	trigger ax_twentynine {
		setstate ax1_2 default
		setstate ax1_3 invisible
		setstate ax2_0 invisible
		setstate ax2_9 default
	}
	//... and even on
}

It only checks the scores at the beginning of the inc_<team> trigger, then calls the right score trigger.

Extend as needed. I do think of one flow in the way I described, and that is due to the func_timer… If the timer just “ticked” and the flag is captured, it takes less than 5 seconds to score a point. Only once on each capture of course, but it can be annoying.


(RayBan) #10

how does this scoreboard look? i mean how big is it?


(RayBan) #11

yeah… kamikazee has the idea there… trigger_if_equals, personally i’d make an intensive scoreboard model ( md3 ) and make it animated…
or one with a large rotary wheel with the scores on seperate quads of the wheel… but that last idea would need a deep back area for the scoreboard.

still there are many ways to do it.


(kamikazee) #12

I used yet another way for ET Headshot 2, using a bunch of remapshader statements and 2 different digit panels per team. The reason why I used this way is to save him the work of removing all the script_movers he made.


(Flippy) #13

Wow thnx kamikazee, i didnt know there was a “trigger_if_equal” function! This is exactly what i needed…

I dont know exactly what to do with the bitset things (saw them in the tank code, but just copied them, dont know how they work…)

but i dont think i really need it…

and about the lenght of the script, i dont really care, it’s just the fact that in my script, there are up to … calculating … 33 * 30 = 990 things it does at the same time! (if i calculated correctly, which is probably not the case, but i dont care :stuck_out_tongue: )

Using trigger_if_equal, only the hide + show scoreboard options for the right score are triggered… :clap:

The flaw that you mention with the func_timer does not bother me at all, actually that’s what i was thinking of in the first place when i started to script with this, but i forgot it on the flow i guess… (i also wanted to make a timer that counts down, and i found it would look weird if it resets to 5 when you lose the flag… but i guess the timer is for later :stuck_out_tongue: )

Rayban, it’s fairly large, teams must be able to see it from far away
Here’s a screenie (gridsize 64 (nr 7 on keypad))

About making a model, i dont have a clue how to convert 3dsmax saving format to md3 and im not gonna bother just for this…

about remapshader… isnt that exactly the same amount of “work” (just doing remapshader instead of setstate?)


(kamikazee) #14

It’s just a little less work in the spawn stage: you just remap the shader to zero instead of making all other digits invisible.
Also, you don’t need to make the old digit invisible and the new one default, it just remaps.

But I would leave it as it is now, or you made those 20 script_movers for nothing. (And it would also void my work on that script snippet)


(Flippy) #15

ok… :stuck_out_tongue: id leave it anyway… script seems more impressive now xD


(RayBan) #16

bitset’s are just a way of extending the usage of accums to use as flags, instead of using a series of accums to say
trigger_if_equal on a certain accum, and using another to do the same for some other part of a script, you can just
use one accum and various bit settings of that accum.


(Loffy) #17

Counters are so right, especially in ctf style maps. Gl Flippy!

On a sidenote: Where did I see a scoreboard in a futuristic deathmatch map that had a running text that basically said “Current leader: Loffy, 29 frags”. It was some years ago. UT?
Hey, I just remember a question for the ETQW team (kills an scripts). Will start a new thread with that question.
//Loffy


(kamikazee) #18

Further off topic: Yep, that was an UT map, it’s called Morpheus.