Random Spots

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Random Spots

Post by HeavenBound »

So I'm making a mod, placing objects on a spot on a map....

Every round, I want them to rotate to different spots....

so here's an example:

Code: Select all

KAR98sniper:

local.trig = spawn trigger_multiple targetname triggerit
local.trig.origin = ( -1190.051 1418.174 44.075 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_KAR98sniper
local.trig wait 2

end

springfield:

local.trig = spawn trigger_multiple targetname triggerit
local.trig.origin = ( -1300.434 388.304 168.125 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_springfield
local.trig wait 2

If I wanted those 2 things to switch back and forth between the 2 spots, how would I script that?
HeavenBound

I'm new at this :)
SA007
Lance Corporal
Posts: 24
Joined: Thu Sep 03, 2009 10:17 pm

Post by SA007 »

Look at the script of obj_team1 (The hunt).

There is a random part to relocate the flak88.

Code: Select all

local.location = ((randomint (local.number_of_locations)) + 1)
Is the intreresting line.

So the code would be in your case something like this:

Code: Select all

  local.gun = randomint (2)
  if (local.gun = 0) {
    thread KAR98sniper
  } else {
    thread springfield
  }
HeavenBound
Colour Sergeant
Posts: 85
Joined: Thu Sep 11, 2008 12:55 am

Post by HeavenBound »

K, so I have 12 items spawned...

Each round I want them to mixed up randomly, (which I think you have right, but I'm not sure how to add it in..Haven't scripted in like 7 months...forgot everything lol.)


Here's an example. On algiers, I have a weapon in the hospital, one in the center path, and one on the mosque roof. Next round, I want the 3 to randomly be mixed up in the 3 spots. (Really, it's a total of 12 items.) Here's the full script for Algiers:

Code: Select all

//Scripting by HeavenBound


main:

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Ultimate Algiers"
setcvar "g_obj_alliedtext2" "Version 2.0"
setcvar "g_obj_alliedtext3" ""
setcvar "g_obj_axistext1" ""
setcvar "g_obj_axistext2" "By:"
setcvar "g_obj_axistext3" "HeavenBound"

setcvar "g_gametypestring" "Ultimate Algiers"


local.master = spawn ScriptMaster

local.master aliascache weapon sound/items/Item_BangaloreAssemble_01.wav soundparms 3.0 0.0 1.0 0.0 100 10000 item loaded maps "m dm obj"


	level waittill prespawn

	exec survivor/main.scr
	
	level waittill spawn

	thread start

end




//--------Start-----------

start:

	thread KAR98sniper
	thread springfield
	thread kar98
	thread m1_garand
	thread mp40
	thread thompsonsmg
	thread axismg
	thread alliesmg
	thread shotgun
	thread nade
	thread bazooka
	thread full_heal
	
end


//-----------Spawn Weapons------------
KAR98sniper:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -2170 928 342 ) //roof
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_KAR98sniper
local.trig wait 2

local.karsniper = spawn script_model targetname karsniper 
local.karsniper = spawn script_model model models/weapons/KAR98sniper.tik origin ( -2193.915 915.958 295.125 )
local.karsniper.angles = ( 0 0 -183 )
local.karsniper rotateY ( 360.0 )
local.karsniper.scale = 1.0
local.karsniper notsolid
local.karsniper light 0 0 1 50 

local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -2193.915 915.958 350.125 )
local.light notsolid
local.light.scale = 1.0

end


//-------Allied Sniper----------
springfield:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -3505.510 1202.006 -27.875 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_springfield
local.trig wait 2

local.springfield = spawn script_model targetname springfield 
local.springfield = spawn script_model model models/weapons/springfield.tik origin ( -3505.510 1202.006 -15.875 )
local.springfield.angles = ( 0 0 -183 )
local.springfield rotateY ( 360.0 )
local.springfield notsolid
local.springfield.scale = 1.0
local.springfield light 1 1 0 50


local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -3505.510 1202.006 35.875 )
local.light notsolid
local.light.scale = 1.0

end

//---------------------Axis Rifle------------

kar98:


local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -1951.021 -632.668 -155.875 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_kar98
local.trig wait 2

local.kar98 = spawn script_model targetname kar98 
local.kar98 = spawn script_model model models/weapons/kar98.tik origin ( -1951.021 -632.668 -140.875 )
local.kar98.angles = ( 0 0 -183 )
local.kar98 rotateY ( 360.0 )
local.kar98 notsolid
local.kar98.scale = 1.0
local.kar98 light 0 1 0 50

local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -1951.021 -632.668 -120.875 )
local.light notsolid
local.light.scale = 1.0


end

//-------------------Allies Rifle------------

m1_garand:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( 142.214 -165.192 -250.513 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_m1_garand
local.trig wait 2

local.m1_garand = spawn script_model targetname m1_garand 
local.m1_garand = spawn script_model model models/weapons/m1_garand.tik origin ( 142.214 -165.192 -235.513 )
local.m1_garand.angles = ( 0 0 -183 )
local.m1_garand rotateY ( 360.0)
local.m1_garand notsolid
local.m1_garand.scale = 1.0
local.m1_garand light 1 1 0 50


local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( 142.214 -165.192 -200.513 )
local.light notsolid
local.light.scale = 1.0


end

//--------------Axis SMG-----------

mp40:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -386.216 -1145.333 -287.725 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_mp40
local.trig wait 2

local.mp40 = spawn script_model targetname mp40 
local.mp40 = spawn script_model model models/weapons/mp40.tik origin ( -386.216 -1145.333 -272.725 )
local.mp40.angles = ( 0 0 -183 )
local.mp40 rotateY ( 360.0 )
local.mp40 notsolid
local.mp40.scale = 1.0
local.mp40 light 0 1 1 50


local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -386.216 -1145.333 -232.725 )
local.light notsolid
local.light.scale = 1.0

end

//--------------Allies SMG-----------


thompsonsmg:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -2983.093 -127.178 -115.875 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_thompsonsmg
local.trig wait 2

local.thompsonsmg = spawn script_model targetname thompsonsmg 
local.thompsonsmg = spawn script_model model models/weapons/thompsonsmg.tik origin ( -2983.093 -127.178 -95.875 )
local.thompsonsmg.angles = ( 0 0 -183 )
local.thompsonsmg rotateY ( 360.0 )
local.thompsonsmg notsolid
local.thompsonsmg.scale = 1.0
local.thompsonsmg light 1 0 0 50

local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -2983.093 -127.178 -55.875 )
local.light notsolid
local.light.scale = 1.0


end

//-------------------Axis MG--------------


axismg:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -1480.233 1719.563 -107.875 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_axismg
local.trig wait 2

local.axismg = spawn script_model targetname axismg 
local.axismg = spawn script_model model models/weapons/mp44.tik origin ( -1480.233 1719.563 -85.875 )
local.axismg.angles = ( 0 0 -183 )
local.axismg rotateY ( 360.0 )
local.axismg notsolid
local.axismg.scale = 1.0
local.axismg light .5 1 0 50

local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -1480.233 1719.563 -45.875 )
local.light notsolid
local.light.scale = 1.0


end

//-----------------Allies MG------------


alliesmg:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -1430.973 295.015 -127.875 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_alliesmg
local.trig wait 2

local.alliesmg = spawn script_model targetname alliesmg 
local.alliesmg = spawn script_model model models/weapons/bar.tik origin ( -1430.973 295.015 -115.875 )
local.alliesmg.angles = ( 0 0 -183 )
local.alliesmg rotateY ( 360.0 )
local.alliesmg notsolid
local.alliesmg.scale = 1.0
local.alliesmg light 0.5 0.5 0 50

local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -1430.973 295.015 -95.875 )
local.light notsolid
local.light.scale = 1.0


end

//---------Shotgun----------

shotgun:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -1566.744 -1126.184 -283.875 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_shotgun
local.trig wait 2

local.shotgun = spawn script_model targetname shotgun 
local.shotgun = spawn script_model model models/weapons/shotgun.tik origin ( -1566.744 -1126.184 -253.875 )
local.shotgun.angles = ( 0 0 -183 )
local.shotgun rotateY ( 360.0 )
local.shotgun notsolid
local.shotgun.scale = 1.0
local.shotgun light 1 0 0 50


local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -1566.744 -1126.184 -223.875 )
local.light notsolid
local.light.scale = 1.0

end

//-------Nade--------

nade:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( 1355.273 -103.644 24.125 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_nade
local.trig wait 2

local.nade = spawn script_model targetname nade 
local.nade = spawn script_model model models/weapons/m2frag_grenade.tik origin ( 1355.273 -103.644 44.125 )
local.nade.angles = ( 0 0 -183 )
local.nade rotateY ( 360.0 )
local.nade notsolid
local.nade.scale = 1.5
local.nade light 0 1 0 50

local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( 1355.273 -103.644 64.125 )
local.light notsolid
local.light.scale = 1.0

end

//-----Bazooka--------

bazooka:

local.trig = spawn trigger_multiple targetname triggerit 
local.trig.origin = ( -270.463 1125.284 -135.875 ) 
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread got_bazooka
local.trig wait 2

local.bazooka = spawn script_model targetname bazooka 
local.bazooka = spawn script_model model models/weapons/bazooka.tik origin ( -270.463 1125.284 -115.875 )
local.bazooka.angles = ( 0 0 -183 )
local.bazooka rotateY ( 360.0 )
local.bazooka notsolid
local.bazooka.scale = 1.0
local.bazooka light 1 0 1 50

local.light = spawn script_model targetname light
local.light = spawn script_model model models/fx/corona_red.tik origin ( -270.463 1125.284 -95.875 )
local.light notsolid
local.light.scale = 1.0


end


//----------Got a Weapon----------

got_KAR98sniper:

local.player = parm.other


local.player give models/weapons/KAR98sniper.tik

local.player use models/weapons/KAR98sniper.tik

local.player iprint "You Picked up an Axis Sniper!"

wait .5

local.player playsound weapon


end

//----------------

got_springfield:

local.player = parm.other

local.player give models/weapons/springfield.tik

local.player use models/weapons/springfield.tik

local.player iprint "You Picked up an Allies Sniper!"


wait .5

local.player playsound weapon


end

//--------------------

got_kar98:

local.player = parm.other

local.player give models/weapons/kar98.tik

local.player use models/weapons/kar98.tik

local.player iprint "You Picked up an Axis Rifle!"

wait .5

local.player playsound weapon


end
//-----------------------

got_m1_garand:

local.player = parm.other

local.player give models/weapons/m1_garand.tik

local.player use models/weapons/m1_garand.tik

local.player iprint "You Picked up an Allied Rifle!"

wait .5

local.player playsound weapon


end

//----------------------

got_mp40:

local.player = parm.other

local.player give models/weapons/mp40.tik

local.player use models/weapons/mp40.tik

local.player iprint "You Picked up an Axis SMG!"

wait .5

local.player playsound weapon

end

//----------------------

got_thompsonsmg:

local.player = parm.other

local.player give models/weapons/thompsonsmg.tik

local.player use models/weapons/thompsonsmg.tik

local.player iprint "You Picked up an Allies SMG!"

wait .5

local.player playsound weapon

end


//------------------

got_axismg:

local.player = parm.other

local.player give models/weapons/mp44.tik

local.player use models/weapons/mp44.tik

local.player iprint "You Picked up an Axis MG!"

wait .5

local.player playsound weapon

end

//------------------

got_alliesmg:

local.player = parm.other

local.player give models/weapons/bar.tik

local.player use models/weapons/bar.tik

local.player iprint "You Picked up an Allies MG!"

wait .5

local.player playsound weapon

end


//---------------------


got_shotgun:

local.player = parm.other

local.player give models/weapons/shotgun.tik

local.player use models/weapons/shotgun.tik

local.player iprint "You Picked up a Shotgun!!"

wait .5

local.player playsound weapon

end

//----------------

got_nade:

local.player = parm.other

local.player give models/weapons/m2frag_grenade.tik

local.player use models/weapons/m2frag_grenade.tik

local.player iprint "You got a Grenade!!"

wait .5

local.player playsound weapon

end


//--------------

got_bazooka:

local.player = parm.other

local.player give models/weapons/bazooka.tik

local.player use models/weapons/bazooka.tik

local.player iprint "You got a Bazooka!!"

wait .5

local.player playsound weapon

end


//-----------------Full Heal-----------

full_heal:

local.trig = spawn trigger_multiple
local.trig.origin = ( -2948.222 2755.797 88.125 )
local.trig setsize ( -10 -10 -10 ) ( 10 10 10 )
local.trig setthread heal 
local.trig wait 2


local.health = spawn script_model targetname health
local.health = spawn script_model model items/dm_50_healthbox.tik origin ( -2948.222 2755.797 108.125 )
local.health.scale = 1.5
local.health ghost
local.health light 0 1 .5 50
local.health rotateX 100
local.health rotateY 100
local.health rotateZ 100 

end

//-----Healing----------

heal: 

self waittill trigger

local.player=parm.other

if (local.player.heal==1) 

end

local.player.heal=1 

//local.player heal .5

local.player.health += 5

local.player iprint "You got Full Health!!"

wait .1

local.player.heal=0

end



//-----------------------------------------------------------------------------

roundbasedthread:

	// Can specify different scoreboard messages for round based games here.

	level waitTill prespawn

	level waittill spawn

		// set the parameters for this round based match
		level.dmrespawning = 0 // 1 or 0
		level.dmroundlimit = 5 // round time limit in minutes
		level.clockside = kills // set to axis, allies, kills, or draw

	level waittill roundstart

end

Any help is appreciated. :)
HeavenBound

I'm new at this :)
Post Reply