#How to increase the player damage
1 messages · Page 1 of 1 (latest)
Start with looking at the Hit event on the events page, and what parameters it gives you
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Hit
It gives an example of adding it to a unit and using params to take each passed argument and turning it into a variable
[apple, pear, orange] call {
_this select 0; //apple
_this select 1; //pear
_this select 2; //orange
};
[apple, pear, orange] call {
params ["_apple", "_pear", "_orange"];
_apple; //apple
_pear; //pear
_orange; //orange
};
just showing you what params is actually doing. Its creating private variables of whatever you want to call them inside of the new scope based on what you pass to the scope.
okay, i see
You can also use any array by using it as the left argument, but if none is present it uses _this which is what parameters are stored in
["1", "2", "3"] params ["_one", "_two", "_three"];
_one; // "1"
_two; // "2"
_three; // "3"
got it
so i need to point which params i want to use
and what each one means, depending on what it is calling for?
so, for example
Yes, and the parameter order needs to match, so if you don't need a value, you can just use ""
["1", "2", "3"] params ["_one", "", "_three"];
_one; // "1"
_two; // undefiend
_three; // "3"
this addEventHandler ["Hit", {
params ["_unit", "_source", "_damage", "_instigator"];
}];
i would have to change the _unit and etc to the specific objects and number i want?
i see, it reads from left to right
No, _unit is the unit that is receiving the damage, and _damage is how much damage the unit just recieved
If you want to change what unit gets the event handler, you want to add it to that unit
Say you have a unit placed in the editor that's called target. If you want to deal more damage to it, you would add the event handler to target.
target addEventHandler ["Hit", {
// ...
}];
Can you clarify that?
What do you mean by "don't want to specify"
the target
like, i want to increase the damage dealt by my player to soldiers, but not to structures or vehicles
You can only add event handlers to a specific object
If you're using CBA, there is a function that lets you add an event handler to a specific class, or classes that inherit from the class you specify
yes, i do have that installed
In that case, you could do:
["CAManBase", "hit", {
params ["_unit", "_source", "_damage", "_instigator"];
}] call CBA_fnc_addClassEventHandler;
Which would add a hit event handler to everything that inherits from CAManBase (i.e. units)
hit should work, although I can't test it myself currently
You could add that code and then just add a systemChat str _this to the event handler code to test it
sure, i have the game ready here
let me set the code and test it out
should i change the _unit, _source, _damage, _instigator to test it out?
It doesn't change anything
like this?
systemChat str _this ["CAManBase", "hit", {
params ["_unit", "_source", "_damage", "_instigator"];
}] call CBA_fnc_addClassEventHandler;
says it's missing something
its missing a ;
["CAManBase", "hit", {
params ["_unit", "_source", "_damage", "_instigator"];
systemChat format["Unit [%1] hit by: %2", _unit, _instigator];
}] call CBA_fnc_addClassEventHandler;
You're running that systemChat line before you add the event handler.
You'd want to put it in the braces in the function call
Like how Hypoxic did it, and also added some nicer formatting
okay, im gonna try it now
to test it i need to shoot someone?
okay, tested it, it showed me the units being hit by "commander" which is my player current slot position
how should i proceed now?
now i only need to fix the destination of the damage and such
what is my next step to dealing more damage to the ai's?
@random cairn got a minute?
i was thinking about what you showed me yesterday with Hypoxic
so in my thought
following the logic to the exemple on params
["CAManBase", "hit", {
["target", "", "_damage", "localplayer"] params ["_unit", "_source", "_damage", "_instigator"];
}] call CBA_fnc_addClassEventHandler;
would this be correct?
or at least close to it?
Nope, the array before params doesn't make sense
Also, i tried using the script for no reload inf ammo
Seems it only affects the secondary weapon
Aka pistols
So i changed mine a bit
Made it only add another mag once the last shot of the gun is fired
you can't use CBA_addClassEventHandler with it, but you use HandleDamage
_unit addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
if (isPlayer _unit) exitWith {_damage};
private _multiplier = 2.0; // double damage to AI
private _damageModified = _damage * _multiplier;
diag_log format["---------- Damage Handle ----------", _unit];
diag_log format["Unit: %1", _unit];
diag_log format["Original Damage: %1", _damage];
diag_log format["Modified Damage: %1", _damageModified];
diag_log "-----------------------------------";
_damageModified
}];
question, it'll affect only my player unit?
It effects whatever unit you put it on. Will not effect players.
This is modifying damage received, not given. Think about it differently.
Now you can add filters so that it only makes it so that damage taken from players is changed, etc
You need to add that handler to every non player unit.
@frigid karma found this one as well
[] spawn {
while {true} do {
{
_x setVariable ["HAF_spawned",true];
_x addEventHandler ["handleDamage", {1}]
} forEach (allUnits select {isNil {_x getVariable "HAF_spawned"} && side _x == EAST});
uiSleep 2;
};
};
but depending on the map and mod map
it doesn't work