-
Notifications
You must be signed in to change notification settings - Fork 89
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
2 additional AI turn actions #718
Open
mmind
wants to merge
2
commits into
Try:master
Choose a base branch
from
mmind:dev/ai-turns
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.
+119
−5
Open
Changes from all commits
Commits
Show all changes
2 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
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
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 |
---|---|---|
|
@@ -1330,6 +1330,21 @@ bool Npc::implLookAt(float dx, float dy, float dz, uint64_t dt) { | |
return false; | ||
} | ||
|
||
bool Npc::implTurnAway(const Npc &oth, uint64_t dt) { | ||
if(&oth==this) | ||
return true; | ||
|
||
auto dx = oth.x-x; | ||
auto dz = oth.z-z; | ||
float a = angleDir(dx, dz) + 180; | ||
if(a > 360) | ||
a-= 360; | ||
|
||
auto gl = guild(); | ||
float step = float(owner.script().guildVal().turn_speed[gl]); | ||
return rotateTo(a,step,false,dt); | ||
} | ||
|
||
bool Npc::implTurnTo(const Npc &oth, uint64_t dt) { | ||
if(&oth==this) | ||
return true; | ||
|
@@ -1352,6 +1367,16 @@ bool Npc::implTurnTo(float dx, float dz, bool noAnim, uint64_t dt) { | |
return rotateTo(dx,dz,step,noAnim,dt); | ||
} | ||
|
||
bool Npc::implWhirlTo(const Npc &oth, uint64_t dt) { | ||
if(&oth==this) | ||
return true; | ||
auto dx = oth.x-x; | ||
auto dz = oth.z-z; | ||
auto gl = guild(); | ||
float step = float(owner.script().guildVal().turn_speed[gl]) * 2; | ||
return rotateTo(dx,dz,step,false,dt); | ||
} | ||
|
||
bool Npc::implGoTo(uint64_t dt) { | ||
float dist = 0; | ||
if(go2.npc) { | ||
|
@@ -2191,6 +2216,27 @@ void Npc::nextAiAction(AiQueue& queue, uint64_t dt) { | |
currentLookAt=act.point; | ||
break; | ||
} | ||
case AI_TurnAway: { | ||
const auto st = bodyStateMasked(); | ||
if(interactive()==nullptr && (st==BS_WALK || st==BS_SNEAK)) { | ||
stopWalkAnimation(); | ||
queue.pushFront(std::move(act)); | ||
break; | ||
} | ||
if(interactive()==nullptr) { | ||
stopWalkAnimation(); | ||
visual.stopDlgAnim(*this); | ||
} | ||
if(act.target!=nullptr && implTurnAway(*act.target,dt)) { | ||
queue.pushFront(std::move(act)); | ||
break; | ||
} | ||
// Not looking quite correct in dialogs, when npc turns around | ||
// Example: Esteban dialog | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Copy-paste? |
||
// currentLookAt = nullptr; | ||
// currentLookAtNpc = nullptr; | ||
break; | ||
} | ||
case AI_TurnToNpc: { | ||
const auto st = bodyStateMasked(); | ||
if(interactive()==nullptr && (st==BS_WALK || st==BS_SNEAK)) { | ||
|
@@ -2212,6 +2258,27 @@ void Npc::nextAiAction(AiQueue& queue, uint64_t dt) { | |
// currentLookAtNpc = nullptr; | ||
break; | ||
} | ||
case AI_WhirlToNpc: { | ||
const auto st = bodyStateMasked(); | ||
if(interactive()==nullptr && (st==BS_WALK || st==BS_SNEAK)) { | ||
stopWalkAnimation(); | ||
queue.pushFront(std::move(act)); | ||
break; | ||
} | ||
if(interactive()==nullptr) { | ||
stopWalkAnimation(); | ||
visual.stopDlgAnim(*this); | ||
} | ||
if(act.target!=nullptr && implWhirlTo(*act.target,dt)) { | ||
queue.pushFront(std::move(act)); | ||
break; | ||
} | ||
// Not looking quite correct in dialogs, when npc turns around | ||
// Example: Esteban dialog | ||
// currentLookAt = nullptr; | ||
// currentLookAtNpc = nullptr; | ||
break; | ||
} | ||
case AI_GoToNpc: | ||
if(!setInteraction(nullptr)) { | ||
queue.pushFront(std::move(act)); | ||
|
@@ -3220,18 +3287,26 @@ bool Npc::turnTo(float dx, float dz, bool noAnim, uint64_t dt) { | |
} | ||
|
||
bool Npc::rotateTo(float dx, float dz, float step, bool noAnim, uint64_t dt) { | ||
//step *= (float(dt)/1000.f)*60.f/100.f; | ||
step *= (float(dt)/1000.f); | ||
|
||
if(dx==0.f && dz==0.f) { | ||
setAnimRotate(0); | ||
return false; | ||
} | ||
|
||
return rotateTo(angleDir(dx, dz), step, noAnim, dt); | ||
} | ||
|
||
bool Npc::rotateTo(float a, float step, bool noAnim, uint64_t dt) { | ||
if(a==0.f) { | ||
setAnimRotate(0); | ||
return false; | ||
} | ||
|
||
if(!isRotationAllowed()) | ||
return false; | ||
|
||
float a = angleDir(dx,dz); | ||
//step *= (float(dt)/1000.f)*60.f/100.f; | ||
step *= (float(dt)/1000.f); | ||
|
||
float da = a-angle; | ||
|
||
if(noAnim || std::cos(double(da)*M_PI/180.0)>0) { | ||
|
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
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.
Based on video evidence you shared previously:
Rotation speed appears(not 100% sure) to be the same, but with different animation.
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.
Ahhhh ... you're right ... thanks for noticing that discrepancy.
Digging deeper, the animation data does have t_surprise_ccw and t_surprise_cw states and G1 data comes uncompiled with "//WhirlAround" comments intact above those :-) .
Additionally, it looks like in G1 everybody including humans have the whirl animation, where in G2, monsters have it - including the newly added ones - but not humans.
So I'll continue digging :-) .