#How to increase the player damage

1 messages · Page 1 of 1 (latest)

cerulean laurel
#

.

random cairn
frigid karma
#
[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.

cerulean laurel
#

okay, i see

random cairn
#

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"
cerulean laurel
#

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

random cairn
#

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"
cerulean laurel
#

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?

cerulean laurel
random cairn
#

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

cerulean laurel
#

and if i don't want to specify?

#

i leave it blank?

random cairn
#

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", {
    // ... 
}];
random cairn
cerulean laurel
#

like, i want to increase the damage dealt by my player to soldiers, but not to structures or vehicles

random cairn
#

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

cerulean laurel
random cairn
#

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

cerulean laurel
#

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?

random cairn
#

It doesn't change anything

cerulean laurel
#

like this?

#

systemChat str _this ["CAManBase", "hit", {
params ["_unit", "_source", "_damage", "_instigator"];
}] call CBA_fnc_addClassEventHandler;

#

says it's missing something

#

its missing a ;

frigid karma
#
["CAManBase", "hit", {
    params ["_unit", "_source", "_damage", "_instigator"];

    systemChat format["Unit [%1] hit by: %2", _unit, _instigator];
}] call CBA_fnc_addClassEventHandler;
random cairn
#

Like how Hypoxic did it, and also added some nicer formatting

cerulean laurel
#

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

cerulean laurel
#

how should i proceed now?

cerulean laurel
#

now i only need to fix the destination of the damage and such

cerulean laurel
#

what is my next step to dealing more damage to the ai's?

cerulean laurel
#

@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?

frigid karma
#

Nope, the array before params doesn't make sense

cerulean laurel
#

Then i have zero idea how to make this work

#

Lol

cerulean laurel
#

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

frigid karma
#

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
}];
cerulean laurel
#

Oooh i see

#

Thanks, I’ll test it out later

#

Thanks a lot

cerulean laurel
frigid karma
cerulean laurel
#

so i should just change "_unit" to "player"?

#

right at the start of the script?

frigid karma
#

This is modifying damage received, not given. Think about it differently.

cerulean laurel
#

oooh

#

i thought it would be damage given

frigid karma
#

Handle damage fires when a unit is damaged.

#

By anything

cerulean laurel
#

so i don't need to change anything?

#

on the script

frigid karma
#

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.

cerulean laurel
#

okay, i'll do it then

#

thanks for the help man

cerulean laurel
#

@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