How to keep certain infantry classes out of certain vehicles

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
xwingguy

How to keep certain infantry classes out of certain vehicles

Post 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
)
Last edited by xwingguy on Wed Jul 12, 2006 12:48 pm, edited 2 times in total.
pinioncorp

Post 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? :D
_____________________________________________________________
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
xwingguy

Post 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.
Last edited by xwingguy on Wed Jul 12, 2006 12:50 pm, edited 2 times in total.
pinioncorp

Post by pinioncorp »

_____________________________________________________________
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯


Just don't apply it to those two bombers (and the shuttles) then, its invaluable either way. Great work.

_____________________________________________________________
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
Schizo

Post 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.
RC-1290

Post 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... :P

RC-1290'Dreadnought'
User avatar
Teancum
Jedi Admin
Jedi Admin
Posts: 11080
Joined: Wed Sep 07, 2005 11:42 pm
Projects :: No Mod project currently.
Games I'm Playing :: Destiny
xbox live or psn: No gamertag set
Location: Indiana

Post 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.
xwingguy

Post 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
)
Last edited by xwingguy on Wed Jul 12, 2006 12:52 pm, edited 2 times in total.
PvtParts
Jedi
Jedi
Posts: 1001
Joined: Mon Apr 03, 2006 9:12 pm
Projects :: No Mod project currently.
xbox live or psn: No gamertag set
Location: plundering yer booty

Post 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.
yankeefan05
Sith
Sith
Posts: 1288
Joined: Fri Mar 31, 2006 9:02 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: New York City
Contact:

Post by yankeefan05 »

Wow. Good find. This could really help. :)
Hebes24
Sith Master
Sith Master
Posts: 2594
Joined: Sat Jun 03, 2006 5:15 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: In An Epic Space Battle!
Contact:

Post by Hebes24 »

You put this in the vehicle's odf, right?? Great find!!! I hate how everyone can use Jedi Starfighters.
User avatar
PR-0927
Old School Staff
Posts: 844
Joined: Fri Dec 31, 2004 9:15 pm
Location: Kent, OH, U.S.A.

Post 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
xwingguy

Post 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.
RC-1290

Post by RC-1290 »

So you can't prevent em to eneter, you can just kick em out when they enter...
t551
General
General
Posts: 791
Joined: Sat Jul 16, 2005 3:23 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Post by t551 »

Hebes24, this is a .lua script.
Post Reply