-
Notifications
You must be signed in to change notification settings - Fork 737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow damage handler (also block only collision damage) #2758
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4cc47ee
Allow Damage Handler
PabstMirror 05c9301
Fix Litter Module Setting
PabstMirror 6ceeac9
Fix allowDamage in fixFloating for PR #2230
PabstMirror 6d15f17
Change fixCollision
PabstMirror 964bc83
Merge remote-tracking branch 'refs/remotes/origin/master' into allowD…
PabstMirror 06fc6fa
Remove handleDamageEH and just use medical
PabstMirror File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Author: PabstMirror | ||
* Called when a unit switched locality | ||
* | ||
* Arguments: | ||
* 0: XEH Object <OBJECT> | ||
* 1: Is local <BOOL> | ||
* | ||
* ReturnValue: | ||
* None | ||
* | ||
* Public: No | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_object", "_local"]; | ||
TRACE_2("params",_object,_local); | ||
|
||
if (_local) then { | ||
local _allowDamageArray = _object getVariable [QGVAR(allowDamage), []]; | ||
if (!(_allowDamageArray isEqualTo [])) then { | ||
//If locality swiched and this unit has had setAllowDamage run, reApply the effects: | ||
[_object, "", -1] call FUNC(setAllowDamage); | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* Author: PabstMirror | ||
* Allows multiple sources to block all or just collision damage on people/objects | ||
* | ||
* Arguments: | ||
* 0: Object (should be local) <OBJECT> | ||
* 1: Source Reason <STRING> | ||
* 2: State (true/false or 0 = allow all, 1 = block colision (CAManBase only + req medical), 2 = block all) <NUMBER><BOOL> | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [box1, "doNotExplode", true] call ace_common_fnc_setAllowDamage; | ||
* [guy, "preventColisionDmg", 1] call ace_common_fnc_setAllowDamage; | ||
* [guy, "", -1] call ace_common_fnc_setAllowDamage; //Won't modifiy state and just reapply effects | ||
* | ||
* Public: Yes | ||
*/ | ||
#include "script_component.hpp" | ||
|
||
params ["_object", "_reason", "_state"]; | ||
TRACE_3("params",_object,_reason,_state); | ||
|
||
if (!local _object) exitWith { | ||
ACE_LOGERROR_1("setAllowDamage - obj not local - %1", _this); | ||
["allowDamage", [_object], _this] call FUNC(targetEvent); | ||
}; | ||
|
||
if ((typeName _state) == "BOOL") then {//Convert bool to number | ||
_state = [2,0] select _state; | ||
}; | ||
if ((_state == 1) && {(!(_object isKindOf "CAManBase")) || {!(["ace_medical"] call FUNC(isModLoaded))}}) then { | ||
_state = 2; //Can't do 'blockCollision' on non man or if mod not loaded | ||
}; | ||
|
||
local _allowDamageReasons = missionNamespace getVariable [QGVAR(allowDamageReasons), []]; | ||
(_object getVariable [QGVAR(allowDamage), [0,0]]) params ["_blockCollisionNum", "_blockDamageNum"]; | ||
|
||
local _blockCollisionArray = [_blockCollisionNum, count _allowDamageReasons] call FUNC(binarizeNumber); | ||
local _blockDamageArray = [_blockDamageNum, count _allowDamageReasons] call FUNC(binarizeNumber); | ||
|
||
//If there is a reason, set it in the arrays: | ||
if (_reason != "") then { | ||
_reason = toLower _reason; | ||
// register new reason (these reasons are shared publicly, since units can change ownership) | ||
if !(_reason in _allowDamageReasons) then { | ||
_allowDamageReasons pushBack _reason; | ||
GVAR(allowDamageReasons) = _allowDamageReasons; | ||
publicVariable QGVAR(allowDamageReasons); | ||
}; | ||
local _index = _allowDamageReasons find _reason; | ||
switch (_state) do { | ||
case (0): { | ||
_blockCollisionArray set [_index, false]; | ||
_blockDamageArray set [_index, false]; | ||
}; | ||
case (1): { | ||
_blockCollisionArray set [_index, true]; | ||
_blockDamageArray set [_index, false]; | ||
}; | ||
case (2): { | ||
_blockCollisionArray set [_index, false]; | ||
_blockDamageArray set [_index, true]; | ||
}; | ||
}; | ||
}; | ||
|
||
local _newBlockCollisionNum = _blockCollisionArray call FUNC(toBitmask); | ||
local _newBlockDamageNum = _blockDamageArray call FUNC(toBitmask); | ||
|
||
//Update and broadcast variables if they changed: | ||
if ((_newBlockDamageNum != _blockDamageNum) || {_newBlockCollisionNum != _blockCollisionNum}) then { | ||
TRACE_2("Updating",_newBlockCollisionNum, _newBlockDamageNum); | ||
_object setVariable [QGVAR(allowDamage), [_newBlockCollisionNum, _newBlockDamageNum], true]; | ||
}; | ||
|
||
if ((_object isKindOf "CAManBase") && {["ace_medical"] call FUNC(isModLoaded)}) then { | ||
//ACE_medical already has a handleDamage installed on the Unit and we can just setVariables for it | ||
TRACE_1("handled by ace medical", _object); | ||
|
||
_object setvariable [QEGVAR(medical,allowDamage), (_newBlockCollisionNum > 0), true]; | ||
_object setvariable [QEGVAR(medical,allowCollisionDamage), (_newBlockCollisionNum > 0), true]; | ||
} else { | ||
if (_newBlockDamageNum > 0) then { | ||
TRACE_1("Blocking Damage", _object); | ||
_object allowDamage false; | ||
} else { | ||
TRACE_1("Allowing Damage", _object); | ||
_object allowDamage true; | ||
}; | ||
}; | ||
|
||
nil |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.