gothic-1-community-patch icon indicating copy to clipboard operation
gothic-1-community-patch copied to clipboard

NPC can move after being enchanted

Open catalinstoian opened this issue 4 years ago • 3 comments

catalinstoian avatar Jan 09 '21 11:01 catalinstoian

https://github.com/AmProsius/gothic-1-community-patch/blob/f386ca443496783307a91437f00772b92802a4dd/scriptbase/_work/Data/Scripts/Content/Magic/ZS/ZS_Berzerk.d#L12-L67

changed to

func int ZS_Berzerk_Loop()
{
	PrintDebugNpc			(PD_ZS_LOOP,	"ZS_Berzerk_Loop");

	var int random;
	
	if	(Npc_GetStateTime(self) > SPL_TIME_BERZERK)
	{
		//-------- Zeit abgelaufen ! --------
		B_FullStop			(self);
		return				LOOP_END;
	};

	Npc_GetTarget			(self);	
	if (Hlp_IsValidNpc	(other)		// Ziel technisch gültig?
	&&	!C_NpcIsDown	(other) 	// Ziel am Leben?
	&&	!Npc_IsPlayer	(other)	)	// Ziel ein NSC (beim ersten Durchlaufen könnte es der Spieler sein!)	
	{																							
		//-------- Ziel angreifen ! --------
		Npc_GetTarget	(self);									// ...other initialisieren!
		AI_Attack    	(self);									// ...FAI anwerfen!	
//		AI_Wait			(self,	0.1); // raus, weil der NPC sich dann anscheinend nicht mehr bewegen konnte

		if (Hlp_Random(100) < 20)
		{
			B_SayOverlay(self,	other,	"$Berzerk");
		};
		
		return	 		LOOP_CONTINUE;
	}
	else
	{
		//-------- neues Ziel suchen ! --------
	    PrintDebugNpc		(PD_ZS_CHECK,	"...kein gültiges Ziel mehr!");
		
		Npc_PerceiveAll		(self);								// sammelt alle NSC im Umkreis ein...
		if ( Wld_DetectNpcEx( self, -1, NOFUNC, -1, FALSE ) )	// ...und wählt irgendeinen davon aus (aber ignoriert den SC!)
		{
		    PrintDebugNpc	(PD_ZS_CHECK,"...Neues Ziel entdeckt!");
			PrintGlobals	(PD_ZS_DETAIL);
			Npc_SetTarget	(self, other);
			return 			LOOP_CONTINUE;
		}
		else
		{
		    PrintDebugNpc	(PD_ZS_CHECK,"...kein neues Ziel mehr vorhanden!");
			PrintGlobals	(PD_ZS_DETAIL);

			AI_GotoWP 		(self,	Npc_GetNearestWP(self));	// zum nächsten...	
			B_SayOverlay	(self,	NULL,	"$Berzerk");
			AI_PlayAni		(self,	"T_SEARCH");
			AI_GotoWP 		(self,	Npc_GetNextWP 	(self));	// dann zum zweitnächsten Waypoint (beide Messungen bei t=0!)
			B_SayOverlay	(self,	NULL,	"$Berzerk");
			AI_PlayAni		(self,	"T_SEARCH");
		};
	};	

};

catalinstoian avatar Jan 09 '21 11:01 catalinstoian

@catalinstoian Can you provide details about this issue? I am not familiar with it.

szapp avatar Jan 24 '21 21:01 szapp

The fix seems to be to disable the AI_Wait in the state loop. This can be achieved by searching the bytecode of the function and count how many function calls to AI_Wait are made (use G1CP_FindCall). Only if it is exactly one and the argument is 0.1, we can assume that the function was unaltered. In that case, replace the function call to an empty function (to disable the waiting).

szapp avatar May 13 '21 13:05 szapp