-
Notifications
You must be signed in to change notification settings - Fork 585
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
[core] new luautil function: getEntitiesInRange() #5816
Conversation
d1a9542
to
48aed07
Compare
targetfind is funny about conals in that it always adds the primary target my work in #5745 will make it more reliable if one needed to use this binding for raw conal findings, but in general the binding seems to work well. It's written explicitly to be used for Dark Ixion, so I'm going to start poking at it there |
I've done some testing and it seems to do what's on the tin here. Ixion functions with the new binding, but will benefit greatly from the extra |
48aed07
to
73538f5
Compare
src/map/lua/lua_baseentity.cpp
Outdated
sol::table CLuaBaseEntity::getEntitiesInRange(CLuaBaseEntity* PLuaEntityTarget, sol::variadic_args va) | ||
{ | ||
auto* baseEntity = dynamic_cast<CBattleEntity*>(m_PBaseEntity); | ||
auto players = lua.create_table(); |
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.
If this is targetfind-based, it can find more than players depending on the flags, no?
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.
Good catch, yes. Started from my old binding. I'll update the variable
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.
Done
src/map/lua/lua_baseentity.h
Outdated
void recalculateAbilitiesTable(); | ||
void recalculateSkillsTable(); | ||
void recalculateAbilitiesTable(); | ||
sol::table getEntitiesInRange(CLuaBaseEntity* PLuaEntityTarget, sol::variadic_args va); |
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.
auto getEntitiesInRange(CLuaBaseEntity* PLuaEntityTarget, sol::variadic_args va) -> sol::table;
src/map/lua/lua_baseentity.cpp
Outdated
* Function: getEntitiesInRange() | ||
* Purpose : Returns a Lua table of entities within range of the base entity | ||
* Example : local players = npc:getEntitiesInRange(target, aoeType, radiusOrigin, distance, findFlags, validTargets) | ||
* Notes : if the passed distance is nil or 0 (as well as many other combinations), empty table will be returned |
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 would add a big fat note here, saying something to the tune of: "APART FROM THIS ONE EXCEPTION, ALL TARGET AND PATH FINDING SHOULD BE DONE EXCLUSIVELY IN CORE"
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.
and say that this is used for Ixion, and possibly there's another usage for this in assault? I don't remember
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.
Can do
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.
And another sub-note: If you have to do expensive operations that are meant for core in Lua, you should be doing them as infrequently as possible: In a mobskill that locks itself off, or anything that isn't on-tick, etc.
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.
Updated the description
get all targets in a sphere around an entity utilizes targetfind on the entity with parameters for aoe type, validtargets, etc
73538f5
to
a42edeb
Compare
For any passers-by: This is logic added using |
I affirm:
What does this pull request do?
Sparked by this comment, I've created a more generic binding for finding entities in range of an entity, using the existing
CTargetFind
class.I'm putting this in draft mode while I test it, but preliminary testing seems to work (the benefits of using pre-existing systems)
This PR lays some groundwork:
The PR's main change:
getEntitiesInRange()
PAI->Targetfind
flow similar to spells or mobskillsSteps to test these changes