Jump to content
phronk

[Release] Fleeing Civilians

Recommended Posts

On 1/1/2017 at 9:36 AM, phronk said:

Works fine in my MP mission tested on a dedicated server with spawned civilians (Civ spawning script used: Engima's Civilians) but the only difference was the 'civFlee' function was defined in it's own script containing functions.

 

 

How did you integrate this into Engima's civs?  I use that in my missions and this would be a great addition.

 

Thanks!

 

--ATV

Share this post


Link to post
Share on other sites

After the line in the engima civs script which creates the unit, I add the eventHandler to the unit.

Share this post


Link to post
Share on other sites

so in engima's ServerFunctions.sqf:

 

if (count _pos > 0) then {
            _group = createGroup _side;
            _unit = _group createUnit [_unitClasses select floor random count _unitClasses, [0, 0, 100], [], random 360, "FORM"];
            ****  INSERT eventhandler HERE??  ****  <---
            ENGIMA_CIVILIANS_INSTANCE_NO = ENGIMA_CIVILIANS_INSTANCE_NO + 1;
            _unit setVehicleVarName "ENGIMA_CIVILIAN_UNIT_" + str ENGIMA_CIVILIANS_INSTANCE_NO;
            
            doStop _unit;
            _unit setPos _pos;
            
            [_unit] spawn _fnc_OnSpawnCallback;
        };

 

Have you seen any weird behavior / conflicts  with your script and Engima's civs as of yet?  Thanks again. 

Share this post


Link to post
Share on other sites

Why this? there are already  OnSpawnCallback function for unit.

You can see it even in your example above.

Go to the configuration file ConfigAndStart.sqf

Find this line:

["ON_UNIT_SPAWNED_CALLBACK", {}],

add your eventhandler there:

["ON_UNIT_SPAWNED_CALLBACK", {_this addeventhandler ..blahblah}],

 

Share this post


Link to post
Share on other sites

 

Ecstatic these animations were found -they were in Arma 2 I believe. We need these so much and thanks for the script.

  • Like 1

Share this post


Link to post
Share on other sites
13 hours ago, davidoss said:

Why this? there are already  OnSpawnCallback function for unit.

You can see it even in your example above.

Go to the configuration file ConfigAndStart.sqf

Find this line:


["ON_UNIT_SPAWNED_CALLBACK", {}],

add your eventhandler there:


["ON_UNIT_SPAWNED_CALLBACK", {_this addeventhandler ..blahblah}],

 

:face_palm:  d'oh I shoulda seen that.  Thanks for the clarification!

 

--ATV

Share this post


Link to post
Share on other sites

@phronk AWESOME script. I've been able to get it work with COS, just by adding the whole "init.sqf" to the addscript_Unit.sqf....works like a charm! 

  • Like 2

Share this post


Link to post
Share on other sites

Hey All

Sounds like an awesome script! Has anyone tried it with ALiVE?

 

I'm looking forward to trying it.

 

Thanks

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi phronk

 

Brilliant idea, the way vanilla civs wander about during firefights as if they were strolling through a park has always bugged me.

 

Thanks, looing forward to trying it out.

 

 

Share this post


Link to post
Share on other sites

 

 Anyone gotten this to work with TPW's spawned civs? Ive added the Call into where the civs are spawned but it seems to work in a delayed fashion. Meaning Ill shoot at a crowd and they dont react, but then ill see a lone civ running scared a block away

Share this post


Link to post
Share on other sites

I didn't have much luck using the callback function in enigma's civ script so I just inserted it directly.  Works awesome. 

 

Phronk, I also merged the arrays of class names that you have for all the buildings for the declared maps and made just one large array (got rid of duplicates) and got rid of searching for what map is loaded.  I don't see any impact behavior so you might just want stick with one array of every enterable building known.  That might simplify things a bit and provide maximum map compatibility.

 

--ATV 

Share this post


Link to post
Share on other sites

Thank you for this awesome script!

But i have no idea how to implement it into the enigma civ script..can anyone give me an example, please?
Sorry for my bad english..

Thanks

Share this post


Link to post
Share on other sites

Hey @phronk thanks for this, it's an awesome script that I think I'll be using in just about every mission going forward.

 

One question though is there some way to take into account suppressors? At the moment the EH just works off the distance to the person firing. Is there some way to adapt it so that range shrinks if the weapon fired has a suppressor?

 

Thanks again for the script, it's great

 

Oh and one more question, is there any way to turn if off on a certain civilian? I wouldn't want my informant running away 

Share this post


Link to post
Share on other sites

Really great Script ! Is there are way to modify the distance they react to? I saw that the firedNear eventhandler just triggers in a distance of maximum 69 meters.

Share this post


Link to post
Share on other sites

I do something similar, but I have them run to the nearestBuilding, rather than choosing one at random. It takes away some randomness, but saves a CPU cycle or two.

Share this post


Link to post
Share on other sites

i think you missunderstood. What i wanted to change was the distance they go in panic mode if a shotis fired. Right now civilians which are more then 70 meters away from the shooter dont react. Looks stupid if they have their animations stil standing around.

but the eventhandler fired says in the biki, is only until 69 meters. im searching for a way to raise the distance to the gunshot they react. maybe a triggerare where they react would be cool. tried to code somtehing but my skills are not the enough sadly.

Share this post


Link to post
Share on other sites

I just want to say i appreciated your video explaining how it (the code) works.

Share this post


Link to post
Share on other sites
On 25/08/2017 at 11:47 AM, Tankbuster said:

I do something similar, but I have them run to the nearestBuilding, rather than choosing one at random. It takes away some randomness, but saves a CPU cycle or two.

@Tankbuster is this a modification of phronk's script or something different you have put together? either way i'd like to have a look if you're willing to share, always keen on comparing scripts and weighing up efficiency vs effect. 

Share this post


Link to post
Share on other sites
Just now, rdme said:

@Tankbuster is this a modification of phronk's script or something different you have put together? either way i'd like to have a look if you're willing to share, always keen on comparing scripts and weighing up efficiency vs effect. 

I don't use @phronk script, to spawn my civilians. I use my own little routine within a large script that populates my primary targets with enemy assets. I'll dig it up and post the relevant bits in my own thread so as not to clutter up this one.

 

*edit* Rather embarrassingly, I don't appear to have written that code, or at least I can't find it. Give me a couple of years to get it done. :)

  • Haha 1

Share this post


Link to post
Share on other sites
1 hour ago, Tankbuster said:

I don't appear to have written that code, or at least I can't find it. Give me a couple of years to get it done. :)

Like most things hehe :rofl::rofl:

  • Haha 1

Share this post


Link to post
Share on other sites

I am really new to scripting.

Is there a way to make it so that rather than flee to the nearest building. The Civs will flee to a random map marker out of a load which have been placed around the area.

Share this post


Link to post
Share on other sites

Very nice !!!

However i have a problem: this overrides civilian presence position. I wanted civilians going to hide in buildings, while it worked previously now they are just running away. Also it would be nice to toggle panic mode on permanently, so i don't need fire near them to active it.

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

×