TOW Script & Random Spawning OBJ >> H-E-L-P !!!??

Post your scripting questions / solutions here

Moderator: Moderators

Post Reply
Slyk
Lieutenant Colonel
Posts: 361
Joined: Sun Jul 14, 2002 12:42 am
Location: Elizabethtown, PA

TOW Script & Random Spawning OBJ >> H-E-L-P !!!??

Post by Slyk »

Ok, I'm at the END of my patience. This whole 'random spawn' BS is more than I can take. Two questions:

1. My 'opel truck' models...IF they are the entitiy to random spawn, should they be a SCRIPT_OBJECT or a SCRIPT_MODEL?????? And why won't EITHER of them show up in radiant??? just little blue or red boxes!?

2. Can anyone (expecting JV to say something)...look through this and tell me WHY the %#!* it won't work? Map loads up about 60% on the progress bar then dumps you into the game to select teams. I've tried placing the random spawn script in various prespawn, spawn, roundstart sections, all to utter failure. I am sure it is ONE minor thing, but I can't figure it out.

Freaking-ly Frustrated-ly yours, Slyk




//----------------------------------------------------------
// Main
//----------------------------------------------------------
main:
level.script="maps/obj/MP_TOWTutorial_TOW.scr"
//level.music="Amb_M5_TownExt_2"

setcvar "g_scoreboardpic" "none"

level.gametype = int( getcvar( g_gametype ) )

//Exec our helper scripts
exec global/tow_dm.scr
exec global/ambient.scr

//gametype 5 = Tug of War
if( level.gametype == 5 )
{
setcvar "g_obj_alliedtext1" "Defend Your Transport"
setcvar "g_obj_alliedtext2" "Keep Generators Running"
setcvar "g_obj_alliedtext3" "Close Assembly Hall Doors"
setcvar "g_obj_alliedtext4" "Capture & Hold Admin Bldg"
setcvar "g_obj_alliedtext5" "Detonate Axis Spawn"

setcvar "g_obj_axistext1" "Detonate Allies Spawn"
setcvar "g_obj_axistext2" "Clear & Control Admin Bldg"
setcvar "g_obj_axistext3" "Open Assembly Hall Doors"
setcvar "g_obj_axistext4" "Turn Off Genertors"
setcvar "g_obj_axistext5" "Defend Your Transports"
}
else
{
//This will remove the bombs so that we can play in other modes...
$alliedtruck_bomb remove
$axistruck_bomb remove

// set scoreboard messages
setcvar "g_obj_alliedtext1" "Slyks's Tractor Works TOW"
setcvar "g_obj_alliedtext2" "by: Mark 'Slyk' Dittman"
setcvar "g_obj_alliedtext3" "February, 2003"
setcvar "g_obj_axistext1" "Special thanks to:"
setcvar "g_obj_axistext2" "HkyStkr187 at 3dchad.com"
setcvar "g_obj_axistext3" "for scripting this TOW map"
}

//////////////////////////
level waittill prespawn
//////////////////////////

$world farplane_color "0.756863 0.796078 0.815686"
level.fogplane = 6656
$world farplane level.fogplane
$world farplane_cull 1


//////////////////////////
level waittill spawn
//////////////////////////


// set the parameters for this round based match
level.bRoundStarted = 0
level.dmrespawning = 1 // 1 or 0
level.clockside = allies // set to axis, allies, kills, or draw
level.dmroundlimit = 20 // round time limit in minutes
level.numObjectives = 5 // Number of objectives needed to win

level.assembly_switch_up = 1 //1=doors open, 2=doors closed
level.admin_switch_up = 1 //1=doors open, 2=doors closed
level.finhall_switch_up = 1 //1=doors open, 2=doors closed
level.GeneratorOn = 1 //1=running, 2=off


//Setup the team spawn locations
thread init_allied_spawns
thread init_axis_spawns
thread random_axis_spawn
thread random_allied_spawn

//////////////////////////
//level waittill roundstart
//////////////////////////

//TOW match init the TOW stuff
if( level.gametype == 5 )
{
$generator loopsound power_generator

//Init the spawner bombs
thread init_spawner_bombs

//Setup the starting team objectives
thread set_objectives

}

end

//-----------------------------------------------
// Set up Random AXIS Spawner Locations:
//-----------------------------------------------

random_axis_spawn:
//generate random number
local.location = ((randomint (2)) + 1)

//bind all surrounding objects to the truck
$obj_axis_spawner bind $axis_truck
$axistruck_bomb_trigger bind $axis_truck
$axistruck_bomb bind $axis_truck
$axis_spawn1 bind $axis_truck
$axis_spawn2 bind $axis_truck
$axis_spawn3 bind $axis_truck

//move the truck and bounded objects to the new random location
local.location = $("axis_spawn" + local.location)
$axis_truck.origin = local.location.origin
end

//-----------------------------------------------
// Set up Random ALLIED Spawner Locations:
//-----------------------------------------------

random_allied_spawn:
//generate random number
local.location = ((randomint (2)) + 1)

//bind all surrounding objects to the truck
$obj_allied_spawner bind $allied_truck
$alliedtruck_bomb_trigger bind $allied_truck
$alliedtruck_bomb bind $allied_truck
$allied_spawn1 bind $allied_truck
$allied_spawn2 bind $allied_truck
$allied_spawn3 bind $allied_truck

//move the truck and bounded objects to the new random location
local.location = $("allied_spawn" + local.location)
$allied_truck.origin = local.location.origin
end



//-----------------------------------------------
// Init the ALLIED Spawn Locations
//-----------------------------------------------
init_allied_spawns:
//Allied spawner locations
$allied_player1_spawn enablespawn
$allied_player2_spawn disablespawn
end

//-----------------------------------------------
// Init the AXIS Spawn Locations
//-----------------------------------------------
init_axis_spawns:
//Axis spawner locations
$axis_player1_spawn enablespawn
$axis_player2_spawn disablespawn
end


//-----------------------------------------------
// Init the spawner bombs
//-----------------------------------------------
init_spawner_bombs:
//Allied spawner bomb
$alliedtruck_bomb thread global/tow_dm.scr::bomb_thinker "axis" maps/obj/MP_TOWTutorial_TOW.scr::destroy_allied_spawner
//Axis spawner bomb
$axistruck_bomb thread global/tow_dm.scr::bomb_thinker "allies" maps/obj/MP_TOWTutorial_TOW.scr::destroy_axis_spawner
end

//----------------------------------------------------------
//Destroy the allied spawner here
//----------------------------------------------------------
destroy_allied_spawner:

iprintln "The Allied Transport has been destroyed!"

//Take over the objective
$obj_allied_spawner TakeOver 0

iprintln "The Allied Team can no longer respawn!"

//See if someone won
thread Check_End_Match
end

//----------------------------------------------------------
//Destroy the axis spawner here
//----------------------------------------------------------
destroy_axis_spawner:

iprintln "The Axis Transport has been destroyed!"

//Take over the objective
$obj_axis_spawner TakeOver 1

iprintln "The Axis Team can no longer respawn!"

//See if someone won
thread Check_End_Match

end

//----------------------------------------------------------
//Set the teams current objectives
//----------------------------------------------------------
set_objectives:

//First lets do the allies
if( $obj_generator.ControlledBy == 0 )
{
$obj_generator SetCurrent 1
}
else if( $obj_assembly.ControlledBy == 0 )
{
$obj_assembly SetCurrent 1
}
else if( $obj_admin.ControlledBy == 0 )
{
$obj_admin SetCurrent 1
}
else if( $obj_axis_spawner.ControlledBy == 0 )
{
$obj_axis_spawner SetCurrent 1
}

//Now the Axis
if( $obj_generator.ControlledBy == 1 )
{
$obj_generator SetCurrent 0
}
else if( $obj_assembly.ControlledBy == 1 )
{
$obj_assembly SetCurrent 0
}
else if( $obj_admin.ControlledBy == 1 )
{
$obj_admin SetCurrent 0
}
else if( $obj_allied_spawner.ControlledBy == 1 )
{
$obj_allied_spawner SetCurrent 0
}
end

//----------------------------------------------------------
//Turn on/off Generator
//----------------------------------------------------------
toggle_handle:
if( parm.other.dmteam == allies )
{
if( $obj_generator.ControlledBy != 1 )
{
//Flip the switch
thread movehandle

//Take the objective
$obj_generator TakeOver 1
iprintln "The Allies have started the generator!"

//Update team current objectives
thread set_objectives

waitthread Check_End_Match
}
}
else if( parm.other.dmteam == axis )
{
if( $obj_generator.ControlledBy != 0 )
{
//Flip the switch
thread movehandle

//Take the objective
$obj_generator TakeOver 0
iprintln "The Axis have turned off the generator!"

//Update team current objectives
thread set_objectives

waitthread Check_End_Match
}
}
end


//----------------------------------------------------------
//Open Assembly Hall Doors ***this one seems to work***
//----------------------------------------------------------
toggle_assembly:
if( parm.other.dmteam == allies )
{
if( $obj_assembly.ControlledBy != 1 )
{
//Flip the switch
thread moveassembly

//Take the objective
$obj_assembly TakeOver 1
iprintln "The Allies have closed the Assembly Hall Doors!"

//Update team current objectives
thread set_objectives

waitthread Check_End_Match
}
}
else if( parm.other.dmteam == axis )
{
if( $obj_assembly.ControlledBy != 0 )
{
//Flip the switch
thread moveassembly

//Take the objective
$obj_assembly TakeOver 0
iprintln "The Axis have opened the Assembly Hall Doors!"

//Update team current objectives
thread set_objectives

waitthread Check_End_Match
}
}
end


//----------------------------------------------------------
//Capture the Admin Building
//----------------------------------------------------------
toggle_admin:
if( parm.other.dmteam == axis )
{
if( $obj_admin.ControlledBy != 0 )
{
//Flip the switch
thread moveadmin

//Take the objective
$obj_admin TakeOver 0
iprintln "The Axis have captured the Admin Building"

//Update team current objectives
thread set_objectives
thread disable_allied_spawn1

waitthread Check_End_Match
}
}
else if( parm.other.dmteam == allies )
{
if( $obj_admin.ControlledBy != 1 )
{
//Flip the switch
thread moveadmin

//Take the objective
$obj_admin TakeOver 1
iprintln "The Allies have control of the Admin Building"

//Update team current objectives
thread set_objectives
thread disable_allied_spawn2

waitthread Check_End_Match
}
}
end

//--------------------------------------------------------------
//Move the switch handle - Generator ***this one works***
//--------------------------------------------------------------
movehandle:
$generator_switch_trigger nottriggerable
$generator_switch bind $generator_switch_origin
if( level.GeneratorOn == 1 )
{
$generator_switch_origin speed 1.0
$generator_switch_origin rotatezdownto 180
$generator_switch_origin waitmove
$generator_switch_origin playsound switchbox
$generator stoploopsound power_generator
level.GeneratorOn = 0
}
else
{
$generator_switch_origin speed 1.0
$generator_switch_origin rotatezupto 0
$generator_switch_origin waitmove
$generator_switch_origin playsound switchbox
$generator loopsound power_generator
level.GeneratorOn = 1
}
$generator_switch_trigger triggerable
end

//--------------------------------------------------------------
//Move the switch handle - Assembly Hall ***this one works***
//--------------------------------------------------------------
moveassembly:
$assembly_trigger nottriggerable
$assembly_switch bind $assembly_switch_origin
if( level.assembly_switch_up == 2 )
{
$assembly_switch_origin speed 1.0
$assembly_switch_origin rotatezupto 0
$assembly_switch_origin waitmove
$assembly_switch_origin playsound switchbox
level.assembly_switch_up = 1
}
else
{
$assembly_switch_origin speed 1.0
$assembly_switch_origin rotatezdownto 180
$assembly_switch_origin waitmove
$assembly_switch_origin playsound switchbox
level.assembly_switch_up = 2

}
$assembly_trigger triggerable
end

//--------------------------------------------------------------
//Move the switch handle - Admin Building ***this one works***
//--------------------------------------------------------------
moveadmin:
$admin_trigger nottriggerable
$admin_switch bind $admin_switch_origin
if( level.admin_switch_up == 2 )
{
$admin_switch_origin speed 1.0
$admin_switch_origin rotatezupto 0
$admin_switch_origin waitmove
$admin_switch_origin playsound switchbox
level.admin_switch_up = 2
}
else
{
$admin_switch_origin speed 1.0
$admin_switch_origin rotatezdownto 180
$admin_switch_origin waitmove
$admin_switch_origin playsound switchbox
level.admin_switch_up = 1

}
$admin_trigger triggerable
end

//-----------------------------------------------
// Open/Close Finishing Hall Door
//-----------------------------------------------
toggle_finhall_door:

$finhall_trigger nottriggerable
$finhall_switch bind $finhall_switch_origin
if( level.finhall_switch_up == 1 )
{
$finhall_switch_origin speed 1.0
$finhall_switch_origin rotatezdownto 180
$finhall_switch_origin waitmove
$finhall_switch_origin playsound switchbox
level.finhall_switch_up = 1

$finhall_door_speaker playsound HangerDoor_Open

}
else
{
$finhall_switch_origin speed 1.0
$finhall_switch_origin rotatezupto 0
$finhall_switch_origin waitmove
$finhall_switch_origin playsound switchbox
level.finhall_switch_up = 2

$finhall_door_speaker playsound HangerDoor_Open

}
$finhall_trigger triggerable
end

//-----------------------------------------------
// Turn OFF ALLIED Spawn1 - turn ON AXIS spawn2
//-----------------------------------------------
disable_allied_spawn1:

$allied_player1_spawn disablespawan
$allied_player2_spawn enablespawn
$axis_player1_spawn disablespawn
$axis_player2_spawn enablespawn
end

//-----------------------------------------------
// Turn OFF ALLIED Spawn2 - turn ON AXIS spawn1
//-----------------------------------------------
disable_allied_spawn2:

$allied_player2_spawn disablespawn
$allied_player1_spawn enablespawn
$axis_player2_spawn disablespawn
$axis_player1_spawn enablespawn
end

//-----------------------------------------------
// See if someone won
//-----------------------------------------------
Check_End_Match:

//Check to see if axis have won
//Axis win by controlling allies spawn, the generator, admin building, and assembly hall doors.
//-----------------------------
if( ( $obj_allied_spawner.ControlledBy == 0 ) && ( $obj_generator.ControlledBy == 0 ) && ( $obj_assembly.ControlledBy == 0 ) && ( $obj_admin.ControlledBy == 0 ) )
{
//if there is a bomb ticking stop it.
waitthread global/tow_dm.scr::StopBomb

teamwin axis
iprintln "The Germans continue their advance on Stalingrad!!"
}


//Check to see if allies have won
//Allies win by controlling axis spawn, the generator, admin building, and assembly hall doors.
//-----------------------------
if( ( $obj_axis_spawner.ControlledBy == 1 ) && ( $obj_generator.ControlledBy == 1 ) && ( $obj_assembly.ControlledBy == 1 ) && ( $obj_admin.ControlledBy == 1 ) )
{
//if there is a bomb ticking stop it.
waitthread global/tow_dm.scr::StopBomb

teamwin allies
iprintln "The Allies halted the German advance!!"
}
end
User avatar
mohaa_rox
Field Marshal
Posts: 2760
Joined: Mon Nov 11, 2002 7:05 am
Contact:

Post by mohaa_rox »

Whoah! I'm all dizzy.....

1) Your opel trucks are to random spawn? Maybe you have to set the stuff in radiant to I think was something like force block models or what. They will show up in the map.

2) Maybe study one of the official TOW maps.
Live to map, not map to live.
-mohaa_rox, .map
moderator
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Should be a script_model and should show up in Radiant. Just make sure you set a model key and enable the view of models in the view -> show menu.

For the second thing, just check your console output. The game will often tell you exactly why it ceased loading your map.
Image
Post Reply