Re: How do I allow AI to trigger OnEnterRegion?
Posted: Sat Dec 10, 2016 10:21 pm
Ok so how what do I write to make it work? OnCPCapture?Marth8880 wrote:DeactivateRegion("regionname") should do it.
Get more from your games!
http://www.gametoast.com/
Ok so how what do I write to make it work? OnCPCapture?Marth8880 wrote:DeactivateRegion("regionname") should do it.
Almost correct.SkinnyODST wrote:OnCPCapture?
Should be:SkinnyODST wrote:Code: Select all
if IsCharacterHuman (character) then
Code: Select all
if not IsCharacterHuman(character) and GetCharacterTeam(character) == REP thenMarth8880 wrote:@Anthony: The problem with SetupAmbushTrigger is that it only proceeds if the character entering the region is human:Code: Select all
--Designers: use this function to set up an ambush (don't call Ambush() directly, please) function SetupAmbushTrigger(ambushRegionName, spawnPathName, numDudes, fromTeam) local trigger --must be declared before being used trigger = OnEnterRegion( function(region, character) if IsCharacterHuman (character) then Ambush(spawnPathName, numDudes, fromTeam) ReleaseEnterRegion(trigger) end end, ambushRegionName ) ActivateRegion(ambushRegionName) end
My bad, I remember Zerted telling me something like that, I guess I took it the wrong way. In fact using "" on REP might be causing his crash issue.Marth8880 wrote:REP isn't a string though, it's very much an integer.
Code: Select all
OnEnterRegion(
function(region, character)
if not GetCharacterTeam(character) and GetCharacterTeam(character) == REP then
Aumbush("ambushregion", "ambushpath", 8, 5)
end,
"ambushregion"
)
end
endAlmost correct! That if-statement needs to be closed, try putting a single end in a new line after Ambush is called. Also remove that stray end at the very bottom of the code you posted.SkinnyODST wrote:Nope, I`ve also tried it with 1 "end", still shows errors.Code: Select all
OnEnterRegion( function(region, character) if not GetCharacterTeam(character) and GetCharacterTeam(character) == REP then Aumbush("ambushregion", "ambushpath", 8, 5) end, "ambushregion" ) end end
Code: Select all
function CaptureTeam1()
-- do stuff, this is where you'd put your KillObject call
endCode: Select all
OnFinishCaptureTeam(
function(post)
-- do stuff, this is where you'd put your KillObject call
end,
REP
)Code: Select all
OnFinishCaptureTeam(
function(post)
KillObject("cp4")
end,
REP
)The core of my wave-based combat system for my Europa map relies on this very method, so yes, I am 200% positive that this works. You just don't seem to be very familiar with how logic and control structures work within programming, which is totally understandable, everyone starts out not knowing. What you need to do is *learn how these things work* though. Like, seriously, you'll get nowhere unless you do. We can't keep writing all your code for you.SkinnyODST wrote:This still doesn`t work for me, are you sure it`s even possible to do this? Everything I`ve tried so far causes errors.
Code: Select all
OnEnterRegion(
function(region, character) -- this is a function
if not GetCharacterTeam(character) and GetCharacterTeam(character) == REP then -- this is an if-statement
Ambush("ambushregion", "ambushpath", 8, 5)
end -- this is what closes the if-statement
end, -- this is what closes the function
"ambushregion"
)Sure. Use GetEntityName with `post` as the argument (passed as the parameter from OnEnterRegion) like so:SkinnyODST wrote:am I able to decide which CP triggers the event I put into it? Because right now with this code, if the Republic captures ANY CP, cp4 will go away, am I able to add in somewhere a certain CP that will trigger CP4 to be "killed"?
Code: Select all
OnFinishCaptureTeam(
function(post)
if GetEntityName(post) == "cpname" then
KillObject("cp4")
end
end,
REP
)