Jump to content
Sign in to follow this  
mith86arg

Inf ammo + No damage for the whole team

Recommended Posts

Hi guys, the title says what im trying to do atm...

The thing is what i'm making an endless survival mission with different types of waves orderer by the time you're alive... at minute 15 a full wave of tanks spawn but my IA team already used EVERYTHING in their pockets to kill the enemy.

So im looking to fix this via scripts commands to finish the test the entire cicle of waves (there are 6 more waves :( )

So far so good i found this on the wiki:

https://community.bistudio.com/wiki/CMB:SimplifyTesting

[] spawn
{
while {true} do
{
 player allowDamage false;
 (vehicle player) allowDamage false;
 sleep 0.1;
};
};

For inf ammo i can use eventhandlers, like:

{_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];} foreach units group player;

but im unsure if i'm doing it right (in game actually i got inf ammo but don't know about the team, plus, im suffering a little stutter every time i shoot a bullet (?)

This code below is the actual frankenstein i'm using:

[] spawn
{
while {true} do
{
 player allowDamage false;
 (vehicle player) addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
 (vehicle player) allowDamage false;
 { _x allowDamage false; } forEach units group player;
 {_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];} foreach units group player;
 sleep 0.1;
};
};

any help to make it work properly would be appreciated

Share this post


Link to post
Share on other sites

you are adding a new fired event handler every 0.1 seconds, this means 10 ehs every second and all of them will execute as soon a you fire, and you only have little stutter? what do you have a supercomputer?

Share this post


Link to post
Share on other sites

[] spawn {
_vehGrp = [];  // empty array to check vehicles in use.
_grp = [];     // empty array to check group for new members.

while {true} do {
	{
		//  check every unit in group, if not in a vehicle and not in _grp array: then add godmode and unlimited ammo and add to _grp array, else do nothing.
		if !(_x in _grp AND (vehicle _x) == _x) then {
			_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
			_x allowDamage false;
			_grp = _grp + [_x];
		};
		//  check every unit in group, if in a vehicle and vehicle is not in _vehGrp array: then add godmode and unlimited ammo to vehicle and add to _vehGrp array, else do nothing.
		if (vehicle _x != _x AND !(vehicle _x in _vehGrp)) then {
			(vehicle _x) addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
			_vehGrp = _vehGrp + [(vehicle _x)];
			(vehicle _x) allowDamage false;
		};
	} foreach units (group player);

	sleep 0.5;
};
};

try this, will only check group for changes ( new group members, vehicles) every 0.5 seconds and add godmode and ammo only once.

Share this post


Link to post
Share on other sites
you are adding a new fired event handler every 0.1 seconds, this means 10 ehs every second and all of them will execute as soon a you fire, and you only have little stutter? what do you have a supercomputer?

Nope, also i said that the micro stutter is there every time i shoot, imagine how worse can this be if i empty a mag in full-auto, my specs are in the raptor profile btw, it's far away from being a super computer.

[] spawn {
_vehGrp = [];  // empty array to check vehicles in use.
_grp = [];     // empty array to check group for new members.

while {true} do {
	{
		//  check every unit in group, if not in a vehicle and not in _grp array: then add godmode and unlimited ammo and add to _grp array, else do nothing.
		if !(_x in _grp AND (vehicle _x) == _x) then {
			_x addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
			_x allowDamage false;
			_grp = _grp + [_x];
		};
		//  check every unit in group, if in a vehicle and vehicle is not in _vehGrp array: then add godmode and unlimited ammo to vehicle and add to _vehGrp array, else do nothing.
		if (vehicle _x != _x AND !(vehicle _x in _vehGrp)) then {
			(vehicle _x) addeventhandler ["fired", {(_this select 0) setvehicleammo 1}];
			_vehGrp = _vehGrp + [(vehicle _x)];
			(vehicle _x) allowDamage false;
		};
	} foreach units (group player);

	sleep 0.5;
};
};

try this, will only check group for changes ( new group members, vehicles) every 0.5 seconds and add godmode and ammo only once.

And here you are solving all my problems -again- haha ty bro! best part is that this piece of code is working super fine! tested with recruited units (from bon infantry) and yes, they have inf ammo when join the squad! many many thnx!

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  

×