Added LookForEnemiesEx() for returning all enemies in an area.#2753
Merged
Conversation
This function allows for ZScript code to get an array with all enemies of the caller found in range. Using similar sight logic as functions like LookForEnemies().
This parameter allows the function to also find players around it.
Contributor
Author
|
Also added a X_WRITE_NIL VM abort in case someone passes a null array to the function. |
Prevent crashes by passing a null array by reference.
78007d7 to
d4c5965
Compare
madame-rachelle
pushed a commit
that referenced
this pull request
Oct 14, 2024
* Compartmentalized the LookForEnemiesInBlock checks * Added LookForEnemiesEx(). This function allows for ZScript code to get an array with all enemies of the caller found in range. Using similar sight logic as functions like LookForEnemies(). * Added noPlayers parameter to LookForEnemiesEx(). This parameter allows the function to also find players around it. * Added VM abort to LookForEnemiesEx(). Prevent crashes by passing a null array by reference.
tiltshiftfocus
pushed a commit
to tiltshiftfocus/gzdoom
that referenced
this pull request
Oct 21, 2024
…#2753) * Compartmentalized the LookForEnemiesInBlock checks * Added LookForEnemiesEx(). This function allows for ZScript code to get an array with all enemies of the caller found in range. Using similar sight logic as functions like LookForEnemies(). * Added noPlayers parameter to LookForEnemiesEx(). This parameter allows the function to also find players around it. * Added VM abort to LookForEnemiesEx(). Prevent crashes by passing a null array by reference.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This is a ZScript function that behaves more or less like LookForEnemies(), and optionally like LookForPlayers() too, and returns an array of pointers to every valid enemy it found in range (By passing an array by reference). Useful for custom look functions, such as for adding additional checks like a monster that only attacks flying enemies, or that can track multiple targets.
Below is an example mod with a test actor called EnemySearch, when spawned in, it will use the function to find every enemy in the area, print their name, and spawn a hovering plasma ball over their heads. When spawned as a friend with summonfriend, it will instead only do those two things with flying monsters.
LookForEnemiesEx.zip