Script to get time


(yekim) #1

Hi guys, I’m looking to mod some maps to adjust the time based on number of objectives completed. However, I’m not looking to do this on a per-objective basis (i.e. objective 1 completed, add 5 mins).

Instead what I want to do is this:

At time X, analyze the number of objectives completed. If Y objectives are completed, add time.

So what this means is setting a trigger in the map.script to occur at a certain time. Is there any script function you guys know about to do this? In code I’m looking for the bolded function:


(Lanz) #2

Hmm, you should be able to do something like this using the func_timer entity.

If you create and link three entities in this order target_relay -> func_timer -> target_script_trigger. Then you should be able to start and stop the timer with the target_relay by using “alertentity <relayentity>” and to create a script event for the timer through the target_script_trigger.


(yekim) #3

Thanks for the tips Lanz, though I’m afraid I am still a total beginner here (I’m a fairly experienced programmer, but have spent a total of 2 hours working on this ET mod).

Maybe you can tell me where I can find a (documented) resource for this? What you’re sayings makes sense at first glance, but I don’t really understand how to implement it at this point. I’ve read docs like the ‘Level Designer’s Reference’ but its not detailed enough on the complete syntax. Is scripting in ET based on some standard scripting language?

BTW, I’ve found a workaround, in which I analyze the score everytime one team gets a point, and if the score is within 5, I add more time. If the score is not within 5, I assume the teams are unfair, and don’t add time.


(nUllSkillZ) #4

Unfortunately it’s not based on any other scripting language.
You will find the best scripting tutorial at:
http://4newbies.planetwolfenstein.gamespy.com/

Direct link:
http://4newbies.planetwolfenstein.gamespy.com/Map_Scripting_4_Newbies.pdf


(kamikazee) #5

Well, it’s based on RTCW map scripting, but that’s all.


(yekim) #6

Thanks, I’ve seen that before, it is helpful. I guess for me understanding scripting is not the problem; what I’m struggling with is the syntax (i.e. I can’t find a single place that shows me all the commands). I do know this:

http://simland.planetquake.gamespy.com/ldr1_1/appendix_a.htm

But as I said, I can’t find anything that Lanz suggested in this doc.

A quick sidebar: Once I’ve made a mod to the script, what’s the best way to implement it? It seems I have a few options:

  1. Re-zip it into the original map’s .pk3 (but will that cause problems with the client? i.e. clients will get “invalid .pk3 file” since their original .pk3 is now different from the server’s?)
  2. Zip the new script into <NewScriptforMapX>.pk3. But I don’t understand how the server will know to use this script, instead of the one in the map’s original .pk3?

Thanks guys!


(kamikazee) #7

I don’t know anything better then this one: Chruker’s game section: Scripting reference


(nUllSkillZ) #8

Please don’t touch the original mapfile-pk3’s.
If the modded mapfile is on the server everyone has to download the map again.
Because it differs from the original.

Just create your own pk3-file.
Name the script the same as the original script.
I think the only thing you have to do is to name your script-pk3 with a name that’s greater than the original mapfile-pk3 (in alphabetical terms).

There are some modded-scriptfiles available (I remember one for railgun).
So you could search the forums and have a look at this pk3-file.

Alternative: ET-Pro mapscript-folder if you are testing your map.
Should be working with ET-Pub too.
But as I haven’t got experience in running an ET-Pro server I can’t help you with that.


(yekim) #9

Ahhh! Ok that makes sense. =SC=Beef advised me in their forums to put the script standalone in a pk3 and name it z_mapname.pk3. So the server goes through the pk3 files in alphabetical order, and uses the last script file for each map?

Makes sense now, thanks guys


(Lanz) #10

Ok I’ll try to explain a bit better, create the entities in Radiant like this:


target_relay
---------------
classname target_relay
targetname timer_relay
target timer


func_timer
-------------
classname func_timer
targetname timer
spawnflags 1  // start on, or use alertentity timer_relay	
wait xx // <---- int value in seconds
target timer_script


target_script_trigger
-------------------------
classname target_script_trigger
targetname timer_script
scriptname timer_handler
target timer_event

then in your script file somewhere after the game_manager block add this:


timer_handler
{
	trigger timer_event
	{
		// do your stuff here
		alertentity timer_relay // stop it
	}
}

This can be changed in infinitum, where you can do stuff like trigger the timer every minut, increase an accum and abort less than a certain value and run game comments like 2 minutes remaining etc etc…

I don’t know how much you know about Radaint etc so I keep it short like this and of course it’s totally untested but should work.