With ofpec down, I thought I might post these for anyone who may have problems with vehicle embarking/disembarking involving a player and WP synchronisation.
Most of the experienced editors will probably have written their own versions already (or gotten one off of ofpec). Still, I thought I'd post these for anyone who's not very experienced, or just doesn't have something similar.
Anyways, Looking through these forums, this seems like it's actually one of the few worthwhile communities on the internet. There's no real trolling or flaming to speak of, and this community seems to be full of helpfull people. So, I think I'll start taking an active part.
I'll be posting assorted scripts that I write, and maybe start putting out missions for the public if you guys would give me some good leads on where they should be hosted.
Anyways, without further ado, here's the promissed scripts.
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Vehicle Unload by ColonelSandersLite Version 1.0
; Requirements:
;
; The Transporting vehicle is assumed to be a truck/apc/whatever, but helicopters wont work
; The squad needs to have a group name. This can be acheived by putting the following in the
; init feild of the squad leader: myGroupName = group this;
; The Transporting vehicle must have a name
; The squad must be in the vehicle before getting out of the vehicle;)
; Usage (who controls the squad doesn't matter at all):
;
; make a move waypoint (NOT A TRANSPORT UNLOAD) for your vehicle where you want
; the squad to disembark from and put the following in the on activation box.
;
; [myVehicleName, (leader MyGroupName), delayInSeconds] exec "vehunload.sqs"
; Example : [testVeh1, (leader testGroup1), 20] exec "vehunload.sqs"
;
; DelayInSeconds is the time the truck will wait to leave after everyone is out.
; Reccomended value is 15-30 seconds, but testing is reccomended. This is here, so the
; squad is clear of the vehicle before it drives off, in order to prevent
; ai driver wonkieness. It can be set to 0 if you don't care to have it.
;
; The squad does not need a get out waypoint, just a normal waypoint to their destination
; after the truck has unloaded them.
; BEGIN SCRIPT
; Get All Passed Data.
_veh = _this select 0
_leader = _this select 1
_delay = _this select 2
; initialize variables.
_stopped = false
_squad = units group _leader
; Stop the vehicle from trying to go to the next WP.
_veh LockWP true
; Stop the vehicle.
_veh action ["Engine Off"]
; This loop checks that the vehicle is stopped and wont let the script progress till it does.
#stoppedCheckLoop
? (velocity _veh select 0 == 0) AND (velocity _veh select 1 == 0) AND (velocity _veh select 2 == 0) : _stopped = true
~1
? !_stopped : goto "stoppedCheckLoop"
; This unloads everyone, even players, quickly.
; reset getOutLoop counter
_tmp = 0
; count the living squad mates
_num = "alive _x" count _squad
#getOutLoop
? (((_squad select _tmp) in _veh) AND (alive (_squad select _tmp))) : unassignVehicle (_squad select _tmp); (_squad select _tmp) action ["eject", _veh]
~.85
_tmp = _tmp + 1
? _tmp < _num : goto "getOutLoop"
; make double sure that everyone is out by runngin the getOutLoop Again without the delay between members
; reset getOutLoop2 counter
_tmp = 0
; count the living squad mates
_num = "alive _x" count _squad
#getOutLoop2
? (((_squad select _tmp) in _veh) AND (alive (_squad select _tmp))) : unassignVehicle (_squad select _tmp); (_squad select _tmp) action ["eject", _veh]
_tmp = _tmp + 1
? _tmp < _num : goto "getOutLoop2"
; timer loop to make the vehicle wait the designated amount of time after squad disembarks.
_timewaited = 0
#waitLoop
~1
_timewaited = _timewaited + 1
? _timewaited < _delay : goto "waitLoop"
; Since everyone is out and clear, let the vehicle resume it's path.
_veh LockWP false
; finished[/QUOTE]
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; Vehicle Pickup by ColonelSandersLite Version 1.0
; Requirements:
;
; The Transporting vehicle is assumed to be a truck/apc/whatever, but helicopters wont work
; The squad needs to have a group name. This can be acheived by putting the following in the
; init feild of the squad leader: myGroupName = group this;
; The Transporting vehicle must have a name
; Usage if the squad is DEFINATELY going to be PLAYER controlled:
;
; Make a move waypoint (NOT LOAD) for your vehicle where you want the vehicle to wait at and
; put the following in the on activation box:
; [myVehicleName, (leader MyGroupName)] exec "vehpickup.sqs"
;
; The vehicle will wait for the player's squad to board
; Usage if the squad may possibly be player controlled, such as in the event of casualties:
;
; Make a move waypoint (NOT LOAD) for your vehicle where you want the vehicle to wait at and
; put the following in the on activation box:
; [myVehicleName, (leader MyGroupName)] exec "vehpickup.sqs"
;
; Make a small radius (10X10) trigger where the vehicle moves to pick up the men.
; Group it to the vehicle with "vehicle present (once)" being the activation.
; The Condition Should be:
; (this AND ((velocity myVehicleName select 0 == 0) AND (velocity myVehicleName select 1 == 0) AND (velocity myVehicleName select 2 == 0))) OR (!canMove myVehicleName)
; The on activation should read: myVehicleNameIsHere = 1;
;
; Give the squad a move/seek and destroy/guard/whatever waypoint. This is what the
; squad is doing before the truck comes to pick them up.
; The condition box should read: myVehicleNameIsHere == 1;
; The on activation should read: ("_x assignAsCargo myVehicleName") forEach (units MyGroupName);
;
; Give the squad a Get In waypoint near where the vehicle is going to load the squad.
;
; Give the Vehicle a move/seek and destroy/guard/whatever waypoint for where it goes after
; the squad is aboard.
; Usage if there's no possible way for the squad to be player controlled:
;
; Don't use this script, although it WILL WORK.
; It's simpler to just use synched load and get in waypoints.
; If you insist, follow the instructions for a squad may possibly be player controlled
; BEGIN SCRIPT
; Get All Passed Data.
_veh = _this select 0
_leader = _this select 1
; initialize variables.
_stopped = false
_squad = units group _leader
_squadGroup = group _leader
_veh LockWP true
_veh action ["Engine Off"]
; This loop checks that the vehicle is stopped and wont let the script progress till it does.
#stoppedCheckLoop
? (velocity _veh select 0 == 0) AND (velocity _veh select 1 == 0) AND (velocity _veh select 2 == 0) : _stopped = true
~1
? !_stopped : goto "stoppedCheckLoop"
; This loop keeps going until everyone is aboard
#waitForBoardLoop
; count the living squad mates
_num = "alive _x" count _squad
; reset counter for squad mates boarded
_inCount = 0
; reset testInLoop counter
_tmp = 0
; this loop counts the number of living squad mates in the vehicle and checks the whole squad
#testInLoop
? (((_squad select _tmp) in _veh) AND (alive (_squad select _tmp))) : _inCount = _inCount + 1
_tmp = _tmp + 1
? _tmp < (count _squad) : goto "testInLoop"
; small delay so the script doesn't eat too many resources
~1
; if all living squad members are not in the truck, loop
? _inCount != _num : goto "waitForBoardLoop"
; since everyone is aboard, let the truck move out
_veh LockWP false
; finished[/QUOTE]
HOME 
Reply With Quote
.....
.
.
