Skip to content
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

[REQUEST] Add new getAdjacentActors function for actor.nut #343

Open
Darxo opened this issue Apr 8, 2024 · 3 comments · May be fixed by #344
Open

[REQUEST] Add new getAdjacentActors function for actor.nut #343

Darxo opened this issue Apr 8, 2024 · 3 comments · May be fixed by #344
Labels
feature request A feature requested by the community good first issue Good for newcomers

Comments

@Darxo
Copy link

Darxo commented Apr 8, 2024

Is your feature request related to a problem? Please describe.
Several skills and perks work off of adjacent entities, meaning anyone standing on the 6 tiles around an entity/position.
In Vanilla this is very copy&pasty done with a for-loop from 0 to 5 which then checks each tile via a getNext(i) function.

MSU currently only offers ::Tactical.Entities.getActorsByFunction but that is not efficient when we know that we only need to check the adjacent tiles. That function instead iterates over every entity on the whole battlefield and it is also a bit harder to parse when reading the code.

Describe the solution you'd like
I would like to have a function getAdjacentActors() for the actor.nut class which returns an array of up to 6 actor references.
Adjacency is where I draw the line already for this. Anything beyond adjacent needs to fall back on a getActorsByFunction call.

@Darxo Darxo added the feature request A feature requested by the community label Apr 8, 2024
@Enduriel Enduriel added the good first issue Good for newcomers label Apr 8, 2024
@Enduriel
Copy link
Member

Enduriel commented Apr 8, 2024

Feel free to make this into a PR, it could be added to 1.4

@LordMidas
Copy link
Member

LordMidas commented Apr 9, 2024

Seems like a useful function to have. I have a couple of questions regarding this:

Question 1:
Should this exist in actor.nut:

<actor>.getAdjacentActors();

Or in tactical_entity_manager.nut:

::Tactical.Entities.getAdjacentActors(actor);

The latter is the usual place for other such functions.

Question 2:
You don't always want every single actor, rather sometimes you may only want allied actors, or hostile actors, etc. So perhaps the function should accept an optional filter of some sort in its parameters? There are four distinct filters we need:

  • Allied (contains both my faction and other allied factions)
  • Hostile
  • Same faction
  • Non faction allied

@LordMidas
Copy link
Member

I have created my suggested implementation in #344

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request A feature requested by the community good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants