GetEntityClass Failure (and jetpacks)

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
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

GetEntityClass Failure (and jetpacks)

Post by Fiodis »

My protect-the-flag mode code has progressed somewhat, but I'm having trouble with a side objective that starts out like this:
Hidden/Spoiler:
[code] OnFlagPickUp(
function(flag, picker)
print("Ok, OnFlagPickUp works....")
if GetEntityClass(picker) == "imp_inf_dark_trooper" then
print("Ok, class of the picker has been verified....")[/code][/size]
I get this in the error log:

Code: Select all

Ok, OnFlagPickUp works....

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "0" not found
So it seems that OnFlagPickUp works, but GetEntityClass doesn't. I've tried variations like GetEntityClassName, GetEntityClass(GetCharacterUnit(picker)), GetCharacterClass, and GetCharacterUnit. None seem to work. Why is that?

And another little thing related to it but not to the code: is there any way to allow units to use jetpacks when they have the flag?
Aman/Pinguin
Jedi
Jedi
Posts: 1104
Joined: Tue Jan 30, 2007 6:04 am
Projects :: Inactive
Location: Germany

Re: GetEntityClass Failure (and jetpacks)

Post by Aman/Pinguin »

I'm not sure why but I never used GetEntityClass(picker), I kinda remember something was wrong with it.

GetCharacterClass(player) works though. It doesn't use the name of the class, but the class index (or whatever its called).
Example from Tuskencamp:
Hidden/Spoiler:
[code]OnCharacterSpawn(
function(player)
if StopEEUnits == true then
print("StopEEUnits is working!")

if GetCharacterClass(player) == 8 and GetCharacterTeam(player) == CIS then
print("haha_inf_penguin check is working!")
AddReinforcements(CIS, 1 )
KillObject( GetCharacterUnit(player) )
SelectCharacterClass(player, "cis_inf_trooper")
SpawnCharacter(player, GetPathPoint("penguin_spawn", 0))

elseif GetCharacterClass(player) == 8 and GetCharacterTeam(player) == REP then
AddReinforcements(REP, 1 )
KillObject( GetCharacterUnit(player) )
SelectCharacterClass(player, "rep_inf_ep3_rifleman")
SpawnCharacter(player, GetPathPoint("golem_spawn", 0))
end
else return
end
end
)[/code][/size]
So, assuming the dark trooper is the 6th class in the IMP team, I would change your code to this:
Hidden/Spoiler:
[code]OnFlagPickUp(
function(flag, picker)
print("Ok, OnFlagPickUp works....")
if GetCharacterClass(picker) == 5 and GetCharacterTeam(picker) == IMP then
print("Ok, class of the picker has been verified....")[/code][/size]
User avatar
Maveritchell
Jedi Admin
Jedi Admin
Posts: 7366
Joined: Mon Aug 21, 2006 11:03 pm

Re: GetEntityClass Failure (and jetpacks)

Post by Maveritchell »

Aman/Pinguin wrote:I'm not sure why but I never used GetEntityClass(picker), I kinda remember something was wrong with it.
Nothing's wrong with it, it just doesn't have a string output. You need to match up a GetEntityClass to a FindEntityClass, a la:

Code: Select all

GetEntityClass(etc) == FindEntityClass("ex_type_entity")
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: GetEntityClass Failure (and jetpacks)

Post by Fiodis »

Thanks! Any idea on the jetpack problem? I found nothing in any odfs and luas I searched, so I assume it's a hard-coded thing.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: GetEntityClass Failure (and jetpacks)

Post by [RDH]Zerted »

You can give everyone a jet pack but with no fuel or recharge rate. When a unit gets the flag, up its recharge rate. When a unit drops the flag, but it back at zero. I think that would work...
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: GetEntityClass Failure (and jetpacks)

Post by Frisbeetarian »

That shouldn't work. When a jedi get's a flag, it has no fuel or recharge rate and still can't use its jump.
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: GetEntityClass Failure (and jetpacks)

Post by Fiodis »

So the lack of jetpacks while carrying a flag is a hardcoded thing? Maybe you could increase the jump distance and add an effect to the unit upon flag pickup to simulate a jump pack similar to the Dark Trooper's...but it's a messy workaround.
User avatar
[RDH]Zerted
Gametoast Staff
Gametoast Staff
Posts: 2982
Joined: Sun Feb 26, 2006 7:36 am
Projects :: Bos Wars AI - a RTS game
Games I'm Playing :: SWBF2 and Bos Wars
xbox live or psn: No gamertag set
Location: USA
Contact:

Re: GetEntityClass Failure (and jetpacks)

Post by [RDH]Zerted »

Jump distance is a class property, so that wouldn't work. I assumed the can't fly with a flag was an ODF property, but I don't know those too well. There is the bug that if you get a flag while flying you can keep flying until you land, but that doesn't really help you...
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: GetEntityClass Failure (and jetpacks)

Post by Fiodis »

If there were only one unit and it were SP, that'd be all right, that it's a class property. Still, it seems these workarounds are too messy to look good.

And I don't recall any ODF property dealing with the jetpack removal while carrying flags either.
Post Reply