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

Implemented AI_LOOKAT #397

Merged
merged 6 commits into from
Feb 3, 2023
Merged

Implemented AI_LOOKAT #397

merged 6 commits into from
Feb 3, 2023

Conversation

CReimer
Copy link
Contributor

@CReimer CReimer commented Feb 1, 2023

This is my first try at actually contributing here. So please be gentle.

Some NPCs in Gothic 1 don't look in the direction they're supposed to. I figured AI_LOOKAT could be the problem.
So I implemented it as best as I could, and the NPCs still don't look in the right direction.

It turns out AI_LOOKAT is only used in the new camp (Neues Lager in German) to make an NPC look at the big pile of ore there. (Waypoint FP_OREPILE_CENTER). I haven't figured out which NPCs but if that information is needed, I might now know how to get it.

I made AI_LOOKAT mutually exclusive with AI_LOOKATNPC as I figured an NPC can't really look at two points at the same time. So whichever function is called last wins.

Your code style is a bit unusual. I hope I got it right.

AI_LookAt is actually for waypoints and not NPCs
Copy link
Owner

@Try Try left a comment

Choose a reason for hiding this comment

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

Hi, @CReimer !

Thanks for PR. Looks good, but need to fix serialization (see comments)

@@ -257,7 +257,7 @@ void Npc::load(Serialize &fin, size_t id) {
loadAiState(fin);

fin.read(currentInteract,currentOther,currentVictum);
fin.read(currentLookAt,currentTarget,nearestEnemy);
fin.read(currentLookAtNpc,currentTarget,nearestEnemy);
Copy link
Owner

Choose a reason for hiding this comment

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

  1. write code wasn't updated to mirror read
  2. Waypoint currentLookAt is not serialized

For proper serialization, you need to bump save file version in Serialize::Version and add check for fin.version() before reading new data.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not exactly sure how the serialization works. But I think it's fixed now

@@ -1988,7 +1995,8 @@ void Npc::tick(uint64_t dt) {
}

if(!isDown()) {
implLookAt(dt);
implLookAtNpc(dt);
Copy link
Owner

Choose a reason for hiding this comment

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

Nit: tabs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hope this is now right, too.

To be fair. I just spend about an hour trying to set your code styling in CLion.
It's just impossible. To many edge-cases and inconsistencies.

@CReimer
Copy link
Contributor Author

CReimer commented Feb 2, 2023

If everything is okay now. I'd like to squash the first new commit in my original fist commit and the same for the second.

@Try Try merged commit 540d494 into Try:master Feb 3, 2023
@Try
Copy link
Owner

Try commented Feb 3, 2023

Hi, @CReimer !

There were few issues with serialization, so I've changed them inline, in merge view.
Squashed and merged, thanks!

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