-
Notifications
You must be signed in to change notification settings - Fork 578
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, lua] Improve draw-in specification to fix some issues #6007
base: base
Are you sure you want to change the base?
[core, lua] Improve draw-in specification to fix some issues #6007
Conversation
Why not change draw in to mean 1 -> target player + pets, and 2 for party/alliance, (so no numbers over 2) and add another mobmod for draw in trigger distance, without the need of having 4 local variables? And actually, the original draw in could be changed to set draw in type (player or party / to in front of mob OR to specified locations, like Khaimaira) |
4a70fea
to
35b8b95
Compare
The idea is there are a lot of potential differences between different draw-ins so would need to have several more mob mods as the dimensions are at least: alliance, in front, trigger dist, max dist, type (leash vs. no leash), include dead/mounted, etc. For brevity not all of these are included in this PR, leash and others will come later on. Also the local variables make understanding mob draw-in logic easier to understand from just the mob file (without needing to look through other logic). |
Since you are already reducing the original mobmod to a bit, one could use the original mobmod as a bitmask. New mobmod This are just ideas. I'm personally not a fan of abusing the use of local variables for global systems |
Yeah, could maybe do it with a bitmask and only three new mob mods: trigger distance, max distance, and leash distance, however we lose the readability and explicitness and have to rely on potential code comments. In the end I do not mind either method, but I guess depends on what should be prioritized. Leash draw-in is where the mob only allows the players to move a specified distance away from a fixed center point of a shape before drawing in potentially to a center point or other point in that shape, thus the mobs never leaves that shape (like dog on leash), this is like Aspid for example (note aspid also has normal non-leash draw-in it can use inside the circle) |
35b8b95
to
f307043
Compare
Ok, I updated the PR to use a bitmask mob mod for DRAW_IN and two new mob mods for setting the trigger distance and max range :) |
f307043
to
832444e
Compare
CI has a real complaint saying PTarget is not used in a lambda |
832444e
to
c3d43eb
Compare
Thanks for pointing this out, I have updated the PR now! |
scripts/enum/mob_mod.lua
Outdated
@@ -19,7 +19,7 @@ xi.mobMod = | |||
HP_HEAL_CHANCE = 9, -- can cast cures below this HP % | |||
SUBLINK = 10, -- sub link group | |||
LINK_RADIUS = 11, -- link radius | |||
DRAW_IN = 12, -- 1 - player draw in, 2 - alliance draw in -- only add as a spawn mod! | |||
DRAW_IN = 12, -- bitmask with different binary options for draw-in (see DRAWIN enum for options) |
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.
To make this even more obvious (since this is a departure from the existing logic) I would probably name this DRAW_IN_BITMASK
or DRAW_IN_MASK
or DRAW_IN_SETTINGS
etc.
@@ -710,11 +710,11 @@ void CMobController::Move() | |||
if (((currentDistance > closeDistance) || move) && PMob->PAI->CanFollowPath()) | |||
{ | |||
// TODO: can this be moved to scripts entirely? | |||
if (PMob->getMobMod(MOBMOD_DRAW_IN) > 0) | |||
if ((PMob->getMobMod(MOBMOD_DRAW_IN) & DRAWIN::DRAWIN_NORMAL) > 0) |
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.
The >0
is redundant here
// get specific draw-in settings that can be set on any given mob otherwise use default values | ||
uint32 drawInTriggerDistance = PMob->getMobMod(MOBMOD_DRAW_IN_TRIGGER_DIST) > 0 ? PMob->getMobMod(MOBMOD_DRAW_IN_TRIGGER_DIST) : PMob->GetMeleeRange() * 2; | ||
uint32 drawInMaxDistance = PMob->getMobMod(MOBMOD_DRAW_IN_MAX_RANGE) > 0 ? PMob->getMobMod(MOBMOD_DRAW_IN_MAX_RANGE) : std::numeric_limits<int16>::max(); | ||
bool includeAlliance = (PMob->getMobMod(MOBMOD_DRAW_IN) & DRAWIN::DRAWIN_INCLUDE_ALLIANCE) > 0 ? true : false; | ||
bool toFrontOfMob = (PMob->getMobMod(MOBMOD_DRAW_IN) & DRAWIN::DRAWIN_TO_FRONT_OF_MOB) > 0 ? true : false; |
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.
Same here, you don't need to be doing all of these extra steps...
const bool toFrontOfMob = PMob->getMobMod(MOBMOD_DRAW_IN) & DRAWIN::DRAWIN_TO_FRONT_OF_MOB;
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.
Also, if you're not going to change the value of the variable later, make it const.
src/map/entities/mobentity.h
Outdated
DRAWIN_NONE = 0x000, // no draw-in (mob can only draw-in by explictly calling the lua drawin function) | ||
DRAWIN_NORMAL = 0x001, // basic draw-in where mob will draw-in battle target when target some distance from mob | ||
DRAWIN_TO_FRONT_OF_MOB = 0x002, // determines if draw-in to the center of mob (bit not set) or front of mob (bit set) | ||
DRAWIN_INCLUDE_ALLIANCE = 0x004 // determines if draw-in includes just the battle target (bit not set) or entire alliance (bit set) |
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.
Needs trailing comma (if that's relevant in C++, I don't remember?)
PMember->loc.p.z = nearEntity.z; | ||
if (toFrontOfMob) | ||
{ | ||
PMember->loc.p.x = nearEntity.x; |
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.
Would it make sense to calculate these positions at the very start of the draw in, validate them on the navmesh, and then assign them here?
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.
Would it make sense to calculate these positions at the very start of the draw in, validate them on the navmesh, and then assign them here?
I think the function is already doing what you describe? It calculates and validates near the start of the draw-in function. Or do you mean even earlier in the draw-in process like in a different function?
c3d43eb
to
696be33
Compare
I affirm:
What does this pull request do?
This PR changes the specification of draw-in functions in several places to support flexibility and the additional options needed for the draw-in logic of different mobs.
Current LSB draw-in problems:
DRAW_IN
mob mod is currently representing two different options that do not always occur together. Specifically, aDRAW_IN > 1
indicates alliance draw-in and aDRAW_IN > 1
also sets the draw-in trigger distance to the mob mod. Thus all mobs with a non-standard trigger distance are also forced to have alliance draw-in. This creates several draw-in bugs.Changes by this PR:
DRAW_IN
mob mod to be a bitmask mod that represents several different draw-in options including perform normal draw-in logic, include alliance members in draw-in, and draw-in to front of mob. Also adds mob mods MOBMOD_DRAW_IN_TRIGGER_DIST and MOBMOD_DRAW_IN_MAX_RANGE to allow specifying the draw-in trigger distance and the max draw-in range. The bitmask approach allows flexibility and easy future expansion to new draw-in types that LSB is still missing.Steps to test these changes
Fight mobs with draw-in and vary the draw-in mob mods to set different options, also test the lua drawIn function call with different parameters