Advanced Teleporter troubles

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

Advanced Teleporter troubles

Post by Fiodis »

I need a teleporter from location A to location B, but there isn't a clear route between the two. So I use the kill-and-forced-respawn type teleporter:
Hidden/Spoiler:
[code] local matrixofunit = GetEntityMatrix(GetCharacterUnit(person))
KillObject(person)
local guy = GetCharacterUnit(person)
SelectCharacterClass(guy, "imp_inf_engineer")
SpawnCharacter(guy, matrixofunit)[/code][/size]
Obviously an event (OnObjectKill, a lever object) triggers this. The beginning goes ObObjectKill(lever, person), so person is the one who kills the lever. My problem is that it doesn't work, and I get a CTD with nothing in the error log about it. Thoughts? I'm certain it's the SelectCharacterClass that's the problem....but the three stock scripts that the Example Finder dredged up weren't much help.

I'm having quite a lot of trouble with LUA lately. :wink:
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: Advanced Teleporter troubles

Post by [RDH]Zerted »

Characters aren't ingame objects, units are. Kill the player's unit not his character.

You (attempt to) kill the player's unit then try to use it. It's dead and gone, don't use things that are destroyed. SelectCharacterclass works on characters not units.

Third, unless you want to force the player to become an engineer, there is no need for the SelectCharacterClass statement. If you just respawn the character, it will respawn as its last selected unit class unless the class's memory pools are full.
Post Reply