Jump to content
Sign in to follow this  
Rhamka

How to create unit in trigger zone and respawn them if killed?

Recommended Posts

Sorry if do not offer any kind of code, but scripting is very difficult. So basically this is a request. Im trying to create a mission where there is a trigger activated by anyone and a group of units respawn inside the trigger zone and then if they are killed they must able to respawn later (whether the unit activating the trigger is still present or if anyone else returns to the zone). Frankly I do not know if they need a group of markers to respawn randomly or not. Can someone help please?

Share this post


Link to post
Share on other sites

Just as a simple example of how it could be done. I'll assume you want to kill US troops.

Create 1 nonplayable blufor unit, somewhere on the map, anywhere it doesn't matter, and set is probability of presence to 0%.Set a trigger to opfor not present,repeatedly, the size of the town or area. Place two invis hpads in the town and give them unique names. You could even set both of the hpads in the very center of the town (center of the trigger area) and give them a placement radius almost as big as the trigger area, to provide some randomness. Anyhow In the example below I named the hpads iPad & tPad respectively. Place a functions module on the map. Place a game logic on the map and name it server. In the triggers onAct put

_handle=[]execVM "townSpawn.sqf"

In your mission folder make a new sqf document named townSpawn

if (!isServer) exitWith {};

waituntil {!isnil "bis_fnc_init"};

_iGroup=[getPos iPad, WEST, 25] call BIS_fnc_spawnGroup;
_tGroup=[getPos tPad, WEST, (configFile >> "CfgGroups" >> "West" >> "BIS_US" >> "Armored" >> "US_MGSPlatoon")] call BIS_fnc_spawnGroup;
nul=[_iGroup, position iPad, 100] call BIS_fnc_taskPatrol;
nul=[_tGroup, position tPad, 100] call BIS_fnc_taskPatrol;

i didn't test this but it should work.

Share this post


Link to post
Share on other sites

You read my mind of what I intended but this is not to kill Blufor but resistance too, actually I'm woking with the stalker addons and the anomalies and bloodsuckers to create a multiplayer mission, the bloodsuckers, blind dogs and zombies are resistance but it doesn't matter as they attack Indfor, bluefor or opfor, I just had no idea of how to respawn them in different places of the map. I'll give it a try right now and play a little with these to have different groups respawning in different places. So many thanks for answering so fast. I think I must config a group of monsters to make this work if there is not one yet.

---------- Post added 12-22-2012 at 12:17 AM ---------- Previous post was 12-21-2012 at 11:42 PM ----------

I tested it and worked with a modification, I think a typo went wrong, if you placed a blufor unit to 0% probability then the trigger must state blufor repeteadly not present (not opfor). I'll try make different respawn points with this for big areas and then respawn different kind of units for simulating a dangerous zone once entered in the "zone". Thanks for the script Iceman77.

Share this post


Link to post
Share on other sites

Yeah my bad I ment blufor not present. I was just copy and pasting code from the wiki, and the code included blufor units, so instead of me looking up proper opfor class names, I changed my initial post so that you're fighting blufor to save myself some time, I just for got to change the "opfor" trigger part too haha

Anyhow, the 0% POP blufor unit is just to make sure the side is defined/established. To spawn units you have to create a sides center, so i assumed you had no other blufor units on the map just to be safe. hence, why i told you the 0% pop unit

Share this post


Link to post
Share on other sites

I've just waited some time and the only problem is that they don't seem to respawn once killed. I thought it was 25 or 100 seconds to wait, but seems thats a different part of the code, can you help?

Share this post


Link to post
Share on other sites

25 is the amount of random unit types to spawn. Did you set the trigger on repeatable? The trigger should repeat if the condition keeps changing. ie west present, west not present etc.

---------- Post added at 21:50 ---------- Previous post was at 21:47 ----------

try

this && round (time %1) == 1

in the condition of the trigger. I just googled repeat triggers and apparently that will ensure the trigger repeats.

Share this post


Link to post
Share on other sites

Yes it did worked, thought I tried to activate it by making anybody present repeteadly and didn't work, but first time I tested it did work, ....(but now for some reason it doesn't and it's entirely as it's indicated... caché memory problem?? ...well... I'll check it) I tried to use a time out of 10 seconds just to test it. But the code you give me works!

---------- Post added at 01:13 AM ---------- Previous post was at 01:12 AM ----------

ah forget it, it was my bad, the blufor-opfor confussion!

---------- Post added at 01:17 AM ---------- Previous post was at 01:13 AM ----------

just to say that timeout makes the script not to work, but countdown is not a problem

Share this post


Link to post
Share on other sites

you want opfor notpresent to activate the trigger. So even at start, the game says hey, theres no opfor present - trigger fires-script runs-units created. When they're all dead, game says hey theres no opfor present - trigger fires-script runs-units created etc

Share this post


Link to post
Share on other sites

yeah, I got it, just wanted something like to tell other player "hey, there is someone over that zone as there are monsters over there", but anyway, I think it makes the mission more challenging

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×