Page 1 of 1

Teleporter problem [Solved]

Posted: Tue Jan 15, 2008 12:08 am
by 1z2x3c
i cant get teleporters to work... ive done the tutorial from penguin, but still no resalt...

tut
Hidden/Spoiler:
There's about 3 topics on teleporters, Since search isn't working i'll post a quick tutorial.

1: Open ZE, create a region that when entered you will teleport from. For tutorial purposes, I've named it 'TeleporterRegion'

2: Create a new path. just place 1 node and name it something that you can remember, For tutorial purposes, I've named it 'TelporterNode'

3: Open your .lua in which you want the teleporter to work.

4: Add this piece of code inside the 'function ScriptPostLoad()' just before 'End'

Code:
OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"TeleportNode")
end,
"TeleportRegion"
)
ActivateRegion("TeleportRegion")


5: Scroll down to the bottom of your Lua, and add this piece of code after the last End 9should be last thing in your script)

Code:
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


6: Munge and test, If it works, have a cookie! (no chocolate ones)
my lua
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
-- ScriptCB_DoFile("T")
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("setup_teams")

-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
-- These variables do not change
ATT = 2;
DEF = 1;


function ScriptPostLoad()




ActivateRegion("TeleportRegion")
OnEnterRegion(
function(regIn,character)
MoveEntityToNode(character,"TeleportNode")
end,
"TeleportRegion"
)







--This defines the CPs. These need to happen first
cp1 = CommandPost:New{name = "cp1"}
cp2 = CommandPost:New{name = "cp2"}
cp3 = CommandPost:New{name = "cp3"}
cp4 = CommandPost:New{name = "cp4"}
cp5 = CommandPost:New{name = "cp5"}
cp6 = CommandPost:New{name = "cp6"}
cp7 = CommandPost:New{name = "cp7"}
cp8 = CommandPost:New{name = "cp8"}



--This sets up the actual objective. This needs to happen after cp's are defined
conquest = ObjectiveConquest:New{teamATT = ATT, teamDEF = DEF,
textATT = "game.modes.con",
textDEF = "game.modes.con2",
multiplayerRules = true}

--This adds the CPs to the objective. This needs to happen after the objective is set up
conquest:AddCommandPost(cp1)
conquest:AddCommandPost(cp2)
conquest:AddCommandPost(cp3)
conquest:AddCommandPost(cp4)
conquest:AddCommandPost(cp5)
conquest:AddCommandPost(cp6)
conquest:AddCommandPost(cp7)
conquest:AddCommandPost(cp8)

conquest:Start()

EnableSPHeroRules()

end


---------------------------------------------------------------------------
-- FUNCTION: ScriptInit
-- PURPOSE: This function is only run once
-- INPUT:
-- OUTPUT:
-- NOTES: The name, 'ScriptInit' is a chosen convention, and each
-- mission script must contain a version of this function, as
-- it is called from C to start the mission.
---------------------------------------------------------------------------
function ScriptInit()

ReadDataFile("dc:Load\\common.lvl")
ReadDataFile("dc:ingame.lvl")
ReadDataFile("ingame.lvl")


SetMaxFlyHeight(220)
SetMaxPlayerFlyHeight (220)

SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo

SetTeamAggressiveness(CIS, 0.5)
SetTeamAggressiveness(REP, 1.0)

ReadDataFile("sound\\nab.lvl;nab2cw")



ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep2_rifleman",
"gar_inf_vanguard",
"rep_inf_ep3_engineer",
"rep_inf_ep3_sniper",
"rep_inf_ep2_pilot",
"rep_1",
"rep_fly_naboo_starfighter",
"rep_inf_ep3_marine")




ReadDataFile("dc:SIDE\\cis.lvl",
"cis_hover_aat",
"cis_inf_pilot",
"cis_hover_mtt",
"cis_fly_droidfighter_dome",
"cis_fly_fedlander_dome",
"cis_hero_darthmaul",
"cis_inf_droideka",
"cis_hover_stap",
"cis_fly_droidfighter_sc")





ReadDataFile("dc:SIDE\\heroes.lvl",
"rep_hero_ep1_obiwan")


ReadDataFile("dc:SIDE\\vehicles.lvl",
"rep_fly_naboo_starfighteradv",
"gun_walk_kaadu")




ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_laser",
"tur_bldg_tower")




ReadDataFile("SIDE\\gun.lvl",
"gun_inf_soldier",
"gun_inf_defender")




SetupTeams{
rep = {
team = REP,
units = 50,
reinforcements = 250,
soldier = { "rep_inf_ep2_pilot",9, 15},
assault = { "gar_inf_vanguard",4, 9},
engineer = { "rep_inf_ep3_engineer",4, 9},
sniper = { "rep_inf_ep3_sniper",4, 6},
officer = {"rep_inf_ep3_marine",4, 6},
special = { "rep_inf_ep2_rifleman",3, 5},
},
cis = {
team = CIS,
units = 50,
reinforcements = 250,
soldier = { "cis_inf_pilot",20, 40},
special = { "cis_inf_droideka",5, 10},
}
}

SetHeroClass(CIS, "cis_hero_darthmaul")
SetHeroClass(REP, "rep_hero_ep1_obiwan")


-- Level Stats
-- ClearWalkers()
AddWalkerType(0, 10) -- special -> droidekas
AddWalkerType(1, 20) -- 1x2 (1 pair of legs)
AddWalkerType(2, 0) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)

-- Fishies
SetNumFishTypes(12)
SetFishType(0,1.1,"fish2")
SetFishType(1,0.8,"fish3")
SetFishType(2,0.9,"fish")
SetFishType(3,0.7,"fish2")
SetFishType(4,0.3,"fish")
SetFishType(5,1.3,"fish3")
SetFishType(6,1.5,"fish")
SetFishType(7,1.9,"fish")
SetFishType(8,3.0,"fish2")
SetFishType(9,2.5,"fish3")
SetFishType(10,0.1,"fish")
SetFishType(11,0.5,"fish")
-- Birdies
SetNumBirdTypes(1)
SetBirdType(0,1.5,"bird")


local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 180)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
-- SetMemoryPoolSize("commandFlyer", 8)
SetMemoryPoolSize("EntityHover", 40)
-- SetMemoryPoolSize("commandHover", 8)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("SoldierAnimation", 400)
SetMemoryPoolSize("EntitySoundStream", 10)
SetMemoryPoolSize("EntitySoundStatic", 32)
SetMemoryPoolSize("MountedTurret", 32)
SetMemoryPoolSize("Navigator", 128)
SetMemoryPoolSize("Obstacle", 1024)
SetMemoryPoolSize("PathNode", 1024)
SetMemoryPoolSize("SoundSpaceRegion", 64)
SetMemoryPoolSize("TreeGridStack", 1024)
SetMemoryPoolSize("UnitAgent", 128)
SetMemoryPoolSize("UnitController", 128)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
--ReadDataFile("dc:NGH\\NGH.lvl", "NGH_conquest")
ReadDataFile("dc:NGH\\NGH.lvl", "NGH_conquest")
SetDenseEnvironment("true")





-- Sound

voiceSlow = OpenAudioStream("sound\\global.lvl", "all_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "gun_unit_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "all_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "cw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\nab.lvl", "nab2")
OpenAudioStream("sound\\nab.lvl", "nab2")
OpenAudioStream("sound\\nab.lvl", "nab2_emt")

-- SetBleedingVoiceOver(REP, REP, "all_off_com_report_us_overwhelmed", 1)
-- SetBleedingVoiceOver(REP, CIS, "all_off_com_report_enemy_losing", 1)
-- SetBleedingVoiceOver(CIS, REP, "cis_off_com_report_enemy_losing", 1)
-- SetBleedingVoiceOver(CIS, CIS, "cis_off_com_report_us_overwhelmed", 1)

-- SetLowReinforcementsVoiceOver(REP, REP, "all_off_defeat_im", .1, 1)
-- SetLowReinforcementsVoiceOver(REP, CIS, "all_off_victory_im", .1, 1)
-- SetLowReinforcementsVoiceOver(CIS, CIS, "cis_off_defeat_im", .1, 1)
-- SetLowReinforcementsVoiceOver(CIS, REP, "cis_off_victory_im", .1, 1)

SetOutOfBoundsVoiceOver(2, "allleaving")
SetOutOfBoundsVoiceOver(1, "cisleaving")

SetAmbientMusic(REP, 1.0, "rep_nab_amb_hunt", 0,1)
-- SetAmbientMusic(REP, 0.9, "rep_nab_amb_middle", 1,1)
-- SetAmbientMusic(REP, 0.1, "rep_nab_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_nab_amb_hunt", 0,1)
-- SetAmbientMusic(CIS, 0.9, "cis_nab_amb_middle", 1,1)
-- SetAmbientMusic(CIS, 0.1, "cis_nab_amb_end", 2,1)

SetVictoryMusic(REP, "rep_nab_amb_victory")
SetDefeatMusic (REP, "rep_nab_amb_defeat")
SetVictoryMusic(CIS, "cis_nab_amb_victory")
SetDefeatMusic (CIS, "cis_nab_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
--SetSoundEffect("BirdScatter", "birdsFlySeq1")
--SetSoundEffect("WeaponUnableSelect", "com_weap_inf_weaponchange_null")
--SetSoundEffect("WeaponModeUnableSelect", "com_weap_inf_modechange_null")
SetSoundEffect("SpawnDisplayUnitChange", "shell_select_unit")
SetSoundEffect("SpawnDisplayUnitAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplaySpawnPointChange", "shell_select_change")
SetSoundEffect("SpawnDisplaySpawnPointAccept", "shell_menu_enter")
SetSoundEffect("SpawnDisplayBack", "shell_menu_exit")


--OpeningSateliteShot
AddCameraShot(0.680750, 0.166072, 0.693115, -0.169089, -73.380493, -1.732174, -238.580643);
AddCameraShot(0.072868, 0.001731, -0.997059, 0.023689, -70.619331, 5.556262, 58.931480);
AddCameraShot(0.837230, -0.217977, 0.485349, 0.126363, 175.996017, 86.005676, -491.943848);
AddCameraShot(0.927767, -0.356048, 0.104287, 0.040022, 76.541031, 48.801895, -418.101868);
AddCameraShot(0.997553, -0.059469, -0.036696, -0.002188, -142.423355, 119.702774, 3.214967);
AddCameraShot(0.997520, -0.068435, -0.016427, -0.001127, -142.423355, 119.702774, 3.214967);
AddCameraShot(0.875007, 0.208614, 0.424945, -0.101313, -95.304901, -1.732174, -201.308670);
AddCameraShot(0.503589, -0.126071, 0.829109, 0.207563, -68.293510, 33.550327, -268.544952);
AddCameraShot(0.526527, -0.085491, -0.834915, -0.135563, 217.454544, 88.669449, 75.060295);
AddCameraShot(0.961176, 0.068786, -0.266543, 0.019075, 195.756622, 101.821358, -59.744576);
AddCameraShot(-0.247446, -0.035897, -0.958206, 0.139009, -110.134361, -1.732174, -197.794998);

end

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
do you name the node or path TeleportNode? i named the path

Re: teleporter prob... a pain.... in you know what

Posted: Tue Jan 15, 2008 12:32 am
by MasterSaitek009
I think your nodes and paths are setup right.
But make sure that you put your region "name"(In this case TeleporterRegion) in the Region Property/type box.
Not the more logical Region name box. That's the way regions work in BF2.
Go figure :?

Re: teleporter prob... a pain.... in you know what

Posted: Tue Jan 15, 2008 12:52 am
by 1z2x3c
ty... he he forgot to put it in Property/type box... my bad


now i get this:


Message Severity: 3
C:\Battlefront2\main\Battlefront2\Source\LuaCallbacks_Mission.cpp(3247)
Path "TeleportNode" node 0 out of range [0..0)

Re: teleporter prob... a pain.... in you know what

Posted: Tue Jan 15, 2008 5:29 pm
by [RDH]Zerted
I'd guess your path doesn't have any nodes. It needs at least one node.

If you keep having problems, I wrote a teleporting script because everyone was having problems implementing that tutorial. You can find the post on how to use it here: http://www.gametoast.com/forums/viewtop ... 63#p199663 (scroll up in the topic for the download link). It hasn't been 'finsihed' because I yet to write a full readme for it, but the code works well and it keeps your lua looking less cluttered.

Re: teleporter prob... a pain.... in you know what

Posted: Tue Jan 15, 2008 9:44 pm
by 1z2x3c
ty zerted, i did have a node, but it wasnt associated w/ the path.
all i had to do is click it.... wierd

Re: teleporter prob... a pain.... in you know what

Posted: Wed Jan 16, 2008 8:06 am
by Moonwolf=SotG=
this might also be a solution
inside the 'function ScriptPostLoad()
doesnt it need to be UNDER scriptpostload?

Re: teleporter prob... a pain.... in you know what

Posted: Wed Jan 16, 2008 8:37 am
by Penguin
Moonwolf=SotG= wrote:this might also be a solution
inside the 'function ScriptPostLoad()
doesnt it need to be UNDER scriptpostload?
It's inside(Or under, for you none-scripters (Although I guess it should be under, since there's no close to scriptpostload?)

If you were to put it IN it, then it would be insert :P