Page 1 of 1
Binding mp players to something
Posted: Fri Apr 16, 2004 6:34 am
by wacko
ok. got my truck running so far, now I must glue the player who does enter the truck bed to the truck. Here's what I copy/pasted together from different other maps:
Code: Select all
truck_enter:
$faketruck_collision notsolid
$player glue $faketruck_playerspot_8 0 //btw, what does this 0 mean?
local.player = parm.other
local.player forcelegsstate CROUCH_IDLE
$player physics_off
$flucktlkw_trigger nottriggerable
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $faketruck_entrypath
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
$faketruck_collision solid
$player physics_on
$player unglue
$faketruck_model stoploopsound
wait 3
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $truck_wayback
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
wait .5
$faketruck_model stoploopsound
$flucktlkw_trigger triggerable
end
Now, when - in DM mode - one player enters the truck (and touches the trigger with setthread truck_enter) it's not just him who gets bound to the script_origin faketruck_playerspot_8, but infact all players, wherever they are, are bound to it.
Of course, I will have to glue additional players who enter the truck as well, to additional script_origins (there are faketruck_playerspot_1/8), but first of all, the players who do NOT enter the truck must not be dragged into the truck and be glued! How can I achieve this?
Posted: Fri Apr 16, 2004 1:28 pm
by bdbodger
You need to glue local.player not $player . $player is all players but $player[1] or $player[2] are two different players . Also after local.player = parm.other you should use local.player in the rest of the thread .
truck
Posted: Fri Apr 16, 2004 2:35 pm
by tltrude
I think trucks have built-in spots to glue passengers. Anyway, you are going to need to make an array of the players that enter the trigger--a for loop with "local.player.size". Then it would check to see how many got in and assign a spot to each, just before or after the truck starts moving. here is a thread that counts how many allied players there are in the game--if that helps.
getnumberallied:
local.j = 0
for(local.i = 1; local.i <= $player.size; local.i++)
{
local.player = $player[local.i]
if(local.player.dmteam == allies)
local.j++
}
end local.j
Posted: Fri Apr 16, 2004 2:59 pm
by Krane
bdbodger wrote:You need to glue local.player not $player . $player is all players but $player[1] or $player[2] are two different players . Also after local.player = parm.other you should use local.player in the rest of the thread .
This has been one of my dreams! But I've tryed $player[1], [2], etc and didn't work

...at least for me.
But local.player sounds cool

! You just need to add the line:
local.player = parm other
in the beggining of the thread? And use local.player in the rest of the thread?
If yes, I'm gonna kiss you, bdb

!
local.sucker
Posted: Fri Apr 16, 2004 3:19 pm
by tltrude
It does not have to be "local.player" because that is just a variable name. So, you can use any name you wish.
local.sucker = parm.other
local.trigger_resident = parm.other
local.passenger = parm.other
etc...
One annoying thing about assigning a local variable name to a player is that it stays with the player, even after they leave the trigger. But, there are ways around that.
Posted: Fri Apr 16, 2004 4:13 pm
by Krane
Hmm, I got it...Thanks, my General!
I like local.krane = parm other (LOL)
But Wacko will probably prefer the other way...
Thanks m8s!

Posted: Fri Apr 16, 2004 11:50 pm
by wacko
local.krane is fine (if it worked...)
the local.player is working perfectly ! Thank you so much!
I also did a kind of counter, see script below. Now, when I start with two players in dm mode, they both get glued to the truck at different spots (but it's #7 and #6(?), surely not #8 and #7 which I was expecting). Somehow, then, just one player is unglued at the stop. Any idea?
Code: Select all
main:
exec global/ai.scr
local.master=spawn ScriptMaster
local.master aliascache m4l3_truck1 sound/vehicle/Truck_m4l3.wav soundparms 1.1 0.0 1.0 0.0 300 2000 auto streamed maps "dm obj"
local.master aliascache m4l2_truckidle sound/vehicle/veh_truck_idle.wav soundparms 0.7 0.0 1.0 0.0 300 2000 auto loaded maps "dm obj"
level waittill prespawn
level.script = maps/dm/truckride.scr
exec global/forceanim.scr
level waittill spawn
$faketruck_collision solid
$faketruck_model anim idlelights
$faketruck_collision bind $faketruck_model // Bind the getawaytruck bed collision to the fake truck
$faketruck_playerspot_1 bind $faketruck_model
$faketruck_playerspot_2 bind $faketruck_model
$faketruck_playerspot_3 bind $faketruck_model
$faketruck_playerspot_4 bind $faketruck_model
$faketruck_playerspot_5 bind $faketruck_model
$faketruck_playerspot_6 bind $faketruck_model
$faketruck_playerspot_7 bind $faketruck_model
$faketruck_playerspot_8 bind $faketruck_model
$fluchtlkw_fahrer exec global/disable_ai.scr // Disable getaway driver AI
$fluchtlkw_fahrer notsolid // Make getaway driver nonsolid
$fluchtlkw_fahrer rendereffects "-shadow" // No shadow
$fluchtlkw_fahrer anim_scripted opel_driver // Play driver animation
$fluchtlkw_fahrer bind $faketruck_model
$fluchtlkw_fahrer show
level.truckspot = 8
end
truck_enter:
wait 0.5
$faketruck_collision notsolid
local.player = parm.other
local.player glue $("faketruck_playerspot_" + level.truckspot) 0
level.truckspot--
local.player forcelegsstate CROUCH_IDLE
local.player physics_off
level.intruck = 1
wait 5
thread intro_truck_jitter
$fluchtlkw_trigger nottriggerable
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $faketruck_entrypath
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
$faketruck_collision solid
local.player physics_on
local.player unglue
level.truckspot++
level.intruck = 0
wait .5
$faketruck_model stoploopsound
wait 3
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $truck_wayback
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
wait .5
$faketruck_model stoploopsound
$fluchtlkw_trigger triggerable
end
//*************************************************************
// shaking the players view while riding the truck
intro_truck_jitter:
while (level.intruck == 1)
{
if (level.intruck == 1)
{
waitexec global/earthquake.scr .3 .1 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 3 .05 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr .5 .15 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 1.5 .05 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr .2 .2 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 3 .05 0 0
}
}
end
number
Posted: Sat Apr 17, 2004 6:31 am
by tltrude
Maybe your spots should be numbered 0-7. There will still be 8 spots.
Posted: Sat Apr 17, 2004 6:43 am
by wacko
yeah, i could try.
But why? it's set to 8 in the beginning ("level.truckspot = 8") and player is glued before "level.truckspot--", so why could it start with 7??
Then, I'd prefer "level.truckspot = 9"... won't have to change the bsp
btw, any idea what the zero is for:
local.player glue $("faketruck_playerspot_" + level.truckspot)
0??
Posted: Sat Apr 17, 2004 7:04 am
by tltrude
Here is what it says in g_allclasses.
glue( Entity parent, [ Integer glueAngles ] ) - glue this entity to the specified entity.
So, I guess the 0 is "glueAngles", but I have never used it.
Posted: Sat Apr 17, 2004 7:40 am
by wacko
ooops
ill never ask again without having looked into g_allclasses
thanks

Posted: Sat Apr 17, 2004 9:36 am
by bdbodger
The only thing is if the thread is run useing setthread then if 8 players trigger the trigger then it will be running 8 time once for every player now you have 8 thread trying to control the truck . Maybe loop the thread and use another thread to glue the players . If this is for multi player then why not make a thread to get the truck back to the start position and then do the glue un glue again and move it along the path again and again . Any way here is a way you can use another thread to glue the players .
Code: Select all
main:
exec global/ai.scr
local.master=spawn ScriptMaster
local.master aliascache m4l3_truck1 sound/vehicle/Truck_m4l3.wav soundparms 1.1 0.0 1.0 0.0 300 2000 auto streamed maps "dm obj"
local.master aliascache m4l2_truckidle sound/vehicle/veh_truck_idle.wav soundparms 0.7 0.0 1.0 0.0 300 2000 auto loaded maps "dm obj"
level waittill prespawn
level.script = maps/dm/truckride.scr
exec global/forceanim.scr
level waittill spawn
$faketruck_collision solid
$faketruck_model anim idlelights
$faketruck_collision bind $faketruck_model // Bind the getawaytruck bed collision to the fake truck
$faketruck_playerspot_1 bind $faketruck_model
$faketruck_playerspot_2 bind $faketruck_model
$faketruck_playerspot_3 bind $faketruck_model
$faketruck_playerspot_4 bind $faketruck_model
$faketruck_playerspot_5 bind $faketruck_model
$faketruck_playerspot_6 bind $faketruck_model
$faketruck_playerspot_7 bind $faketruck_model
$faketruck_playerspot_8 bind $faketruck_model
$fluchtlkw_fahrer exec global/disable_ai.scr // Disable getaway driver AI
$fluchtlkw_fahrer notsolid // Make getaway driver nonsolid
$fluchtlkw_fahrer rendereffects "-shadow" // No shadow
$fluchtlkw_fahrer anim_scripted opel_driver // Play driver animation
$fluchtlkw_fahrer bind $faketruck_model
$fluchtlkw_fahrer show
level.truckspot = 8
thread truck_enter
end
truck_enter:
$fluchtlkw_trigger waittill trigger // use this and setthread player_glue for glueing
wait 0.5 // longer maybe to let players get in ????
$faketruck_collision notsolid
// local.player = parm.other
// local.player glue $("faketruck_playerspot_" + level.truckspot) 0
// level.truckspot--
// local.player forcelegsstate CROUCH_IDLE
/ local.player physics_off
level.intruck = 1
wait 5
thread intro_truck_jitter
$fluchtlkw_trigger nottriggerable // maybe you don't need this now 1st player in starts the truck
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $faketruck_entrypath
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
$faketruck_collision solid
// local.player physics_on
// local.player unglue
// level.truckspot++
level.intruck = 0
wait .5
$faketruck_model stoploopsound
wait 3
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $truck_wayback
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
wait .5
$faketruck_model stoploopsound
$fluchtlkw_trigger triggerable // maybe you don't need this now
end
player_glue:
local.player = parm.other
local.player glue $("faketruck_playerspot_" + level.truckspot) 0
level.truckspot--
local.player forcelegsstate CROUCH_IDLE
local.player physics_off
while(level.intruck == 1)
waitframe
local.player physics_on
local.player unglue
level.truckspot++
end
//*************************************************************
// shaking the players view while riding the truck
intro_truck_jitter:
while (level.intruck == 1)
{
if (level.intruck == 1)
{
waitexec global/earthquake.scr .3 .1 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 3 .05 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr .5 .15 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 1.5 .05 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr .2 .2 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 3 .05 0 0
}
}
end
Posted: Sat Apr 17, 2004 5:09 pm
by wacko
thanks, will try this asap (i have to work now

) or maybe Krane will!?
the prob with players glued to the wrong spots I could solve (probably) with a wait command...
Posted: Sun Apr 18, 2004 3:03 pm
by wacko
heyho

thanks!!!
looks quite good now! here's what I did (with trigger's setthread changed to truck_glue, ofcourse):
Code: Select all
main:
// exec global/ai.scr
local.master=spawn ScriptMaster
local.master aliascache m4l3_truck1 sound/vehicle/Truck_m4l3.wav soundparms 1.1 0.0 1.0 0.0 300 2000 auto streamed maps "dm obj"
local.master aliascache m4l2_truckidle sound/vehicle/veh_truck_idle.wav soundparms 0.7 0.0 1.0 0.0 300 2000 auto loaded maps "dm obj"
level waittill prespawn
level.script = maps/dm/truckride.scr
exec global/forceanim.scr
thread truck_prep
level waittill spawn
thread truck_enter
end
//***************************************************************
truck_prep:
$faketruck_collision solid
$faketruck_model anim idlelights
$faketruck_collision bind $faketruck_model // Bind the getawaytruck bed collision to the fake truck
$faketruck_playerspot_1 bind $faketruck_model
$faketruck_playerspot_2 bind $faketruck_model
$faketruck_playerspot_3 bind $faketruck_model
$faketruck_playerspot_4 bind $faketruck_model
$faketruck_playerspot_5 bind $faketruck_model
$faketruck_playerspot_6 bind $faketruck_model
$faketruck_playerspot_7 bind $faketruck_model
$faketruck_playerspot_8 bind $faketruck_model
// $fluchtlkw_fahrer exec global/disable_ai.scr // Disable getaway driver AI
$fluchtlkw_fahrer.enableEnemy = 0 // Makes the driver ignore enemies (the same as above, right?)
$fluchtlkw_fahrer notsolid // Make getaway driver nonsolid
$fluchtlkw_fahrer rendereffects "-shadow" // No shadow
$fluchtlkw_fahrer anim_scripted opel_driver // Play driver animation
$fluchtlkw_fahrer bind $faketruck_model
$fluchtlkw_fahrer show
level.truckspot = 8
level.jvbot_tasks_priority [follow] = 0 // Makes the driver NOT to turn to you when he sees you
waitthread global/jv_bots/jv_mp_ai.scr::enable 0 0 0 0 // Now this map is a jvbots map...dunno if you want this
end
//***************************************************************
truck_enter:
$fluchtlkw_trigger waittill trigger
level.intruck = 1
iprintln "10"
wait 2
iprintln "8"
wait 2
iprintln "6"
wait 2
iprintln "4"
wait 2
iprintln "2"
wait 2
iprintln "0"
$truckhatch speed 20
$truckhatch playsound m2l1_gate_open // hatch close sound
$truckhatch moveDown 76
$truckhatch waitmove
$truckhatch playsound door_metal_close_stop4 // hatch end-close sound
$faketruck_collision notsolid
wait 1
thread intro_truck_jitter
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $faketruck_entrypath
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
$faketruck_collision solid
level.intruck = 0
wait .5
$faketruck_model stoploopsound
wait 3
$faketruck_model playsound m4l3_truck1
$faketruck_model followpath $truck_wayback
$faketruck_model waitmove
$faketruck_model loopsound m4l2_truckidle
wait .5
$faketruck_model stoploopsound
$truckhatch playsound m2l1_gate_open // hatch close sound
$truckhatch moveUp 76
$truckhatch waitmove
$truckhatch playsound door_metal_close_stop4 // hatch end-close sound
goto truck_enter
end
//************************************************************
truck_glue:
local.player = parm.other
local.player glue $("faketruck_playerspot_" + level.truckspot)
wait .5
level.truckspot--
local.player forcelegsstate CROUCH_IDLE
local.player physics_off
while(level.intruck == 1)
waitframe
local.player physics_on
local.player unglue
level.truckspot++
end
//*************************************************************
// shaking the players view while riding the truck
intro_truck_jitter:
while (level.intruck == 1)
{
if (level.intruck == 1)
{
waitexec global/earthquake.scr .3 .1 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 3 .05 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr .5 .15 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 1.5 .05 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr .2 .2 0 0
}
if (level.intruck == 1)
{
waitexec global/earthquake.scr 3 .05 0 0
}
}
end
anything I could improve?