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

Fix non-closing gates in Gothic 1 #629

Merged
merged 1 commit into from
Jun 8, 2024
Merged

Fix non-closing gates in Gothic 1 #629

merged 1 commit into from
Jun 8, 2024

Conversation

thokkat
Copy link
Contributor

@thokkat thokkat commented May 16, 2024

At start of chapter 4 gate guards change daily routine to TA_GuardWheelClosed. Then in function ZS_GuardWheelClosed() the state of the next mob with matching scheme name is checked.

	if (Wld_GetMobState	(self, 	"VWHEEL") == 0)						// Tor offen?
	{
		PrintDebugNpc 	(PD_TA_CHECK,	"...Tor offen!");	
		AI_UseMob		(self, 	"VWHEEL", 1);						// ...dann wieder zumachen!
		AI_UseMob		(self, 	"VWHEEL", -1);                      //und vom Mobsi abmelden
		AI_AlignToWP	(self);
	};

Wld_GetMobState internally checks only for mobs the npc has collided with while moving which makes the check fail. This is replaced by World::findInteractive, a search for all mobsis in close range. The default range has been increased slightly, otherwise only one gate could be opened.

Script comment for Wld_GetMobState says it's looking for the next mob that matches the scheme name. This would be in line with the change.

Script also has a command to close the inner gate but this fails in vanilla. In OG with this PR it fails because the mob can't be found. A Problem could be that the responsible npc GRD_280_Gardist has wrong id=230 but GRD_230_Gardist is the npc closing the main gate.

For testing you can use insert sh and use the first chapter 4 option.

Fixes #628

@Try
Copy link
Owner

Try commented May 17, 2024

Wld_GetMobState internally checks only for mobs the npc has collided with while moving which makes the check fail.

There is a reason to implement it like that, for G2:

// PERC_MOVEMOB handler
func void B_MoveMob()
{
	var string door;
	door = Npc_GetDetectedMob(self);
	if(Hlp_StrCmp(door,"DOOR"))
	{
		if(Wld_GetMobState(self,door) == 0)
		{
			Npc_ClearAIQueue(self);
			AI_UseMob(self,door,1);
			AI_UseMob(self,door,-1);
		};
	}
	else
	{
		return;
	};
	AI_ContinueRoutine(self);
};

This script has only one use-case, that I'm aware of: when Gorn leaves the jail he can open the door by himself

@thokkat thokkat force-pushed the fix-gates branch 2 times, most recently from 1b09ea9 to ebce84d Compare May 19, 2024 18:43
@thokkat
Copy link
Contributor Author

thokkat commented May 19, 2024

Ah didn't see that script but Gorn opening the gate works. I changed the search method to be like availableMob to return only a mob with correct scheme name.

For G1 gate guards this search is needed but I could a add a previous check for detectedMob if you think that makes sense.

Closing gates now don't allow npcs like Milten to leave old camp which is another problem caused by #585

game/world/worldobjects.cpp Outdated Show resolved Hide resolved
@@ -1652,8 +1652,8 @@ int GameScript::wld_getmobstate(std::shared_ptr<zenkit::INpc> npcRef, std::strin
return -1;
}

auto mob = npc->detectedMob();
if(mob==nullptr || mob->schemeName()!=scheme) {
auto mob = world().findMob(*npc,scheme);
Copy link
Owner

Choose a reason for hiding this comment

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

Should this line be a part of detectedMob?

Idea behind detectedMob is to return:

  • actively used modsi
  • mobsi that cause collision event
  • [new] closemost with valid scheme

game/world/worldobjects.cpp Outdated Show resolved Hide resolved
@thokkat
Copy link
Contributor Author

thokkat commented Jun 8, 2024

Ok Wld_GetMobState already checks availability so this extra handling is not needed.

Should this line be a part of detectedMob?

Hmm question is what happens if scheme name doesn't match collision mob. If the npc is interacting with a mob the mob's state is returned even if scheme is different but this seems illogical. Gorn opening the door isn't working in vanilla so couldn't test what a scheme mismatch would do there.

Wld_GetMobState is only used for G1 gates and for Gorn moving out of jail. In latter case the collision guarantees that a search for closest door would find the collision object.

Script comments indicate Npc_GetDetectedMob is only allowed in conjunction with PERC_MOVEMOB while Wld_GetMobState returns just the state of the nearest found mob. I'd like to keep it as is until there's some possible non-working case.

@Try Try merged commit 008fec3 into Try:master Jun 8, 2024
1 check passed
@Try
Copy link
Owner

Try commented Jun 8, 2024

Script comments indicate Npc_GetDetectedMob is only allowed in conjunction with PERC_MOVEMOB while Wld_GetMobState returns just the state of the nearest found mob. I'd like to keep it as is until there's some possible non-working case.

Agreed, lets keep as-is, and revisit if something breaks in future. 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.

[Gothic 1] Old camps gates do not close after chapter 4 started
2 participants