Jump to content

Global Variable setting problem


icecreamassassin

Recommended Posts

Ok, so I have a character that runs a lot of AI packages based on the "CRBarlonisState" global variable I have set up. It's zero by default where he will wander an Inn. You talk to him and have him follow you, which sets it to 1 and he follows. When you enter a specific house I have set up, the script will ID him as being there and his state as 1 and set his state to 2, then when you talk to him again his greeting is different which gives you the option to let him rent the house. You say yes and get some money and the topic sets the variable to 3 which allows him to start his normal day andf night cycle at the house he is now renting. the topic also starts a new quest handler (just for the script) and every 7 days a rent variable is increased and you go to talk to him to collect the rent and the variable is reset. So far so good.

 

After 17 days in the house, the moron burns it down by accident. The script for the rent quest handler disables the house, enables the smoldering wreckage, and sets his state to 4 which SHOULD make him go to a marker outside and start weeping like a baby, however he does not. Instead he stays inside the house cell until his state 3 AI packages take him outside the house to wander town and he remains in state 3. I manually set the global variable to 4, but something keeps changing it back! I have gone through and removed the "set CRBarlonisState to 3" command from all the scripts that apply and made sure that it's only being set by the dialog which initially rents him the house. But no dice. He also has a greeting that is dependent on being in state 4 which continues the quest to rebuild the house, get him to repay you, or send him to jail, etc. So below are the scripts which apply

 

The main script which initiates you being able to talk to the bank about renting your properties and also the script which sets the CRBarlonisstate to 2 (currently touring the house):

scn CRhouserentalscript

float timer1
short checkonce


Begin GameMode

if checkonce == 0	
if CRHousesOwned >= 3
	setstage CRrentals 10
	set checkonce to 1
endif
endif

if CRBarlonisREF.getincell darkwizardhouse == 1 && CRBarlonisState == 1
set CRbarlonisstate to 2		
endif


end

 

this is the code on the main quest handler which handles the functions for the specific house rental and the events which initiates when the rental occurs:

 

scn CRCheydinhalrentscript

short rented
short weekpassed

short eventcountdown
short daycounter

short repayment
short payday
short BarlonisRepaid

Begin GameMode

if rented == 0
set weekpassed to gamedayspassed
set rented to 1
endif

if rented == 1 && CRBarlonisState == 3
if gamedayspassed >= weekpassed + 7
	set CRRentAmtCheydinhal to CRRentAmtCheydinhal + 120
	message "It's time to collect rent from Barlonis"
	set rented to 0
endif
endif

if eventcountdown == 0
set daycounter to gamedayspassed
set eventcountdown to 1
endif

if eventcountdown == 1
if gamedayspassed >= daycounter + 17
	set CRBarlonisState to 4
	CRdrakeburnburnt.enable
	CRDrakeburnhouseExterior.disable
	CRDBtrapdoorexterior.enable
	CRDBtrapdoorInterior.disable
	messagebox "A messenger approaches you and hands you a letter before quickly moving on."
	player.additem CRburnthousenote 1
	set eventcountdown to 2
endif
endif	

if CRBarlonisState == 5 || CRBarlonisState == 8
if CheydinhalWestGateMapMarker.getdistance CRBarlonisREF <= 50
	CRBarlonisREF.disable
endif
endif

if CRBarlonisState == 7 && eventcountdown == 2
set daycounter to gamedayspassed
set eventcountdown to 3
endif

if eventcountdown == 3
if gamedayspassed >= daycounter + 2 && gamedayspassed <= daycounter + 5
	CRdrakeburnburnt.disable
	CRDBstage1.enable
elseif gamedayspassed >= daycounter + 6 && gamedayspassed <= daycounter + 10
	CRDBstage2.enable
elseif gamedayspassed >= daycounter + 11
	CRDrakeburnhouseExterior.enable
	CRDBstage1.disable
	CRDBstage2.disable
	CRDBtrapdoorexterior.disable
	CRDBtrapdoorInterior.enable
	set eventcountdown to 4
	set CRBarlonisState to 9
endif
endif

if eventcountdown == 4
messagebox "A messenger appears and gives you a letter before rushing along to his next delivery. It's from Barlonis."
player.additem CRBarlonisNote1 1
set eventcountdown to 5
endif

if CRBarlonisState == 5

if repayment == 0
	set payday to gamedayspassed
	set repayment to 1
endif

if repayment == 1 && BarlonisRepaid < 24
	if gamedayspassed == payday + 7
		message "Barlonis has made a deposit to your account"
		set CRPersonalaccount to CRpersonalaccount + 300
		set BarlonisRepaid to BarlonisRepaid + 1
		set repayment to 0
	endif
endif

if BarlonisRepaid == 24
	set repayment to -1
	messagebox "Barlonis has finally repaid me in full for the loss of the Drakeburne estate in Cheydinhal"
	set BarlonisRepaid to 25
endif
endif

end

 

so anyone have any ideas why the CRBarlonisState is being set to 3 any time it's greater than 3?

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...