Scripts / Trigger zone - Respawn enemies when passing by

Author
Message
DareESP
User Offline
Joined: 15th Aug 2021
Location:
Posted: 6th Sep 2021 22:47
Hi All,

I was playing with the trigger zone LUA script by default but I am not able to create what I want.

I would like to spawn enemies every time the player is passing by the trigger zone. Can someone help me?

Thank you in advance!
PM
DareESP
User Offline
Joined: 15th Aug 2021
Location:
Posted: 6th Sep 2021 23:01
Just to clarify. The current trigger zone is working like that only once, but if the player is passing by again, it does not take any effect.
PM
GubbyBlips
2
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 7th Sep 2021 01:22
Seems like a question often asked here in the forums, but I couldn't find a specific thread on it.
I don't see a trigger_zone.lua script. I see the plrinzone.lua script which comes attached to trigger zones.
I think you just remove the line that says --Destroy(e).

Optionally if your zone you wish to use is not a complex shape -- iow if it can just be a point you approach
and get close to, could you use GetPlayerDistance( e )
if GetPlayerDistance( e ) < 150 then
Spawn(the_hordes) -- ? ... and might need some checks on their health status, existence etc.
PM
DareESP
User Offline
Joined: 15th Aug 2021
Location:
Posted: 7th Sep 2021 09:49
Hi !

Thank you for your response. Yes, but the issue is that by deleting the line Destroy is not working. There is no enemies respawn when passing by.



I would like enemies to respawn when players when out of the trigger zone and come in again.
PM
smallg
Community Leader
15
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 7th Sep 2021 16:17
the Spawn() function (or ActivateIfUsed()) doesn't work like that, it spawns the object which was set as spawnatstart = no, so if the entity is already active (from being spawned before) it will not spawn a copy of it but rather spawn the same entity again (i.e. it will get reset health etc)... if you are dealing with AI or things that have moved etc you will need to custom script it to put them back where they started so it works as expected
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
GubbyBlips
2
Years of Service
User Offline
Joined: 14th Jan 2019
Location:
Posted: 7th Sep 2021 18:43
@DareESP
My suggestion: for bet results try to think outside the GG stock box (stuff which is "supplied").
So smallg is directing you in the right way. (I never knew what ActivateIfUsed was used for!)

If you want to take control with a red-neck attitude like I basically do with scripting, you could
just have these enemies moved to the edge of the map when they are detained, (NOT destroyed)
and this will deactivate them, and if you want to be absolutely sure they are glued in place, you
could have them moved into a "jail" cell (ie say concrete box) and then move them with script back
to the spawn location when you pass by the spawn point. I would assume they would be plenty
aggravated enough from all that back and forth and ready to attack. This would be a little trick to it,
and a bit involved but worth the experience of self- accomplishment.

I see where you took bluemeenie195's help to offer this Destroy(AI) of previous task;
Maybe just move them instead so they can come back w/ Schwarzenegger?

function plrinzone_init(e)
end
function plrinzone_main(e)
if g_Entity[e]['plrinzone']==1 then
Hide(1) -- change the 1 to the entity # of the object you want to hide
PlaySound(e,0)
---- Destroy(e) -- Try a SetPosition(AI#,999,999,999)
---- Injured? SetPosition back to your happy place!
--- https://www.youtube.com/watch?v=sCLlwww-iy0
ActivateIfUsed(e)
end
end
PM

Login to post a reply

Server time is: 2021-11-27 12:27:12
Your offset time is: 2021-11-27 12:27:12