Home   Help Search Login Register  

Author Topic: Fleeing Civilians when weapons fired near. Multiplayer use.  (Read 4320 times)

0 Members and 1 Guest are viewing this topic.

Offline Bandicoot

  • Members
  • *
    • www.teameliteforces.com
Hi everyone.

This demo is intended for MP.

I have a demo of civilians fleeing when shots fired near them to create an extra element for mission makers.  This idea I started on BIS forums and was suggest by a user Hoz(not sure if same as one here) to submit to this forum.  When I've played some missions I've found there to be a lack civilians and realism which ends up looking like playing on a desert island map.  So I thought what if you had the civilians run in random directions to simulate civilians in panic and adding the element for units to use caution when firing.

I might mention this point the config you can give units "this allowfleeing 1" only made the units go to one location in town.

The main setup config to what civilians flee is a radius of about 25mtrs from the unit firing a weapon. 

The only major problem I found with this is, if the server is running as persist state(continuous play) all new players joining will receive the error about the publiceventhandler.  I am thinking the init.sqf file needs an edit to run with onplayerconnect scripting.  Remove eventhandler then reinitalize or something for everyone.  Otherwise the demo works fine when everyone starts the mission at the same time.

You could also replace the triggers on map and replace with scripting in the init for performance, but I have not been able to have the time in RL to persue sqf scripting. 

This idea I thought maybe good for those maps like Evo or Domination missions where you have true population to think about instead of carpet bombing the town.   :whistle: :o   Manage the lag with west present type deal suggestion.   ????

Anyhow appreciate anyone that can improve this idea.


Regards,
Bandicoot
www.teameliteforces.com




Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Fleeing Civilians when weapons fired near. Multiplayer use.
« Reply #1 on: 15 Feb 2009, 10:20:43 »
What kind of error do you have there?
Anyway, you may try to:
Add a Sleep 1 at the beginning of the init.sqf
Add a Fired_Gun = objNull at the beginning of the init.sqf
Add the Fired event handlers to the units in the init.sqf inside a condition ifServer {

Offline Bandicoot

  • Members
  • *
    • www.teameliteforces.com
Re: Fleeing Civilians when weapons fired near. Multiplayer use.
« Reply #2 on: 18 Feb 2009, 06:02:48 »
What kind of error do you have there?

The error is:
'... {_this exec "fleeCiv.sqf" };
Fired_Gun |#|addPublicVariableEventHandler { [((_this...'
Error addPublicVariableEventHandler: Type Object, expected String

This only occurs to the new player joining the mission while the mission is in progress.




Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Fleeing Civilians when weapons fired near. Multiplayer use.
« Reply #3 on: 19 Feb 2009, 22:17:59 »
You might try the steps listed above, perhaps the problem will be gone this way.

Offline Bandicoot

  • Members
  • *
    • www.teameliteforces.com
Re: Fleeing Civilians when weapons fired near. Multiplayer use.
« Reply #4 on: 07 Jan 2010, 09:40:32 »
Just thought I'd like to share that I did get this resolved with the following.

Unit init field:
Code: [Select]
this addEventHandler ["fired",{_this exec "flee.sqf"}];

Init.sqf
Code: [Select]
Fired_gun= nil;
if (isServer) then {
Fired_Gun_handler = {_this exec "fleeCiv.sqf" };
Fired_Gun addPublicVariableEventHandler { [((_this select 1) select 0)] call Fired_Gun_handler };
};

Flee.sqf
Code: [Select]
if (!isServer) exitWith {};
_unit = _this select 0;
Fired_Gun = _unit;
Publicvariable "Fired_Gun";
Fired_Gun call Fired_Gun_handler;
if (true) exitWith {};

FleeCiv.sqf
Code: [Select]
_unit = Fired_gun;
_list = position _unit nearObjects 25;
{if (side _x == civilian) then {_x setspeedMode "full"; _x domove [(getpos _x select 0)+(Random 100 - (random 100)),(getpos _x select 1)+(Random 100 - (random 100)),0];}}foreach _list;
Fired_gun= nil;
publicVariable "Fired_gun";
if (true) exitWith {};

The civilians run in any direction for up to 100metres.

Thank you Mandoble.

Regards,
Bandicoot
www.teameliteforces.com