Page 1 of 1
How to keep certain infantry classes out of certain vehicles
Posted: Tue Jul 11, 2006 9:14 pm
by xwingguy
I once heard that somebody wanted to know how to keep certain classes out of particular vehicles
A really cool element of this code allows you to create a hero only vehicle.
Code: Select all
OnCharacterEnterVehicle(
function (player, vehicle)
if GetEntityClass(GetCharacterUnit(player)) == GetEntityClassPtr("NameOfInfantryClassYouWANTinVehicle") and GetEntityClass(vehicle)== GetEntityPtr("NameOfAVehicleClass") then
else
SetProperty(vehicle, "DisableTime", 0.25)
end
end
)
Posted: Wed Jul 12, 2006 12:40 am
by pinioncorp
_____________________________________________________________
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Thats a nice bit of code there xwing, I hope people put this on every space map, to stop those pesky marines piloting ships. I'm not exactly sure how to read this, but correct me if I'm wrong: If the player that enters the vehicle is not of the correct class, then the vehicle is disabled. Therefore, if a non correct class player continueously tries to enter the vehicle, the correct class cannot either within the disabled timeframe (which, from the looks of it, is a quarter of a second)..?
Are we going to see some hero ships at BOE then?
_____________________________________________________________
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Posted: Wed Jul 12, 2006 1:02 am
by xwingguy
You're exactly right pinioncorp on how the system works. And yes I'm going to put some hero ships in BOE. (Probably an enhanced x-wing for Wedge since I doubt I'm going to get a Millinium Falcon. Don't know about the Empire yet.)
oh and if you don't want this code to affect human players use this:
Code: Select all
OnCharacterEnterVehicle(
function (player, vehicle)
if not IsCharacterHuman(player) then
if GetEntityClass(GetCharacterUnit(player)) == GetEntityPtr("NameOfInfantryClassYouWantInVehicle") and GetEntityClass(vehicle)== GetEntityPtr("NameOfAVehicleClass") then
else
SetProperty(vehicle, "DisableTime", 0.25)
end
end
end
)
EDIT: There's one little flaw in how this works although it only applies to the TIE bomber and the Y wing. Because these ships are 2 seaters, if a pilot is in the pilot seat and then a marine decides to jump into the second seat BOTH are kicked out of the ship.
Posted: Wed Jul 12, 2006 1:53 am
by pinioncorp
_____________________________________________________________
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Just don't apply it to those two bombers (and the shuttles) then, its invaluable either way. Great work.
_____________________________________________________________
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Posted: Wed Jul 12, 2006 2:44 am
by Schizo
Alternatively, you could just add "NoEnterVehicles = 1" to the ODF of the unit you don't want to be able to pilot them. Unless, of course, you want the player to be able to use it, but not the bots. In that case, this could come in handy.
Posted: Wed Jul 12, 2006 7:44 am
by RC-1290
Yay, so now we get classes who are specialized for special vehicles. Tie-fighter Pilot, Tie-Bomber Pilot, Kamikaze pilot...euh...did I just say that?
I like the idea that you need to be a special class for a special fighter. Also, you could have a special class wich specializes in the enemy vehicles. Or something like that...
RC-1290'Dreadnought'
Posted: Wed Jul 12, 2006 8:34 am
by Teancum
Schizo wrote:Alternatively, you could just add "NoEnterVehicles = 1" to the ODF of the unit you don't want to be able to pilot them. Unless, of course, you want the player to be able to use it, but not the bots. In that case, this could come in handy.
Good point. But I'm thinking he was setting this up as such that x class could get in some ships, but not others. That way nobody can steal someone's rightfully earned (by high score) Millenium Falcon or whatever.
Posted: Wed Jul 12, 2006 11:09 am
by xwingguy
I've got a system now that should keep any non-pilots out of the 1-manned starfighters. Keep in mind that this will only work for the Galactic Civil War.
EDIT: This works garanteed now!
Code: Select all
OnCharacterEnterVehicle(
function(player, vehicle)
if (GetEntityClass(GetCharacterUnit(player)) == GetEntityClassPtr("all_inf_pilot")) then --Pilot is the 1st on the list
elseif (GetEntityClass(GetCharacterUnit(player)) == GetEntityClassPtr("imp_inf_pilot")) then
elseif (GetEntityClass(vehicle) == GetEntityClassPtr("all_fly_gunship_sc")) then
elseif (GetEntityClass(vehicle) == GetEntityClassPtr("all_fly_ywing_sc")) then
elseif (GetEntityClass(vehicle) == GetEntityClassPtr("imp_fly_trooptrans")) then
elseif (GetEntityClass(vehicle) == GetEntityClassPtr("imp_fly_tiebomber_sc")) then
else
SetProperty(vehicle,"DisableTime", 0.25)
end
end
)
Posted: Wed Jul 12, 2006 11:41 am
by PvtParts
That bit of code helped my more than the first. Cause now I know how its used.
I had thought about doing this with, say, Jedi Starfighters. Good thinking and nicely done.
Posted: Wed Jul 12, 2006 1:41 pm
by yankeefan05
Wow. Good find. This could really help.

Posted: Wed Jul 12, 2006 2:00 pm
by Hebes24
You put this in the vehicle's odf, right?? Great find!!! I hate how everyone can use Jedi Starfighters.
Posted: Wed Jul 12, 2006 2:21 pm
by PR-0927
Hmm, what if you made it so that only pilots could PILOT vehicles, but other soldiers could jump in as passengers and gunners? That'd be the most useful for me.
Great find!
- Majin Revan
Posted: Wed Jul 12, 2006 2:25 pm
by xwingguy
with this exception:
There's one little flaw in how this works although it only applies to the TIE bomber and the Y wing. Because these ships are 2 seaters, if a pilot is in the pilot seat and then a marine decides to jump into the second seat BOTH are kicked out of the ship.
Posted: Wed Jul 12, 2006 2:38 pm
by RC-1290
So you can't prevent em to eneter, you can just kick em out when they enter...
Posted: Wed Jul 12, 2006 3:54 pm
by t551
Hebes24, this is a .lua script.