Page 1 of 2

Ambush and animation when entering region?

Posted: Sat Oct 01, 2016 9:30 pm
by SkinnyODST
How am I able to make an animation play when I step into an ambush region (planning for a CIS lander to come down and land) and THEN the AI ambushers spawn. So step into region, animated object lands, AI spawn. BTW, I already know how to set up AI ambush :mrgreen:
thanks

Re: Ambush and animation when entering region?

Posted: Sat Oct 01, 2016 9:47 pm
by AQT
Do you know how to:
  • animate props and play the animation via lua
  • create a timer
  • trigger an ambush via lua without having the player enter a region
?

If so, use all of that with the following, and you should be good to go:

Re: Ambush and animation when entering region?

Posted: Sun Oct 02, 2016 12:29 am
by SkinnyODST
AQT wrote:Do you know how to:
  • animate props and play the animation via lua
  • create a timer
  • trigger an ambush via lua without having the player enter a region
?

If so, use all of that with the following, and you should be good to go:

1. I know how to animate props but not how to play them via lua
2. Not really, i`ve read the tut on it but don`t really understand how to set thing out.
3. No

I have taken a look at that OnEnterRegion thing and have no idea how to make my CIS lander plan work. I get it up until the "if [whatever callbacks you want] then
whatvever you want to happen" part. I don`t know what to write there to make it work

Re: Ambush and animation when entering region?

Posted: Sun Oct 02, 2016 1:41 am
by GAB
SkinnyODST wrote:
AQT wrote:Do you know how to:
  • animate props and play the animation via lua
1. I know how to animate props but not how to play them via lua
Read section V of the procedural animation mode doc. It teaches everything you'll need to know about that topic.
SkinnyODST wrote:
AQT wrote:
  • create a timer
2. Not really, i`ve read the tut on it but don`t really understand how to set thing out.
Assuming you read this tutorial, I'd say timers don't get any more simple than that. Try looking at the template provided in that tutorial and compare it to examples in campaign scripts. Put those neurons to work.
SkinnyODST wrote:
AQT wrote:
  • trigger an ambush via lua without having the player enter a region
    ?
3. No
This tutorial should be helpful, more specifically the THE OTHER METHOD: AMBUSH() section.
SkinnyODST wrote:I have taken a look at that OnEnterRegion thing and have no idea how to make my CIS lander plan work. I get it up until the "if [whatever callbacks you want] then whatvever you want to happen" part. I don`t know what to write there to make it work
Same thing as with the timers, look at the template provided in that tutorial and compare it to examples in campaign scripts. It usually is the best way to figure out how things work.

Re: Ambush and animation when entering region?

Posted: Sun Oct 02, 2016 2:21 am
by SkinnyODST
I tried copy and pasting some script from COR`s campaign script into my conquest script and nothing happens.

Here`s what I added, I`m just trying to give the objective of capturing one of the cp`s.
Hidden/Spoiler:
--
-- Copyright (c) 2005 Pandemic Studios, LLC. All rights reserved.
--

-- load the gametype script
ScriptCB_DoFile("ObjectiveConquest")
ScriptCB_DoFile("setup_teams")
ScriptCB_DoFile("Ambush")
ScriptCB_DoFile("ObjectiveGoto")

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

function ScriptPostLoad()
ScriptCB_SetGameRules("campaign")
SetAIDifficulty(2, -2, "medium")
DisableAIAutoBalance()

onfirstspawn = OnCharacterSpawn(
function(character)
if IsCharacterHuman(character) then
ReleaseCharacterSpawn(onfirstspawn)
onfirstspawn = nil
objectives_timer = CreateTimer("objectives_timer")
SetTimerValue(objectives_timer, 2)
StartTimer(objectives_timer)
begin_objectives = OnTimerElapse(
function(timer)
StartObjectives ()
PlayAnimationFromTo("laat hover",1.0,100.0)

end,
objectives_timer
)
end
end
)

Objective1CP = CommandPost:New{name = "cp5", hideCPs = false}
Objective1 = ObjectiveConquest:New{teamATT = ATT, teamDEF = GAR, text = "hi there",
popupText = "hi there"}
Objective1:AddCommandPost(cp5)

Objective1.OnStart = function (self)

end

SetClassProperty("cis_inf_rifleman", "NoEnterVehicles", "1")


--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 = "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()

SetUberMode(1);

EnableSPHeroRules()
SetupAmbushTrigger("ambushregion", "ambushpath", 8, 5)

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

ReadDataFile("ingame.lvl")


SetMaxFlyHeight(62)
SetMaxPlayerFlyHeight (62)

SetMemoryPoolSize ("ClothData",20)
SetMemoryPoolSize ("Combo",50) -- should be ~ 2x number of jedi classes
SetMemoryPoolSize ("Combo::State",650) -- should be ~12x #Combo
SetMemoryPoolSize ("Combo::Transition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Condition",650) -- should be a bit bigger than #Combo::State
SetMemoryPoolSize ("Combo::Attack",550) -- should be ~8-12x #Combo
SetMemoryPoolSize ("Combo::DamageSample",6000) -- should be ~8-12x #Combo::Attack
SetMemoryPoolSize ("Combo::Deflect",100) -- should be ~1x #combo

ReadDataFile("sound\\yav.lvl;yav1cw")
ReadDataFile("SIDE\\\\des.lvl",
"rep_inf_ep2_pilot")
ReadDataFile("dc:SIDE\\rep.lvl",
"rep_inf_ep3_rifleman",
"rep_inf_ep3_rocketeer",
"rep_inf_ep3_engineer",
"rep_inf_ep3_sniper",
"rep_inf_ep3_officer",
"rep_inf_ep2_pilot",
"rep_inf_ep3_jettrooper",
"rep_inf_ep2_marine",
"rep_inf_ep2_jettrooper",
"rep_hover_fightertank",
"rep_hero_anakin",
"rep_inf_ep3_scorchco",
"rep_walk_atte",
"rep_hover_barcspeeder")
ReadDataFile("dc:SIDE\\cis.lvl",
"cis_inf_rifleman",
"cis_inf_marine",
"cis_inf_rocketeer",
"cis_inf_engineer",
"cis_inf_sniper",
"cis_inf_officer",
"cis_inf_droideka",
"cis_hero_darthmaul",
"cis_hover_aat",
"cis_walk_spider",
"cis_hover_stap")


ReadDataFile("dc:SIDE\\tur.lvl",
"tur_bldg_laser",
"tur_bldg_tower",
"tur_bldg_chaingun",
"tur_bldg_built_chaingun",
"tur_yav_bldg_watchtower",
"tur_bldg_recoilless_fel_auto",
"tur_bldg_recoilless_kas",
"tur_bldg_recoilless_lg",
"tur_bldg_recoilless_md",
"tur_bldg_recoilless_myg_auto",
"tur_bldg_recoilless_nab_auto")

SetupTeams{
rep = {
team = REP,
units = 150,
reinforcements = 705,
soldier = { "rep_inf_ep3_rifleman",30,60},
assault = { "rep_inf_ep3_rocketeer",10, 20},
engineer = { "rep_inf_ep3_sniper",5, 10},
sniper = { "rep_inf_ep3_engineer",7, 20},
officer = { "rep_inf_ep3_jettrooper",3, 6},
special = { "rep_inf_ep2_pilot",5, 15},
extra1 = { "rep_inf_ep2_marine",8, 15},
AddUnitClass(REP, "rep_inf_ep3_officer",0,1)

},
cis = {
team = CIS,
units = 150,
reinforcements = 700,
soldier = { "cis_inf_marine",30, 60},
assault = { "cis_inf_rocketeer",10, 20},
engineer = { "cis_inf_engineer",5, 15},
sniper = { "cis_inf_sniper",4, 10},
special = { "cis_inf_rifleman",5, 10},
officer = { "cis_inf_droideka",5, 10},
extra1 = { "cis_inf_officer",5, 10},

},

abt = {
team = ABT,
units = 8,
reinforcements = -1,
sniper = { "cis_inf_sniper", 8, 8},
}

}

SetTeamAsFriend(ABT, CIS)
SetTeamAsFriend(CIS, ABT)
SetTeamAsEnemy(ABT, REP)
SetTeamAsEnemy(REP, ABT)
ClearAIGoals(ABT)
AddAIGoal(ABT, "Deathmatch", 100)

SetClassProperty("cis_inf_marine", "WeaponName1", "cis_weap_inf_rifle")
SetClassProperty("cis_inf_marine", "WeaponName2", "cis_weap_inf_pistol")
SetClassProperty("cis_inf_marine", "WeaponName3", "cis_weap_inf_thermaldetonator")
SetClassProperty("rep_inf_ep3_officer", "FleeLikeAHero", "1")

AddUnitClass(CIS, "cis_inf_officer",5,10)
AddUnitClass(REP, "rep_inf_ep2_marine",8,15)
AddUnitClass(REP, "rep_inf_ep2_pilot",8,15)



-- Level Stats
-- ClearWalkers()
AddWalkerType(0, 4) -- special -> droidekas
AddWalkerType(1, 0) -- 1x2 (1 pair of legs)
AddWalkerType(2, 1) -- 2x2 (2 pairs of legs)
AddWalkerType(3, 1) -- 3x2 (3 pairs of legs)
local weaponCnt = 1024
SetMemoryPoolSize("Aimer", 75)
SetMemoryPoolSize("AmmoCounter", weaponCnt)
SetMemoryPoolSize("BaseHint", 1024)
SetMemoryPoolSize("CommandWalker", 1)
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)

SetSpawnDelay(10.0, 0.25)
--ReadDataFile("dc:CCC\\CCC.lvl", "CCC_conquest")
ReadDataFile("dc:CCC\\CCC.lvl", "CCC_conquest")
SetDenseEnvironment("false")




-- Sound

SetSoundEffect("ScopeDisplayZoomIn", "binocularzoomin")
SetSoundEffect("ScopeDisplayZoomOut", "binocularzoomout")

voiceSlow = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_slow")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_slow", voiceSlow)
AudioStreamAppendSegments("sound\\global.lvl", "global_vo_slow", voiceSlow)

voiceQuick = OpenAudioStream("sound\\global.lvl", "rep_unit_vo_quick")
AudioStreamAppendSegments("sound\\global.lvl", "cis_unit_vo_quick", voiceQuick)

OpenAudioStream("sound\\global.lvl", "cw_music")
-- OpenAudioStream("sound\\global.lvl", "global_vo_quick")
-- OpenAudioStream("sound\\global.lvl", "global_vo_slow")
OpenAudioStream("sound\\yav.lvl", "yav1")
OpenAudioStream("sound\\yav.lvl", "yav1")
OpenAudioStream("sound\\yav.lvl", "yav1_emt")

SetBleedingVoiceOver(REP, REP, "rep_off_com_report_us_overwhelmed", 1)
SetBleedingVoiceOver(REP, CIS, "rep_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, REP, "cis_off_com_report_enemy_losing", 1)
SetBleedingVoiceOver(CIS, CIS, "cis_off_com_report_us_overwhelmed", 1)

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

SetAmbientMusic(REP, 1.0, "rep_yav_amb_start", 0,1)
SetAmbientMusic(REP, 0.8, "rep_yav_amb_middle", 1,1)
SetAmbientMusic(REP, 0.2, "rep_yav_amb_end", 2,1)
SetAmbientMusic(CIS, 1.0, "cis_yav_amb_start", 0,1)
SetAmbientMusic(CIS, 0.8, "cis_yav_amb_middle", 1,1)
SetAmbientMusic(CIS, 0.2, "cis_yav_amb_end", 2,1)

SetVictoryMusic(REP, "rep_yav_amb_victory")
SetDefeatMusic (REP, "rep_yav_amb_defeat")
SetVictoryMusic(CIS, "cis_yav_amb_victory")
SetDefeatMusic (CIS, "cis_yav_amb_defeat")

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


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

AddCameraShot(-0.481173, 0.024248, -0.875181, -0.044103, 14.767292, -30.602322, -144.506851);
AddCameraShot(0.999914, -0.012495, -0.004416, -0.000055, 1.143253, -33.602314, -76.884430);
AddCameraShot(0.839161, 0.012048, -0.543698, 0.007806, 19.152437, -49.802273, 24.337317);
AddCameraShot(0.467324, 0.006709, -0.883972, 0.012691, 11.825212, -49.802273, -7.000720);
AddCameraShot(0.861797, 0.001786, -0.507253, 0.001051, -11.986043, -59.702248, 23.263165);
AddCameraShot(0.628546, -0.042609, -0.774831, -0.052525, 20.429928, -48.302277, 9.771714);
AddCameraShot(0.765213, -0.051873, 0.640215, 0.043400, 57.692474, -48.302277, 16.540724);
AddCameraShot(0.264032, -0.015285, -0.962782, -0.055734, -16.681797, -42.902290, 129.553268);
AddCameraShot(-0.382320, 0.022132, -0.922222, -0.053386, 20.670977, -42.902290, 135.513001);
end
The other AI don`t spawn even when I spawned in. And I noticed that the buff effects like energy regen and damage boost show up, but without this campaign script they don`t :runaway:

Re: Ambush and animation when entering region?

Posted: Sun Oct 02, 2016 3:10 am
by AQT
You should undo everything you did there.

Combining the information from the various tutorials provided, I've taken the liberty and done 95% of the work for you:

Code: Select all

ActivateRegion("regionname")
testfunction = OnEnterRegion(
     function(region, player)
          PlayAnimation("whateveranimationgroup")
          timername = CreateTimer("timername")
          SetTimerValue(timername, number)
          StartTimer(timername)
               OnTimerElapse(
                    function(timer)
                    Ambush(ambushpath, numDudes, fromTeam)
                    DestroyTimer(timer)
               end,
          timername
          )   
     end,
"regionname"
)
  • regionname = name of the region player steps into
  • whateveranimationgroup = name of the animation group
  • timername = name of timer
  • number = the amount of seconds it takes for animation group to play from start to finish
  • ambushpath = name of ambush path
  • numDudes = number of AI to spawn from path/number of spawn nodes on path
  • fromTeam = the team in which the ambush AI spawn from
Can you figure out the remaining 5% by yourself?

Re: Ambush and animation when entering region?

Posted: Sun Oct 02, 2016 4:26 am
by SkinnyODST
AQT wrote:You should undo everything you did there.

Combining the information from the various tutorials provided, I've taken the liberty and done 95% of the work for you:

Code: Select all

ActivateRegion("regionname")
testfunction = OnEnterRegion(
     function(region, player)
          PlayAnimation("whateveranimationgroup")
          timername = CreateTimer("timername")
          SetTimerValue(timername, number)
          StartTimer(timername)
               OnTimerElapse(
                    function(timer)
                    Ambush(ambushpath, numDudes, fromTeam)
                    DestroyTimer(timer)
               end,
          timername
          )   
     end,
"regionname"
)
  • regionname = name of the region player steps into
  • whateveranimationgroup = name of the animation group
  • timername = name of timer
  • number = the amount of seconds it takes for animation group to play from start to finish
  • ambushpath = name of ambush path
  • numDudes = number of AI to spawn from path/number of spawn nodes on path
  • fromTeam = the team in which the ambush AI spawn from
Can you figure out the remaining 5% by yourself?
This is right under "function ScriptPostLoad()"
Hidden/Spoiler:
function ScriptPostLoad()

ActivateRegion("ambushregion")
testfunction = OnEnterRegion(
function(region, player)
PlayAnimation("thing")
timername = CreateTimer("timername")
SetTimerValue(timername, 5)
StartTimer(timername)
OnTimerElapse(
function(timer)
Ambush(ambushpath, 8, 5)
DestroyTimer(timer)
end,
timername
)
end,
"ambushregion"
)
The animation is called "thing" and the region is called "ambushregion". The animation starts anyway. It goes from 0 to 15 seconds, I don`t get how I make the animation play ONLY when I step into the region. The ambush works because it was already set up.

Re: Ambush and animation when entering region?

Posted: Sun Oct 02, 2016 2:06 pm
by AQT
SkinnyODST wrote:The animation starts anyway. It goes from 0 to 15 seconds, I don`t get how I make the animation play ONLY when I step into the region.
Three things:
  • Calm down and double-check what you are doing.
  • You have "Plays When Level Begins" enabled in ZE for this animation group. It means and does what it means and does in plain English. (Yes, disable it.)
  • 0 to 15 seconds is 15 seconds in total. So it takes 15 seconds for your animated ship to completely land? Then why did you set your timer for 5 seconds?

Code: Select all

SetTimerValue(timername, 5)
SkinnyODST wrote:The ambush works because it was already set up.
It works when? 5 seconds after stepping into the region or immediately? If immediately, you have something that is causing conflict in your lua. This is what I found in the lua you originally posted:

Code: Select all

SetupAmbushTrigger("ambushregion", "ambushpath", 6, 3)
And this is what you have now in code you posted above:

Code: Select all

Ambush(ambushpath, 8, 5)
(You need quotation marks around ambushpath, by the way.) Assuming that SetupAmbushTrigger line is still there, are you using the same ambush region and path for AI ambushes from team 3 and team 5? Or is this a separate ambush, and you renamed the region and path (which you are allowed to) to something else?

The more details you provide, the quicker this issue will be solved. Also, please do not quote the entirety of the post before yours for no reason. It will be obvious who you are replying based on the context of your reply.

Re: Ambush and animation when entering region?

Posted: Sun Oct 02, 2016 11:19 pm
by SkinnyODST
The ambushers spawn immediately, I changed the animation so it doesn`t start when the level begins and it doesn`t start when I go into the region either. I also changed the errors in my lua code that you pointed out. The ambushers are from team 5. And what do you mean "you renamed the region and path (which you are allowed to) to something else?" They are ambushregion and ambushpath.

EDIT
Oh and something else:
ActivateRegion("ambushregion")
testfunction = OnEnterRegion(
function(region, player)
if IsCharacterHuman(character) then PlayAnimation("thing")
end
end,
"ambushregion"
)

I tried using this OnEnterRegion code to JUST play the animation and it didn`t work. I took out the other code so it was just this and still nothing. I`m thinking I could maybe make 2 separate regions, one for the animation and one for the ambush. Do you know why this isn`t working?

Double posting is against the RULES; please EDIT your post instead -Staff

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 12:15 am
by AQT
SkinnyODST wrote:And what do you mean "you renamed the region and path (which you are allowed to) to something else?" They are ambushregion and ambushpath.
I thought I couldn't have made it more clear. Just answer the question: Are you still using this line or anything that looks like it in your lua?

Code: Select all

SetupAmbushTrigger("ambushregion", "ambushpath", 6, 3)
If you are, get rid of it. Having this line causes the ambush to occur immediately.
SkinnyODST wrote:Do you know why this isn`t working?
Again, it could be a number of things:
  • It could be that "thing" isn't really the name of your animation group, so it's trying to play a nonexistent animation group.
  • If you really wanted to test if the problem is with your animation, use the PlayAnimation("thing") line by itself outside of the OnEnterRegion function. The animation would play at the start of the level if there are no problems. And no, I am not saying to enable the "Plays When Level Begins" button again in ZE. Again, you are merely testing to see if the PlayAnimation function will play your animation on its own outside of the OnEnterRegion function.
  • You are making things more complicated than they need to be; OnEnterRegion doesn't already work with AI units, so having the condition that checks to see if a human player is entering the region is redundant. But if you really want to do it anyway, the line you are using is wrong. Instead of:

    Code: Select all

    IsCharacterHuman(character)
    It should be:

    Code: Select all

    IsCharacterHuman(player)
    Because it would then match with:

    Code: Select all

    function(region, player)
Also, when you post a chunk of code, please do everyone a favor and use the code tags; it'll preserve the formatting of the code.

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 12:44 am
by SkinnyODST
I`m just going to forget about the ambush AND animation when entering the region, its extremely hard for me, and it`s annoying you at how stupid I am with it. Now all I wish to know is: How do I get an animation to start when I enter a region? I`m going to just not worry about doing both an ambush as well as the animation. Will the OnEnterRegion work in doing that? If not, what code will?

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 1:43 am
by Marth8880
SkinnyODST wrote:I`m just going to forget about the ambush AND animation when entering the region, its extremely hard for me, and it`s annoying you at how stupid I am with it. Now all I wish to know is: How do I get an animation to start when I enter a region? I`m going to just not worry about doing both an ambush as well as the animation. Will the OnEnterRegion work in doing that? If not, what code will?

Code: Select all

ActivateRegion("region_name")
OnEnterRegion(
	function(region, player)
		PlayAnimation("animation_group_name")
		
		DeactivateRegion("region_name")	-- Keep this line if you want the animation to play only once
	end,
"region_name"
)
Put anywhere at the end of the ScriptPostLoad() function in your Lua.

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 2:33 am
by SkinnyODST

Code: Select all

ActivateRegion("region_name")
OnEnterRegion(
	function(region, player)
		PlayAnimation("animation_group_name")
		
		DeactivateRegion("region_name")	-- Keep this line if you want the animation to play only once
	end,
"region_name"
)
Put anywhere at the end of the ScriptPostLoad() function in your Lua.

Code: Select all

ActivateRegion("arcregion")
OnEnterRegion(
   function(region, player)
      PlayAnimation("region_anim", "arcflyregion", 0, 15)
      
      DeactivateRegion("arcregion")   -- Keep this line if you want the animation to play only once
   end,
"arcregion"
)
Everything is named right and set up in ZE. However nothing happens when I step into the region? "region_anim" is the name of the animation group and "arcflyregion" is the name of the animation. 0, 15 is how long it goes for. I also disabled "play when game starts" and the region is in fact called "arcregion"

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 2:40 am
by Marth8880
SkinnyODST wrote:

Code: Select all

...
      PlayAnimation("region_anim", "arcflyregion", 0, 15)
...
Everything is named right and set up in ZE. However nothing happens when I step into the region?
I don't know why you added those extra arguments to PlayAnimation(), but the only argument PlayAnimation() takes is the name of the animation group to play. It seems like you were aiming to use PlayAnimationFromTo() which takes three arguments: animation group name, begin time, end time. See here: https://sites.google.com/site/swbf2modt ... wer-of-LUA

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 3:38 am
by SkinnyODST
I don't know why you added those extra arguments to PlayAnimation()
I added the other ones after it didn`t work, I tried adding some things to it to see if it would fix it, which it didn`t. Originally I only had the name of the animation which didn`t work.

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 4:01 am
by Marth8880
Did you create an animation group and add the animation to it? You have to do so or else it absolutely will not work. https://sites.google.com/site/swbf2modt ... tion-group

Also what has the debugger been outputting?

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 5:36 am
by SkinnyODST
I have, its called "region_anim" and the only animation is has in it is called "arcflyregion". The debugger, which I assume is the munge error list, shows nothing. No errors

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 10:23 am
by Oceans14
The debugger is the bf2_modtools.exe, and the error log is called bf2_log.txt (or something similar, you'll see it.) If you haven't already, move bf2_modtools.exe from your modding directory to your actual bf2 directory. It should be sitting next to the exe for the actual game.

If you're going to post the error log here, read this: viewtopic.php?f=27&t=10864 and remove all the lines it says to. That makes it easier for us reading it to see what the problem is without wading through lines of pre-documented errors. Use standard hide and code tags.

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 7:42 pm
by Marth8880
Oceans14 wrote:The debugger is the bf2_modtools.exe, and the error log is called bf2_log.txt (or something similar, you'll see it.) If you haven't already, move bf2_modtools.exe from your modding directory to your actual bf2 directory. It should be sitting next to the exe for the actual game.
Yep. Specifically, the name of the log file is BFront2.log, and BF2_ModTools.exe must be copied to and launched from the GameData directory.

Re: Ambush and animation when entering region?

Posted: Mon Oct 03, 2016 10:04 pm
by SkinnyODST
I never did that. I added modtools.exe to the game dir and everything works fine, but when I load my map it crashes. And the only thing I could find like bf2_log is called BFront2