Преглед изворни кода

Updated the tip calculation to actually be able to make some money.

Changed the calculation - with max level in all relevant skills and 10/10 appearance even a busker makes more than the price of a sandwich in an hour.
(561 rubels was the absolute top amount when everything was maxed out, a Rubens sandwich costs 340 rubels. Not really realistic, seriously. I made more money with busking than that.)

I lowered the effect of appearance, and removed the /50, reverting it to the /5.
However, I finally implemented a rough right-skewed distribution, meaning that the higher the amount, the lower the chance that the player will receive it.
Half the time (51.9%) the tip will be 33.33% of the maximum possible value.

This can be refined, but if someone has 100 in all 3 relevant skills, making enough money to buy a dozen Big Macs is not really impossible.  I made enough money to buy 2 and I sucked at busking.
netuttki пре 1 година
родитељ
комит
b6ad35884a
1 измењених фајлова са 85 додато и 9 уклоњено
  1. 85 9
      locations/music_buskingevents.qsrc

+ 85 - 9
locations/music_buskingevents.qsrc

@@ -33,6 +33,7 @@ if $ARGS[0] = 'busking':
 !!  Random events come here. The displayed actions depend on the event
 	act 'Finish': gs 'music_buskingevents', 'finish'
 	killvar 'ml_buskingtime'
+	killvar 'ml_tipsearned'
 end
 
 
@@ -40,28 +41,62 @@ end
 if $ARGS[0] = 'calculate_tips':
 	
 	if $region = 'city_center' or $region = 'city_park':
-		ml_location_mod = 30
+		ml_location_mod = 6
 	elseif $region = 'pav':
 		ml_location_mod = 0
 	elseif $region = 'liames':
-		ml_location_mod = 15
+		ml_location_mod = 3
 	end 	
 
-	ml_time_mod = 5
-	if week >= 5: ml_time_mod += 10
-	if hour >= 17: ml_time_mod += 10
+	ml_time_mod = 1
+	if week >= 5: ml_time_mod += 2
+	if hour >= 17: ml_time_mod += 2
 		
 	ml_time_loc_mod = (ml_location_mod + ml_time_mod)	
+	'Location Modifier (region: <<$region>>) = <<ml_time_loc_mod>>'
+	'Time modifier (day:<<day>> hour: <<hour>>) = <<ml_time_mod>> '
+	ml_skill_tip_max = pcs_instrmusic + pcs_vokal + pcs_perform
+	'Skill total for tip: <<ml_skill_tip_max>>'
+	ml_appearance_tip_bonus = (ml_skill_tip_max * ((hotcat-4)*2))/100
+	'Appearance bonus (hotcat: <<hotcat>>: <<ml_appearance_tip_bonus>>'
+	ml_tip_poss_max = (ml_skill_tip_max + ml_appearance_tip_bonus) * ml_time_loc_mod
+	'Possible maximum tip: <<ml_tip_poss_max>>'
 
-	ml_tipsmax = ((pcs_instrmusic + pcs_vokal + pcs_perform + ((hotcat-4)*35)) * ml_time_loc_mod)/50	
-
-	ml_tipsearned = (max(rand(ml_time_loc_mod,ml_tipsmax),0)*ml_buskingtime) / 60
+	if ml_tip_poss_max > 0:
+		bin_value = func('music_buskingevents', 'get_bin_value', ml_tip_poss_max)
+		'Bin_value: <<bin_value>> rubels'
+		devRand = rand(0, 1000)
+		'devRand = <<devRand>>'
+		if devRand < 24: 
+			ml_tipsearned = (max(rand(0,bin_value),0)*ml_buskingtime) / 60 
+			'Tips earned: <<ml_tipsearned>> = (max(rand(0,<<bin_value>>),0)*<<ml_buskingtime>>) / 60'
+		elseif devRand < 520: 
+			ml_tipsearned = (max(rand(bin_value+1,bin_value*2),0)*ml_buskingtime) / 60 
+			'Tips earned: <<ml_tipsearned>> = (max(rand(<<bin_value+1>>,<<bin_value*2>>),0)*<<ml_buskingtime>>) / 60'
+		elseif devRand < 818: 
+			ml_tipsearned = (max(rand((bin_value*2)+1,bin_value*3),0)*ml_buskingtime) / 60 
+			'Tips earned: <<ml_tipsearned>> = (max(rand(<<(bin_value*2)+1>>,<<bin_value*3>>),0)*<<ml_buskingtime>>) / 60'
+		elseif devRand < 925: 
+			ml_tipsearned = (max(rand((bin_value*3)+1,bin_value*4),0)*ml_buskingtime) / 60 
+			'Tips earned: <<ml_tipsearned>> = (max(rand(<<(bin_value*3)+1>>,<<bin_value*4>>),0)*<<ml_buskingtime>>) / 60'
+		elseif devRand < 978: 
+			ml_tipsearned = (max(rand((bin_value*4)+1,bin_value*5),0)*ml_buskingtime) / 60 
+			'Tips earned: <<ml_tipsearned>> = (max(rand(<<(bin_value*4)+1>>,<<bin_value*5>>),0)*<<ml_buskingtime>>) / 60'
+		elseif devRand <= 1000: 
+			ml_tipsearned = (max(rand((bin_value*5)+1,bin_value*6),0)*ml_buskingtime) / 60 
+			'Tips earned: <<ml_tipsearned>> = (max(rand(<<(bin_value*5)+1>>,<<bin_value*6>>),0)*<<ml_buskingtime>>) / 60'
+		end
+	else
+		'Tips max is 0, tips earned is 0'
+	end
 
-	
 	killvar 'ml_location_mod'
 	killvar 'ml_time_mod'	
 	killvar 'ml_tipsmax'
 	killvar 'ml_time_loc_mod'
+	killvar 'ml_maxTip'
+	killvar 'ml_appearance_tip_bonus'
+	killvar 'ml_skill_tip_max'
 end
 
 !! TODO: Add the vocal only scenario ??
@@ -166,4 +201,45 @@ if $ARGS[0] = 'finish':
 		gs 'music_actions', 'finish'
 	end
 end
+
+if $ARGS[0] = 'get_bin_value':
+	'Total amount to be split to bins: <<ARGS[1]>> rubels'
+	result = func('music_buskingevents', 'round', ARGS[1], 6)
+end
+
+if $ARGS[0] = 'round':
+	'Total amount to split and round: <<ARGS[1]>>'
+	'Number of bins: <<ARGS[2]>>'
+	if total > 10000:
+		div = 10000
+	elseif total > 1000: 
+		div = 1000
+	elseif total > 100: 
+		div = 100
+	elseif total > 10:
+		div = 10
+	else	
+		div = 1
+	end
+	'Divide for MOD and rounding: <<div>>'
+	total = (ARGS[1] * div)/ARGS[2]
+	'Unrouded bin value: <<total>> = (<<ARGS[1]>> * <<div>>) / <<ARGS[2]>>'
+
+	base = (total / div) * div
+	'Base: <<base>> = (<<total>> / <<div>>) * div'
+	fraction = total MOD div
+	'Fraction: <<fraction>> = <<total>> MOD <<div>>'
+
+	if fraction < (div/2): 
+		result = base/div
+	else
+		result = (base + div)/div
+	end	
+
+	killvar 'total'
+	killvar 'base'
+	killvar 'fraction'
+	killvar 'div'
+end
+
 --- music_buskingevents ---------------------------------