Really frustrated. Sometimes when I test my map, my code works fine. Other times, even if I don't change the code at all, it doesn't. It always seems to revolve around my use of GetWorldPosition (and sometimes GetCharacterUnit). But I can't figure out any pattern to it. Here's my ScriptPostLoad:
Hidden/Spoiler:
[code]
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("setup_teams")
-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
TAR = 3;
CIV = 4;
-- These variables do not change
ATT = REP;
DEF = CIS;
function ScriptPostLoad()
--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"}
--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:Start()
--LET'S KILL SOME TARGETS - BEGIN KTT
--going to define almost all of my timers and local variables here
-------------------------------------------------------------------------------------------------------
--Behaviour: Team 3 is the target team. Individual units will spawn and be marked for the player to kill.
-- Team 4 is the civilian team. A large number of these units will spawn all over the map and
-- pretty much just stand/walk around. I may add functionality later which permits them to run
-- around panicking for a minute or so, once shots are fired.
-- Team 2 is the guard team. Currently they stick close to the selected target, but I plan to
-- change this so that they will patrol the map in small groups until shots are fired. They will
-- go aggro on the player if the player opens fire on *anyone*, and chase the player around until
-- the player is able to hide from them for a sufficient length of time. At that point they will
-- return to their guard duties until another fight starts.
-- Team 1 is just the player. The player starts out friendly to all other teams except Team 3,
-- which he is neutral toward.
--Possible Future Teams: - Cameras/Turrets
-- - Backup for Team 1
-- - Rival assassins?
-------------------------------------------------------------------------------------------------------
print("\n\n----BEGIN KILL THE TARGET----")
print("Everything below this point is for debugging\n")
deftimer = CreateTimer("deftimer")
SetTimerValue(deftimer, 1.0)
evadetimer = CreateTimer("evadetimer")
SetTimerValue(evadetimer, 25.0)
noevadetimer = CreateTimer("noevadetimer")
SetTimerValue(noevadetimer, 10.0)
switchtargettimer1 = CreateTimer("switchtargettimer1")
SetTimerValue(switchtargettimer1, 0.5)
switchtargettimer2 = CreateTimer("switchtargettimer2")
SetTimerValue(switchtargettimer2, 0.5)
i = 1
numTargetsDone = 0
numInnocentsKilled = 0
xplayer,yplayer,zplayer = 0
xenemy,yenemy,zenemy = 0
detected = 0
endGame = false
AllowAISpawn(1, false)
ForceHumansOntoTeam1()
AICanCaptureCP("cp1", 2, false)
AICanCaptureCP("cp2", 2, false)
AICanCaptureCP("cp3", 2, false)
AICanCaptureCP("cp4", 2, false)
AICanCaptureCP("cp1", 3, false)
AICanCaptureCP("cp2", 3, false)
AICanCaptureCP("cp3", 3, false)
AICanCaptureCP("cp4", 3, false)
AICanCaptureCP("cp1", 4, false)
AICanCaptureCP("cp2", 4, false)
AICanCaptureCP("cp3", 4, false)
AICanCaptureCP("cp4", 4, false)
playerone = GetTeamMember(1,0) --Name the player
target1 = GetTeamMember(3,0) --Begin Target setup
target2 = GetTeamMember(3,1)
target3 = GetTeamMember(3,2)
SelectCharacterClass(target1, "cis_hero_darthmaul")
SelectCharacterClass(target2, "cis_hero_countdooku")
SelectCharacterClass(target3, "cis_hero_jangofett")
SpawnCharacter(target1, GetPathPoint("cp4_spawn", 0))
SpawnCharacter(target2, GetPathPoint("cp2_spawn", 0))
SpawnCharacter(target3, GetPathPoint("cp3_spawn", 0))
print("Target setup complete")
SetClassProperty("cis_hero_darthmaul", "MaxSpeed", 4.0) --Initial speed settings: Targets and guards walk at a brisk pace, civilians kind of wander
SetClassProperty("cis_hero_countdooku", "MaxSpeed", 4.0)
SetClassProperty("cis_hero_jangofett", "MaxSpeed", 4.0)
SetClassProperty("cis_inf_rifleman", "MaxSpeed", 4.0)
SetClassProperty("cis_inf_engineer", "MaxSpeed", 2.0)
AddAIGoal(3, "deathmatch", 100)
AddAIGoal(4, "deathmatch", 100)
dummy = CreateTimer("dummy")
SetTimerValue(dummy, 0.5)
StartTimer(dummy)
print("Timer dummy elapsed")
OnTimerElapse(
function(timer)
ClearAIGoals(2)
AddAIGoal(2, "follow", 600, GetCharacterUnit(target1))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target2))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target3))
--MapAddEntityMarker(GetCharacterUnit(target1), "hud_objective_icon_circle", 5, 1, "RED", true, true, true) --map marker
DestroyTimer(dummy)
print("Map marker created")
end,
dummy
)
SetTeamAsFriend(1,2)
SetTeamAsNeutral(1,3)
SetTeamAsFriend(1,4)
SetTeamAsFriend(2,1)
SetTeamAsFriend(2,3)
SetTeamAsFriend(2,4)
SetTeamAsFriend(3,1)
SetTeamAsFriend(3,2)
SetTeamAsFriend(3,4)
SetTeamAsFriend(4,1)
SetTeamAsFriend(4,2)
SetTeamAsFriend(4,3)
print("Team diplomacy set")
print("State: Anonymous")
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
AllowAISpawn(3, false)
ShowMessageText("level.jer.kill1")
end
end
)
-----------------------------------------------------------------------------------------------------
-- This section will handle all character deaths, checking for civilian losses and target elimination
-----------------------------------------------------------------------------------------------------
personKill = OnCharacterDeath(
function(character, killer)
if GetCharacterTeam(character) == 4 and GetCharacterTeam(killer) == 1 then --CIVILIANS KILLED
ShowMessageText("level.jer.innocentkill")
StartTimer(evadetimer)
numInnocentsKilled = numInnocentsKilled + 1
if numInnocentsKilled < 5 and numInnocentsKilled > 0 then --CIVILIAN MURDER MESSAGE
ShowMessageText("level.jer.innocentcount-" .. numInnocentsKilled)
print(numInnocentsKilled .. " innocents killed, " .. (5 - numInnocentsKilled) .. " more allowed.")
end
elseif character == target1 and numTargetsDone == 0 then --FIRST TARGET KILLED
numTargetsDone = 1
ShowMessageText("level.jer.evade")
elseif character == target2 and numTargetsDone == 1 then --SECOND TARGET KILLED
numTargetsDone = 2
ShowMessageText("level.jer.evade")
elseif character == target3 and numTargetsDone == 2 then --THIRD TARGET KILLED
numTargetsDone = 3
ShowMessageText("level.jer.evade")
end
if numInnocentsKilled >= 5 then --TOO MANY CIVILIANS DEAD
StartTimer(deftimer)
print("Too many civs killed. Starting defeat timer...")
end
if GetNumTeamMembersAlive(1) == 0 then --PLAYER KILLED
StartTimer(deftimer)
print("Starting defeat timer...")
elseif numTargetsDone == 3 and endGame == false then --ALL TARGETS DEAD
endGame = true
ClearAIGoals(2)
AddAIGoal(2, "destroy", 1000, GetCharacterUnit(killer))
ActivateRegion("choppa")
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
MapAddRegionMarker("choppa", "hud_objective_icon_circle", 5, 1, "BLUE", true, true, true)
print("Target eliminated")
print("Safe zone activated")
ShowMessageText("level.jer.escape")
end
end
)
function EnemyDistance() --Do anonymity checking... basically try to figure out whether the player is sufficiently far away from all the guards
detected = 0
for unitnum = 0, 9 do --make sure this is updated to reflect the number of people on team 2, or face the consequences
enemynum = GetTeamMember(2,unitnum)
xenemy,yenemy,zenemy = GetWorldPosition(GetCharacterUnit(enemynum))
print("\nGetting enemy X: " .. xenemy)
print("Getting enemy Y: " .. yenemy)
print("Getting enemy Z: " .. zenemy)
if (math.abs(xenemy - xplayer) <= 16) and (math.abs(zenemy - zplayer) <= 16) then
print("Enemy too close")
ShowMessageText("level.jer.noevade")
StartTimer(noevadetimer)
detected = detected + 1
break
else
print("Enemy far enough away, moving on")
end
end
if detected == 0 then
print("State: Anonymous")
SetTeamAsFriend(1,2)
SetTeamAsFriend(2,1)
ClearAIGoals(2)
ShowMessageText("level.jer.evadecomplete")
if numTargetsDone == 1 then
StartTimer(switchtargettimer1)
elseif numTargetsDone == 2 then
StartTimer(switchtargettimer2)
elseif numTargetsDone == 0 then
AddAIGoal(2, "follow", 600, GetCharacterUnit(target1))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target2))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target3))
elseif numTargetsDone >= 3 then
AddAIGoal(2, "deathmatch", 100)
end
end
end
OnTimerElapse(
function(timer)
xplayer,yplayer,zplayer = GetWorldPosition(GetCharacterUnit(playerone))
print("\nGetting player X again: " .. xplayer)
print("Getting player Y again: " .. yplayer)
print("Getting player Z again: " .. zplayer)
StopTimer(noevadetimer)
SetTimerValue(noevadetimer, 15)
EnemyDistance()
end,
noevadetimer)
OnTimerElapse(
function(timer)
xplayer,yplayer,zplayer = GetWorldPosition(GetCharacterUnit(playerone))
print("\nGetting player X: " .. xplayer)
print("Getting player Y: " .. yplayer)
print("Getting player Z: " .. zplayer)
StopTimer(evadetimer)
SetTimerValue(evadetimer, 25)
EnemyDistance()
end,
evadetimer
)
OnTimerElapse(
function(timer)
if numTargetsDone == 1 then
StopTimer(switchtargettimer1)
--SetTimerValue(switchtargettimer1, 0.5)
ClearAIGoals(2)
AddAIGoal(2, "follow", 700, GetCharacterUnit(target2))
AddAIGoal(2, "follow", 300, GetCharacterUnit(target3))
ClearAIGoals(3)
AddAIGoal(3, "deathmatch", 100)
--MapAddEntityMarker(GetCharacterUnit(target2), "hud_objective_icon_circle", 5, 1, "RED", true, true, true) --map marker
print("Second map marker created")
ShowMessageText("level.jer.kill2")
end
end,
switchtargettimer1)
OnTimerElapse(
function(timer)
if numTargetsDone == 2 then
StopTimer(switchtargettimer2)
--SetTimerValue(switchtargettimer2, 0.5)
ClearAIGoals(2)
AddAIGoal(2, "follow", 1000, GetCharacterUnit(target3))
ClearAIGoals(3)
AddAIGoal(3, "deathmatch", 100)
--MapAddEntityMarker(GetCharacterUnit(target3), "hud_objective_icon_circle", 5, 1, "RED", true, true, true) --map marker
print("Third map marker created")
ShowMessageText("level.jer.kill3")
end
end,
switchtargettimer2)
victorycheck = OnEnterRegion(
function(region, character)
if GetCharacterTeam(character) == 1 then
MissionVictory(1)
print("Congration you done it (victory)")
end
end,
"choppa"
)
dmgcheck = OnObjectDamage(function(object, damager)
print("Check damage")
if GetObjectTeam(GetCharacterUnit(damager)) == 1 and detected == 0 then
detected = 1
StartTimer(evadetimer)
ClearAIGoals(3)
AddAIGoal(3, "follow", 500, "cp4") --he'll run away
AddAIGoal(3, "follow", 500, "cp3")
ClearAIGoals(2)
AddAIGoal(2, "destroy", 700, GetCharacterUnit(damager)) --and they'll try to kill you
AddAIGoal(2, "follow", 300, GetCharacterUnit(target1))
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
SetClassProperty("cis_inf_rifleman", "MaxSpeed", 5.4)
print("State: Detected")
end
end)
OnTimerElapse(
function(timer)
MissionDefeat(1)
print("Mission defeat")
DestroyTimer(deftimer)
end,
deftimer
)
DisableAIAutoBalance()
--END KTT
SetUberMode(1);
--EnableSPHeroRules()
end
[/code]
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--
-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("setup_teams")
-- REP Attacking (attacker is always #1)
REP = 1;
CIS = 2;
TAR = 3;
CIV = 4;
-- These variables do not change
ATT = REP;
DEF = CIS;
function ScriptPostLoad()
--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"}
--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:Start()
--LET'S KILL SOME TARGETS - BEGIN KTT
--going to define almost all of my timers and local variables here
-------------------------------------------------------------------------------------------------------
--Behaviour: Team 3 is the target team. Individual units will spawn and be marked for the player to kill.
-- Team 4 is the civilian team. A large number of these units will spawn all over the map and
-- pretty much just stand/walk around. I may add functionality later which permits them to run
-- around panicking for a minute or so, once shots are fired.
-- Team 2 is the guard team. Currently they stick close to the selected target, but I plan to
-- change this so that they will patrol the map in small groups until shots are fired. They will
-- go aggro on the player if the player opens fire on *anyone*, and chase the player around until
-- the player is able to hide from them for a sufficient length of time. At that point they will
-- return to their guard duties until another fight starts.
-- Team 1 is just the player. The player starts out friendly to all other teams except Team 3,
-- which he is neutral toward.
--Possible Future Teams: - Cameras/Turrets
-- - Backup for Team 1
-- - Rival assassins?
-------------------------------------------------------------------------------------------------------
print("\n\n----BEGIN KILL THE TARGET----")
print("Everything below this point is for debugging\n")
deftimer = CreateTimer("deftimer")
SetTimerValue(deftimer, 1.0)
evadetimer = CreateTimer("evadetimer")
SetTimerValue(evadetimer, 25.0)
noevadetimer = CreateTimer("noevadetimer")
SetTimerValue(noevadetimer, 10.0)
switchtargettimer1 = CreateTimer("switchtargettimer1")
SetTimerValue(switchtargettimer1, 0.5)
switchtargettimer2 = CreateTimer("switchtargettimer2")
SetTimerValue(switchtargettimer2, 0.5)
i = 1
numTargetsDone = 0
numInnocentsKilled = 0
xplayer,yplayer,zplayer = 0
xenemy,yenemy,zenemy = 0
detected = 0
endGame = false
AllowAISpawn(1, false)
ForceHumansOntoTeam1()
AICanCaptureCP("cp1", 2, false)
AICanCaptureCP("cp2", 2, false)
AICanCaptureCP("cp3", 2, false)
AICanCaptureCP("cp4", 2, false)
AICanCaptureCP("cp1", 3, false)
AICanCaptureCP("cp2", 3, false)
AICanCaptureCP("cp3", 3, false)
AICanCaptureCP("cp4", 3, false)
AICanCaptureCP("cp1", 4, false)
AICanCaptureCP("cp2", 4, false)
AICanCaptureCP("cp3", 4, false)
AICanCaptureCP("cp4", 4, false)
playerone = GetTeamMember(1,0) --Name the player
target1 = GetTeamMember(3,0) --Begin Target setup
target2 = GetTeamMember(3,1)
target3 = GetTeamMember(3,2)
SelectCharacterClass(target1, "cis_hero_darthmaul")
SelectCharacterClass(target2, "cis_hero_countdooku")
SelectCharacterClass(target3, "cis_hero_jangofett")
SpawnCharacter(target1, GetPathPoint("cp4_spawn", 0))
SpawnCharacter(target2, GetPathPoint("cp2_spawn", 0))
SpawnCharacter(target3, GetPathPoint("cp3_spawn", 0))
print("Target setup complete")
SetClassProperty("cis_hero_darthmaul", "MaxSpeed", 4.0) --Initial speed settings: Targets and guards walk at a brisk pace, civilians kind of wander
SetClassProperty("cis_hero_countdooku", "MaxSpeed", 4.0)
SetClassProperty("cis_hero_jangofett", "MaxSpeed", 4.0)
SetClassProperty("cis_inf_rifleman", "MaxSpeed", 4.0)
SetClassProperty("cis_inf_engineer", "MaxSpeed", 2.0)
AddAIGoal(3, "deathmatch", 100)
AddAIGoal(4, "deathmatch", 100)
dummy = CreateTimer("dummy")
SetTimerValue(dummy, 0.5)
StartTimer(dummy)
print("Timer dummy elapsed")
OnTimerElapse(
function(timer)
ClearAIGoals(2)
AddAIGoal(2, "follow", 600, GetCharacterUnit(target1))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target2))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target3))
--MapAddEntityMarker(GetCharacterUnit(target1), "hud_objective_icon_circle", 5, 1, "RED", true, true, true) --map marker
DestroyTimer(dummy)
print("Map marker created")
end,
dummy
)
SetTeamAsFriend(1,2)
SetTeamAsNeutral(1,3)
SetTeamAsFriend(1,4)
SetTeamAsFriend(2,1)
SetTeamAsFriend(2,3)
SetTeamAsFriend(2,4)
SetTeamAsFriend(3,1)
SetTeamAsFriend(3,2)
SetTeamAsFriend(3,4)
SetTeamAsFriend(4,1)
SetTeamAsFriend(4,2)
SetTeamAsFriend(4,3)
print("Team diplomacy set")
print("State: Anonymous")
onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
AllowAISpawn(3, false)
ShowMessageText("level.jer.kill1")
end
end
)
-----------------------------------------------------------------------------------------------------
-- This section will handle all character deaths, checking for civilian losses and target elimination
-----------------------------------------------------------------------------------------------------
personKill = OnCharacterDeath(
function(character, killer)
if GetCharacterTeam(character) == 4 and GetCharacterTeam(killer) == 1 then --CIVILIANS KILLED
ShowMessageText("level.jer.innocentkill")
StartTimer(evadetimer)
numInnocentsKilled = numInnocentsKilled + 1
if numInnocentsKilled < 5 and numInnocentsKilled > 0 then --CIVILIAN MURDER MESSAGE
ShowMessageText("level.jer.innocentcount-" .. numInnocentsKilled)
print(numInnocentsKilled .. " innocents killed, " .. (5 - numInnocentsKilled) .. " more allowed.")
end
elseif character == target1 and numTargetsDone == 0 then --FIRST TARGET KILLED
numTargetsDone = 1
ShowMessageText("level.jer.evade")
elseif character == target2 and numTargetsDone == 1 then --SECOND TARGET KILLED
numTargetsDone = 2
ShowMessageText("level.jer.evade")
elseif character == target3 and numTargetsDone == 2 then --THIRD TARGET KILLED
numTargetsDone = 3
ShowMessageText("level.jer.evade")
end
if numInnocentsKilled >= 5 then --TOO MANY CIVILIANS DEAD
StartTimer(deftimer)
print("Too many civs killed. Starting defeat timer...")
end
if GetNumTeamMembersAlive(1) == 0 then --PLAYER KILLED
StartTimer(deftimer)
print("Starting defeat timer...")
elseif numTargetsDone == 3 and endGame == false then --ALL TARGETS DEAD
endGame = true
ClearAIGoals(2)
AddAIGoal(2, "destroy", 1000, GetCharacterUnit(killer))
ActivateRegion("choppa")
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
MapAddRegionMarker("choppa", "hud_objective_icon_circle", 5, 1, "BLUE", true, true, true)
print("Target eliminated")
print("Safe zone activated")
ShowMessageText("level.jer.escape")
end
end
)
function EnemyDistance() --Do anonymity checking... basically try to figure out whether the player is sufficiently far away from all the guards
detected = 0
for unitnum = 0, 9 do --make sure this is updated to reflect the number of people on team 2, or face the consequences
enemynum = GetTeamMember(2,unitnum)
xenemy,yenemy,zenemy = GetWorldPosition(GetCharacterUnit(enemynum))
print("\nGetting enemy X: " .. xenemy)
print("Getting enemy Y: " .. yenemy)
print("Getting enemy Z: " .. zenemy)
if (math.abs(xenemy - xplayer) <= 16) and (math.abs(zenemy - zplayer) <= 16) then
print("Enemy too close")
ShowMessageText("level.jer.noevade")
StartTimer(noevadetimer)
detected = detected + 1
break
else
print("Enemy far enough away, moving on")
end
end
if detected == 0 then
print("State: Anonymous")
SetTeamAsFriend(1,2)
SetTeamAsFriend(2,1)
ClearAIGoals(2)
ShowMessageText("level.jer.evadecomplete")
if numTargetsDone == 1 then
StartTimer(switchtargettimer1)
elseif numTargetsDone == 2 then
StartTimer(switchtargettimer2)
elseif numTargetsDone == 0 then
AddAIGoal(2, "follow", 600, GetCharacterUnit(target1))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target2))
AddAIGoal(2, "follow", 200, GetCharacterUnit(target3))
elseif numTargetsDone >= 3 then
AddAIGoal(2, "deathmatch", 100)
end
end
end
OnTimerElapse(
function(timer)
xplayer,yplayer,zplayer = GetWorldPosition(GetCharacterUnit(playerone))
print("\nGetting player X again: " .. xplayer)
print("Getting player Y again: " .. yplayer)
print("Getting player Z again: " .. zplayer)
StopTimer(noevadetimer)
SetTimerValue(noevadetimer, 15)
EnemyDistance()
end,
noevadetimer)
OnTimerElapse(
function(timer)
xplayer,yplayer,zplayer = GetWorldPosition(GetCharacterUnit(playerone))
print("\nGetting player X: " .. xplayer)
print("Getting player Y: " .. yplayer)
print("Getting player Z: " .. zplayer)
StopTimer(evadetimer)
SetTimerValue(evadetimer, 25)
EnemyDistance()
end,
evadetimer
)
OnTimerElapse(
function(timer)
if numTargetsDone == 1 then
StopTimer(switchtargettimer1)
--SetTimerValue(switchtargettimer1, 0.5)
ClearAIGoals(2)
AddAIGoal(2, "follow", 700, GetCharacterUnit(target2))
AddAIGoal(2, "follow", 300, GetCharacterUnit(target3))
ClearAIGoals(3)
AddAIGoal(3, "deathmatch", 100)
--MapAddEntityMarker(GetCharacterUnit(target2), "hud_objective_icon_circle", 5, 1, "RED", true, true, true) --map marker
print("Second map marker created")
ShowMessageText("level.jer.kill2")
end
end,
switchtargettimer1)
OnTimerElapse(
function(timer)
if numTargetsDone == 2 then
StopTimer(switchtargettimer2)
--SetTimerValue(switchtargettimer2, 0.5)
ClearAIGoals(2)
AddAIGoal(2, "follow", 1000, GetCharacterUnit(target3))
ClearAIGoals(3)
AddAIGoal(3, "deathmatch", 100)
--MapAddEntityMarker(GetCharacterUnit(target3), "hud_objective_icon_circle", 5, 1, "RED", true, true, true) --map marker
print("Third map marker created")
ShowMessageText("level.jer.kill3")
end
end,
switchtargettimer2)
victorycheck = OnEnterRegion(
function(region, character)
if GetCharacterTeam(character) == 1 then
MissionVictory(1)
print("Congration you done it (victory)")
end
end,
"choppa"
)
dmgcheck = OnObjectDamage(function(object, damager)
print("Check damage")
if GetObjectTeam(GetCharacterUnit(damager)) == 1 and detected == 0 then
detected = 1
StartTimer(evadetimer)
ClearAIGoals(3)
AddAIGoal(3, "follow", 500, "cp4") --he'll run away
AddAIGoal(3, "follow", 500, "cp3")
ClearAIGoals(2)
AddAIGoal(2, "destroy", 700, GetCharacterUnit(damager)) --and they'll try to kill you
AddAIGoal(2, "follow", 300, GetCharacterUnit(target1))
SetTeamAsEnemy(1,2)
SetTeamAsEnemy(2,1)
SetClassProperty("cis_inf_rifleman", "MaxSpeed", 5.4)
print("State: Detected")
end
end)
OnTimerElapse(
function(timer)
MissionDefeat(1)
print("Mission defeat")
DestroyTimer(deftimer)
end,
deftimer
)
DisableAIAutoBalance()
--END KTT
SetUberMode(1);
--EnableSPHeroRules()
end
[/code]
Hidden/Spoiler:
[code]
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetWorldPosition' (string expected, got nil)
stack traceback:
[C]: in function `GetWorldPosition'
(none): in function `EnemyDistance'
(none): in function <(none):274>
[/code]
Message Severity: 3
.\Source\LuaHelper.cpp(312)
CallProc failed: bad argument #1 to `GetWorldPosition' (string expected, got nil)
stack traceback:
[C]: in function `GetWorldPosition'
(none): in function `EnemyDistance'
(none): in function <(none):274>
[/code]




