this is a script from 1 of a few maps i've been working on it's a bit on the untidy side. haven't had time to go through it. (it work's) can some1 have a look and comment & tidy it up a small bit
cheers for any assisant ye can give:
Their's a bit of everything in there
main:
exec global/loadout.scr maps/mission1.scr
exec global/alarmer.scr //for the alarms
level waittill prespawn
exec global/ambient.scr mission1
exec global/ai.scr //i wonder!
exec global/cabinet.scr //the men that jump out of cabinet
exec global/door_locked.scr //sound for locked door
exec global/exploder.scr // used for blowning up things
exec global/bomber.scr // used for planes
level waittill spawn
//Allied weapons
//$player item weapons/m1_garand.tik
$player item weapons/Springfield.tik
//$player item weapons/M2frag_grenade_sp.tik
$player item weapons/thompsonsmg.tik
$player item weapons/colt45.tik
$player item weapons/shotgun.tik
//ammo
$player ammo pistol 60
$player ammo rifle 100
$player ammo smg 300
//$player ammo mg 400
//$player ammo grenade 3
$player ammo shotgun 30
//$player ammo heavy 10
$player useweaponclass pistol //the fisrt weapon to appear
level.script = "maps/mission1.scr"
thread music1 //call music to b played
thread objectives
thread patrols
thread setup_start
thread gate_setup
thread bombs_1_pickup
end
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////// threads called in script /////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////setup level stuff
setup_start:
$mg42 thread global/mg42_active.scr::mg42
$mg42a thread global/mg42_active.scr::mg42
level.planesleft = 6
$bomb_wall_1_trigger nottriggerable
$bomb_wall_1 hide
$end_level1 nottriggerable
$end_level2 nottriggerable
end
///////////////music played
music1: //music that will be played
$player stufftext "tmstartloop sound/music/mus_15a_mystery.mp3"
end
/////////////starts the patrols
patrols:
thread patrol1
thread patrol2
wait 20
thread patrol3
thread patrol4
end
//for the bombs pickup
bombs_1_pickup:
$bomb1_pickup remove
$bomb1_pickup_trigger nottriggerable
end
bomb_pickup_on:
$bomb1_pickup show
$bomb1_pickup_trigger triggerable
end
bombs_1:
$bomb_wall_1_trigger triggerable
$bomb_wall_1 show
$door2_lock nottriggerable
end
/// gate stuff
gate_setup:
//gate Speeds
$gate_1 time 5
$gate_2 time 5
end
/////////////for turnin the switches
switch_on:
$switch1 anim turn //animate the switch into the on position
$switch2 anim turn
$switch3 anim turn
$switch4 anim turn
$switch1 anim waittill animdone
$switch2 anim waittill animdone
$switch3 anim waittill animdone
$switch4 anim waittill animdone
$switch1 anim on //animate the switch into the on position
$switch2 anim on
$switch3 anim on
$switch4 anim on
end
switch_off:
$switch1 anim off //animate the switch into the off position
$switch2 anim off
$switch3 anim off
$switch4 anim off
end
//// door is gone
door_remove: /// called in 1 of objectives
$door1_trigger nottriggerable
$door1 remove
$door2 show
end
///////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////// the patrol guys ///////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
patrol1:
$patrol_guy_1 walkto $path11
wait 5
$patrol_guy_1 walkto $path12
wait 1
$patrol_guy_1 walkto $path13
wait 1
$patrol_guy_1 walkto $path14
wait 1
$patrol_guy_1 walkto $path15
wait 5
$patrol_guy_1 walkto $path13
wait 1
$patrol_guy_1 walkto $path12
wait 10
end
patrol2:
$patrol_guy_2 walkto $path21
wait 5
$patrol_guy_2 walkto $path22
wait 2
$patrol_guy_2 walkto $path23
wait 2
$patrol_guy_2 walkto $path24
wait 5
$patrol_guy_2 walkto $path23
wait 2
$patrol_guy_2 walkto $path22
end
patrol3:
$patrol_guy_3 walkto $path31
wait 5
$patrol_guy_3 walkto $path32
wait 2
$patrol_guy_3 walkto $path33
wait 2
$patrol_guy_3 walkto $path34
wait 5
$patrol_guy_3 walkto $path33
wait 2
$patrol_guy_3 walkto $path32
end
patrol4:
$patrol_guy_4 walkto $path41
wait 5
$patrol_guy_4 walkto $path42
wait 2
$patrol_guy_4 walkto $path43
wait 2
$patrol_guy_4 walkto $path44
wait 5
$patrol_guy_4 walkto $path43
wait 2
$patrol_guy_4 walkto $path42
end
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////// threads called from map ///////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////just a door wit a trigger /////////////////////////////////////
//////////////////////////////////// covering it //////////////////////////////////////////////////
/////////////////////////////////// wit a setthread in it //////////////////////////////////////////
door1_lock: //disabled later because door get's blown to bits
$player playsound door_wood_locked
end
//////////////////////////////////////////// planes/////////////////////////////////////////////////////////
//////////////////// first 1
plane_fly1:
$plane_fly_trigger2 nottriggerable
$plane_fly_trigger nottriggerable //so it won't trigger infinitly
thread global/bomber.scr::bomb 37 //the set no of the bomber and spline paths
thread global/bomber.scr::bomb 38
thread global/bomber.scr::bomb 39
wait 3
$player playsound m3l2_first_airstrike //sound
wait 70 //make it so you can trigger it later
$plane_fly_trigger triggerable // let them fly
$plane_fly_trigger2 triggerable
end
///////////////second 1
plane_fly2:
$plane_fly_trigger2 nottriggerable
$plane_fly_trigger nottriggerable //so it won't trigger infinitly
thread global/bomber.scr::bomb 37 //the set no of the bomber and spline paths
thread global/bomber.scr::bomb 38
thread global/bomber.scr::bomb 39
wait 5
$player playsound m3l2_first_airstrike //sound
wait 70 //make it so you can trigger it later
$plane_fly_trigger triggerable // let them fly
$plane_fly_trigger2 triggerable
end
////////////////////////////////////////// for the alarms///////////////////////////////////////////////////
alarm_player_reset: //the setthread value (used in the entity window
thread global/alarmer.scr::alarm_player_reset
end
/////////////////////////////////////////bomb for blowing the wall ////////////////////////////////////////////
pickup_bomb:
$bomb1_pickup remove
$bomb1_pickup_trigger nottriggerable
waitthread global/items.scr::add_item "explosive" // gives player bombs
end
/////////////////////////////////////////for blowing the wall ////////////////////////////////////////////
bomb_wall_1_house:
$bomb_wall_1_trigger waittill trigger //name for trigger
$bomb_wall_1 model "animate/explosive.tik"
$bomb_wall_1 playsound plantbomb // sound tick tick
$player loopsound bombtick1
$player stopwatch 5
wait 5
$player stoploopsound bombtick1
$bomb_wall_1 playsound explode_building_small1 //kaboom!
$bomb_wall_1 remove //remove from wall the bomb
$bomb_wall_1_trigger nottriggerable
waitthread global/exploder.scr::explode 26 //set no (26)
radiusdamage $hurtobject1 256 384
end
////////////////////////////////////////////gates//////////////////////////////////////////////////
////////gate 1
gate_move:
thread switch_on
$gate_switch waittill trigger
$gate_switch nottriggerable
$gate_1 playsound elevator_start wait
wait .5
$gate_1 playsound elevator_run
$gate_1 moveto $gate_top
$gate_1 waitmove
wait 6
thread gate1_down
end
gate1_down:
wait 30
$gate_1 playsound elevator_start wait
wait .5
$gate_1 playsound elevator_run
$gate_1 moveto $gate_bottom
$gate_1 waitmove
thread switch_off
wait 6
$gate_switch triggerable
$gate_switch2 triggerable
end
//////GATE SWITCH INSIDE
gate_move_inside:
thread switch_on
$gate_switch2 waittill trigger
$gate_switch2 nottriggerable
$gate_1 playsound elevator_start wait
wait .5
$gate_1 playsound elevator_run
$gate_1 moveto $gate_top
$gate_1 waitmove
wait 6
thread gate1_down
end
//////gate 2
gate2_move:
thread switch_on
$gate2_switch waittill trigger
$gate2_switch nottriggerable
$gate_2 playsound elevator_start wait
wait .5
$gate_2 playsound elevator_run
$gate_2 moveto $gate_top2
$gate_2 waitmove
wait 6
thread gate2_down
end
gate2_down:
wait 30
$gate_2 playsound elevator_start wait
wait .5
$gate_2 playsound elevator_run
$gate_2 moveto $gate_bottom2
$gate_2 waitmove
thread switch_off
wait 6
$gate2_switch triggerable
$gate2_switch2 triggerable
end
/////////////gate 2 inside
gate2_move_inside2:
thread switch_on
$gate2_switch2 waittill trigger
$gate2_switch2 nottriggerable
$gate_2 playsound elevator_start wait
wait .5
$gate_2 playsound elevator_run
$gate_2 moveto $gate_top2
$gate_2 waitmove
wait 6
thread gate2_down
end
////////////////////////////////////////////////////////////end level triggers///////////////////////////////////////////
the_end_level1:
$end_level2 nottriggerable
$end_level1 nottriggerable
wait 2
waitthread global/objectives.scr::add_objectives 5 3 "Gain Access to the Warehouse's" $objective_finish.origin
wait 2
exec global/missioncomplete.scr mission2 1
end
the_end_level2:
$end_level1 nottriggerable
$end_level2 nottriggerable
wait 2
waitthread global/objectives.scr::add_objectives 5 3 "Gain Access to the Warehouse's" $objective_finish.origin
wait 2
exec global/missioncomplete.scr m1l3a 1
end
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// objectives /////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////
objectives: ///no1
waitthread global/objectives.scr::add_objectives 1 2 "Meet Up With Undercover Agent" $obj_undercover.origin
set_objective_pos $obj_undercover
//waitthread global/objectives.scr::add_objectives 2 2 "Destroy The Planes" $obj_planes.origin
player playsound objective_text
//waitthread global/objectives.scr::current_objectives 1
end
undercover_objective: //no2
waitthread global/objectives.scr::add_objectives 1 3 "Meet Up With Undercover Agent" $obj_undercover.origin
iprintln_noloc "The Agent Has Been Killed"
iprintln_noloc "Find The documents That He Had For You"
iprintln_noloc "Before The Enemy Has Time To Analyse Them."
wait 2
exec global/autosave.scr 1
set_objective_pos $objective_doc
waitthread global/objectives.scr::add_objectives 2 2 "Obtain The Documents" $objective_doc.origin
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes" $obj_planes.origin
$player playsound objective_text
thread door_remove
end
doc1_pickup: //no3
$doc1 remove
$doc_pickup nottriggerable
$player playsound pickup_papers1
wait .5
waitthread global/objectives.scr::add_objectives 2 3 "papers collected" $objective_doc.origin
//$player playsound objective_text
set_objective_pos $obj_planes
wait 2
exec global/autosave.scr 1
iprintln_noloc "The Agent Had Discovered That They Are"
iprintln_noloc "Trying To Stockpile A New Weapon"
iprintln_noloc "Try And Find More Information."
iprintlnbold_noloc "New Objective Added."
waitthread global/objectives.scr::add_objectives 4 2 "Steal The Secret Plans" $objective_doc2.origin
//waitthread global/objectives.scr::current_objectives 2
thread bomb_pickup_on
end
doc2_pickup: //no5
$doc2 remove
$doc2_pickup2 nottriggerable
$player playsound pickup_papers1
wait .5
waitthread global/objectives.scr::add_objectives 4 3 "papers collected" $objective_doc.origin
wait 1
exec global/autosave.scr 1
$end_level1 triggerable
$end_level2 triggerable
waitthread global/objectives.scr::add_objectives 5 2 "Gain Access to the Warehouse's" $objective_finish.origin
set_objective_pos $objective_finish
end
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////// Planes stuff///////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
plane_destroyed:
self waittill death //The one that called the thread will wait till it dies...
//iprintlnbold_noloc "Plane Destroyed"
level.planesleft-- //planes left -1
thread stuka_obj
end
stuka_obj: //no4
if (level.planesleft == 6)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [6 remaining]"
}
if (level.planesleft == 5)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [5 remaining]"
}
if (level.planesleft == 4)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [4 remaining]"
}
if (level.planesleft == 3)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [3 remaining]"
}
if (level.planesleft == 2)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [2 remaining]"
}
if (level.planesleft == 1)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [1 remaining]"
}
if (level.planesleft == 0)
{
waitthread global/objectives.scr::add_objectives 3 3 "Planes Destroyed."
$player playsound objective_text
set_objective_pos $objective_doc2
wait 3
exec global/autosave.scr 1
thread bombs_1
}
end
tidy up?
Moderator: Moderators
- williewisp
- First Lieutenant
- Posts: 208
- Joined: Fri May 16, 2003 1:10 pm
- Location: ireland
tidy up?
it's not a time for thinking its a time for drinking!
Well the script is a little too long to go through entirely
but I'll give some hints
exec global/loadout.scr maps/mission1.scr
This line really doesn't do anything...
exec global/ai.scr //i wonder!
This line should only be used if you're working with fancy things like $enemyspawners. Otherwise it's best to omit this line.
//$player item weapons/M2frag_grenade_sp.tik
I think this line needs to be 'uncommented-out' (:?), as I think it enables the player to throw grenades when he finds grenade ammo.
level.script = "maps/mission1.scr"
This line really is useless
player playsound objective_text
Not sure why you added this line
Anyway I think it should be
$player playsound objective_text
Otherwise the script won't even compile or you'll get a 'cannot cast const string to listener' error.
if (level.planesleft == 6)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [6 remaining]"
}
if (level.planesleft == 5)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [5 remaining]"
}
if (level.planesleft == 4)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [4 remaining]"
}
if (level.planesleft == 3)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [3 remaining]"
}
if (level.planesleft == 2)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [2 remaining]"
}
if (level.planesleft == 1)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [1 remaining]"
}
This can be tidied up quite nicely
:
if (level.planesleft > 0)
{
waitthread global/objectives.scr::add_objectives 3 2 ("Destroy The Planes. [" + level.planesleft + " remaining]")
}
Also this line
if (level.planesleft == 0)
is best changed to
if(level.planesleft <= 0)
I don't know if it's possible, but imagine level.planesleft decreasing to -1 or lower. The == 0 check would return false whereas the <= 0 still returns true. This helps making your code more bug proof.
Hopefully this helps you somehow
exec global/loadout.scr maps/mission1.scr
This line really doesn't do anything...
exec global/ai.scr //i wonder!
This line should only be used if you're working with fancy things like $enemyspawners. Otherwise it's best to omit this line.
//$player item weapons/M2frag_grenade_sp.tik
I think this line needs to be 'uncommented-out' (:?), as I think it enables the player to throw grenades when he finds grenade ammo.
level.script = "maps/mission1.scr"
This line really is useless
player playsound objective_text
Not sure why you added this line
$player playsound objective_text
Otherwise the script won't even compile or you'll get a 'cannot cast const string to listener' error.
if (level.planesleft == 6)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [6 remaining]"
}
if (level.planesleft == 5)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [5 remaining]"
}
if (level.planesleft == 4)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [4 remaining]"
}
if (level.planesleft == 3)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [3 remaining]"
}
if (level.planesleft == 2)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [2 remaining]"
}
if (level.planesleft == 1)
{
waitthread global/objectives.scr::add_objectives 3 2 "Destroy The Planes. [1 remaining]"
}
This can be tidied up quite nicely
if (level.planesleft > 0)
{
waitthread global/objectives.scr::add_objectives 3 2 ("Destroy The Planes. [" + level.planesleft + " remaining]")
}
Also this line
if (level.planesleft == 0)
is best changed to
if(level.planesleft <= 0)
I don't know if it's possible, but imagine level.planesleft decreasing to -1 or lower. The == 0 check would return false whereas the <= 0 still returns true. This helps making your code more bug proof.
Hopefully this helps you somehow
level.script = "maps/mission1.scr"
This line is needed for the global/bomber.scr if you have a $setthread value on the first node of the bomb's spline path for a thread in the level script to run when the bomb hits the ground such as the global/exploder.scr . The bomber script uses the parameter level.script .
This line is needed for the global/bomber.scr if you have a $setthread value on the first node of the bomb's spline path for a thread in the level script to run when the bomb hits the ground such as the global/exploder.scr . The bomber script uses the parameter level.script .
- williewisp
- First Lieutenant
- Posts: 208
- Joined: Fri May 16, 2003 1:10 pm
- Location: ireland
-
smartaiguy
- Brigadier General
- Posts: 512
- Joined: Tue Jul 08, 2003 2:52 pm
- williewisp
- First Lieutenant
- Posts: 208
- Joined: Fri May 16, 2003 1:10 pm
- Location: ireland
using this or the targetname
patrol1:
$patrol_guy_1 walkto $path11
wait 5
$patrol_guy_1 walkto $path12
wait 1
$patrol_guy_1 walkto $path13
wait 1
$patrol_guy_1 walkto $path14
wait 1
$patrol_guy_1 walkto $path15
wait 5
$patrol_guy_1 walkto $path13
wait 1
$patrol_guy_1 walkto $path12
wait 10
end
i tried to loop it by just callin the thread at the end of each one, thread patrol1
but when i killed the patrol guy an error came up in the console.
null listener, i know why it happened but what i want to know is
1. how to properly loop it
2. using theses if needed $patrol_guy_1 and $path12.
cheers for any help
patrol1:
$patrol_guy_1 walkto $path11
wait 5
$patrol_guy_1 walkto $path12
wait 1
$patrol_guy_1 walkto $path13
wait 1
$patrol_guy_1 walkto $path14
wait 1
$patrol_guy_1 walkto $path15
wait 5
$patrol_guy_1 walkto $path13
wait 1
$patrol_guy_1 walkto $path12
wait 10
end
i tried to loop it by just callin the thread at the end of each one, thread patrol1
but when i killed the patrol guy an error came up in the console.
null listener, i know why it happened but what i want to know is
1. how to properly loop it
2. using theses if needed $patrol_guy_1 and $path12.
cheers for any help
it's not a time for thinking its a time for drinking!
This way it should be error free:
I really do not understand your second question 
Code: Select all
patrol1:
local.guy = $patrol_guy_1 // stops typos ;)
while(isAlive local.guy)
{
local.guy walkto $path11
wait 5
for(local.i = 12; isAlive local.guy && local.i <= 15; local.i++)
{
local.guy walkto $("path" + local.i)
wait 1
}
wait 4
if !(isAlive local.guy)
break
local.guy walkto $path13
wait 1
if !(isAlive local.guy)
break
local.guy walkto $path12
wait 10
}
end
- williewisp
- First Lieutenant
- Posts: 208
- Joined: Fri May 16, 2003 1:10 pm
- Location: ireland

