OSP Code SP [WB] Entertainement skill

Users who are viewing this thread

Heart of my changes, module_game_menus (EDIT should have been rest_for_hours_interactive for all but 1-hour wait!)

Code:
  	("choose_music",0,"What do you want to do?",
	"none",
		[	
			# (assign, "$entertainement_on", 0), MOTO will kill morale bonus trigger (so done there)
		],
		[
      ("simple",[],"I want to perform a simple piece of music.(1 hour)",
		  [(assign, "$entertainment_type", entertainment_simple),
		   # (assign, "$g_infinite_camping", 0),             
		   (assign, "$auto_enter_town", "$current_town"),
		   (assign, "$g_town_visit_after_rest", 1),
		   (assign, "$g_last_rest_center", "$current_town"),
		   (assign, ":num_hours", 1),
		   (store_current_hours, "$entertainment_done_time"),
		   (val_add, "$entertainment_done_time", ":num_hours"),
		   (val_max, "$g_check_autos_at_hour", "$entertainment_done_time"),
           (assign, "$auto_menu", "mnu_perform_music"),
		   # (val_add, ":num_hours", 1),
		   (rest_for_hours, ":num_hours", ":num_hours", 0),
           (change_screen_return)]
       ),
      ("medium",[(store_skill_level,":skill_lvl","skl_entertain",0),
			   (ge, ":skill_lvl", 2),
			   (ge, "$bardic_reputation", 130),
			   ],"I want to perform a medium piece of music.(3 hours)",
		  [(assign, "$entertainment_type", entertainment_medium),
		   # (assign, "$g_infinite_camping", 0),             
		   (assign, "$auto_enter_town", "$current_town"),
		   (assign, "$g_town_visit_after_rest", 1),
		   (assign, "$g_last_rest_center", "$current_town"),
		   (assign, ":num_hours", 3),
		   (store_current_hours, "$entertainment_done_time"),
		   (val_add, "$entertainment_done_time", ":num_hours"),
		   (val_max, "$g_check_autos_at_hour", "$entertainment_done_time"),
           (assign, "$auto_menu", "mnu_perform_music"),
		   # (val_add, ":num_hours", 1),
		   (rest_for_hours_interactive, ":num_hours", ":num_hours", 0),
           (change_screen_return)]
       ),
      ("complex",[(store_skill_level,":skill_lvl","skl_entertain",0),
			   (ge, ":skill_lvl", 5),
			   (ge, "$bardic_reputation", 470),
			   ],"I want to perform a complex piece of music.(5 hours)",
		  [(assign, "$entertainment_type", entertainment_complex),
		   # (assign, "$g_infinite_camping", 0),             
		   (assign, "$auto_enter_town", "$current_town"),
		   (assign, "$g_town_visit_after_rest", 1),
		   (assign, "$g_last_rest_center", "$current_town"),
		   (assign, ":num_hours", 5),
		   (store_current_hours, "$entertainment_done_time"),
		   (val_add, "$entertainment_done_time", ":num_hours"),
		   (val_max, "$g_check_autos_at_hour", "$entertainment_done_time"),
           (assign, "$auto_menu", "mnu_perform_music"),
		   # (val_add, ":num_hours", 1),
		   (rest_for_hours_interactive, ":num_hours", ":num_hours", 0),
           (change_screen_return)]
       ),
      ("lordly",[(store_skill_level,":skill_lvl","skl_entertain",0),
			   (ge, ":skill_lvl", 9),
			   (ge, "$bardic_reputation", 1150),
			   ],"I want to perform a lordly piece of music.(15 hours)",
		  [(assign, "$entertainment_type", entertainment_lordly),
		   # (assign, "$g_infinite_camping", 0),             
		   (assign, "$auto_enter_town", "$current_town"),
		   (assign, "$g_town_visit_after_rest", 1),
		   (assign, "$g_last_rest_center", "$current_town"),
		   (assign, ":num_hours", 15),
		   (store_current_hours, "$entertainment_done_time"),
		   (val_add, "$entertainment_done_time", ":num_hours"),
		   (val_max, "$g_check_autos_at_hour", "$entertainment_done_time"),
           (assign, "$auto_menu", "mnu_perform_music"),
		   # (val_add, ":num_hours", 1),
		   (rest_for_hours_interactive, ":num_hours", 5, 0),
           (change_screen_return)]
       ),
      ("royal",[(store_skill_level,":skill_lvl","skl_entertain",0),
			   (ge, ":skill_lvl", 14),
			   (ge, "$bardic_reputation", 3550),
			   ],"I want to perform a royal piece of music.(35 hours)",
		  [(assign, "$entertainment_type", entertainment_royal),
		   # (assign, "$g_infinite_camping", 0),             
		   (assign, "$auto_enter_town", "$current_town"),
		   (assign, "$g_town_visit_after_rest", 1),
		   (assign, "$g_last_rest_center", "$current_town"),
		   (assign, ":num_hours", 35),
		   (store_current_hours, "$entertainment_done_time"),
		   (val_add, "$entertainment_done_time", ":num_hours"),
		   (val_max, "$g_check_autos_at_hour", "$entertainment_done_time"),
           (assign, "$auto_menu", "mnu_perform_music"),
		   # (val_add, ":num_hours", 1),
		   (rest_for_hours_interactive, ":num_hours", 5, 0),
           (change_screen_return)]
       ),
      ("speech",[],"I want to give a speech.(3 hours)",
		  [(assign, "$entertainment_type", entertainment_speech),
		   # (assign, "$g_infinite_camping", 0),             
		   (assign, "$auto_enter_town", "$current_town"),
		   (assign, "$g_town_visit_after_rest", 1),
		   (assign, "$g_last_rest_center", "$current_town"),
		   (assign, ":num_hours", 3),
		   (store_current_hours, "$entertainment_done_time"),
		   (val_add, "$entertainment_done_time", ":num_hours"),
		   (val_max, "$g_check_autos_at_hour", "$entertainment_done_time"),
           (assign,"$auto_menu","mnu_perform_music"),
		   # (val_add, ":num_hours", 1),
		   (rest_for_hours_interactive, ":num_hours", ":num_hours", 0),
           (change_screen_return)]
       ),
    ]
  ),
  
  	("perform_music", 0, "{s0}", "none", [
		(store_current_hours, ":cur_hours"),
		(try_begin),
			(lt, ":cur_hours", "$entertainment_done_time"),
			(str_store_string, s0, "@Interrupted, all your preparations go to waste."),
		(else_try),
			(try_begin),
				(eq, "$entertainment_type", entertainment_simple),
				(val_max, "$entertainement_on", 1),
				(assign, ":entertain_income_rate", 7),
				(assign, ":entertain_income_type", income_denars),
				(assign, ":entertain_income_type2", income_bard_reputation),
				(str_store_string, s0, "@You perform some simple music."),
			(else_try),
				(eq, "$entertainment_type", entertainment_medium),
				(val_max, "$entertainement_on", 1),
				(assign, ":entertain_income_rate", 15),
				(assign, ":entertain_income_type", income_denars),
				(assign, ":entertain_income_type2", income_bard_reputation),
				(str_store_string, s0, "@You perform some music."),
			(else_try),
				(eq, "$entertainment_type", entertainment_complex),
				(val_max, "$entertainement_on", 1),
				(assign, ":entertain_income_rate", 50),
				(assign, ":entertain_income_type", income_denars),
				(assign, ":entertain_income_type2", income_bard_reputation),
				(str_store_string, s0, "@You perform some complex music."),
			(else_try),
				(eq, "$entertainment_type", entertainment_lordly),
				(val_max, "$entertainement_on", 2),
				(assign, ":entertain_income_rate", 90),
				(assign, ":entertain_income_type", income_denars),
				(assign, ":entertain_income_type2", income_bard_reputation),
				(str_store_string, s0, "@You perform some lordly music."),
			(else_try),
				(eq, "$entertainment_type", entertainment_royal),
				(assign, "$entertainement_on", 3),
				(assign, ":entertain_income_rate", 170),
				(assign, ":entertain_income_type", income_denars),
				(assign, ":entertain_income_type2", income_bard_reputation),
				(str_store_string, s0, "@You perform some royal music."),
			(else_try),
				(eq, "$entertainment_type", entertainment_speech),
				(assign, "$entertainement_on", 3),	#for best troop morale bonus
				# (assign, ":entertain_income_rate", 9),	MOTO you'd have to have entertainment skill 20 for this to happen (see script_entertain_income)
				(troop_get_slot, ":entertain_income_rate", "trp_player", slot_troop_renown),
				(val_div, ":entertain_income_rate", 3),	#offset $entertainement_on
				(assign, ":entertain_income_type", income_reputation),
				(assign, ":entertain_income_type2", income_right_to_rule),
				(str_store_string, s0, "@You give a speech."),
			(else_try),
				(str_store_string, s0, "@{!}mnu_perform_music: you should not be reading this."),
			(try_end),
			
			(store_skill_level, ":max", "skl_entertain", "trp_player"),
			(val_add, ":max", ":entertain_income_rate"),
			(val_mul, ":max", "$entertainement_on"),

			(store_mul, ":min", ":entertain_income_rate", -1),
			(val_div, ":min", 2),
			(val_div, ":min", "$entertainement_on"),

			(store_random_in_range, ":income", ":min", ":max"),
			(store_div, ":reputation", "$bardic_reputation", 400),
			(val_min, ":reputation", 1),
			(val_add, ":reputation", 1),
			(val_mul, ":income", ":reputation"),
			(val_sub, ":income", ":reputation"),
			(call_script, "script_entertain_income", ":income", ":entertain_income_type"),
			(call_script, "script_entertain_income", ":income", ":entertain_income_type2"),
			(assign, "$entertainment_last_center", "$current_town"),
		(try_end),
	], [
		("continue", [], "Continue...", [
			(rest_for_hours_interactive, 0, 0, 0), #stop resting
			(change_screen_return)])
   	]),
I would have liked to limit performances to occur between the hours of noon and midnight, but couldn't think of a way before. Now I think I'd add up to 12 hours to prep time.

The original menu could probably use a "Never mind" cancellation option.

Remove the following line in the camp and town menus. They interfere with the morale bonus trigger.
Code:
	  (assign, "$entertainement_on", 0),

Update the following in the camp_wait_here and castle_wait menus...
Code:
	  (assign, "$entertainement_on", 1),

...to the following to avoid wiping out the extra benefit in the morale trigger for lordly and royal performances
Code:
 	  (val_max, "$entertainement_on", 1), #MOTO avoid overwriting higher value

To prevent multiple performances in a town, the town menu option now looks like the following:
Code:
      ("entertaiment",
       [(party_slot_eq,"$current_town",slot_party_type, spt_town),
	    (neq, "$entertainment_last_center", "$current_town"),	#MOTO force travel time between performances
        (this_or_next|eq,"$entry_to_town_forbidden",0),
        (eq, "$sneaked_into_town",1),],
       "Attempt a music performance or speech.",
       [(jump_to_menu, "mnu_choose_music"),]),

With the new constants required, the section in module_constants now looks like the following:
Code:
instruments_begin		= "itm_lyre"
instruments_end			= "itm_instruments_end"
income_denars		= 1
income_honor			= 2
income_reputation		= 3
income_right_to_rule	= 4
income_bard_reputation	= 5
entertainment_simple	= 0
entertainment_medium	= 1
entertainment_complex	= 2
entertainment_lordly	= 3
entertainment_royal	= 4
entertainment_speech	= 5
slot_agent_already_begg  = 45 #check for conflict!

The entertainment section of module_simple_triggers now looks like the following. The one that I moved to the automenu can be simply deleted if there is no save game issue.

First trigger, here once per day, if the player rested in camp or town/castle OR performed, gives a morale bonus up to +30 for rank 20 bard giving the top level of performance, but even a level 2 bard gets at least a point. Otherwise the troops grumble or even lose a point of morale!

The next trigger, here firing once every two days, I think needs more attention. If I'm reading it correctly, it does nothing until a bard reaches 1000 bardic rep, at which point it starts DOUBLING player renown every time. I think that's supposed to be a store_add() there instead of store_mul()...
Code:
	#entertainment party morale bonus
  	(24,	[#(ge, "$entertainement_on", 1),
		 # (assign, ":hero_count", 0),
		 (assign, ":entertain_bonus", 0),
		 #companions
		 (try_for_range, ":hero", companions_begin, companions_end),
		   (main_party_has_troop,":hero"),
		   # (val_add, ":hero_count", 1),
		   (store_skill_level,":skill","skl_entertain",":hero"),
		   (store_mul, reg0, ":skill", ":skill"),	#higher skill has bigger effect
		   (val_add, ":entertain_bonus", reg0),
		 (try_end),
		 #player troop
		 # (val_add, ":hero_count", 1),
		 (store_skill_level,":skill","skl_entertain","trp_player"),
		 (store_mul, reg0, ":skill", ":skill"),	#higher skill has bigger effect
		 (val_add, ":entertain_bonus", reg0),
		 #now get the bonus
		 # (val_add, ":hero_count", 5),	MOTO these will almost always zero the morale benefit
		 # (val_div, ":entertain_bonus", ":hero_count"),
		 (assign, reg0, ":entertain_bonus"),
		 (convert_to_fixed_point, reg0),
		 (store_sqrt, ":entertain_bonus", reg0),
		 (convert_from_fixed_point, ":entertain_bonus"),
		 (val_mul, ":entertain_bonus", "$entertainement_on"), #normal kind is 1 but if it is an aewsome entertainement it will get a bonus (like playing lordly/royal musics)
		 (val_div, ":entertain_bonus", 2),	#every two skill level gives a morale point (normally)
		 #and apply it
		 (try_begin),
		   (gt, ":entertain_bonus", 0),
		   (display_message, "@Your troops enjoy the entertainment you and your companions give them."),
		   (call_script, "script_change_player_party_morale", ":entertain_bonus"),
		 (else_try),
		   (display_message, "@Your troops wish you and your companions would provide more entertainment."),
		   (lt, "$entertainement_on", 1),
		   (call_script, "script_change_player_party_morale", -1),
		 (try_end),
		 (assign, "$entertainement_on", 0),	#init for new day
		 ]),
		 
	#bardic reputation bonus
	(48,[(store_div, ":reputation", "$bardic_reputation", 1000),
		 (val_min, ":reputation", 1),
		 (val_add, ":reputation", 1),
		 (troop_get_slot, ":old_reputation", "trp_player", slot_troop_renown),
		 (store_mul, ":new_reputation", ":old_reputation", ":reputation"),	#MOTO: multiply? $bardic_reputation will have an EXPONENTIAL effect...
		 (troop_set_slot, "trp_player", slot_troop_renown, ":new_reputation"),
		 (store_sub, reg12, ":new_reputation", ":old_reputation"),
         (try_begin),
            (gt, reg12, 0),
            (display_message, "@You gained {reg12} renown over the last two days from your bardic reputation.", 0x33ff33),
         (else_try),
            (lt, reg12, 0),
			(val_mul, reg12, -1),
            (display_message, "@You lost {reg12} renown over the last two days from your bardic reputation.", 0xff3333),
         (try_end),
		 ]),
		 
	#entertainment effects other than party morale NOW in an automenu
	(12,	[(ge, "$entertainement_on", 1),
		 # (assign, ":income_rate", "$entertain_income_rate"),
		 # (assign, ":income_type", "$entertain_income_type"),
		 # (assign, ":income_type2", "$entertain_income_type2"),
		 
		 # (store_mul, ":max", ":income_rate", 1),
		 # (store_skill_level,":skill_lvl","skl_entertain","trp_player"),
		 # (val_add, ":max", ":skill_lvl"),
		 # (val_mul, ":max", "$entertainement_on"),
		 
		 # (store_mul, ":min", ":income_rate", -1),
		 # (val_div, ":min", 2),
		 # (val_div, ":min", "$entertainement_on"),
		 
		 # (store_random_in_range, ":income", ":min", ":max"),
		 # (store_div, ":reputation", "$bardic_reputation", 400),
		 # (val_min, ":reputation", 1),
		 # (val_add, ":reputation", 1),
		 # (val_mul, ":income", ":reputation"),
		 # (val_sub, ":income", ":reputation"),
		 # (call_script, "script_entertain_income", ":income", ":income_type"),
		 # (call_script, "script_entertain_income", ":income", ":income_type2"),
		 ]),

Which means the line in module_skills should be
Code:
  ("entertain","Entertain",sf_base_att_cha|sf_effects_party,15,"Every day you rest or perform, each hero with this skill increases the morale of the party. It also helps you while begging, performing or playing music. (Personal skill)."),

Changes to script_entertain_income in module_scripts I think were textual/feedback to the player.
Code:
# script_entertain_income
# input_1 = income
# input_2 = income_type
# used on playing music or making a speech
  ("entertain_income",
   [(store_script_param, reg12, 1),
	(store_script_param, ":income_type", 2),
	(try_begin),
	######### HONOR #########
	  (eq, ":income_type", income_honor),
	  (val_div, reg12, 30),
	  (val_add, "$player_honor", reg12),
	  (assign, reg13, "$player_honor"),
	  (try_begin),
		(gt, reg12, 0),
		(display_message, "@Your honor has increased {reg12}, and it is {reg13} now.", 0x33ff33),
	  (else_try),
		(lt, reg12, 0),
		(val_mul, reg12, -1),
		(display_message, "@Your honor has decreased {reg12}, and it is {reg13} now.", 0xff3333),
	  (else_try),
		(display_message, "@People think neither better or worse of you.", 0xff3333),
	  (try_end),
	(else_try),
	######### REPUTATION #########
	  (eq, ":income_type", income_reputation),
	  (val_div, reg12, 30),
	  (troop_get_slot, ":reputation", "trp_player", slot_troop_renown),
	  (val_add, ":reputation", reg12),
	  (troop_set_slot, "trp_player", slot_troop_renown, ":reputation"),
	  (assign, reg13, ":reputation"),
	  (try_begin),
		(gt, reg12, 0),
		(display_message, "@You gained {reg12} renown, and it is {reg13} now.", 0x33ff33),
	  (else_try),
		(lt, reg12, 0),
		(val_mul, reg12, -1),
		(display_message, "@You lost {reg12} renown, and it is {reg13} now.", 0xff3333),
	  (else_try),
		(display_message, "@No one listens to you.", 0xff3333),
	  (try_end),
	(else_try),
	######### RIGHT TO RULE #########
	  (eq, ":income_type", income_right_to_rule),
	  (val_div, reg12, 30),
	  (val_add, "$player_right_to_rule", reg12),
	  (assign, reg13, "$player_right_to_rule"),
	  (try_begin),
		(gt, reg12, 0),
		(display_message, "@You gained {reg12} right to rule, and you have {reg13} now.", 0x33ff33),
	  (else_try),
		(lt, reg12, 0),
		(val_mul, reg12, -1),
		(display_message, "@You lost {reg12} right to rule, and you have {reg13} now.", 0xff3333),
	  (else_try),
		(display_message, "@Your claims to rule fall on deaf ears.", 0xff3333),
	  (try_end),
	(else_try),
	######### BARDIC REPUTATION #########
	  (eq, ":income_type", income_bard_reputation),
	  (val_div, reg12, 2),
	  (val_add, "$bardic_reputation", reg12),
	  (assign, reg13, "$bardic_reputation"),
	  (try_begin),
		(gt, reg12, 0),
		(display_message, "@You gained {reg12} bardic reputation, and it is {reg13} now.", 0x33ff33),
	  (else_try),
		(lt, reg12, 0),
		(val_mul, reg12, -1),
		(display_message, "@You lost {reg12} bardic reputation, and it is {reg13} now.", 0xff3333),
	  (try_end),
	(else_try),
	######### DENARS #########
	  (try_begin),
		(gt, reg12, 0),
		(set_show_messages, 0),
		(troop_add_gold, "trp_player", reg12),
		(set_show_messages, 1),
		(store_troop_gold, reg13, "trp_player"),
		(display_message, "@You got {reg12} scillingas, and you have {reg13} now.", 0x33ff33),
	  (else_try),
		(lt, reg12, 0),
		(val_mul, reg12, -1),
		(set_show_messages, 0),
		(troop_remove_gold, "trp_player", reg12),
		(set_show_messages, 1),
		(store_troop_gold, reg13, "trp_player"),
		(display_message, "@You lost {reg12} scillingas, and you have {reg13} now.", 0xff3333),
	  (try_end),
	(try_end),
   ]),

All the rest is as the original.

Thanks Ikaguia for adding a dimension to the game! I'm actually thinking of trying out a bard character (high morale being a rare commodity in Brytenwalda).
 
Brytenwalda player feedback: prevent morale effects for solo player party! So I added that condition to the party morale bonus trigger (using try_begin so as not to miss the reinit of the global at the end of the trigger).
 
I used this code on my experimental mod (first post) and noticed something is bugged with the reputation income thingy. Every time I get a reputation bonus due to bardic reputation, my reputation doubles, which is like cheating and a little bit gamebreaking.
I am hunting for the bug, but so far I haven't found it.
 
it's this bit that do it:
Code:
(24,[(store_div, ":reputation", "$bardic_reputation", 1000),
		 (val_min, ":reputation", 1),
		 (val_add, ":reputation", 1),
		 (troop_get_slot, ":old_reputation", 0, slot_troop_renown),
		 (store_mul, ":new_reputation", ":old_reputation", ":reputation"),
		 (troop_set_slot, 0, slot_troop_renown, ":new_reputation"),
		 (store_sub, ":reputation_change", ":new_reputation", ":old_reputation"),
         (try_begin),
but I don't think it is bugged.
 
guspav said:
I used this code on my experimental mod (first post) and noticed something is bugged with the reputation income thingy. Every time I get a reputation bonus due to bardic reputation, my reputation doubles, which is like cheating and a little bit gamebreaking.
I am hunting for the bug, but so far I haven't found it.
Ah, so I was right. See my comment on the 48-hour trigger above. EDIT 24-hour in Ikaguia's original!

I was proactive and rewrote the module further. Dropped this trigger too and instead bump renown when bardic rep is bumped. I leveled it so max return would be 50 (max bump from battles). It's worth the effort as it's a popular feature with players.

Or you could just change the
(store_mul, ":new_reputation", ":eek:ld_reputation", ":reputation"),
to
(store_add, ":new_reputation", ":eek:ld_reputation", ":reputation"),
so it will be adding 2 every two days day instead of multiplying by 2.
 
Well, I don't know if you intended for reputation to double, right? So if the code doesn't do what it was intended to do it is bugged. I am guessing something in the calculation formula is wrong and I think it has to do with the store_mul bit.
I have changed it to store_add for the time being, which makes reputation increases more reasonable.
 
well, reputation above 1000 would double the renown, but I don't think anyone get 1000 that fast...

and 24 hours is a bit too often, change it to 7*24
 
Ikaguia said:
well, reputation above 1000 would double the renown, but I don't think anyone get 1000 that fast...

and 24 hours is a bit too often, change it to 7*24
My renown in that game currently exceeds 64000 which is insane.
 
I know, but it took me about 3 game weeks to get over 1000 bardic reputation and then hell broke lose.
Don't get me wrong, I applaud your effort, it is a very good idea and the code is very creative, but if it can be a little bit more refined, all the better. :wink:
 
I know, it can be much more refined... maybe It in another way.

edit:
maybe like this:
Code:
(7*24,[(troop_get_slot, ":old_reputation", 0, slot_troop_renown),
		 (store_mul, ":new_reputation", ":old_reputation", 1000),
		 (val_mul, ":new_reputation", "$bardic_reputation"),
		 (store_sub, ":reputation_change", ":new_reputation", ":old_reputation"),
		 (val_div, ":reputation_change", ":reputation_change"),
		 (store_add, ":new_reputation", ":reputation_change", ":old_reputation"),
		 (store_sub, ":reputation_change", ":new_reputation", ":old_reputation"),
		 (val_div, ":reputation_change", ":reputation_change"),
		 (val_div, ":reputation_change", 1000),
		 (troop_set_slot, 0, slot_troop_renown, ":new_reputation"),
         (try_begin),
 
Back
Top Bottom