Browse Source

[fixed][added] the court gameover stuff. Fixed bugs

anjuna krokus 8 months ago
parent
commit
f5e1e64363

+ 1 - 1
locations/cikl.qsrc

@@ -1367,7 +1367,7 @@ if policeQW['fine_deadline'] > 0:
 	end
 end
 
-gs 'sentence', 'sort_policeQW_arrays'
+gs 'shortgs', 'coupled_array_sort', 'police_courtletter_dates', '$police_courtletter_subjects'
 
 
 --- cikl ---------------------------------

+ 1 - 1
locations/pav_station.qsrc

@@ -1073,7 +1073,7 @@ if $ARGS[0] = 'rape_report':
 
 			if $loc = 'pav_commercial':
 				'"In th-the commercial district. But he pulled me away. I... I don''t remember how far..."'
-			else:
+			else
 				'"In th-the residential district. But he pulled me away. I... I don''t remember how far..."'
 			end
 

+ 1 - 1
locations/pcs_has_attr.qsrc

@@ -238,7 +238,7 @@ if $ARGS[0] = 'body_strong':
 	end
 
 elseif $ARGS[0] = 'body_weak':
-	if strenbug <= 20 and stren_plus_lvl <= 0:
+	if strenbuf <= 20 and stren_plus_lvl <= 0:
 		result = 1
 	else
 		result = 0

+ 2 - 0
locations/post_office.qsrc

@@ -208,6 +208,7 @@ if $postloc = 'counter':
 				policeQW['legal_fine'] = 0
 				policeQW['missed_fine_deadlines'] = 0
 				policeQW['fine_deadline'] = 0
+					policeQW['arrest_gameover_flag'] = 0
 
 				'<br>You pay the full amount of your outstanding fine/s to the cashier and they print out a receipt to say that it is paid off.'
 
@@ -228,6 +229,7 @@ if $postloc = 'counter':
 				policeQW['legal_fine'] = 0
 				policeQW['missed_fine_deadlines'] = 0
 				policeQW['fine_deadline'] = 0
+				policeQW['arrest_gameover_flag'] = 0
 				gs 'stat'
 
 				'<center><b><font color="maroon">Counter</font></b></center>'

+ 54 - 82
locations/sentence.qsrc

@@ -11,13 +11,27 @@ if $ARGS[0] = 'letter':
 
 	killvar 'policeQW_courtletter_dates', 0
 
-	if policeQW['missed_court_dates'] + policeQW['missed_fine_deadlines'] > 20:
-		!!gs 'sentence', 'police_arrest2'
+	if (policeQW['missed_court_dates'] + policeQW['missed_fine_deadlines']) > 1:
+		if (policeQW['tot_court_dates_missed'] + policeQW['tot_fines_deadlines_missed']) > 30 and policeQW['tot_arrested'] > 10:
+			killvar 'policeQW_courtletter_subjects', 0
+			policeQW['tot_arrested'] += 1
+			if policeQW['arrest_gameover_flag'] = 1:
+				gt 'sentence', 'police_arrest', 2
+			else
+				policeQW['arrest_gameover_flag'] = 1
+				gt 'sentence', 'police_arrest', 1
+			end
+		end
+
+		if (policeQW['missed_court_dates'] + policeQW['missed_fine_deadlines']) > 3:
+			killvar 'policeQW_courtletter_subjects', 0
+			policeQW['tot_arrested'] += 1
+			gt 'sentence', 'police_arrest', 0
+		end
 	end
 
 	'<center><img <<$set_imgh>> src="images/locations/city/shared/court/openletter.jpg"></center>'
 
-
 	!! Handling the various different letters.
 	if $policeQW_courtletter_subjects[0] = 'fine':
 
@@ -64,6 +78,7 @@ if $ARGS[0] = 'letter':
 					policeQW['legal_fine'] = 0
 					policeQW['missed_fine_deadlines'] = 0
 					policeQW['fine_deadline'] = 0
+					policeQW['arrest_gameover_flag'] = 0
 					minut += 5
 					gs 'stat'
 
@@ -125,6 +140,7 @@ if $ARGS[0] = 'letter':
 					policeQW['legal_fine'] = 0
 					policeQW['missed_fine_deadlines'] = 0
 					policeQW['fine_deadline'] = 0
+					policeQW['arrest_gameover_flag'] = 0
 					minut += 5
 					gs 'stat'
 
@@ -210,6 +226,7 @@ if $ARGS[0] = 'letter':
 
 	act 'Continue': gt $loc, $loc_arg
 	killvar 'temp_fine'
+	killvar 'policeQW_courtletter_subjects', 0
 end
 
 
@@ -231,47 +248,6 @@ if $ARGS[0] = 'add_fine':
 end
 
 
-if $ARGS[0] = 'sort_policeQW_arrays':
-	killvar 'temp_array1'
-	killvar 'temp_array2'
-
-	:courthearing_loop
-	if arrsize('policeQW_courthearing_dates') > 0:
-		temp_pos = arrpos('policeQW_courthearing_dates', min('policeQW_courthearing_dates'))
-		
-		temp_array1[] = policeQW_courthearing_dates[temp_pos]
-		temp_array2[] = policeQW_courthearing_subjects[temp_pos]
-		
-		killvar 'policeQW_courthearing_dates', temp_pos
-		killvar 'policeQW_courthearing_subjects', temp_pos
-		jump 'courthearing_loop'
-	end
-	copyarr('policeQW_courthearing_dates', 'temp_array1')
-	copyarr('policeQW_courthearing_subjects', 'temp_array2')
-	killvar 'courthearing_loop'
-	killvar 'temp_array1'
-	killvar 'temp_array2'
-
-	:courtletter_loop
-	if arrsize('policeQW_courtletter_dates') > 0:
-		temp_pos = arrpos('policeQW_courtletter_dates', min('policeQW_courtletter_dates'))
-		
-		temp_array1[] = policeQW_courtletter_dates[temp_pos]
-		temp_array2[] = policeQW_courtletter_subjects[temp_pos]
-		
-		killvar 'policeQW_courtletter_dates', temp_pos
-		killvar 'policeQW_courtletter_subjects', temp_pos
-		jump 'courtletter_loop'
-	end
-	copyarr('policeQW_courtletter_dates', 'temp_array1')
-	copyarr('policeQW_courtletter_subjects', 'temp_array2')
-	killvar 'courtletter_loop'
-	killvar 'temp_pos'
-	killvar 'temp_array1'
-	killvar 'temp_array2'
-end
-
-
 if $ARGS[0] = 'start':
 	*clr & cla
 	minut += 2
@@ -796,7 +772,7 @@ end
 
 
 !!this should trigger the next time Sveta is home after having not gone to court
-if $ARGS[0] = 'police_arrest1':
+if $ARGS[0] = 'police_arrest':
 	gs 'stat'
 
 	'<center><img <<$set_imgh>> src="images/locations/shared/police/police_door.jpg"></center>'
@@ -811,56 +787,52 @@ if $ARGS[0] = 'police_arrest1':
 		'One of them holds up a piece of paper for you to read. "This is a warrant for your arrest for failure to show up for court or pay your fines." You get to read part of it before he puts it away. It seems all those letters you got about court was not a joke. The other office handcuffs your hands behind your back. Then they take you down to their police car and drive you to the city police station, where they throw you in a holding cell.'
 
 		act 'Next morning':
-			*clr & cla
-			gs 'stat'
-
-			'<center><img <<$set_imgh>> src="images/locations/city/shared/court/judge.jpg"></center>'
-			'You are taken out of holding and over to the courthouse to await your hearing. The judge reviews your case, "It seems you have missed your hearings, Miss <<$pcs_lastname>>, what do you have to say for yourself?"'
-			'You begin to look around, trying to come up with an excuse. But in the end you decide it''s best to admit, "I have no excuse your honor." you meekly answer.'
-
-			act 'Await punishment': gt 'sentence', 'punishment'
+			if ARGS[1] = 1:
+				gt 'sentence', 'police_arrest2'
+			elseif ARGS[1] = 2:
+				gt 'sentence', 'police_arrest3'
+			else
+				gt 'sentence', 'police_arrest1'
+			end
 		end
 	end
 end
 
 
-!!this should trigger the next time Sveta is home after having not payed the fine
-if $ARGS[0] = 'police_arrest2':
-	policeQW['arrest_fine'] = 1
-!!this code will stay until Sveta pays her fine, not sure how to code it so it is removed when she pays her fine
+!!this should trigger the next time Sveta is home after having not gone to court
+if $ARGS[0] = 'police_arrest1':
 	gs 'stat'
 
-	'<center><img <<$set_imgh>> src="images/locations/shared/police/police_door.jpg"></center>'
-	'There is a loud knock at the door. You walk up to the door and open it. You see a two police officers in uniform standing in the hallway. "<<$pcs_firstname>> <<$pcs_lastname>>! You are under arrest."'
-
-	act 'Get Arrested':
-		*clr & cla
-		gs 'stat'
+	'<center><img <<$set_imgh>> src="images/locations/city/shared/court/judge.jpg"></center>'
+	'You are taken out of holding and over to the courthouse to await your hearing. The judge reviews your case, "It seems you have missed your hearings, Miss <<$pcs_lastname>>, what do you have to say for yourself?"'
+	'You begin to look around, trying to come up with an excuse. But in the end you decide it''s best to admit, "I have no excuse your honor." you meekly answer.'
 
-		'<center><img <<$set_imgh>> src="images/locations/shared/police/police_arrested.jpg"></center>'
-		'Wondering what they want from you, you ask. "What is this all about?"'
-		'One of them holds up a piece of paper for you to read. "This is a warrant for your arrest for failure to show up for court or pay your fines." You get to read part of it before he puts it away. It seems all those letters you got about court was not a joke. The other office handcuffs your hands behind your back. Then they take you down to their police car and drive you to the city police station, where they throw you in a holding cell.'
+	act 'Await punishment': gt 'sentence', 'punishment'
+end
 
-		act 'Next morning':
-			*clr & cla
-			gs 'stat'
 
-			'<center><img <<$set_imgh>> src="images/locations/city/shared/court/judge.jpg"></center>'
-			if policeQW['arrest_court'] = 1:
-				'You are taken out of holding and over to the courthouse to await your hearing. The judge reviews your case, "It seems you believe you are above the law, I assure you, you are not. I sentence you to one year in prison." You break down into tears as you are hauled away to serve your time.'
-				act 'Continue': over = 14 & gt 'gameover'
-				!!can we make this in big red letters and then it is a game over not sure how to code that.
+!!this should trigger the next time Sveta is home after having not payed the fine
+if $ARGS[0] = 'police_arrest2':
+	gs 'stat'
 
-			else
-				'You are taken out of holding and over to the courthouse to await your hearing. The judge reviews your case, "It seems you refused to pay your fines Miss <<$pcs_lastname>>, what do you have to say for yourself?"'
-				'You begin to look around, trying to come up with an excuse. But in the end you decide it''s best to admit, "I have no excuse your honor." you meekly answer.'
-				'With the judges eyes piercing through you, they clear their throat, "I see, you have thirty days to pay your fine. If you fail to do so you will be arrested again and next time I will sentence you to one year in prison."'
-				'You try your best to hold back the tears as you nod that you understand.'
+	'You are taken out of holding and over to the courthouse to await your hearing. The judge reviews your case, "It seems you refused to pay your fines Miss <<$pcs_lastname>>, what do you have to say for yourself?"'
+	'You begin to look around, trying to come up with an excuse. But in the end you decide it''s best to admit, "I have no excuse your honor." you meekly answer.'
+	'With the judges eyes piercing through you, they clear their throat, "I see, you have thirty days to pay your fine. If you fail to do so you will be arrested again and next time I will sentence you to one year in prison."'
+	'You try your best to hold back the tears as you nod that you understand.'
 !!can we add a out of character note that stats. If you fail to pay your fines again and get arrested a second time it will lead to a game over.
 
-				act 'Leave the court': gt 'city_center'
-			end
-		end
+	act 'Leave the court': gt 'city_center'
+end
+
+
+if $ARGS[0] = 'police_arrest3':
+	gs 'stat'
+
+	'<center><img <<$set_imgh>> src="images/locations/city/shared/court/judge.jpg"></center>'
+	if policeQW['arrest_court'] = 1:
+		'You are taken out of holding and over to the courthouse to await your hearing. The judge reviews your case, "It seems you believe you are above the law, I assure you, you are not. I sentence you to one year in prison." You break down into tears as you are hauled away to serve your time.'
+		act 'Continue': over = 14 & gt 'gameover'
+		!!can we make this in big red letters and then it is a game over not sure how to code that.
 	end
 end
 

+ 85 - 0
locations/shortgs.qsrc

@@ -928,6 +928,7 @@ if $ARGS[0] = 's_pow':
 	if(ARGS[2] > 10) : msg('Warning: s_pow operations with large exponents may cause integer overflows. <<ARGS[1]>> ^ <<ARGS[2]>>')
 	
 	if(ARGS[2]) < 0:
+		!! n ^(-m) = 0
 		msg('Error: s_pow cannot accept negative exponents! <<ARGS[1]>> ^ <<ARGS[2]>>')
 	elseif ARGS[2] = 0:
 		result = 1
@@ -939,5 +940,89 @@ if $ARGS[0] = 's_pow':
 		result = ARGS[1] * func('shortgs', 's_pow', ARGS[1] * ARGS[1], (ARGS[2] - 1) / 2)
 	end
 end
+
+
+!! Improved exponent calculation based on - https://en.wikipedia.org/wiki/Exponentiation_by_squaring
+!! use: func('shortgs', 's_pow2', var, exp)
+!! returns var ^exp
+!! if exp < 0, returns 0
+!! example: func('shortgs', 's_pow2', 2, 3) -> 8
+if $ARGS[0] = 's_pow2':
+	if ARGS[2] = 0:
+		result = 1
+	elseif ARGS[2] < 0:
+		result = 0
+
+	elseif ARGS[2] = 1:
+		result = ARGS[1]
+	elseif ARGS[2] = 2:
+		result = ARGS[1] * ARGS[1]
+	elseif ARGS[2] = 3:
+		result = ARGS[1] * ARGS[1] * ARGS[1]
+
+	elseif (ARGS[2] mod 2) = 0:
+		result = func('shortgs', 's_pow2', ARGS[1] * ARGS[1], ARGS[2] / 2)
+	else
+		result = ARGS[1] * func('shortgs', 's_pow2', ARGS[1] * ARGS[1], ARGS[2] / 4)
+	end
+end
+
+
+!! Takes multiple arrays and sorts them based on the first one.
+!! Sorts the key_array (which must only have value entries) in ascending order.
+!! gs 'shortgs', 'coupled_array_sort'. 'key_array', 'array1', 'array2', 'array3', ...
+!!
+!! String arrays must start with a $ otherwise the numeric values will be copied instead.
+!!
+!! examples:
+!!		example 1: we want to sort a single array with values called values_array
+!!				gs 'shortgs', 'coupled_array_sort', 'values_array'
+!!		example 2: we have an array filled with days (called trigger_days), and a coupled array filled with npc_codes (called $trigger_npc_codes)
+!!				gs 'shortgs', 'coupled_array_sort', 'trigger_days', '$trigger_npc_codes'
+
+if $ARGS[0] = 'coupled_array_sort':
+	:shortgs_coupled_array_sort_loop_start
+	if arrsize($ARGS[1]) > 0:
+		shortgs_temp_pos = arrpos($ARGS[1], min($ARGS[1]))
+
+		shortgs_args_index = 1
+		:shortgs_casl_inner_start
+		if $ARGS[shortgs_args_index] ! '':
+			if arrsize($ARGS[shortgs_args_index]) > 0:
+				if mid($ARGS[shortgs_args_index], 1, 1) = '$':
+					dynamic '$shortgs_temp_array<<shortgs_args_index>>[] = <<$ARGS[shortgs_args_index]>>[shortgs_temp_pos]'
+				else
+					dynamic 'shortgs_temp_array<<shortgs_args_index>>[] = <<$ARGS[shortgs_args_index]>>[shortgs_temp_pos]'
+				end
+				killvar $ARGS[shortgs_args_index], shortgs_temp_pos
+
+				shortgs_args_index += 1
+				jump 'shortgs_casl_inner_start'
+			end
+		end
+		jump 'shortgs_coupled_array_sort_loop_start'
+	end
+
+	shortgs_max_args_index = shortgs_args_index
+
+	shortgs_args_index = 1
+	:shortgs_casl_outer_start
+	if shortgs_args_index < shortgs_max_args_index:
+		dynamic 'copyarr(''<<$ARGS[shortgs_args_index]>>'', ''shortgs_temp_array<<shortgs_args_index>>'')'
+		dynamic 'killvar ''shortgs_temp_array<<shortgs_args_index>>'' '
+		
+		shortgs_args_index += 1
+		jump 'shortgs_casl_outer_start'
+	end
+	
+	killvar 'shortgs_casl_inner_start'
+	killvar 'shortgs_args_index'
+	killvar 'shortgs_coupled_array_sort_loop_start'
+	killvar 'shortgs_casl_outer_start'
+	killvar 'shortgs_max_args_index'
+	killvar 'shortgs_temp_pos'
+end
+
+
 --- shortgs ---------------------------------