Teleportation problem [Solved]

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
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 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: All Along The Watchtower

Teleportation problem [Solved]

Post by jangoisbaddest »

somen00b suggested that I start a new thread on this, so I will. I tested the functionality of an OnEnterRegion trigger to teleport a unit to a path node, but it didn't work. The modtools log gave me nothing. Mainly, though, I think this is because I'm so lacking in knowledge of the programming of the scripts - I probably put the function in the wrong place. Does it need to go into ScriptPostLoad, ScriptInt....? Cause the space LUAs are different than the land ones, but they share those functions....
archer01

RE: Teleportation

Post by archer01 »

I just tested it by copying it straight out of the thread where I posted it (in case I made a mistake in the post). I only changed the region and path names, and it worked fine for me.

All listeners (things beginning with "On") should go into the ScriptPostLoad() function. I've never seen them used in ScriptInit() so I'm assuming they won't function there. Also make sure you have activated the region using ActivateRegion(). Regions that aren't activated won't throw the EnterRegion event.

If none of that works, post the lua where you use it so we can try to see what the problem might be.
User avatar
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 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: All Along The Watchtower

Re: RE: Teleportation

Post by jangoisbaddest »

I've done several variations on this, so I don't know what's up with it. This is the Space Assault LUA for my map:
Hidden/Spoiler:
[quote="BRDg_Diet Dr. Pepper"]
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
-- SPAX - Galactic Civil War Template Assault File
--

ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("BRDg_cmn")

ScriptCB_DoFile("ObjectiveSpaceAssault")
ScriptCB_DoFile("LinkedShields")
ScriptCB_DoFile("LinkedDestroyables")

myGameMode = "BRD_GCW-Assault"

function ScriptPostLoad()
SetupObjectives()

SetupShields()
SetupDestroyables()
SetupTurrets()

AddAIGoal(ALL, "Deathmatch", 100)
AddAIGoal(IMP, "Deathmatch", 100)

DisableSmallMapMiniMap()

OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"teleport1")
end,
"teleport"
)
ActivateRegion("teleport")
end

function SetupObjectives()
assault = ObjectiveSpaceAssault:New{
teamATT = IMP, teamDEF = ALL,
multiplayerRules = true
}

local impTargets = {
engines = {"all_drive_1", "all_drive_2", "all_drive_3", "all_drive_4", "all_drive_5", "all_drive_6"},
lifesupport = "all-life-ext",
bridge = "all-bridge",
comm = "all-comms",
sensors = "all-sensors",
frigates = "all-frigate",
internalSys = { "all-life-int", "all-engines" },
}

local allTargets = {
engines = { "imp_drive_1", "imp_drive_2", "imp_drive_3" },
lifesupport = "imp-life-ext",
bridge = "imp-bridge",
comm = "imp-comms",
sensors = "imp-sensors",
frigates = "imp-frigate",
internalSys = { "imp-life-int", "imp-engines" },
}

assault:SetupAllCriticalSystems( "imp", impTargets, true )
assault:SetupAllCriticalSystems( "all", allTargets, false )

assault:Start()
end

function SetupShields()
-- ALL Shielded objects
local linkedShieldObjectsALL = { "all_ship_1", "all_ship_2",
"all-bridge", "all-comms", "all-life-ext", "all-sensors",
"all_drive_1", "all_drive_2", "all_drive_3", "all_drive_4", "all_drive_5", "all_drive_6"}
shieldStuffALL = LinkedShields:New{objs = linkedShieldObjectsALL, controllerObject = "all-shield"}
shieldStuffALL:Init()

function shieldStuffALL:OnAllShieldsDown()
ShowMessageText("level.spa.hangar.shields.atk.down", IMP)
ShowMessageText("level.spa.hangar.shields.def.down", ALL)

BroadcastVoiceOver( "IOSMP_obj_16", IMP )
BroadcastVoiceOver( "AOSMP_obj_17", ALL )
end
function shieldStuffALL:OnAllShieldsUp()
ShowMessageText("level.spa.hangar.shields.atk.up", IMP)
ShowMessageText("level.spa.hangar.shields.def.up", ALL)

BroadcastVoiceOver( "IOSMP_obj_18", IMP )
BroadcastVoiceOver( "AOSMP_obj_19", ALL )
end


-- IMP Shielded objects
local linkedShieldObjectsIMP = { "imp_ship_1", "imp_ship_2", "imp_ship_3", "imp_ship_4", "imp_ship_5", "imp_ship_6",
"imp-bridge", "imp-comms", "imp-life-ext", "imp-sensors",
"imp_drive_1", "imp_drive_2", "imp_drive_3"}
shieldStuffIMP = LinkedShields:New{objs = linkedShieldObjectsIMP, controllerObject = "imp-shield"}
shieldStuffIMP:Init()

function shieldStuffIMP:OnAllShieldsDown()
ShowMessageText("level.spa.hangar.shields.atk.down", ALL)
ShowMessageText("level.spa.hangar.shields.def.down", IMP)

BroadcastVoiceOver( "IOSMP_obj_17", IMP )
BroadcastVoiceOver( "AOSMP_obj_16", ALL )
end
function shieldStuffIMP:OnAllShieldsUp()
ShowMessageText("level.spa.hangar.shields.atk.up", ALL)
ShowMessageText("level.spa.hangar.shields.def.up", IMP)

BroadcastVoiceOver( "IOSMP_obj_19", IMP )
BroadcastVoiceOver( "AOSMP_obj_18", ALL )
end
end


function SetupDestroyables()
--ALL destroyables
lifeSupportLinkageALL = LinkedDestroyables:New{ objectSets = {{"all-life-int"}, {"all-life-ext"}} }
lifeSupportLinkageALL:Init()

engineLinkageALL = LinkedDestroyables:New{ objectSets = {{"all_drive_1", "all_drive_2", "all_drive_3", "all_drive_4", "all_drive_5", "all_drive_6"}, {"all-engines"}} }
engineLinkageALL:Init()

--IMP destroyables
lifeSupportLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp-life-int"}, {"imp-life-ext"}} }
lifeSupportLinkageIMP:Init()

engineLinkageIMP = LinkedDestroyables:New{ objectSets = {{"imp_drive_1", "imp_drive_2", "imp_drive_3"}, {"imp-engines"}} }
engineLinkageIMP:Init()
end[/quote]
One thing - do I have to choose a specific Region type, or am I okay if I just make a new one and name it?
archer01

RE: Re: RE: Teleportation

Post by archer01 »

That might be your problem actually. I've found that the game uses the region's type as it's "name"... I have no idea why... :?
Try setting both the editor name and the region's type to the same thing and try it again.

Also, where is the "MoveEntityToNode()" function? It was also in the other thread and is needed for the OnEnterRegion listener to work (it calls it).
User avatar
Karnage
Commander Randomtoast
Posts: 947
Joined: Sun Oct 23, 2005 9:17 pm
Projects :: No Mod project currently.
Games I'm Playing :: Overwatch
xbox live or psn: No gamertag set
Location: Wherever there is shenanigannery.

Post by Karnage »

This is what i'm getting from this:

Place a region in a map, leaving it as it's original name.

Place a node with a specific name.

Enter...
OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"***")
end,
"***"
)
ActivateRegion("***")
end
this into the LUA of the map (replacing *** with the name of region and/or node), and you can teleport people?

If this is completely wrong, could you type out some sort of a tutorial on how to do this?
User avatar
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 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: All Along The Watchtower

Re: RE: Re: RE: Teleportation

Post by jangoisbaddest »

AHA! The BFlog is finally useful now.

Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: (none):0: attempt to call global `MoveEntityToNode' (a nil value)
stack traceback:
(none): in function <(none):28>

I thought I put it in the ScriptPostLoad function....it's right there in the LUA. :?

Maybe do you have to specify the specific node IN the path..?
archer01

RE: Re: RE: Re: RE: Teleportation

Post by archer01 »

What you have in your lua is just the "call" to the function. The function itself also has to be defined somewhere in your script (it is NOT one of the game's functions).

Here it is from the other thread:

Code: Select all

function MoveEntityToNode(entIn,pathIn,nodeIn)
   if not entIn then
      print("Warning!: Entity not specified for move")
      return false
   elseif not pathIn then
      print("Warning!: Path not specified for Entity " .. entIn .. " move")
      return false
   end
   
   local node
   if nodeIn then
      node = nodeIn
   else
      node = 0
   end
   
   local locDest = GetPathPoint(pathIn,node)
   local charUnit = GetCharacterUnit(entIn)
   if charUnit then
      SetEntityMatrix(charUnit,locDest)
      return true
   end
   return false
end
Just paste that at the very end of your lua script.
User avatar
jangoisbaddest
Lieutenant General
Lieutenant General
Posts: 661
Joined: Mon Feb 27, 2006 12:10 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: All Along The Watchtower

Post by jangoisbaddest »

:lol:

That was the problem. Thanks, archer01! It works! Awsome.
Post Reply