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

The Rice Lord gives infinite water to the player

Open AmProsius opened this issue 4 years ago • 6 comments

Describe the bug On the first day of receiving Lefty's quest, the Rice Lord can be infinitely asked to give a ration of water bottles to the player.

Expected behavior The Rice Lord now gives only one ration of water bottles to the player every day.

AmProsius avatar Feb 06 '21 07:02 AmProsius

Error in comparing the elapsed time. It is also worth adding an increase to the time for in the dialog

https://github.com/AmProsius/gothic-1-community-patch/blob/c5097df6da1f67bcaff41f81dff3396f804de583/scriptbase/_work/Data/Scripts/Content/Story/Missions/DIA_BAU_900_Ricelord.d#L162-L189

changed to

FUNC VOID DIA_Ricelord_GetWater_Info()
{	
	AI_Output (other, self,"DIA_Ricelord_GetWater_15_00"); //Ich soll den Bauern Wasser bringen.
	
	//if(Lefty_WorkDay == Wld_GetDay())
	if(Lefty_WorkDay >= Wld_GetDay())
	{
		AI_Output			(self, other,"DIA_Ricelord_GetWater_12_01"); //Gut. Hier sind ein Dutzend Flaschen Wasser.
		AI_Output			(self, other,"DIA_Ricelord_GetWater_12_02"); //Es gibt etwa doppelt so viele Bauern, also verteil sie gleichmäßig.

		CreateInvItems		(self, ItFo_Potion_Water_01, 12);
		B_GiveInvItems		(self, other, ItFo_Potion_Water_01, 12);

		Ricelord_AskedForWater = FALSE;

		//new add
		Ricelord_AskedForWater_Day = (Wld_GetDay() + 1);

		//This diary entry is endless
		B_LogEntry			(CH1_CarryWater,	"Der Reislord gab mir ein Dutzend Wasserflaschen.");

		AI_StopProcessInfos	(self);
	}
	else if (Lefty_WorkDay == Wld_GetDay()-1)
	{
		AI_Output (self, other,"DIA_Ricelord_GetWater_TooLate_12_00"); //Das war gestern, Bursche! Geh besser zu ihm. Er hat dir was zu sagen.
		AI_StopProcessInfos	(self);
	}
	else
	{
		AI_Output (self, other,"DIA_Ricelord_GetWater_TooLate_12_01"); //Das war vor einigen Tagen, Bursche! Geh besser zu ihm. Er hat dir was zu sagen.
		AI_StopProcessInfos	(self);
	};
};

N1kX94 avatar Apr 02 '21 10:04 N1kX94

Thanks. I updated your comment to include the original script.

Unfortunately, that solution seems incomplete. The variable Ricelord_AskedForWater_Day does not exist. I guess it will be added to the dialog condition function of DIA_Ricelord_LeftySentMe.

I don't understand what good the change of the comparison would do:

if(Lefty_WorkDay >= Wld_GetDay())

The variable Lefty_WorkDay should never be larger than Wld_GetDay(). If it is, it would still only allow to get water ahead of time - but still repeatedly.

szapp avatar Apr 02 '21 12:04 szapp

The variable Lefty_WorkDay update in Dialogs on Lefty

func void DIA_Lefty_First_Yes()
{
***
Lefty_WorkDay = B_SetDayTolerance(); 
***
};
func void DIA_Lefty_First_Never()
{
***
Lefty_WorkDay = B_SetDayTolerance(); 
***
};
func void DIA_Lefty_WorkDay_Info()
{
***
Lefty_WorkDay = B_SetDayTolerance(); 
***
};

As for the new variable, yes, you can not use it, but you can change the condition of the dialog to this

func int DIA_Ricelord_GetWater_Condition()
{
	//if(Ricelord_AskedForWater == TRUE)
	if (Ricelord_AskedForWater == TRUE) 
	&& (Lefty_Mission == LOG_RUNNING)
	{
		return 1;
	};
};

N1kX94 avatar Apr 02 '21 12:04 N1kX94

The variable Lefty_WorkDay update in Dialogs on Lefty

Yes, but it will never be higher than Wld_GetDay() (expect just before midnight):

https://github.com/AmProsius/gothic-1-community-patch/blob/c5097df6da1f67bcaff41f81dff3396f804de583/scriptbase/_work/Data/Scripts/Content/Story/B/B_SetDayTolerance.d#L1-L11

Therefore the change in comparison makes no difference.

As for the new variable, yes, you can not use it, but you can change the condition of the dialog to this

func int DIA_Ricelord_GetWater_Condition()
{
	//if(Ricelord_AskedForWater == TRUE)
	if (Ricelord_AskedForWater == TRUE) 
	&& (Lefty_Mission == LOG_RUNNING)
	{
		return 1;
	};
};

That won’t make a difference because the state of the mission does not change after just receiving the water (only after passing out all the water). The dialog can thus still be triggered again right away after receiving the water.

szapp avatar Apr 02 '21 13:04 szapp

Hm-m, in GMF With the addition of a new variable and comparing it in the condition prohibits taking water more than once a day.

var int Ricelord_AskedForWater_Day;

instance DIA_Ricelord_LeftySentMe(C_Info)
{
	npc = Bau_900_Ricelord;
	nr = 1;
	condition = DIA_Ricelord_LeftySentMe_Condition;
	information = DIA_Ricelord_LeftySentMe_Info;
	permanent = 1;
	description = "Меня послал Лефти.";
};


func int DIA_Ricelord_LeftySentMe_Condition()
{
	if (Npc_KnowsInfo(hero,DIA_Ricelord_Hello))
	&& (Lefty_Mission == LOG_RUNNING) 
	&& (Ricelord_AskedForWater == FALSE) 
	&& (LeftyDead == FALSE) 
	&& (Ricelord_AskedForWater_Day != (Wld_GetDay() + 1))
	{
		return 1;
	};
};

func void DIA_Ricelord_LeftySentMe_Info()
{
	AI_Output(other,self,"DIA_Ricelord_LeftySentMe_15_00");	//Меня послал Лефти.
	AI_Output(self,other,"DIA_Ricelord_LeftySentMe_12_01");	//Да, и что он сказал?
	Ricelord_AskedForWater = TRUE;
};


instance DIA_Ricelord_GetWater(C_Info)
{
	npc = Bau_900_Ricelord;
	nr = 1;
	condition = DIA_Ricelord_GetWater_Condition;
	information = DIA_Ricelord_GetWater_Info;
	permanent = 1;
	description = "Я должен отнести крестьянам воду.";
};


func int DIA_Ricelord_GetWater_Condition()
{
	//if(Ricelord_AskedForWater == TRUE)
	if((Ricelord_AskedForWater == TRUE) && (Lefty_Mission == LOG_RUNNING))
	{
		return 1;
	};
};

func void DIA_Ricelord_GetWater_Info()
{
	AI_Output(other,self,"DIA_Ricelord_GetWater_15_00");	//Я должен отнести крестьянам воду.
	if(Lefty_WorkDay >= Wld_GetDay())//if(Lefty_WorkDay == Wld_GetDay())
	{
		AI_Output(self,other,"DIA_Ricelord_GetWater_12_01");	//Хорошо. Вот тебе дюжина бутылок.
		
		CreateInvItems(other,ItFo_Potion_Water_01,12);
		CreateInvItem(other,FakeItem);
		ScreenMessage = "Получено 12 бутылок воды.";
		AI_UseItem(other,FakeItem);
		
		AI_Output(self,other,"DIA_Ricelord_GetWater_12_02");	//Крестьян там почти вдвое больше, так что проследи, чтобы всем досталось поровну.
		//CreateInvItems(self,ItFo_Potion_Water_01,12);
		//B_GiveInvItems(self,other,ItFo_Potion_Water_01,12);
		Ricelord_AskedForWater_Day = (Wld_GetDay() + 1);
		Ricelord_AskedForWater = FALSE;
		if(!self.aivar[AIV_PASSGATE])
		{
			B_LogEntry(CH1_CarryWater,"Лорд дал мне дюжину бутылок воды.");
			self.aivar[AIV_PASSGATE] = 1;
		};
		AI_StopProcessInfos(self);
	}
	else if(Lefty_WorkDay == (Wld_GetDay() - 1))
	{
		AI_Output(self,other,"DIA_Ricelord_GetWater_TooLate_12_00");	//Это было вчера, парень! Лучше сходи к нему, он хочет тебе что-то сказать.
		AI_StopProcessInfos(self);
	}
	else
	{
		AI_Output(self,other,"DIA_Ricelord_GetWater_TooLate_12_01");	//Это было несколько дней назад, парень! Лучше сходи к нему, он хочет тебе кое-что сказать.
		AI_StopProcessInfos(self);
	};
};

N1kX94 avatar Apr 02 '21 13:04 N1kX94

I think the only thing addressing the issue is the condition

(Ricelord_AskedForWater_Day != (Wld_GetDay() + 1))

We should add something like that.

szapp avatar Apr 02 '21 13:04 szapp