Here's a little practice script I made to get my brain rolling back to the coding mindset. Haven't been able to write much code for a few weeks due to real life stuff.Code:nearunits = []; shotsfired = 0; hint "Initializing"; vehicle player addeventhandler ["Fired", "shotsfired = shotsfired + 1; nearunits = nearestobjects [player, ['Man'], 8]; nearunits set [0, 'remplayer']; nearunits = nearunits - ['remplayer']; {if(side _x == side player || side _x == civilian) then {_x playmove 'aidlpknlmstpslowwrfldnon_idlesteady02'};} foreach nearunits; player groupchat format['Shots fired: %1', shotsfired]; player groupchat format['nearunits = %1',nearunits]; nearunits = [];"];
Here's what this code does - Whenever you fire, any nearby units will crouch and wait. This avoids those terrible moments where AI will run in front of your line of fire (potentially causing a teamkill or friendly fire incident). This still needs some work done to it such as having your fire only affect your side, and not everyone. Maybe the player's side and civilians.
Very tired at the moment, but thought this could be a useful piece of code to some people (maybe even potential for a mod?).
EDIT - Made the gunfire awareness only affect units on the player's side and civilians.
HOME
Reply With Quote