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

2 additional AI turn actions #718

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

2 additional AI turn actions #718

wants to merge 4 commits into from

Conversation

mmind
Copy link
Contributor

@mmind mmind commented Jan 15, 2025

AI_WhirlAround is doing the same as ai_turntonpc, just faster.
The script does not contain specific values for whirl-speed, so just use
double of the NPc's turn-speed.

AI_turnaway does what the name implies and turns the back to the npc.
There might be a nicer way to calculate that angle than in my code.

game/world/objects/npc.cpp Outdated Show resolved Hide resolved
game/world/objects/npc.cpp Outdated Show resolved Hide resolved
mmind added 4 commits January 29, 2025 21:59
All characters (except only the humans in Gothic 2) have T_SURPRISE_CW
and T_SURPRISE_CCW animations used in the whirl-around type of movement.

This is mainly used in Gothic 1 to portray a different style of turning
to an enemy or surprising event.

This adds the animation to the solver. Normally the whirl animation should
not happen in water, but keep the case around just to be on the save side.
There are multiple turning variants (regular, whirl, away) that all will
need the same preparation steps, so move them to a separate function
for re-use.
It is supposed to be a faster version of AI_TurnToNpc and seemlingly
used in Gothic 1 in a number of places.

It's for example used when the player draws a weapon behind an NPC
but also with the Firedaemon in Xardas' tower.
Defined as 'npc' turns away from 'other', just like turnTo
but +180 degrees.

One user is for example Baal Netbek in the swamp where the player
character ends the dialog with turning away saying "This guy won't
be of help", the other example is the fire demon in Xardas' tower,
where the player first turns away before whirling back to the demon.
@mmind
Copy link
Contributor Author

mmind commented Jan 29, 2025

With the underlying rotation issues out of the way I think I found a nice way for those two turn variants now.

@@ -519,3 +521,9 @@ enum class AaPreset : uint32_t {
ULTRA,
PRESETS_COUNT
};

enum TurnAnim : uint8_t {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be moved into AnimationSolver, similar to AnimationSolver::Anim.

@@ -812,7 +812,7 @@ Vec2 Pose::headRotation() const {
return Vec2(headRotX,headRotY);
}

void Pose::setAnimRotate(const AnimationSolver &solver, Npc &npc, WeaponState fightMode, int dir) {
void Pose::setAnimRotate(const AnimationSolver &solver, Npc &npc, WeaponState fightMode, enum TurnAnim turn, int dir) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

enum TurnAnim turn

In opengothic we are not using enum or struct as part of function signature. In C++ you don't need to.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants