Page 1 of 1

Little Lua Problem [Krell Hunt Mode] [Solved]

Posted: Sat Oct 04, 2014 11:46 am
by thelegend
Hey all, I am working on an extra mode for my map there you have to defeat one person with your team.
I want that my team (the clones) try to kill the Jedi General Krell (The enemy). But there's a small problem:
My team just run around him and don't try to kill him. They also don't shot him. But Krell kills everyone (me included). That's what I did want, but the clones also have to do their job.
That's what happens in my mode. And I hope someone knows there the error is.
Here is my lua:
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("setup_teams")

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



function ScriptPostLoad()
ForceHumansOntoTeam1()


--force all the human players onto the attacking side


hunt = ObjectiveTDM:New{teamATT = 1, teamDEF = 2,
textATT = "level.geo1.objectives.hunt_att", textDEF = "level.geo1.objectives.hunt_def", multiplayerRules = true, isCelebrityDeathmatch = false}

hunt:Start()

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()
-- Designers, these two lines *MUST* be first.
SetPS2ModelMemory(4100000)
ReadDataFile("ingame.lvl")

SetClassProperty("rep_rex", "PointsToUnlock", 0)
SetProperty("rep_hero_krell", "MaxHealth", 10000)
SetProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "MaxHealth", 10000)
SetTeamAggressiveness(CIS, 1.0)
SetTeamAggressiveness(REP, 1.0)

ReadDataFile("dc:sound\\bou.lvl;boucw")
ReadDataFile("dc:sound\\bon.lvl;boncw")
ReadDataFile("sound\\spa.lvl;spa2cw")
ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_engineer",
"rep_inf_ep3_sniper",
"rep_rex",
"rep_hero_krell" )



-- Level Stats

ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 6) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)
local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("rep_rex", 1)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
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)
SetClassProperty("rep_rex", "PointsToUnlock", 0)
SetProperty("rep_hero_krell", "MaxHealth", 10000)
SetProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "MaxHealth", 10000)
SetTeamAggressiveness(CIS, 1.0)
SetTeamAggressiveness(REP, 1.0)

SetSpawnDelay(10.0, 0.25)

SetupTeams{

rep = {
team = REP,
units = 50,
reinforcements = 50,

soldier = { "rep_inf_ep3_rifleman", 30},
assault = { "",0, 0},
engineer = { "rep_inf_ep3_engineer", 10},
sniper = { "rep_inf_ep3_sniper", 10},
officer = {"",0, 0},
special = { "rep_rex",0, 0},


},
cis = {
team = CIS,
units = 1,
reinforcements = 1,
soldier = { "rep_hero_krell", 1},

}
}

ReadDataFile("dc:BOU\\BOU.lvl", "BOU_hunt")

SetMinFlyHeight(-65)
SetMaxFlyHeight(50)
SetMaxPlayerFlyHeight(50)

-- Sound

OpenAudioStream("dc:sound\\bou.lvl", "boucw_music")
OpenAudioStream("sound\\global.lvl", "cw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\spa.lvl", "spa2")
OpenAudioStream("sound\\spa.lvl", "spa2")
OpenAudioStream("sound\\spa.lvl", "spa2_emt")

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

SetAmbientMusic(REP, 1.0, "rep_kam_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_spa_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2, "rep_spa_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "rep_kam_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_spa_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2, "cis_spa_amb_end", 2,1)

SetVictoryMusic(REP, "rep_geo_amb_victory")
SetDefeatMusic (REP, "rep_geo_amb_defeat")
SetVictoryMusic(CIS, "cis_geo_amb_victory")
SetDefeatMusic (CIS, "cis_geo_amb_defeat")

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

SetClassProperty("rep_rex", "PointsToUnlock", 0)
SetProperty("rep_hero_krell", "MaxHealth", 10000)
SetProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "MaxHealth", 10000)

SetAttackingTeam(ATT)
AddCameraShot(0.908386, -0.209095, -0.352873, -0.081226, -45.922508, -19.114113, 77.022636);

end
Ah and before I forgot that: In singleplayer it works pereftcly if you will force onto team 1. But in multiplayer you only will be forced onto team 2. Is there a fix or does it actually work in multiplayer?

Re: Little Lua Problem

Posted: Sat Oct 04, 2014 12:11 pm
by AQT
Although they are already specified in ObjectiveTDM.lua, try putting the AI goals directly in your mission lua. I suggest giving team 1 the "Destroy" goal so that the clones actually go after Krell.

ForceHumansOntoTeam1() only works best for single player, so in order to not have it run in multiplayer, use the following:

Code: Select all

if not ScriptCB_InMultiplayer() then
	ForceHumansOntoTeam1()
end
To prevent human players from playing as Krell on multiplayer, just make the amount of points to unlock him extremely high.

Re: Little Lua Problem

Posted: Sat Oct 04, 2014 12:53 pm
by thelegend
Thanks for the reply,
I guess the multiplayer part will work,
but the clones are still running over the plans and still don't shot the one enemy.
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("ObjectiveTDM")
ScriptCB_DoFile("setup_teams")

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



function ScriptPostLoad()
ForceHumansOntoTeam1()


--force all the human players onto the attacking side


hunt = ObjectiveTDM:New{teamATT = 1, teamDEF = 2,
textATT = "level.geo1.objectives.hunt_att", textDEF = "level.geo1.objectives.hunt_def", multiplayerRules = true, isCelebrityDeathmatch = true} --I set that to "true"

hunt:Start()
AddAIGoal(1, "Destroy", 100)
AddAIGoal(2, "Destroy", 100) --I added these lines. First only the first line changed from Deathmatch to Destroy (didn't work) and also still nothing is changed.
end

if not ScriptCB_InMultiplayer() then
ForceHumansOntoTeam1()


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()
-- Designers, these two lines *MUST* be first.
SetPS2ModelMemory(4100000)
ReadDataFile("ingame.lvl")

SetClassProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "PointsToUnlock", 100)
SetProperty("rep_hero_krell", "MaxHealth", 10000)
SetProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "MaxHealth", 10000)
SetTeamAggressiveness(CIS, 1.0)
SetTeamAggressiveness(REP, 1.0)

ReadDataFile("dc:sound\\bou.lvl;boucw")
ReadDataFile("dc:sound\\bon.lvl;boncw")
ReadDataFile("sound\\spa.lvl;spa2cw")
ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_engineer",
"rep_inf_ep3_sniper",
"rep_rex",
"rep_hero_krell" )



-- Level Stats

ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 6) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 0) -- 3x2 (3 pairs of legs)
local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("rep_rex", 1)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("EnergyBar", weaponCnt)
SetMemoryPoolSize("EntityCloth", 32)
SetMemoryPoolSize("EntityFlyer", 32)
SetMemoryPoolSize("EntityHover", 32)
SetMemoryPoolSize("EntityLight", 200)
SetMemoryPoolSize("EntitySoundStream", 4)
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)
SetClassProperty("rep_rex", "PointsToUnlock", 0)
SetProperty("rep_hero_krell", "MaxHealth", 10000)
SetProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "MaxHealth", 10000)
SetTeamAggressiveness(CIS, 1.0)
SetTeamAggressiveness(REP, 1.0)

SetSpawnDelay(10.0, 0.25)

SetupTeams{

rep = {
team = REP,
units = 50,
reinforcements = 50,

soldier = { "rep_inf_ep3_rifleman", 30},
assault = { "",0, 0},
engineer = { "rep_inf_ep3_engineer", 10},
sniper = { "rep_inf_ep3_sniper", 10},
officer = {"",0, 0},
special = { "rep_rex",0, 0},


},
cis = {
team = CIS,
units = 1,
reinforcements = 1,
soldier = { "rep_hero_krell", 1},

}
}

ReadDataFile("dc:BOU\\BOU.lvl", "BOU_hunt")

SetMinFlyHeight(-65)
SetMaxFlyHeight(50)
SetMaxPlayerFlyHeight(50)

-- Sound

OpenAudioStream("dc:sound\\bou.lvl", "boucw_music")
OpenAudioStream("sound\\global.lvl", "cw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\spa.lvl", "spa2")
OpenAudioStream("sound\\spa.lvl", "spa2")
OpenAudioStream("sound\\spa.lvl", "spa2_emt")

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

SetAmbientMusic(REP, 1.0, "rep_kam_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_spa_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2, "rep_spa_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "rep_kam_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_spa_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2, "cis_spa_amb_end", 2,1)

SetVictoryMusic(REP, "rep_geo_amb_victory")
SetDefeatMusic (REP, "rep_geo_amb_defeat")
SetVictoryMusic(CIS, "cis_geo_amb_victory")
SetDefeatMusic (CIS, "cis_geo_amb_defeat")

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

SetClassProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "PointsToUnlock", 100)
SetProperty("rep_hero_krell", "MaxHealth", 10000)
SetProperty("rep_rex", "PointsToUnlock", 0)
SetClassProperty("rep_hero_krell", "MaxHealth", 10000)

SetAttackingTeam(ATT)
AddCameraShot(0.908386, -0.209095, -0.352873, -0.081226, -45.922508, -19.114113, 77.022636);

end

Re: Little Lua Problem

Posted: Sat Oct 04, 2014 1:16 pm
by AQT
Move the block of code I showed you before the end currently directly above it. (That end closes off function ScriptPostLoad().) Also, remove the ForceHumansOntoTeam1() after function ScriptPostLoad(); you don't need it anymore.

When you use the "Destroy" goal, you need to specify a target. Since Krell is the only team member on team 2, use the following:

Code: Select all

	AddAIGoal(1, "Destroy", 100, GetTeamMember(2, 0))
The 2 refers to the team, and the 0 refers to the first team member.

Re: Little Lua Problem

Posted: Sat Oct 04, 2014 1:36 pm
by thelegend
Thanks AQT!
It works now without any problems. :)