thanks
Ambush and animation when entering region?
Moderator: Moderators
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Ambush and animation when entering region?
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
thanks
thanks
-
AQT
- Gametoast Staff

- Posts: 4910
- Joined: Sat Nov 03, 2007 4:55 pm
- Location: SoCal, USA
Re: Ambush and animation when entering region?
Do you know how to:
If so, use all of that with the following, and you should be good to go:
- 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:
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
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
- GAB
- 1st Lieutenant

- Posts: 431
- Joined: Sun Jul 03, 2011 8:56 pm
- Location: Somewhere around the world
- Contact:
Re: Ambush and animation when entering region?
Read section V of the procedural animation mode doc. It teaches everything you'll need to know about that topic.SkinnyODST wrote:1. I know how to animate props but not how to play them via luaAQT wrote:Do you know how to:
- animate props and play the animation via lua
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:2. Not really, i`ve read the tut on it but don`t really understand how to set thing out.AQT wrote:
- create a timer
This tutorial should be helpful, more specifically the THE OTHER METHOD: AMBUSH() section.SkinnyODST wrote:3. NoAQT wrote:
- trigger an ambush via lua without having the player enter a region
?
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.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
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
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.
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 
Here`s what I added, I`m just trying to give the objective of capturing one of the cp`s.
Hidden/Spoiler:
-
AQT
- Gametoast Staff

- Posts: 4910
- Joined: Sat Nov 03, 2007 4:55 pm
- Location: SoCal, USA
Re: Ambush and animation when entering region?
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:
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
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
This is right under "function ScriptPostLoad()"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" )Can you figure out the remaining 5% by yourself?
- 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
Hidden/Spoiler:
-
AQT
- Gametoast Staff

- Posts: 4910
- Joined: Sat Nov 03, 2007 4:55 pm
- Location: SoCal, USA
Re: Ambush and animation when entering region?
Three things: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.
- 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)
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:SkinnyODST wrote:The ambush works because it was already set up.
And this is what you have now in code you posted above:Code: Select all
SetupAmbushTrigger("ambushregion", "ambushpath", 6, 3)
(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?Code: Select all
Ambush(ambushpath, 8, 5)
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.
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
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
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
-
AQT
- Gametoast Staff

- Posts: 4910
- Joined: Sat Nov 03, 2007 4:55 pm
- Location: SoCal, USA
Re: Ambush and animation when entering region?
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?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.
If you are, get rid of it. Having this line causes the ambush to occur immediately.Code: Select all
SetupAmbushTrigger("ambushregion", "ambushpath", 6, 3)
Again, it could be a number of things:SkinnyODST wrote:Do you know why this isn`t working?
- 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:
It should be:
Code: Select all
IsCharacterHuman(character)Because it would then match with:Code: Select all
IsCharacterHuman(player)Code: Select all
function(region, player)
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
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?
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Ambush and animation when entering region?
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"
)-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
Put anywhere at the end of the ScriptPostLoad() function in your Lua.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" )
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"
)-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Ambush and animation when entering 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-LUASkinnyODST wrote:Everything is named right and set up in ZE. However nothing happens when I step into the region?Code: Select all
... PlayAnimation("region_anim", "arcflyregion", 0, 15) ...
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
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.I don't know why you added those extra arguments to PlayAnimation()
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Ambush and animation when entering region?
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?
Also what has the debugger been outputting?
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
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
- Oceans14
- Command Sergeant Major

- Posts: 296
- Joined: Mon Apr 27, 2015 7:09 pm
- Projects :: Athenova Campaign
- Location: Planet 4546b
Re: Ambush and animation when entering region?
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.
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.
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Ambush and animation when entering region?
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.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.
-
SkinnyODST
- Lieutenant Colonel

- Posts: 545
- Joined: Mon Jul 04, 2016 10:56 pm
- Location: My other account
- Contact:
Re: Ambush and animation when entering region?
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
