Script not working

Post your scripting questions / solutions here

Moderator: Moderators

User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Script not working

Post by Alcoholic »

since i lost my map and script, im making a test one before i start a real map. this is just to make sure i can get driving to work right. heres my script but it doesnt work...

Code: Select all

main:

level waittill prespawn

exec global/ai.scr
exec global/alarmer.scr
exec global/friendly.scr


//Variables
level.captain = level.friendly1
level.private1 = level.friendly2
level.private2 = level.friendly3
level.engineer = level.friendly4
level.medic = level.friendly5

level.script = maps/test_introtruck.scr

level waittill spawn

//fadein 2 0 0 0 1

//Stick people to truck
$player notsolid
level.captain notsolid
level.private1 notsolid
level.private2 notsolid
level.engineer notsolid
level.medic notsolid

$player physics_off
level.captain physics_off
level.private1 physics_off
level.private2 physics_off
level.engineer physics_off
level.medic physics_off

$player glue $origin_player
level.captain glue $origin_captain
level.private1 glue $origin_private1
level.private2 glue $origin_private2
level.engineer glue $origin_engineer
level.medic glue $origin_medic

$origin_player bind $introtruck1
$origin_captain bind $introtruck1
$origin_private1 bind $introtruck1
$origin_private2 bind $introtruck1
$origin_engineer bind $introtruck1
$origin_medic bind $introtruck1

$introtruck1_clip bind $introtruck1
$introtruck1_clip hide

//Initial threads
thread initial_drive
thread initial_dialogue
end

$player item weapons/bar.tik

initial_drive:

//$introtruck1 followpath $introtruck1_path
$introtruck1 drive $introtruck1_path 260 50 200 256 //<vehicle> drive <target> <speed> <acceleration> <reach distance> <lookahead>
$introtruck1 waittill drive
thread disembark
end

initial_dialogue:

level.captain say dfr_m1l1_101j8 //Squad listen up, rescue mission, blah blah.
level.captain waittill saydone
wait 2
level.private2 say dfr_m1l1_104k_1 //cmon, CMON!
level.private2 waittill saydone
end

disembark:

level.captain say dfr_m1l1_add03j7
level.captain waittill saydone

level.captain runto destination_captain
level.private1 runto destination_private1
level.private2 runto destination_private2
level.engineer runto destination_engineer
level.medic runto destination_medic

level.captain waittill movedone

thread ai_setup
end

all the names are right but it dont work... :cry:
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

Ok i made a little debug...

heres my new script...

Code: Select all

main:

level waittill prespawn

	exec global/ai.scr
	exec global/alarmer.scr
	exec global/friendly.scr


	//Variables
	level.captain = level.friendly1
	level.private1 = level.friendly2
	level.private2 = level.friendly3
	level.engineer = level.friendly4
	level.medic = level.friendly5

	level.script = maps/test_introtruck.scr

	level waittill spawn
	iprintlnbold_noloc "Part1"
	//fadein 2 0 0 0 1

	//Setup people on truck
	/*$player forcelegsstate CROUCH_IDLE

	level.captain exec global/crouch.scr
	level.private1 exec global/crouch.scr
	level.private2 exec global/crouch.scr
	level.engineer exec global/crouch.scr
	level.medic exec global/crouch.scr*/
	$player notsolid
	level.captain notsolid
	level.private1 notsolid
	level.private2 notsolid
	level.engineer notsolid
	level.medic notsolid

	$player physics_off
	level.captain physics_off
	level.private1 physics_off
	level.private2 physics_off
	level.engineer physics_off
	level.medic physics_off
	
	$player glue $origin_player
	level.captain glue $origin_captain
	level.private1 glue $origin_private1
	level.private2 glue $origin_private2
	level.engineer glue $origin_engineer
	level.medic glue $origin_medic
	
	$origin_player bind $introtruck1
	$origin_captain bind $introtruck1
	$origin_private1 bind $introtruck1
	$origin_private2 bind $introtruck1
	$origin_engineer bind $introtruck1
	$origin_medic bind $introtruck1
	
	$introtruck1_clip bind $introtruck1
	$introtruck1_clip hide
	iprintlnbold_noloc "Part2"
	//Initial threads
	thread initial_drive
	thread initial_dialogue
	iprintlnbold_noloc "3"
	end

initial_drive:

	//$introtruck1 followpath $introtruck1_path
	$introtruck1 drive $introtruck1_path 260 50 200 256 //<vehicle> drive <target> <speed> <acceleration> <reach distance> <lookahead>
	$introtruck1 waittill drive
	thread disembark
	end
	iprintlnbold_noloc "4"
initial_dialogue:
	
	level.captain say dfr_m1l1_101j8 //Squad listen up, rescue mission, blah blah.
	level.captain waittill saydone
	wait 2
	level.private2 say dfr_m1l1_104k_1 //cmon, CMON!
	level.private2 waittill saydone
	iprintlnbold_noloc "5"
	end
	
disembark:

	level.captain say dfr_m1l1_add03j7
	level.captain waittill saydone
	
	level.captain runto destination_captain
	level.private1 runto destination_private1
	level.private2 runto destination_private2
	level.engineer runto destination_engineer
	level.medic runto destination_medic
	
	level.captain waittill movedone
	iprintlnbold_noloc "6"
	thread ai_setup
	iprintlnbold_noloc "7"
	end
if you didnt notice, i made it print messages at various points of the script. the messages printed, but they stopped at 3. i ddint get anything after 3. my truck still just sits there, not following paths. i can hear the truck moving sound, but it does nothing plz help.
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

You typed the '4' line below the end of the thread, so you can't reasonably expect it to show up :?
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

path

Post by tltrude »

You must have an info_spline path with the first node named "introtruck1_path" in your map for it to work. And, the truck should have the name "introtruck1".
Tom Trude,

Image
jv_map
Site Admin
Posts: 6521
Joined: Tue Sep 03, 2002 2:53 pm
Location: The Netherlands
Contact:

Post by jv_map »

Or even better an info_vehiclepoint.
Image
User avatar
tltrude
Chuck Norris
Posts: 4774
Joined: Sun Jul 07, 2002 4:03 am
Location: Oklahoma, USA
Contact:

waypoint

Post by tltrude »

Far as I know, an info_vehiclepoint is just a waypoint that sits on the ground. His script calls for a path.

$introtruck1 drive $introtruck1_path
Tom Trude,

Image
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

yeah but my targetname has a $ in frnot of it ( so its $thisisthename ). i looked in the single player maps and they put the $ in front of theirs too.
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

ok by making the truck notsolid, it follows the path.

now the next problem...

the script_origins and the truck clip dont move with teh truck. i binded the script origins and truck clip to the truck, but didnt work. i was stuck to the script origin, and i was released when the truck got to teh end, so that worked. so... why doesnt the truck clip//script_origins move with the script_model?

heres the new script...

Code: Select all

main:

level waittill prespawn

	exec global/ai.scr
	exec global/alarmer.scr
	exec global/friendly.scr


	//Variables
	level.captain = level.friendly1
	level.private1 = level.friendly2
	level.private2 = level.friendly3
	level.engineer = level.friendly4
	level.medic = level.friendly5

	level.script = maps/test_introtruck.scr

	level waittill spawn
	iprintlnbold_noloc "Part1"
	//fadein 2 0 0 0 1

	//Setup people on truck
	$player forcelegsstate CROUCH_IDLE

	/*level.captain exec global/crouch.scr
	level.private1 exec global/crouch.scr
	level.private2 exec global/crouch.scr
	level.engineer exec global/crouch.scr
	level.medic exec global/crouch.scr */
	$player notsolid
	level.captain notsolid
	level.private1 notsolid
	level.private2 notsolid
	level.engineer notsolid
	level.medic notsolid
	
	$introtruck1 notsolid
	$introtruck1_clip notsolid

	$player physics_off
	level.captain physics_off
	level.private1 physics_off
	level.private2 physics_off
	level.engineer physics_off
	level.medic physics_off
	
	$player glue $origin_player
	level.captain glue $origin_captain
	level.private1 glue $origin_private1
	level.private2 glue $origin_private2
	level.engineer glue $origin_engineer
	level.medic glue $origin_medic
	
	$origin_player bind $introtruck1
	$origin_captain bind $introtruck1
	$origin_private1 bind $introtruck1
	$origin_private2 bind $introtruck1
	$origin_engineer bind $introtruck1
	$origin_medic bind $introtruck1
	
	$introtruck1_clip bind $introtruck1
	//$introtruck1_clip hide
	iprintlnbold_noloc "Part2"
	//Initial threads
	thread initial_drive
	thread initial_dialogue
	iprintlnbold_noloc "3"
	end

initial_drive:

	//$introtruck1 followpath $introtruck1_path
	$introtruck1 drive $introtruck1_path 260 50 200 256 /*<vehicle> drive <target> <speed> <acceleration> <reach distance> <lookahead>*/
	$introtruck1 waittill drive
	thread disembark
	iprintlnbold_noloc "4"
	end
	
//initial_dialogue:
	
	/*level.captain say dfr_m1l1_101j8 //Squad listen up, rescue mission, blah blah.
	level.captain waittill saydone
	wait 2
	level.private2 say dfr_m1l1_104k_1 //cmon, CMON!
	level.private2 waittill saydone
	iprintlnbold_noloc "5"
	end*/
	
disembark:

	//level.captain say dfr_m1l1_add03j7
	//level.captain waittill saydone
	
	level.captain unglue
	level.private1 unglue
	level.private2 unglue
	level.engineer unglue
	level.medic unglue
	
	level.captain solid
	level.private1 solid
	level.private2 solid
	level.engineer solid
	level.medic solid
	
	level.captain physics_on
	level.private1 physics_on
	level.private2 physics_on
	level.engineer physics_on
	level.medic physics_on
	
	$player unglue
	$player solid
	$player physics_on
	
	level.captain runto destination_captain
	level.private1 runto destination_private1
	level.private2 runto destination_private2
	level.engineer runto destination_engineer
	level.medic runto destination_medic
	
	level.captain waittill movedone
	level.private1 waittill movedone
	level.private2 waittill movedone
	level.engineer waittill movedone
	level.medic waittill movedone
	iprintlnbold_noloc "6"
	thread ai_setup
	iprintlnbold_noloc "7"
	end
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

by the way, i tried gluing the script origins, and it worked, except they were glued to teh center of the script_model bounding box. :cry:
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

ok this time i tried binding the everything to a universal script origin, then binding the script origin to the vehicle, but still no luck. :cry: :cry:

(the players are still glued to the origins.)

i unhid the clip to see if it was moving, but it wasnt. for some reason, the clip seems to halt the truck. by making it notsolid, the truck drove without a problem, but then whats the point of having a clip?

when i start the map, everyone is stuck to their origins, and their on the truck, but the truck drives off without us, and were still floating in the air, until the truck reaches the end, then we plop to the ground...

heres the new script... (sorry that it makes the scroll bar really small)

Code: Select all

main:

level waittill prespawn

	exec global/ai.scr
	exec global/alarmer.scr
	exec global/friendly.scr


	//Variables
	level.captain = level.friendly1
	level.private1 = level.friendly2
	level.private2 = level.friendly3
	level.engineer = level.friendly4
	level.medic = level.friendly5

	level.script = maps/test_introtruck.scr

	level waittill spawn
	iprintlnbold_noloc "Part1"
	//fadein 2 0 0 0 1

	//Setup people on truck
	$player forcelegsstate CROUCH_IDLE

	/*level.captain exec global/crouch.scr
	level.private1 exec global/crouch.scr
	level.private2 exec global/crouch.scr
	level.engineer exec global/crouch.scr
	level.medic exec global/crouch.scr */
	$player notsolid
	level.captain notsolid
	level.private1 notsolid
	level.private2 notsolid
	level.engineer notsolid
	level.medic notsolid
	
	$introtruck1 notsolid
	$introtruck1_clip notsolid

	$player physics_off
	level.captain physics_off
	level.private1 physics_off
	level.private2 physics_off
	level.engineer physics_off
	level.medic physics_off
	
	$player glue $origin_player
	level.captain glue $origin_captain
	level.private1 glue $origin_private1
	level.private2 glue $origin_private2
	level.engineer glue $origin_engineer
	level.medic glue $origin_medic
	
	$origin_player bind $introtruck1_origin
	$origin_captain bind $introtruck1_origin
	$origin_private1 bind $introtruck1_origin
	$origin_private2 bind $introtruck1_origin
	$origin_engineer bind $introtruck1_origin
	$origin_medic bind $introtruck1_origin
	
	$introtruck1_clip bind $introtruck1_origin
	
	$introtruck1_origin bind $introtruck1
	//$introtruck1_clip hide
	iprintlnbold_noloc "Part2"
	//Initial threads
	thread initial_drive
	thread initial_dialogue
	iprintlnbold_noloc "3"
	end

initial_drive:

	//$introtruck1 followpath $introtruck1_path
	$introtruck1 drive $introtruck1_path 260 50 200 256 /*<vehicle> drive <target> <speed> <acceleration> <reach distance> <lookahead>*/
	$introtruck1 waittill drive
	thread disembark
	iprintlnbold_noloc "4"
	end
	
//initial_dialogue:
	
	/*level.captain say dfr_m1l1_101j8 //Squad listen up, rescue mission, blah blah.
	level.captain waittill saydone
	wait 2
	level.private2 say dfr_m1l1_104k_1 //cmon, CMON!
	level.private2 waittill saydone
	iprintlnbold_noloc "5"
	end*/
	
disembark:

	//level.captain say dfr_m1l1_add03j7
	//level.captain waittill saydone
	
	level.captain unglue
	level.private1 unglue
	level.private2 unglue
	level.engineer unglue
	level.medic unglue
	
	level.captain solid
	level.private1 solid
	level.private2 solid
	level.engineer solid
	level.medic solid
	
	level.captain physics_on
	level.private1 physics_on
	level.private2 physics_on
	level.engineer physics_on
	level.medic physics_on
	
	$player unglue
	$player solid
	$player physics_on
	
	wait 1
	
	level.captain runto destination_captain
	level.private1 runto destination_private1
	level.private2 runto destination_private2
	level.engineer runto destination_engineer
	level.medic runto destination_medic
	
	level.captain waittill movedone
	level.private1 waittill movedone
	level.private2 waittill movedone
	level.engineer waittill movedone
	level.medic waittill movedone
	iprintlnbold_noloc "6"
	thread ai_setup
	iprintlnbold_noloc "7"
	end
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

oh yeah and please dont try to tell me, "just look in the singleplayer scripts and compare your with theirs" because thats what ive been doing all this time, and im getting no luck.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

Make the clip brushes a script object and have the truck target it by selecting the truck first then the script object and press the control key and K . You should see a line from the truck to clips you can hide the clips under the terain or up in the sky if you want , I did this for a spearhead map but I think it is the same for mohaa maps . I know you can bind things to script objects and script models but don't know about normal models .
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

yeah but the clip has to be in the same plane of the vehicle. the player starts off riding in the vehicle, like in m1l1, m4l2, and m4l3.
User avatar
bdbodger
Moderator
Posts: 2596
Joined: Tue Feb 25, 2003 7:34 am
Location: canada
Contact:

Post by bdbodger »

I had a look at the m1l1.scr to see if I could see how they did it and here is what I found .
first they turn the physics of the player and friendlys off


level.actor1 = level.friendly1
level.actor2 = level.friendly2
level.actor3 = level.friendly3
level.actor4 = level.friendly4

if (level.intro == 1)
{

/*
level.friendly1 physics_off
level.friendly2 physics_off
level.friendly3 physics_off
level.friendly4 physics_off
*/

level.friendly1 notsolid
level.friendly2 notsolid
level.friendly3 notsolid
level.friendly4 notsolid

level.friendly1 exec global/disable_ai.scr
level.friendly2 exec global/disable_ai.scr
level.friendly3 exec global/disable_ai.scr
level.friendly4 exec global/disable_ai.scr

then they spawn a fake interior model for the player to be glued to I don't think this model draws

level.intropath = spawn script_model
level.intropath model "vehicles/gmctruckpath_opening.tik"
level.intropath.origin = (0 0 1)
level.intropath.angles = (0 270 0)

I think these are for animations

spawn script_model "targetname" "intropath3"
$intropath3 model "vehicles/gmctruckpath_opening.tik"
$intropath3.origin = (0 0 1)
$intropath3.angles = (0 270 0)
$intropath3.no_idle = 1

spawn script_model "targetname" "intropath2"
$intropath2 model "vehicles/truck2path_opening.tik"
$intropath2.origin = (0 0 1)
$intropath2.angles = (0 270 0)

level.intropath notsolid
$intropath2 notsolid
$intropath3 notsolid


this is the real truck

spawn script_model "targetname" "introtruck2" "spawnflags" "2"
$introtruck2 model "vehicles/opeltruck.tik"

$introtruck2 solid

$2ndtruckclip delete

spawn script_model "targetname" "introtruck" "spawnflags" "2"
$introtruck model "vehicles/gmctruck_opening.tik"
$introtruck anim idlenolights

$introtruck playsound truck1_run
$introtruck2 loopsound truck2_run
$introtruck2 anim start_wheels

exec global/entsound.scr $introtruck "driver" "dfr_m1l1_add01" 2 // Two hundred yards


level.actor1.angles = (0 270 0)
level.actor2.angles = (0 270 0)
level.actor3.angles = (0 270 0)
level.actor4.angles = (0 270 0)


spawn script_origin "targetname" "org_1"
spawn script_origin "targetname" "org_2"
spawn script_origin "targetname" "org_3"
spawn script_origin "targetname" "org_4"

level.actororg1 = $org_1
level.actororg2 = $org_2
level.actororg3 = $org_3
level.actororg4 = $org_4

}

level.flags[door] = 0 //
level.flags[bazooka] = 0 //
level.flags1 = 0

thread fader

if (level.intro == 0)
goto temp
else

level.intropath notsolid
spawn script_origin "targetname" "truckorg"

here they seem to spawn a non drawing turret to glue player to and puts the ai's in there position in the fake truck

local.turret = spawn models/statweapons/m1l1truckride.tik

if (level.glueplayer == 1)
{
local.o = level.intropath gettagposition "tag_camera" //gmctruck
local.o = local.o + (0 0 0)
$truckorg.origin = local.o
local.a = level.intropath gettagangles "tag_camera"
local.a[1] = local.a[1] + 210

$truckorg.angles = local.a

local.turret.viewangles = local.turret.viewangles - (local.oldangles - local.a)
local.oldangles = local.a
local.turret.angles = ( 0 0 0 )
}

if (level.exiting[1] == 0)
{
local.a = level.intropath gettagangles "Captain01 origin"
level.actor1.angles = local.a
local.o = level.intropath gettagposition "Captain01 origin" //gmctruck
level.actor1.origin = local.o
}



if (level.glueplayer == 1)
{
setcvar sv_fps "10"
local.turret setPlayerUsable 1
local.turret doUse $player
local.turret setPlayerUsable 0
$player glue $truckorg 0

$player physics_off
$player.turretride = local.turret
local.turret.viewangles = (0 180 0)
}
if (level.exiting[2] == 0)
{
local.a = level.intropath gettagangles "guy01 origin"
level.actor2.angles = local.a
local.o = level.intropath gettagposition "guy01 origin" //gmctruck
level.actor2.origin = local.o
}

if (level.exiting[3] == 0)
{
local.a = level.intropath gettagangles "guy2 origin"
level.actor3.angles = local.a
local.o = level.intropath gettagposition "guy2 origin" //gmctruck
level.actor3.origin = local.o
}

if (level.exiting[4] == 0)
{
local.a = level.intropath gettagangles "guy3 origin"
level.actor4.angles = local.a
local.o = level.intropath gettagposition "guy3 origin" //gmctruck
level.actor4.origin = local.o
}

local.turret glue $truckorg

After the truck ride

$player physics_on
println "should be able to shoot now"
$player item weapons/colt45.tik
$player item weapons/m1_garand.tik
$player ammo rifle 1000
$player ammo pistol 1000
$player useweaponclass rifle
$player ammo agrenade 5

/*
$player.turretride setPlayerUsable 1
$player.turretride doUse $player
$player.turretride setPlayerUsable 0
// $player show
$player forcelegsstate CROUCH_IDLE
$player.origin = $player.origin + (0 0 -35)
*/

$player.turretride setPlayerUsable 1
$player.turretride doUse $player
$player.turretride setPlayerUsable 0

$player.turretride notsolid //### this will ensure the turret doesn't block the player,
// regardless of any weird stuff having been done to it

$player show
$player unglue $truckorg
$player forcelegsstate CROUCH_IDLE
$player.origin = $player.origin + (0 0 -35)

these lines seem to keep the fake truck and the real truck in sync

while (level.flags[ridecomplete] == 0)
{

// println ("1 " + level.actor1.origin + " 4 " + level.actor4.origin)

local.a = level.intropath gettagangles "truck dummy"
$introtruck.angles = local.a
local.o = level.intropath gettagposition "truck dummy"
local.v = local.o - $introtruck.origin
$introtruck.origin = local.o
$introtruck.velocity = local.v

if (level.flags[introbazooka] == 0)
{
local.a = $intropath2 gettagangles "truck2 dummy"
// Rotate the angles by 90 degrees
local.a_pitch = local.a[2]
local.a_roll = -local.a[0]
local.a_yaw = local.a[1] + 270
local.a = ( local.a_pitch local.a_yaw local.a_roll )
// Now assign it to the truck
$introtruck2.angles = local.a
local.o = $intropath2 gettagposition "truck2 dummy"
$introtruck2.origin = local.o
// println $introtruck2.angles
}

Pretty complicated isn't it
User avatar
Alcoholic
General
Posts: 1470
Joined: Sat May 17, 2003 5:57 am
Location: California
Contact:

Post by Alcoholic »

ok i just about figured it out. what they do is use a script_model, glue you to a spot on there, and use followpath to make the script_model follow splinepaths. the only problem is it's a pain that you have to put in the angles manually, in order for the truck to look like it's turning. (think of func_train in half life).
Post Reply