Page 1 of 1

AI Hunt Down Player

Posted: Wed Jul 27, 2011 1:37 am
by SpartanA259
Hi I was wondering if it is possible to get the Enemy AI to just come after and hunt down the player kinda like zombies.

Re: AI Hunt Down Player

Posted: Wed Jul 27, 2011 2:23 am
by Marth8880
Well that depends: do you want the player to be the solo unit on a team (no A.I. on the player's team) or do you want him to have A.I. allies on the same team?

Re: AI Hunt Down Player

Posted: Wed Jul 27, 2011 2:45 am
by SpartanA259
Well for my Project it has the player and a couple other AI allies against the enemy AI. I would just like the enemy AI to hunt down the player and not stop to capture command posts or do other things

Re: AI Hunt Down Player

Posted: Wed Jul 27, 2011 3:06 am
by AQT
Here's something from the Kashyyyk campaign script that could help you:
kas2c_c wrote:

Code: Select all

AddAIGoal(CIS, "Destroy", 10, "woodl")
Just change CIS to the team name you want to do the hunting, the 10 to an 100 to get all the AI on the team to do this goal, and woodl to the unit being hunted down. I'm not sure if this will work on units, though, but it's worth a try.

Re: AI Hunt Down Player

Posted: Wed Jul 27, 2011 3:34 am
by SpartanA259
Were would I put this in a my conquest maps LUA and what did you mean by change woodl to the unit being hunted down. Would I have to put in a specific name like the players or the unit that the player is playing as like a stormtrooper? EDIT: Ok so I got it to kinda work. The AI come after me but they still wanted those CPs so I removed the capture regions on the CPs on the stock Death Star map and now its like Hero Assault. Some are hunting most are standing around day dreaming. If I need to post my LUA I will.

Re: AI Hunt Down Player

Posted: Wed Jul 27, 2011 11:20 am
by Cerfon Rournes
Yes, please post your LUA.

Re: AI Hunt Down Player

Posted: Wed Jul 27, 2011 11:38 am
by SpartanA259
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
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.
---------------------------------------------------------------------------


function ScriptPostLoad()
TrashStuff();
PlayAnimExtend();
PlayAnimTakExtend();

BlockPlanningGraphArcs("compactor")
OnObjectKillName(CompactorConnectionOn, "grate01")

DisableBarriers("start_room_barrier")
DisableBarriers("dr_left")
DisableBarriers("circle_bar1")
DisableBarriers("circle_bar2")

-- handle reinforcment loss and defeat condition
OnCharacterDeathTeam(function(character, killer) AddReinforcements(1, -1) end, 1)
OnTicketCountChange(function(team, count) if count == 0 then MissionDefeat(team) end end)

OnObjectRespawnName(PlayAnimExtend, "Panel-Chasm");
OnObjectKillName(PlayAnimRetract, "Panel-Chasm");

OnObjectRespawnName(PlayAnimTakExtend, "Panel-Tak");
OnObjectKillName(PlayAnimTakRetract, "Panel-Tak");

EnableSPHeroRules()
KillObject("CP6")
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"}

--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:Start()

AddDeathRegion("DeathRegion01")
AddDeathRegion("DeathRegion02")
AddDeathRegion("DeathRegion03")
AddDeathRegion("DeathRegion04")
AddDeathRegion("DeathRegion05")

end

function CompactorConnectionOn()
UnblockPlanningGraphArcs ("compactor")
end
--START BRIDGEWORK!

-- OPEN
function PlayAnimExtend()
PauseAnimation("bridgeclose");
RewindAnimation("bridgeopen");
PlayAnimation("bridgeopen");

-- allow the AI to run across it
UnblockPlanningGraphArcs("Connection122");
DisableBarriers("BridgeBarrier");

end
-- CLOSE
function PlayAnimRetract()
PauseAnimation("bridgeopen");
RewindAnimation("bridgeclose");
PlayAnimation("bridgeclose");

-- prevent the AI from running across it
BlockPlanningGraphArcs("Connection122");
EnableBarriers("BridgeBarrier");

end

--START BRIDGEWORK TAK!!!

-- OPEN
function PlayAnimTakExtend()
PauseAnimation("TakBridgeOpen");
RewindAnimation("TakBridgeClose");
PlayAnimation("TakBridgeClose");

-- allow the AI to run across it
UnblockPlanningGraphArcs("Connection128");
DisableBarriers("Barrier222");

end
-- CLOSE
function PlayAnimTakRetract()
PauseAnimation("TakBridgeClose");
RewindAnimation("TakBridgeOpen");
PlayAnimation("TakBridgeOpen");

-- prevent the AI from running across it
BlockPlanningGraphArcs("Connection128");
EnableBarriers("Barrier222");

end

function TrashStuff()

trash_open = 1
trash_closed = 0

trash_timer = CreateTimer("trash_timer")
SetTimerValue(trash_timer, 7)
StartTimer(trash_timer)
trash_death = OnTimerElapse(
function(timer)
if trash_open == 1 then
AddDeathRegion("deathregion")
SetTimerValue(trash_timer, 5)
StartTimer(trash_timer)
trash_closed = 1
trash_open = 0
print("death region added")

elseif trash_closed == 1 then
RemoveRegion("deathregion")
SetTimerValue(trash_timer, 15)
StartTimer(trash_timer)
print("death region removed")
trash_closed = 0
trash_open = 1
end
end,
trash_timer
)
end




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

-- Empire Attacking (attacker is always #1)
local ALL = 1
local IMP = 2
-- These variables do not change
local ATT = 1
local DEF = 2

ReadDataFile("sound\\dea.lvl;dea1gcw")


SetMaxFlyHeight(72)
SetMaxPlayerFlyHeight (72)
AISnipeSuitabilityDist(30)

ReadDataFile("SIDE\\all.lvl",
"all_inf_rifleman_fleet",
"all_inf_rocketeer_fleet",
"all_inf_engineer_fleet",
"all_inf_sniper_fleet",
"all_inf_officer",
"all_hero_luke_jedi",
"all_inf_wookiee")
ReadDataFile("SIDE\\imp.lvl",
"imp_inf_rifleman",
"imp_inf_rocketeer",
"imp_inf_engineer",
"imp_inf_sniper",
"imp_inf_officer",
"imp_inf_dark_trooper")

ReadDataFile("SIDE\\imp.lvl",
"imp_hero_emperor")

SetupTeams{

all={
team = ALL,
units = 32,
reinforcements = 150,
soldier = {"all_inf_rifleman_fleet",7, 25},
assault = {"all_inf_rocketeer_fleet",1, 4},
engineer = {"all_inf_engineer_fleet",1, 4},
sniper = {"all_inf_sniper_fleet",1, 4},
officer = {"all_inf_officer",1, 4},
special = {"all_inf_wookiee",1, 4},

},

imp={
team = IMP,
units = 32,
reinforcements = 150,
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},


}
}

SetHeroClass(ALL, "all_hero_luke_jedi")
SetHeroClass(IMP, "imp_hero_emperor")

-- Level Stats
ClearWalkers()
-- AddWalkerType(0, 0) -- 8 droidekas (special case: 0 leg pairs)
-- AddWalkerType(1, 0) -- 8 droidekas (special case: 0 leg pairs)
-- AddWalkerType(2, 0) -- 2 spider walkers with 2 leg pairs each
-- AddWalkerType(3, 0) -- 2 attes with 3 leg pairs each
local weaponCnt = 200
SetMemoryPoolSize ("Aimer", 0)
SetMemoryPoolSize ("AmmoCounter", weaponCnt)
SetMemoryPoolSize ("BaseHint", 300)
SetMemoryPoolSize ("EnergyBar", weaponCnt)
SetMemoryPoolSize ("EntityCloth", 18)
SetMemoryPoolSize ("EntityLight", 100)
SetMemoryPoolSize ("EntitySoundStatic", 30)
SetMemoryPoolSize ("SoundSpaceRegion", 50)
SetMemoryPoolSize ("MountedTurret", 0)
SetMemoryPoolSize ("Navigator", 50)
SetMemoryPoolSize ("Obstacle", 260)
SetMemoryPoolSize ("PathFollower", 50)
SetMemoryPoolSize ("PathNode", 512)
SetMemoryPoolSize ("RedOmniLight", 130)
SetMemoryPoolSize ("ShieldEffect", 0)
SetMemoryPoolSize ("TreeGridStack", 200)
SetMemoryPoolSize ("UnitAgent", 50)
SetMemoryPoolSize ("UnitController", 50)
SetMemoryPoolSize ("Weapon", weaponCnt)
SetMemoryPoolSize ("EntityFlyer", 6)
AddAIGoal(ALL, "Destroy", 100, "imp_inf_rifleman")
-- Local Stats
--SetTeamName (3, "locals")
--AddUnitClass (3, "ewk_inf_trooper", 4)
--AddUnitClass (3, "ewk_inf_repair", 6)
--SetUnitCount (3, 14)
--SetTeamAsFriend(3,ATT)
--SetTeamAsEnemy(3,DEF)


SetSpawnDelay(10.0, 0.25)
ReadDataFile("dc:DET\\dea1.lvl", "dea1_Conquest")
SetDenseEnvironment("true")

--SetStayInTurrets(1)


-- Movies
-- SetVictoryMovie(ALL, "all_end_victory")
-- SetDefeatMovie(ALL, "imp_end_victory")
-- SetVictoryMovie(IMP, "imp_end_victory")
-- SetDefeatMovie(IMP, "all_end_victory")

-- 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\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\dea.lvl", "dea1")
OpenAudioStream("sound\\dea.lvl", "dea1")
-- OpenAudioStream("sound\\cor.lvl", "dea1gcw_emt")

SetBleedingVoiceOver(ALL, ALL, "all_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(ALL, IMP, "all_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, ALL, "imp_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(IMP, IMP, "imp_off_com_report_us_overwhelmed", 1)

SetLowReinforcementsVoiceOver(ALL, ALL, "all_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(ALL, IMP, "all_off_victory_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, IMP, "imp_off_defeat_im", .1, 1)
SetLowReinforcementsVoiceOver(IMP, ALL, "imp_off_victory_im", .1, 1)

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

SetAmbientMusic(ALL, 1.0, "all_dea_amb_start", 0,1)
SetAmbientMusic(ALL, 0.8, "all_dea_amb_middle", 1,1)
SetAmbientMusic(ALL, 0.2,"all_dea_amb_end", 2,1)
SetAmbientMusic(IMP, 1.0, "imp_dea_amb_start", 0,1)
SetAmbientMusic(IMP, 0.8, "imp_dea_amb_middle", 1,1)
SetAmbientMusic(IMP, 0.2,"imp_dea_amb_end", 2,1)

SetVictoryMusic(ALL, "all_dea_amb_victory")
SetDefeatMusic (ALL, "all_dea_amb_defeat")
SetVictoryMusic(IMP, "imp_dea_amb_victory")
SetDefeatMusic (IMP, "imp_dea_amb_defeat")

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")
-- SetSoundEffect("BirdScatter", "birdsFlySeq1")
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.404895, 0.000992, -0.514360, -0.002240, -121.539894, 62.536297, -257.699493)
--Homestead
AddCameraShot(0.040922, -0.004049, -0.994299, -0.098381, -103.729523, 55.546598, -225.360893)
--Sarlac Pit
AddCameraShot(-1.0, 0.0, -0.514360, 0.0, -55.381485, 50.450953, -96.514324)
end

Re: AI Hunt Down Player

Posted: Wed Jul 27, 2011 11:31 pm
by [RDH]Zerted
It matters if this is for single player or multi-player; which is it?

For SP
  • 1) First use ClearAIGoals(<team number>) to clear any existing AI goals from which ever teams you want to attack the player
  • 2) When the player spawns (first time only), use AddAIGoal(<team>, <goal type>, <weight>, <object>).
    • Use the Follow goal type to have the AI run after the player.
    • The weight doesn't matter unless you add in more AI goals for that team. Have it above zero.
    • The object should be the player's character id or the player's unit object. For SP, the human's character id is always the number zero.

Re: AI Hunt Down Player

Posted: Thu Jul 28, 2011 1:29 am
by SpartanA259
Thank you for the help the AI do come after the player now. Ive got two more questions (1 how would I stop the Wampas from jumping off the platforms. You can see my problem here http://www.xfire.com/video/4b15ed/ The stormtroopers are the smart ones :stormie:) (2 how would I add the Acklays scream to the whole Alliance team thanks.)

Re: AI Hunt Down Player

Posted: Thu Jul 28, 2011 12:51 pm
by Cerfon Rournes
1: Notice how the Wampas are all jumping In the same spot? That Is because there Is a jump hintnode placed there In ZE. Simply go In ZE and take It out to fix this. (For more info on hintnodes, click Here
2: Please explain this a bit more. How are you trying to add the scream? To one unit?

Re: AI Hunt Down Player

Posted: Thu Jul 28, 2011 12:59 pm
by SpartanA259
Im trying to give the scream to all the units on the Rebels team so every time they would get shot or would say random words on the battlefield all you would hear is the Acklay scream.

Re: AI Hunt Down Player

Posted: Thu Jul 28, 2011 1:14 pm
by Cerfon Rournes
This should do it, but I'm not that sure..(It works for me :)
First, load up the Acklay side In your LUA.
Hidden/Spoiler:
Add this were you load up your sides
ReadDataFile("SIDE\\geo.lvl")
Second, look at the odf geo_inf_acklay In BF2_ModTools/assets/sides/geo/odf. you should see these lines..
Hidden/Spoiler:
VOUnitType = 176

///SOUND
HurtSound = "acklayhurt"
DeathSound = "acklaydie"
FootstepSound0 = "acklaystepleft"
FootstepSound1 = "acklaystepright"
FootstepSound4 = "acklaystepleft"
FootstepSound5 = "acklaystepright"
LowHealthSound = "acklaychatter"
LowHealthThreshold = "1.1"
//FoleyFXClass = "rep_inf_soldier"
I think "acklayhurt" would be a scream.
Now, try this to get the sound working.
In all_inf_default, change these lines

Code: Select all

HurtSound               = "all_inf_com_chatter_wound"
DeathSound              = "all_inf_com_chatter_death
To this

Code: Select all

HurtSound               = "acklayhurt"
DeathSound              = "acklaydie"
This will make the units sound like the acklay then they get hurt or die. About the other sounds I'm not that sure. Anyone know how to make all sounds the acklayhurt sound?

Re: AI Hunt Down Player

Posted: Fri Jul 29, 2011 12:23 am
by SpartanA259
I tried that but I dont really know how to set up the sounds...
In other news I have a couple questions so here they are:
1- How would I set up a blaster rifle to shoot like a pistol in one hand but fire like a blaster rifle.
2- How would I give the wampa animations to the Stormtroopers I read through the tutorials but they were a bit confusing. By the way im new to setting up new animations.
3- Is there some way to take the arm off a stormtrooper at the elbow down?
Thanks for all the help so far :stormie: