Page 1 of 1

Scripting gate animation trouble [Solved]

Posted: Thu Dec 28, 2006 6:14 pm
by Zaniac
So I am trying to set up a gate like in Kashyyyk, that raises and closes depending on if the gate panel is still operational. Then I'm trying to set AI goals to defend/destroy the gate panel. So I looked in the KAS world script and copied over the needed parts and adjusted the names of objects and barriers to fit my map. So I munge and get these errors:
C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\KAE\KAEc_con.lua:66: <eof> expected near `end'
ERROR[scriptmunge scripts\KAE\KAEc_con.lua]:Could not read input file.ERROR[scriptmunge scripts\KAE\KAEc_con.lua]:Could not read input file. [continuing]
2 Errors 0 Warnings

ERROR[levelpack mission\KAEc_con.req]:Expecting bracket, but none was found.
File : munged\pc\kaec_con.script.req(1)...

ucft <--
ERROR[levelpack mission\KAEc_con.req]:Expecting bracket, but none was found.
File : munged\pc\kaec_con.script.req(1)...

ucft <--

2 Errors 0 Warnings
I know the last two errors just need a bracket somewhere but I don't know where to place them. I don't know how to fix the first two errors. My map works fine in game but the gate won't lift when you destroy the gatepanel and the AI don't try to destroy it. Here's my lua:
Hidden/Spoiler:
[quote]--
-- 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;
-- 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"}
cp5 = CommandPost:New{name = "local_cp"}
cp6 = CommandPost:New{name = "cp6"}



--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.OnStart = function(self)
conquest.goal1 = AddAIGoal(REP, "Destroy", 100, "gatepanel1")
conquest.goal2 = AddAIGoal(CIS, "Defend", 70, "gatepanel1")
end

conquest:Start()

EnableSPHeroRules()

end


--Gate Stuff --
BlockPlanningGraphArcs("seawalldoor1")
DisableBarriers("disableme");

SetProperty("gatepanel1", "MaxHealth", 1000)
SetProperty("gatepanel1", "CurHealth", 1000)


OnObjectKillName(PlayAnimDown, "gatepanel1");
OnObjectRespawnName(PlayAnimUp, "gatepanel1");

end

function PlayAnimDown()
PauseAnimation("thegateup");
RewindAnimation("thegatedown");
PlayAnimation("thegatedown");
ScriptCB_SndPlaySound("KAS_obj_13")
SetProperty("gatepanel1", "MaxHealth", 2200)
-- SetProperty("gatepanel1", "CurHealth", 50000)
-- PlayAnimation("gatepanel");
--SetProperty("gatepanel1", "MaxHealth", 1e+37)
--SetProperty("gatepanel1", "CurHealth", 1e+37)


-- Allowing AI to run under gate
UnblockPlanningGraphArcs("seawall1");
DisableBarriers("seawalldoor1");

end

function PlayAnimUp()
PauseAnimation("thegatedown");
RewindAnimation("thegateup");
PlayAnimation("thegateup");


-- Allowing AI to run under gate
BlockPlanningGraphArcs("seawall1");
EnableBarriers("seawalldoor1");
EnableBarriers("vehicleblocker");
SetProperty("gatepanel1", "MaxHealth", 1000)
SetProperty("gatepanel1", "CurHealth", 1000)

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()
(And the rest is some sound and side setup that I doubt are involved in the errors.)[/quote]
Could anyone help a noob figure out how to fix it so my gate and objectives work? Oh and also I was wondering what would I add to disable a death region when a certain object is destroyed?

Thanks in advance.

RE: Scripting Trouble

Posted: Thu Dec 28, 2006 6:50 pm
by Teancum
C:\BF2_ModTools\ToolsFL\Bin\luac.exe: ..\..\common\scripts\KAE\KAEc_con.lua:66: <eof> expected near `end'

--This means there's an error on line 66 near "end". If you look, you have two end functions in Scriptpostload.

Posted: Thu Dec 28, 2006 11:34 pm
by Zaniac
Thank you Teancum, I deleted one of the ends and now my AI goals work :D But when the gate panel is destroyed the gate still doesn't raise. I renamed everything like it is in the shipped Kashyyyk world and tried to copy over the Gate part of the script but it still doesn't work. Is there something else I have to do in Zeroeditor? Like add a region or something?

Posted: Sun Dec 31, 2006 6:54 pm
by Zaniac
Ok I've spent a couple more frustrating hours trying to get the seawall working but I just can't figure it out. I've renamed all the objects, barriers, and pathing just like in the shipped Kashyyyk map. Could someone just tell me all the steps I need to take to add a working seawall?

Also for disabling death regions when an object is destroyed would I do something like this:
function PlayAnimUp()
PauseAnimation("thegatedown");
RewindAnimation("thegateup");
PlayAnimation("thegateup");

-- Allowing AI to run under gate
BlockPlanningGraphArcs("seawall1");
EnableBarriers("seawalldoor1");
DisableDeathRegions("deathregion1");
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)

end
Could someone just help me out?

Posted: Thu Jan 04, 2007 3:26 pm
by [RDH]Zerted
I don't think it matters too much, but you should put your 'gate stuff' inside ScriptPostLoad().

Pause the animation before you rewind it.

Posted: Fri Jan 05, 2007 12:10 am
by Zaniac
Zerted: When you say put my gate stuff inside my ScriptPostLoad() you mean this right?:
Hidden/Spoiler:
[quote]
--
-- 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;
-- These variables do not change
ATT = REP;
DEF = CIS;

function ScriptPostLoad()

--Gate Stuff --
BlockPlanningGraphArcs("seawall1")
DisableBarriers("disableme");

SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)

OnObjectKillName(PlayAnimDown, "gatepanel");
OnObjectRespawnName(PlayAnimUp, "gatepanel");

end

function PlayAnimDown()
PauseAnimation("thegateup");
RewindAnimation("thegatedown");
PlayAnimation("thegatedown");
ShowMessageText("level.kas2.objectives.gateopen",1)
ScriptCB_SndPlaySound("KAS_obj_13")
SetProperty("gatepanel", "MaxHealth", 2200)
-- SetProperty("gatepanel", "CurHealth", 50000)
-- PlayAnimation("gatepanel");
--SetProperty("gatepanel", "MaxHealth", 1e+37)
--SetProperty("gatepanel", "CurHealth", 1e+37)


-- Allowing AI to run under gate
UnblockPlanningGraphArcs("seawall1");
DisableBarriers("seawalldoor1");
DisableBarriers("vehicleblocker");

end

function PlayAnimUp()
PauseAnimation("thegatedown");
RewindAnimation("thegateup");
PlayAnimation("thegateup");


-- Allowing AI to run under gate
BlockPlanningGraphArcs("seawall1");
EnableBarriers("seawalldoor1");
EnableBarriers("vehicleblocker");
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)

end


--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 = "local_cp"}
cp6 = CommandPost:New{name = "cp6"}

--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.OnStart = function(self)
conquest.goal1 = AddAIGoal(REP, "Destroy", 100, "gatepanel")
conquest.goal2 = AddAIGoal(CIS, "Defend", 70, "gatepanel")
end

conquest:Start()

EnableSPHeroRules()

---------------------------------------------------------------------------
-- 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.
---------------------------------------------------------------------------
[/quote]
I tried this and it caused my map to crash. :cry: I didn't get any errors during munging so I'm sure I did something stupid again like had one to many "ends".

Also I don't really understand what you mean by pause the animation before I rewind it. In my lua I see it already says:
function PlayAnimUp()
PauseAnimation("thegatedown");
RewindAnimation("thegateup");
PlayAnimation("thegateup");
Is that what your talking about or is it something different? Sorry I'm not really good with coding and am still learning all the ins and outs of the lua.

Posted: Sat Jan 06, 2007 4:11 am
by Big_rich
Here is what I used for a fortress map. You have to make an animation for the gate to go up and down.
In this code I made the gate auctually a destroyable object which can be repaired. Also the panel can be destroyed(which causes the gate to go down) and reapired and the gate to go back up.

Hidden/Spoiler:
[code]
-
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

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

function ScriptPostLoad()
--ScriptCB_PlayInGameMovie("dc:movies\\tat3.mvs","tat3fly")
--SetMissionEndMovie("tat3.mvs", "tat3fly")
ScriptCB_PlayInGameMovie("movies\\fi1.mvs", "fi1")
--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()

EnableSPHeroRules()

BlockPlanningGraphArcs("door1_con")
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)
SetProperty("gate", "MaxHealth", 18000)
SetProperty("gate", "CurHealth", 18000)
OnObjectKillName(PlayAnimDown, "gatepanel");
OnObjectRespawnName(PlayAnimUp, "gatepanel");
OnObjectRespawnName(PlayAnimUp, "gate");
OnObjectKillName(PlayAnimDown1, "gate");
end


function PlayAnimDown()
PauseAnimation("thegateup");
RewindAnimation("thegatedown");
PlayAnimation("thegatedown");
ShowMessageText("level.kas2.objectives.gateopen1")
--ScriptCB_SndPlaySound("KAS_obj_13")
SetProperty("gatepanel", "MaxHealth", 1200)
UnblockPlanningGraphArcs("door1_con");
DisableBarriers("door1");
end

function PlayAnimDown1()
SetProperty("gatepanel", "MaxHealth", 99999)
SetProperty("gatepanel", "CurHealth", 99999)
SetProperty("gate", "MaxHealth", 4000)
ShowMessageText("level.kas2.objectives.gateopen")
UnblockPlanningGraphArcs("door1_con");
DisableBarriers("door1");
end

function PlayAnimUp()
--SpawnObject("gate")
SetProperty("gatepanel", "MaxHealth", 1000)
SetProperty("gatepanel", "CurHealth", 1000)
SetProperty("gate", "CurHealth", 18000)
SetProperty("gate", "MaxHealth", 18000)
PauseAnimation("thegatedown");
RewindAnimation("thegateup");
PlayAnimation("thegateup");
BlockPlanningGraphArcs("door1_con");
EnableBarriers("door1");
ShowMessageText("level.kas2.objectives.gateopen2")
end[/code]

Posted: Sat Jan 06, 2007 3:14 pm
by Zaniac
Big_rich: I tried applying your code, (by naming my gate: "gate" and gatepanel: "gatepanel") Once again it didn't work. So I obviously my problem is I must not have the animations. ( :oops: Wow I'm an idiot) In the assets' animation folder I found the "log_gate" animation which I thought would be what I would need. (Since I didn't find a folder with "thegateup" and "thegatedown" animations.) So I just my question now is where are the proper animations I need and where do I put them... :oops:

Also thanks alot Teancum, Zerted, and Big_rich for helping me out, I really appreciate it.

Kashyyyk wood gate animation

Posted: Sat Jan 06, 2007 3:49 pm
by AceMastermind
This is in the "kas2.ANM" file in:
BF2_ModTools\assets\worlds\KAS\world2
Pandemic wrote:
Hidden/Spoiler:
[code]Animation("gatedown", 2.50, 0, 0)
{
AddPositionKey(0.00, 0.00, 0.00, 0.00, 1, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00);
AddPositionKey(2.50, 0.00, -10.74, 0.00, 1, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00);
}

Animation("gateup", 2.50, 0, 0)
{
AddPositionKey(0.00, 0.00, -10.74, 0.00, 1, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00);
AddPositionKey(2.50, 0.00, 0.00, 0.00, 1, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00);
}

Animation("woodgate", 0.10, 0, 0)
{
AddPositionKey(0.00, 0.00, 0.00, 0.00, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00);
AddPositionKey(0.10, 0.00, -300.05, -1000.27, 0, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00);
}

AnimationGroup("thegatedown", 0, 0)
{
Animation("gatedown", "gate01");
}

AnimationGroup("thegateup", 0, 0)
{
Animation("gateup", "gate01");
}

AnimationGroup("woodgate", 0, 0)
{
Animation("woodgate", "woodgate");
}

AnimationGroup("gatepanel", 0, 0)
{
Animation("woodgate", "gatepanel");
}[/code]
You could just rename the gate parts to what is specified in the above code and re-use this animation by copying it to your "ABC.ANM" file.

ABC = Example modID

Posted: Sun Jan 07, 2007 12:24 am
by Zaniac
Huzzah! It worked, thanks alot guys for all the help! :D