Page 1 of 1

Rebel Raider gametype for PC/Xbox versions - research

Posted: Thu Mar 25, 2010 10:32 pm
by Teancum
I've been trying to recreate the PSP version's Rebel Raider (though I call it Smuggler). The premise of this gametype is really simple. There are multiple "flags" to steal throughout a map - The Rebels (technically there's only one on the PSP) have to grab the objects one by one and bring it back to the capture region. The Imperials simply try to kill the Rebels. Trouble is that I can pick up the "flags", but they do not actually capture when I get to the capture region. From all I can read of the PSP's mission lua it just uses ObjectiveCTF, but I'm beginning to think this might be easier to use if a whole new objective type was coded. Below is my mission lua, which has multiple capture regions (since I thought that might be the problem). Any help/direction on this mode would be great.
Hidden/Spoiler:
[code]--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
CTF = ScriptCB_DoFile("ObjectiveCTF")
ScriptCB_DoFile("setup_teams")

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

--PostLoad, this is all done after all loading, etc.
function ScriptPostLoad()

AddDeathRegion("Death")
AddDeathRegion("Death1")
AddDeathRegion("Death2")
AddDeathRegion("Death3")
AddDeathRegion("Death4")

SetProperty ("LibCase1","MaxHealth",1000)
SetProperty ("LibCase2","MaxHealth",1000)
SetProperty ("LibCase3","MaxHealth",1000)
SetProperty ("LibCase4","MaxHealth",1000)
SetProperty ("LibCase5","MaxHealth",1000)
SetProperty ("LibCase6","MaxHealth",1000)
SetProperty ("LibCase7","MaxHealth",1000)
SetProperty ("LibCase8","MaxHealth",1000)
SetProperty ("LibCase9","MaxHealth",1000)
SetProperty ("LibCase10","MaxHealth",1000)
SetProperty ("LibCase11","MaxHealth",1000)
SetProperty ("LibCase12","MaxHealth",1000)
SetProperty ("LibCase13","MaxHealth",1000)
SetProperty ("LibCase14","MaxHealth",1000)
SetProperty ("LibCase1","CurHealth",1000)
SetProperty ("LibCase2","CurHealth",1000)
SetProperty ("LibCase3","CurHealth",1000)
SetProperty ("LibCase4","CurHealth",1000)
SetProperty ("LibCase5","CurHealth",1000)
SetProperty ("LibCase6","CurHealth",1000)
SetProperty ("LibCase7","CurHealth",1000)
SetProperty ("LibCase8","CurHealth",1000)
SetProperty ("LibCase9","CurHealth",1000)
SetProperty ("LibCase10","CurHealth",1000)
SetProperty ("LibCase11","CurHealth",1000)
SetProperty ("LibCase12","CurHealth",1000)
SetProperty ("LibCase13","CurHealth",1000)
SetProperty ("LibCase14","CurHealth",1000)

DisableBarriers("SideDoor1")
DisableBarriers("MainLibraryDoors")
DisableBarriers("SideDoor2")
DisableBarriers("SIdeDoor3")
DisableBarriers("ComputerRoomDoor1")
DisableBarriers("StarChamberDoor1")
DisableBarriers("StarChamberDoor2")
DisableBarriers("WarRoomDoor1")
DisableBarriers("WarRoomDoor2")
DisableBarriers("WarRoomDoor3")
PlayAnimation("DoorOpen01")
PlayAnimation("DoorOpen02")

ctf.OnStart = function(self)
ForceHumansOntoTeam1(true)
AllowAISpawn(ATT, false)
AddAIGoal(DEF, "Deathmatch", 1000)
end

SoundEvent_SetupTeams( ALL, 'all', IMP, 'imp' )
--This is all the actual ctf objective setup
ctf = ObjectiveCTF:New{teamATT = ATT, teamDEF = DEF, textATT = "game.modes.CTF", textDEF = "game.modes.CTF2"}
ctf:AddFlag{name = "item1", homeRegion = "", captureRegion = "capture1"}
ctf:AddFlag{name = "item2", homeRegion = "", captureRegion = "capture2"}
ctf:AddFlag{name = "item3", homeRegion = "", captureRegion = "capture3"}
ctf:AddFlag{name = "item4", homeRegion = "", captureRegion = "capture4"}
ctf:AddFlag{name = "item5", homeRegion = "", captureRegion = "capture5"}
ctf:AddFlag{name = "item6", homeRegion = "", captureRegion = "capture6"}
ctf:Start()

end

function ScriptInit()
-- Designers, these two lines *MUST* be first!
SetPS2ModelMemory(3990000)
ReadDataFile("ingame.lvl")

-- These variables do not change
ATT = 1
DEF = 2
ALL = ATT
IMP = DEF

SetMapNorthAngle(180, 1)
SetMaxFlyHeight(25)
SetMaxPlayerFlyHeight (25)
AISnipeSuitabilityDist(30)

ReadDataFile("sound\\cor.lvl;cor1gcw")
ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer",
"imp_inf_dark_trooper",
"imp_hero_emperor")
ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman",
"all_inf_rocketeer",
"all_inf_engineer",
"all_inf_sniper",
"all_inf_officer",
"all_inf_wookiee",
"all_hero_luke_jedi")
ReadDataFile("SIDE\\rep.lvl",
"rep_fly_assault_DOME",
"rep_fly_gunship_DOME")
ReadDataFile("SIDE\\tur.lvl",
"tur_bldg_laser")

-- set up teams
SetupTeams{
imp = {
team = IMP,
units = 32,
reinforcements = 8,
soldier = { "imp_inf_rifleman",7, 25},
assault = { "imp_inf_rocketeer",1, 4},
engineer = { "imp_inf_engineer",1, 4},
sniper = { "imp_inf_sniper",1, 4},
officer = {"imp_inf_officer",1, 4},
special = { "imp_inf_dark_trooper",1, 4},
},
all = {
team = ALL,
units = 32,
reinforcements = -1,
soldier = { "all_inf_rifleman",7, 25},
assault = { "all_inf_rocketeer",1, 4},
engineer = { "all_inf_engineer",1, 4},
sniper = { "all_inf_sniper",1, 4},
officer = {"all_inf_officer",1, 4},
special = { "all_inf_wookiee",1, 4},
}
}

-- Level Stats
ClearWalkers()
AddWalkerType(0, 0) -- 8 droidekas (special case: 0 leg pairs)
AddWalkerType(1, 0) --
AddWalkerType(2, 0) -- 2 spider walkers with 2 leg pairs each
AddWalkerType(3, 0) -- 2 attes with 3 leg pairs each
local weaponCnt = 220
SetMemoryPoolSize("Aimer", 15)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 250)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 19)
SetMemoryPoolSize("EntityFlyer", 4)
SetMemoryPoolSize("EntityLight", 96)
SetMemoryPoolSize("EntitySoundStream", 10)
SetMemoryPoolSize("EntitySoundStatic", 0)
SetMemoryPoolSize("FlagItem", 2)
SetMemoryPoolSize("MountedTurret", 16)
SetMemoryPoolSize("Navigator", 50)
SetMemoryPoolSize("Obstacle", 400)
SetMemoryPoolSize("PathFollower", 50)
SetMemoryPoolSize("PathNode", 256)
SetMemoryPoolSize("ShieldEffect", 0)
SetMemoryPoolSize("SoundSpaceRegion", 38)
SetMemoryPoolSize("TentacleSimulator", 8)
SetMemoryPoolSize("TreeGridStack", 140)
SetMemoryPoolSize("UnitAgent", 50)
SetMemoryPoolSize("UnitController", 50)
SetMemoryPoolSize("Weapon", weaponCnt)

SetSpawnDelay(10.0, 0.25)
ReadDataFile("cor\\cor1.lvl")
ReadDataFile("cor\\cor1a.lvl","cor1_smuggler")
AddDeathRegion("DeathRegion1")

-- Sound

voiceSlow = OpenAudioStream("sound\\global.lvl", "all_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)
voiceQuick = OpenAudioStream("sound\\global.lvl", "all_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "imp_unit_vo_quick", voiceQuick)
OpenAudioStream("sound\\global.lvl", "gcw_music")
OpenAudioStream("sound\\cor.lvl", "cor1")
OpenAudioStream("sound\\cor.lvl", "cor1")

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

SetAmbientMusic(ALL, 1.0, "all_cor_amb_start", 0,1)
SetAmbientMusic(ALL, 0.9, "all_cor_amb_middle", 1,1)
SetAmbientMusic(ALL, 0.1, "all_cor_amb_end", 2,1)
SetAmbientMusic(IMP, 1.0, "imp_cor_amb_start", 0,1)
SetAmbientMusic(IMP, 0.9, "imp_cor_amb_middle", 1,1)
SetAmbientMusic(IMP, 0.1, "imp_cor_amb_end", 2,1)
SetVictoryMusic(ALL, "all_cor_amb_victory")
SetDefeatMusic (ALL, "all_cor_amb_defeat")
SetVictoryMusic(IMP, "imp_cor_amb_victory")
SetDefeatMusic (IMP, "imp_cor_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
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")



SetAttackingTeam(ATT)


AddCameraShot(0.419938, 0.002235, -0.907537, 0.004830, -15.639358, 5.499980, -176.911179);
AddCameraShot(0.994506, 0.104463, -0.006739, 0.000708, 1.745251, 5.499980, -118.700668);
AddCameraShot(0.008929, -0.001103, -0.992423, -0.122538, 1.366768, 16.818106, -114.422173);
AddCameraShot(0.761751, -0.117873, -0.629565, -0.097419, 59.861904, 16.818106, -81.607773);
AddCameraShot(0.717110, -0.013583, 0.696703, 0.013197, 98.053314, 11.354497, -85.857857);
AddCameraShot(0.360958, -0.001053, -0.932577, -0.002721, 69.017578, 18.145807, -56.992413);
AddCameraShot(-0.385976, 0.014031, -0.921793, -0.033508, 93.111061, 18.145807, -20.164375);
AddCameraShot(0.695468, -0.129569, -0.694823, -0.129448, 27.284357, 18.145807, -12.377695);
AddCameraShot(0.009002, -0.000795, -0.996084, -0.087945, 1.931320, 13.356332, -16.410583);
AddCameraShot(0.947720, -0.145318, 0.280814, 0.043058, 11.650738, 16.955814, 28.359180);
AddCameraShot(0.686380, -0.127550, 0.703919, 0.130810, -30.096384, 11.152356, -63.235146);
AddCameraShot(0.937945, -0.108408, 0.327224, 0.037821, -43.701199, 8.756138, -49.974789);
AddCameraShot(0.531236, -0.079466, -0.834207, -0.124787, -62.491230, 10.305247, -120.102989);
AddCameraShot(0.452286, -0.179031, -0.812390, -0.321572, -50.015198, 15.394646, -114.879379);
AddCameraShot(0.927563, -0.243751, 0.273918, 0.071982, 26.149965, 26.947924, -46.834148);
end

[/code]

Re: Rebel Raider gametype for PC/Xbox versions - research

Posted: Fri Mar 26, 2010 10:01 am
by Master_Ben
From ObjectiveCTF.lua:
Hidden/Spoiler:
OnEnterRegion(
--when a carrier enters the flag's capture region...
function(region, carrier)
if self.isComplete then return end

if not CanCharacterInteractWithFlag(carrier) then return end

--check to see if he's carrying this flag and is on an enemy team, and
--the flag's capture region corresponds to this region
for i, f in pairs(self.flags) do
if f.carrier == carrier and string.lower(f.captureRegion) == string.lower(GetRegionName(region)) then
local flagPtr = GetObjectPtr(f.name)
local flagTeam = GetObjectTeam(f.name)
local carrierTeam = GetCharacterTeam(carrier)

if flagTeam ~= carrierTeam then
--print("in OnEnterRegion()")
CaptureFlag(f, carrierTeam)
end
end
end
end,
flag.captureRegion
)
end
I'd say, edit this code and put some simple notifiers (I'd use ShowMessageText("blahblahblah")) in each of the conditional statements. This way, you'll be able to see how far the game logic is taking the function before it stops working and keeps from getting to the "CaptureFlag" line itself. From there, you can focus on tweaking just one part of the code.
Did I word that right? sorry, way too little sleep.

Re: Rebel Raider gametype for PC/Xbox versions - research

Posted: Fri Mar 26, 2010 10:05 am
by Teancum
Heh, the old Print-to-Debug. Probably best. I'll have to write some debug localization strings, but that's not too big of a deal. Do you mind posting all of objectiveCTF.lua? I'm at work and can't access my home PC.

Also - anyone know what GetObjectPtr() does? I've never had to use it.

Re: Rebel Raider gametype for PC/Xbox versions - research

Posted: Fri Mar 26, 2010 10:07 am
by Master_Ben
Sure. Picked that line series as the most relevant, but I haven't looked at the whole thing (below that point) myself.
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

ScriptCB_DoFile("Objective")
ScriptCB_DoFile("SoundEvent_ctf")

--=============================
-- CaptureFlag
-- Prototype for a captureable flag in the game world
--=============================
CaptureFlag =
{
-- required external fields:
name = nil, -- Name of the flag object in the level
captureRegion = nil, -- Name of the region where the flag needs to be carried to be captured. Should never be set to nil

-- optional external fields:
homeRegion = nil, -- Name of the region where the flag will respawn back to. If nil, then it never respawns.
capRegionMarker = "hud_objective_icon_circle", -- Name of the icon used to mark the capture point on the mini-map
capRegionMarkerScale = 3.0, -- How big the capRegionMarker should be on the minimap
capRegionDummyObjectATT = nil, --need dummy objects so we can add an in-HUD marker (regions can't be marked in the HUD currently...it's a long story)
capRegionDummyObjectDEF = nil,
mapIcon = "hud_target_flag_onscreen", -- Texture name of the icon that appears on the map
mapIconScale = 3.0, -- How big to draw the map icon
}

function CaptureFlag:New(o)
o = o or {}
setmetatable(o, self)
self.__index = self
return o
end

--=============================
-- ObjectiveCTF
-- Handles the logic for a capture the flag game
--=============================
ObjectiveCTF = Objective:New
{
-- external values
captureLimit = 5,
neutralFlagMessage = "game.flag.neutral.",
enemyFlagMessage = "game.flag.enemy.",
friendFlagMessage = "game.flag.friend.",
}


--
-- Add a flag to the game
-- Caller should send AddFlag() a table that corresponds to the CaptureFlag prototype (seen above)
--
function ObjectiveCTF:AddFlag(flagParams)
-- make sure we have a table to add the flag to
self.flags = self.flags or {}

--error check the params
assert(flagParams.name, "ERROR: no name specified for the flag!")
assert(flagParams.captureRegion, "ERROR: flag missing capture region name")
assert(GetRegion(flagParams.captureRegion), "ERROR: capture region for a flag does not exist in map")
if flagParams.homeRegion == "" then
flagParams.homeRegion = nil --because designers sometimes use "" to specify no home region
end
if flagParams.homeRegion and not GetRegion(flagParams.homeRegion) then
--NOTE: it *is* valid to have a nil homeRegion
assert(false, "WARNING: Home region for a flag does not exist in map!") end
flagParams.name = string.lower(flagParams.name)

-- add a new flag to the list of flags
self.flags[flagParams.name] = CaptureFlag:New(flagParams)

end


-- DESIGNERS: Override these functions if necessary
function ObjectiveCTF:OnCapture(flag)

end

function ObjectiveCTF:OnReturn(flag)

end

function ObjectiveCTF:OnPickup(flag)

end

function ObjectiveCTF:OnDrop(flag)

end

function ObjectiveCTF:OnReset(flag)

end

-- Get game time limit as set in game options menu, if any. 0 if none.
function ObjectiveCTF:GetGameTimeLimit()
return ScriptCB_GetCTFMaxTimeLimit()
end

function ObjectiveCTF:GameOptionsTimeLimitUp()
local team1pts = GetTeamPoints(1)
local team2pts = GetTeamPoints(2)
if ( team1pts > team2pts ) then
MissionVictory(1)
elseif ( team1pts < team2pts ) then
MissionVictory(2)
else
--tied, so victory for both
MissionVictory({1,2})
end
end


--
-- Initialize the capture objective
--
function ObjectiveCTF:Start()
--=============================
-- local functions
--=============================
--
-- gets the opposite team from what you passed in
--
local GetOpposingTeam = function(team)
if team == self.teamATT then
return self.teamDEF
else
return self.teamATT
end
end

--
-- message generator
--
local FlagMessage = function(flag, message)
if not self.multiplayerRules then return end --ignore flag messages in single player

local flagTeam = GetObjectTeam(flag.name)
if flagTeam == 0 then
if self.neutralFlagMessage then
--broadcast a neutral message to everyone
ShowMessageText(self.neutralFlagMessage .. message)
end
else
--setup "friendTeam" to be the flag's team, and "enemyTeam" to be the other team
local friendTeam = flagTeam
local enemyTeam = GetOpposingTeam(friendTeam)

--send appropriate localized messages to each team
if self.friendFlagMessage then
ShowMessageText(self.friendFlagMessage .. message, friendTeam)
end
if self.enemyFlagMessage then
ShowMessageText(self.enemyFlagMessage .. message, enemyTeam)
end

local missionTime = ScriptCB_GetMissionTime()
local timeSinceLastPlayed = missionTime - self.lastVOPlayTime
if self.multiplayerRules and (timeSinceLastPlayed > 3.0) then
-- I think brad is working under a different model than I am
-- For me, the attacking team is the one taking the flag (and of opposite team of the flag)
SoundEvent_BroadcastVO( message, enemyTeam, friendTeam )
self.lastVOPlayTime = missionTime
end
end
end


local UpdateMarkerPulses = function(flag)
if not flag.mapIcon then
return end

local flagTeam = GetObjectTeam(flag.name)
local carrierTeam = 0
if flagTeam ~= 0 then
carrierTeam = GetOpposingTeam(flagTeam)
end

--TODO: update ObjectiveCTF to take advantage of self.capRegionDummyObjectATT and self.capRegionDummyObjectDEF
print("updating markers for flag:", flag.name)
if flag.carrier then
print("flag carrier")
--no marker on the flag, yes marker on the capture region
MapRemoveEntityMarker(flag.name)
MapAddRegionMarker(GetRegion(flag.captureRegion), flag.capRegionMarker, 4.0,
carrierTeam, "YELLOW", false, false, true)
else
print("no carrier")
--yes marker on the flag, no marker on the capture region
MapAddEntityMarker(flag.name, flag.mapIcon, 4.0, carrierTeam, "YELLOW", true, false, true, true)
MapRemoveRegionMarker(GetRegion(flag.captureRegion))
end
end


local CaptureFlag = function(flag, carrierTeam)
self:OnCapture(flag)
local flagPtr = GetObjectPtr(flag.name)
AddFlagCapturePoints(GetFlagCarrier(flag.name))
flag.carrier = nil
UpdateMarkerPulses(flag)
FlagMessage(flag, "captured")
AddTeamPoints(carrierTeam, 1)
KillObject(flagPtr)
end


local ReturnFlag = function(flag, carrierTeam)
self:OnReturn(flag)
local flagPtr = GetObjectPtr(flag.name)
flag.carrier = nil
UpdateMarkerPulses(flag)
FlagMessage(flag, "returned")
KillObject(flagPtr)
print( "------------ SHOULD HAVE PLAYED RETURN VO" )
end

--==========
-- Set the number of guys in the level to number in game options
--==========
ScriptCB_SetNumBots(ScriptCB_GetCTFNumBots())


--===============================
-- Initialization logic
--===============================
--showTeamPoints defaults to true in multiplayer mode if the designer doesn't specify it
if self.showTeamPoints == nil and self.multiplayerRules then
self.showTeamPoints = true
else
self.showTeamPoints = false
end

--initialize the base objective data
Objective.Start(self)

-- initialize internal values
self.flags = self.flags or {}

self.lastVOPlayTime = -10000.0

-- error checking
numFlags = 0
for i, f in pairs(self.flags) do
numFlags = numFlags + 1
end
if(numFlags == 0) then
assert(false, "ERROR: no flags were added to the objective")
return
end

if self.multiplayerRules then
self.captureLimit = ScriptCB_GetCTFCaptureLimit()
SetReinforcementCount(self.teamATT, -1)
SetReinforcementCount(self.teamDEF, -1)
SetFlagGameplayType("2flag")
else
SetFlagGameplayType("campaign")
end


--make sure the flags are colored properly when they're dropped
SetClassProperty("com_item_flag", "DroppedColorize", 1)

-- activate map markers, set region properties on the c++ objects, activate the regions, etc..
self.AIGoals = {}
for i, flag in pairs(self.flags) do
local flagPtr = GetObjectPtr(flag.name)
assert(flagPtr, "ERROR: flag "..flag.name.." does not exist in the map")
local flagTeam = GetObjectTeam(flag.name)

--Add AI Goals
if self.AIGoalWeight > 0.0 then
table.insert(self.AIGoals, AddAIGoal(GetOpposingTeam( flagTeam ), "CTFOffense", 70*self.AIGoalWeight, flag.captureRegion, flagPtr))
if flag.homeRegion then
table.insert(self.AIGoals, AddAIGoal(flagTeam, "CTFDefense", 30*self.AIGoalWeight, flagPtr))
else
--if a flag has no home region, we can't put it in traditional CTFDefense mode, but we can put
--it in generic "Defend this object" mode, so they'll put up a parameter around the flag
--and shoot anyone who gets near
table.insert(self.AIGoals, AddAIGoal(flagTeam, "Defend", 30*self.AIGoalWeight, flag.name))
end
end

ActivateRegion(flag.captureRegion)

--always display two solid markers: one for the flag and one for the capture region
local displayTeam = 0
if flagTeam ~= 0 then
displayTeam = GetOpposingTeam(flagTeam)
end

--initialize the "pulse" effect
UpdateMarkerPulses(flag)

if(flag.homeRegion) then
SetProperty(i, "HomeRegion", flag.homeRegion)
ActivateRegion(flag.homeRegion)
end

SetProperty(flagPtr, "AllowTeamPickup", 0) --disallow teammates from picking up their own flags

--just in case the player is standing right where the flag spawns when the objective starts...
flag.carrier = GetFlagCarrier(flag.name)
if flag.carrier then
UpdateMarkerPulses(flag)
FlagMessage(flag, "taken")
self:OnPickup(flag)
end
end


--=======================================
-- Event responses
--=======================================

-- flag reset to starting position
OnFlagReset(
function (flagPtr)
if self.isComplete then return end

local flagName = GetEntityName(flagPtr)
local flag = self.flags[flagName]

if not flag then return end --this particular flag is not part of this goal

-- set as not moved
flag.carrier = nil

-- force enter-region event for anyone in the home region
if flag.homeRegion then
DeactivateRegion(flag.homeRegion)
ActivateRegion(flag.homeRegion)
end
UpdateMarkerPulses(flag)
self:OnReset(flag)
end
)


OnFlagPickUp(
function(flagPtr, carrierObj)
if self.isComplete then return end

local flagName = GetEntityName(flagPtr)
local flag = self.flags[flagName]
if not flag then return end --this particular flag is not part of this goal
local carrierTeam = GetCharacterTeam(carrierObj)

flag.carrier = carrierObj


if GetObjectTeam(flag.name) == carrierTeam then
--if the flag is in its home region, return it to the stand
if flag.homeRegion and IsCharacterInRegion(carrierObj, flag.homeRegion) then
ReturnFlag(flag, carrierTeam)
end
else
--if the flag is in its capture region, cap the flag
if IsCharacterInRegion(carrierObj, flag.captureRegion) and CanCharacterInteractWithFlag(carrierObj) then
--print("carrierObj:", carrierObj)
--print("inside OnFlagPickUp()")
CaptureFlag(flag, carrierTeam)
end
end

UpdateMarkerPulses(flag)
FlagMessage(flag, "taken")

--play a little ditty in campaign mode
if not self.multiplayerRules then
BroadcastVoiceOver("common_objComplete")
end

self:OnPickup(flag)
end
)


OnFlagDrop(
function(flagPtr, carrierObj)
if self.isComplete then return end

local flagName = GetEntityName(flagPtr)
local flag = self.flags[flagName]
if not flag then return end --this particular flag is not part of this goal
local carrierTeam = GetCharacterTeam(carrierObj)

flag.carrier = nil

UpdateMarkerPulses(flag)
FlagMessage(flag, "dropped")
self:OnDrop(flag)
end
)


for i, flag in pairs(self.flags) do
if(flag.homeRegion) then
OnEnterRegion(
--when a carrier enters the flag's home region...
function(region, carrier)
if self.isComplete then return end

--check to see if he's carrying this flag, and if the flag's home region
--corresponds to this region
for i, f in pairs(self.flags) do
if f.carrier == carrier and string.lower(f.homeRegion) == string.lower(GetRegionName(region)) then
local flagPtr = GetObjectPtr(f.name)
local flagTeam = GetObjectTeam(f.name)
local carrierTeam = GetCharacterTeam(carrier)
if flagTeam == carrierTeam then
ReturnFlag(f, carrierTeam)
end
end
end
end,
flag.homeRegion
)
end

OnEnterRegion(
--when a carrier enters the flag's capture region...
function(region, carrier)
if self.isComplete then return end

if not CanCharacterInteractWithFlag(carrier) then return end

--check to see if he's carrying this flag and is on an enemy team, and
--the flag's capture region corresponds to this region
for i, f in pairs(self.flags) do
if f.carrier == carrier and string.lower(f.captureRegion) == string.lower(GetRegionName(region)) then
local flagPtr = GetObjectPtr(f.name)
local flagTeam = GetObjectTeam(f.name)
local carrierTeam = GetCharacterTeam(carrier)

if flagTeam ~= carrierTeam then
--print("in OnEnterRegion()")
CaptureFlag(f, carrierTeam)
end
end
end
end,
flag.captureRegion
)
end

-- team points change
OnTeamPointsChange(
function (team, points)
if self.isComplete then return end

if points >= self.captureLimit then
for i, flag in pairs(self.flags) do
MapRemoveRegionMarker(flag.captureRegion)
MapRemoveEntityMarker(flag.name)
end
--SetFlagGameplayType("none") -- moved to objective:start
self:Complete(team)
end
end
)

end

gSoundEventsCTF_src = {
all = {
taken_att = "all_impFlag_take_all",
dropped_att = "all_impFlag_drop_all",
taken_def = "all_allFlag_take_imp",
dropped_def = "all_allFlag_drop_imp",
returned_att = "all_allFlag_returned",
returned_def = "all_impFlag_returned",
captured_att = "all_allFlag_score",
captured_def = "all_impFlag_score",
},
imp = {
taken_att = "imp_allFlag_take_imp",
dropped_att = "imp_allFlag_drop_imp",
taken_def = "imp_impFlag_take_all",
dropped_def = "imp_impFlag_drop_all",
returned_att = "imp_impFlag_returned",
returned_def = "imp_allFlag_returned",
captured_att = "imp_impFlag_score",
captured_def = "imp_allFlag_score",
},
rep = {
taken_att = "rep_cisFlag_take_rep",
dropped_att = "rep_cisFlag_drop_rep",
taken_def = "rep_repFlag_take_cis",
dropped_def = "rep_repFlag_drop_cis",
returned_att = "rep_repFlag_returned",
returned_def = "rep_cisFlag_returned",
captured_att = "rep_repFlag_score",
captured_def = "rep_cisFlag_score",
},
cis = {
taken_att = "cis_repFlag_take_cis",
dropped_att = "cis_repFlag_drop_cis",
taken_def = "cis_cisFlag_take_rep",
dropped_def = "cis_cisFlag_drop_rep",
returned_att = "cis_cisFlag_returned",
returned_def = "cis_repFlag_returned",
captured_att = "cis_cisFlag_score",
captured_def = "cis_repFlag_score",
},
}
Also, You could do it through printing multiple lines (one for the first if-then, two for the second, etc...) if you don't feel like making the localization.

Re: Rebel Raider gametype for PC/Xbox versions - research

Posted: Fri Mar 26, 2010 11:47 am
by Teancum
I'm debugging mostly through the Xbox, which means I can't use Print(). I want to make sure it works there - then I know it'll work on the PC.

Re: Rebel Raider gametype for PC/Xbox versions - research

Posted: Fri Mar 26, 2010 12:45 pm
by Maveritchell
Teancum wrote:Also - anyone know what GetObjectPtr() does? I've never had to use it.
From Battlefront2_scripting_system.doc:
GetObjectPtr (name) → object
This function returns the Object with the specified name, or nil if none exists.
It's one of a few functions that returns object properties.

Tean, if it were me I'd just recode your new mode. It's not incredibly difficult - all you really want is a trigger region that kills off any flags brought into it. You can use the same code to increment (or not) a ticker that keeps track of how many flags scored or (more ideal in my opinion) how many flags you have left.

Re: Rebel Raider gametype for PC/Xbox versions - research

Posted: Fri Mar 26, 2010 2:09 pm
by Teancum
Yeah, that's kindof what I'm thinking too. It's going to be easier to do things from scratch. I think the CTF code requires 1 flag per team anyhow, as the player team has -- for a score, whereas the enemy team had an actual score.