-
Notifications
You must be signed in to change notification settings - Fork 40
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
Eventhandlers - Add Delay to AI Explosion Reaction #418
Open
lambdatiger
wants to merge
4
commits into
nk3nny:master
Choose a base branch
from
lambdatiger:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
PREP(delayExplosionEH); | ||
PREP(explosionEH); |
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,39 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: Lambda.Tiger | ||
* Delayed reaction to explosions. The delay is calculated on | ||
* a) A base line of reaction time | ||
* b) Distance from the explosion | ||
* c) AI general skill | ||
* | ||
* Arguments: | ||
* BIS Explosion EH | ||
* | ||
* Return Value: | ||
* None | ||
* | ||
* Example: | ||
* [BIS EXPLOSION EH ARGS] call lambs_eventhandlers_fnc_delayExplosionEH; | ||
* | ||
* Public: No | ||
*/ | ||
params [ | ||
["_unit", objNull], | ||
"", | ||
["_explosionSource", objNull] | ||
]; | ||
|
||
if (!alive _unit || | ||
!(local _unit) || | ||
isPlayer _unit) exitWith {}; | ||
|
||
private _skill = _unit skill "general"; | ||
private _timeOfFlight = if (isNull _explosionSource) then { | ||
0.03 // 10 m radius | ||
} else { | ||
(_unit distance _explosionSource) / 343 // 343 m/s - good value for speed of sound | ||
}; | ||
// min delay of 160 ms based on | ||
// EFFECTS OF PREKNOWLEDGE AND STIMULUS INTENSITY UPON SIMPLE REACTION TIME by J. M. Speiss | ||
// Loudness and reaction time: I by D. L. Kohfeld, J. L. Santee, and N. D. Wallace | ||
[{_this call FUNC(explosionEH)}, _this, 0.16 + _timeOfFlight + 0.2 * (1 - random _skill)] call CBA_fnc_waitAndExecute; |
Oops, something went wrong.
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.
we should move/do more of the checks we do in the here before we run the waitAndExecute
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.
I agree, but I think a few of these could change in time:
!GVAR(ExplosionEventHandlerEnabled)
- should have been there!alive
- coversisNull
- probably could be replaced with{!(_unit call EFUNC(main,isAlive))
{!isNul objectParent _unit}
- could be added, but units may be getting in/out and the transition happens in time{(stance _unit) isEqualTo "PRONE"}
- a thing that could be changing in that ~0.15-0.3 ms{_unit getVariable [QGVAR(explosionReactionTime), 0] > time}
- delay could be computed and then checked against this statementI'll make the changes I think I made clear I think are good ideas, but for checking if a unit is in a vehicle or is prone I could go either way on.