OSP Kit SP Duel Kit v0.5 released - duel your troops, companions, lord and kings.

Users who are viewing this thread

MartinF

Squire
Hi guys,

as some of you have probably already seen I've been working on a kit for duelling based on an idea by Phosphoer in this thread. I've since been adding on bits and pieces until it has come to the stage where I think it's ready to be a standalone kit that you can implement into your own mod if you want to. So I'm hereby releasing version 0.5

Feel free to use this for whatever you want, but a credit would be nice. And please let me know so I can try it out :smile:

Credits and thanks

  • Phosphoer - original idea and original code
  • Jinnai - help with the coding and explanation of slots.
  • HokieBT - Screenies and bugfix

Features

  • Practice duelling with your own troops, from recruits to knights
  • Duel your companions. Firentis *****ing about Katrin again? Beat the **** out of him! :grin:
  • As your renown increases, duel lord and eventually even kings!
  • Duel mounted or on foot using a range of weapons options: your own weapons, sword and shield, 2-handed weapons or ranged weapons.
  • The kit keeps track of how many times you fight a certain npc and whether you win or lose. The dialog changes accordingly.
  • Duels take place in arenas

They way it works is very straightforward. You start a conversation with a (neutral or friendly) lord or king and say "I want to ask you something". It will then come up with the option to challenge them to a friendly duel. They'll either accept or decline based on your renown.
If they accept, they'll ask you a series of questions which determine whether you'll fight mounted or unmounted and which weapons you'll use.
For your own party members, go to the party screen, select a unit and press 'Talk'. Then for your normal units the option will show up straight away, for companions again you click "I want to ask you something".

Note: After the dialog closes, it will put you back into the party screen or the scene you were in when you addressed the NPC. Press <Tab> to exit the scene and go to the duel menu, or press close in the party screen.


So now to implementing it. No original code needs to be changed, you're just adding stuff. You'll need to edit the following files:

  • module_constants.py - 2 places
  • module_dialogs.py - 1 place
  • module_game_menus.py - 1 place
  • module_mission_templates.py - 1 place

module_constants.py

I use slots which have to be added to the constants file, as well as two constants for setting the minimum renown needed to duel lords and kings. Where you put them doesn't really matter. For consistancy I put the slot_troop pieces with the other troop slots and the constants all the way at the end of the file.
Note, if you've already added extra slots, you might want to change the numbers. These are the first 'empty' slots for troop.

Code:
# Duel Mod Troop Slots

slot_troop_duel_won				  = 142		#duel mod - how many duels player won against this troop
slot_troop_duel_lost			  = 143		#duel mod - how many duels player lost against this troop
slot_troop_duel_started			  = 144		#duel mod - if player started dueling with this troop

# Duel mod constants

king_renown_for_duel = 150		# Minimum renown needed to challenge a king to a friendly duel
lord_renown_for_duel = 50		# Minimum renown needed to challenge a king to a friendly duel

module_dialog.py

This is where most of the jazz happens. There are different dialog bits for the four different types (troops, companions, lords and kings). The dialog also sets up the fight. All this is explained in the comments in the code itself.

Where you place it is not hugely important, but I would suggest just above the line "### COMPANIONS" as that works well for me

[edit] changed the first king dialog option to fix a bug, see post by Hokie[/edit]

Code:
################################################  # Duel Mod Start ################################################  

# dialog for companions 

  [anyone|plyr,"member_question_2", [], "I would like to challenge you to a friendly duel.", "duel_accept",[]],
  
# dialog to challenge regular troops in player party  

  [anyone|plyr,"regular_member_talk", [], "Let's have a practice duel.", "duel_accept",[]],
  
# dialog for kings. Renown requirements can be set in the module_constants file.  

  [anyone|plyr,"lord_talk_ask_something_2",[
					(is_between, "$g_talk_troop", kings_begin, kings_end),
					(assign, reg(25), 1),															
					(troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
					(ge, ":player_renown", king_renown_for_duel),
					], "My lord, I would like to challenge you to a friendly duel.", "lord_question_duel",[]],					
  [anyone|plyr,"lord_talk_ask_something_2",[
					(is_between, "$g_talk_troop", kings_begin, kings_end),
					(troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
					(lt, ":player_renown", king_renown_for_duel),
					], "My lord, I would like to challenge you to a friendly duel.", "king_decline_duel",[]],

  [anyone, "king_decline_duel", [], "It would hardly be fitting for a king to duel a mere soldier like yourself. Perhaps after you have distinguished yourself we can duel on friendly terms.", "lord_talk_ask_something_2",[]],

# dialog for lords. Renown requirements can be set in the module_constants file.

  [anyone|plyr,"lord_talk_ask_something_2",[
					(is_between, "$g_talk_troop", kingdom_heroes_begin, kingdom_heroes_end),
					(neq, reg(25), 1), #make sure lord is not a king
					(troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
					(ge, ":player_renown", lord_renown_for_duel),
					], "I would like to challenge you to a friendly duel.", "lord_question_duel",[]],
					
    [anyone|plyr,"lord_talk_ask_something_2",[
					(is_between, "$g_talk_troop", kingdom_heroes_begin, kingdom_heroes_end),
					(neq, reg(25), 1),
					(troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
					(lt, ":player_renown", lord_renown_for_duel),
					], "I would like to challenge you to a friendly duel.", "lord_decline_duel",[]],
  
	[anyone,"lord_decline_duel", [], "It would hardly be fitting for a lord to duel a mere soldier like yourself. Perhaps after you have distinguished yourself we can duel on friendly terms.", "lord_talk_ask_something_2",[]],

	
# next are the replies to the duel request by the lord, based on how many duels player won/lost against him.
		
[anyone, "lord_question_duel", [
                          (troop_get_slot, ":duel_wins", "$g_talk_troop", slot_troop_duel_won),
                          (troop_get_slot, ":duel_losses", "$g_talk_troop", slot_troop_duel_lost),
						  (troop_get_slot, ":duel_started", "$g_talk_troop", slot_troop_duel_started),
						  (try_begin),
							(eq, ":duel_started", 0),
							(str_store_string, s1, "@A duel, that sounds like an interesting idea. We could keep score and see who is the better fighter!"),
							(troop_set_slot, "$g_talk_troop", slot_troop_duel_started, 1),
						  (else_try),
							(gt, ":duel_losses", ":duel_wins"),						  
							(str_store_string, s1, "@Ah, so you wish to be beaten by me again, eh? I shall teach you another lesson in the art of dueling"),
						  (else_try),
							(gt, ":duel_wins", ":duel_losses"),						    
							(str_store_string, s1, "@You may have won more of our duels than I, but that will change today!"),
						  (else_try),
							(eq, ":duel_losses", ":duel_wins"),
							(str_store_string, s1, "@We seem to be evenly match so another duel should prove to be interesting."),
						  (else_try),
						    (str_store_string, s1, "@You should not be seeing this text."),
						  (try_end),
								], "{s1}", "duel_accept",[]],


      
# show different dialog options based on if you're challenging a mounted or unmounted unit.
# note that there's no check if you are mounted yourself, so if you have no horse and challenge someone to a mounted duel, you won't get a horse.
# the visitor numbers correlate with templates in the mission template. So which weapons to use and which items to override. Visitor nr 0 is template 1.
  
[anyone,"duel_accept", [
        (assign, "$g_duel_result", 0),              
        (assign, "$g_duel_vis_point_plyr", 0),      #this is the visitor nr for the player 
        (assign, "$g_duel_vis_point_opp", 0),       #this is the visitor nr for the opponent
        (assign, "$talk_troop_mounted",0),
        (str_clear, s3),
        (try_begin),
           (this_or_next|troop_is_mounted, "$g_talk_troop"),
           (troop_is_guarantee_horse, "$g_talk_troop"),
           (str_store_string, s3, "@I accept your challenge.^Do you wish to fight on horseback or on foot?"),
        (else_try),
           (str_store_string, s3, "@I accept your challenge. ^Let us choose our weapons."),
        (try_end),  
    ],
	"{s3}", "duel_choose_mount", []],

 [anyone|plyr,"duel_choose_mount", [
            (this_or_next|troop_is_mounted, "$g_talk_troop"),
            (troop_is_guarantee_horse, "$g_talk_troop"),
            (assign, "$talk_troop_mounted",1),
            ],
         "I would like to duel mounted", "duel_weap_mounted", [(str_clear, s4), (str_store_string, s4, "@horseback"),]],
  
 [anyone|plyr,"duel_choose_mount", [
            (this_or_next|troop_is_mounted, "$g_talk_troop"),
            (troop_is_guarantee_horse, "$g_talk_troop"),
            ],
         "I would like to duel on foot", "duel_weap_choose", [(str_clear, s4), (str_store_string, s4, "@foot"),]],
  
 [anyone|plyr,"duel_choose_mount", [
            (neq, "$talk_troop_mounted", 1),
            ],
         "Very well.", "duel_weap_choose", [(str_clear, s4), (str_store_string, s4, "@foot"),]],

 [anyone|plyr,"duel_choose_mount", [],
         "Forget about it.", "close_window", []],

#options for the mounted fights
[anyone, "duel_weap_mounted", [], "What kind of weapons would you like to fight with?", "duel_weap_mounted", []],
    [anyone|plyr,"duel_weap_mounted", [],
         "We should use our own weapons.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@our own weapons"),(
             assign, "$g_duel_vis_point_plyr", 0), (assign, "$g_duel_vis_point_opp", 1),]],
    [anyone|plyr,"duel_weap_mounted", [],
         "Let us fight with sword and shield.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@sword and shield"),
            (assign, "$g_duel_vis_point_plyr", 4), (assign, "$g_duel_vis_point_opp", 5),]],
    [anyone|plyr,"duel_weap_mounted", [],
         "We should fight with two-handed weapons.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@two handed weapons"),
            (assign, "$g_duel_vis_point_plyr", 8), (assign, "$g_duel_vis_point_opp", 9),]],
    [anyone|plyr,"duel_weap_mounted", [],
         "A duel with light armor and ranged weapons would be my choice.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@light armor and ranged weapons"),
            (assign, "$g_duel_vis_point_plyr", 12), (assign, "$g_duel_vis_point_opp", 13),]],
    [anyone|plyr,"duel_weap_mounted", [],
         "What was your previous question again?.", "duel_accept", []],

#options for the unmounted fights
 [anyone, "duel_weap_choose", [], "What kind of weapons would you like to fight with?", "duel_weap_choose", []],
    [anyone|plyr,"duel_weap_choose", [],
         "We should use our own weapons.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@our own weapons"),
            (assign, "$g_duel_vis_point_plyr", 2), (assign, "$g_duel_vis_point_opp", 3),]],
    [anyone|plyr,"duel_weap_choose", [],
         "Let us fight with sword and shield.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@sword and shield"),
            (assign, "$g_duel_vis_point_plyr", 6), (assign, "$g_duel_vis_point_opp", 7),]],
    [anyone|plyr,"duel_weap_choose", [],
         "We should fight with two-handed weapons.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@two handed weapons"),
            (assign, "$g_duel_vis_point_plyr", 10), (assign, "$g_duel_vis_point_opp", 11),]],
    [anyone|plyr,"duel_weap_choose", [],
         "A duel with light armor and ranged weapons would be my choice.", "duel_start", [(str_clear, s5), (str_store_string, s5, "@light armor and ranged weapons"),
            (assign, "$g_duel_vis_point_plyr", 14), (assign, "$g_duel_vis_point_opp", 15),]],
    [anyone|plyr,"duel_weap_choose", [],
         "What was your previous question again?.", "duel_accept", []],

#final dialog
[anyone, "duel_start", [], "Very well {playername}. ^^We will be duelling on {s4}, using {s5}.^^If this is all right, I will meet you down at the arena as soon as you finish preparing.", "duel_start", []],
    [anyone|plyr, "duel_start", [], "That sound great. I'll meet you down there.", "close_window", [(assign, reg(0), "$g_talk_troop"),(jump_to_menu, "mnu_duel_menu"),]],
    [anyone|plyr, "duel_start", [], "No, you've got it all wrong, let's try again.", "duel_accept", []],

  
################################################  # Duel Mod End  ################################################

module_game_menus.py

This is the start and end of the each duel. This is where you see how many duels you've fought/won/lost against this troop.

Search for "simple_encounter" and put the right above that one.

Code:
 ############################### Duel Mod Start  ##############################


("duel_menu",0,
   "{s1}{s2}",
   "none",
   [
 (str_clear, s2),  (str_clear, s3), (str_clear, s5), (str_clear, s6), (str_clear, s7),
   (troop_get_slot, ":duel_wins", "$g_talk_troop", slot_troop_duel_won),
   (assign, reg(6), ":duel_wins"),
   (troop_get_slot, ":duel_losses", "$g_talk_troop", slot_troop_duel_lost),
   (assign, reg(7), ":duel_losses"),
   (store_add, ":duel_total", ":duel_wins", ":duel_losses"),
   (assign, reg(5), ":duel_total"),
   (str_store_troop_name, s3, "$g_talk_troop"),
	(try_begin),
		(eq, "$g_duel_result", -1),
		(str_store_string, s1, "@You lost your duel against ^^{s3}"),
	(else_try),
		(eq, "$g_duel_result", 1),
		(str_store_string, s1, "@You won your duel against ^^{s3}"),
	(else_try),
		(str_store_string, s1, "@You prepare to duel ^^{s3}"),
	(try_end),
    (try_begin),
		(troop_is_hero, "$g_talk_troop"),
		(str_store_string, s2, "@^^^^You have fought {s3} {reg5} times. ^^You've won {reg6} times. ^^You've lost {reg7} times"),
	(else_try),
		(str_store_string, s2, "@^^^^Dueling with your own troops will not count towards your dueling statistics."),
	(try_end),

    ],
   
   [
      ("start_fight",[(eq, "$g_duel_result", 0)],"Start the duel.",
       [(try_begin),      
          (is_between, "$g_encountered_party", towns_begin, towns_end),      
            (party_get_slot, ":arena_scene", "$g_encountered_party", slot_town_arena),    
        (else_try),      
            (assign, ":closest_dist", 100000),      
            (assign, ":closest_town", -1),      
            (try_for_range, ":cur_town", towns_begin, towns_end),        
                (store_distance_to_party_from_party, ":dist", ":cur_town", "p_main_party"),        
                (lt, ":dist", ":closest_dist"),        
                (assign, ":closest_dist", ":dist"),        
                (assign, ":closest_town", ":cur_town"),      
            (try_end),      
            (party_get_slot, ":arena_scene", ":closest_town", slot_town_arena),
        (try_end),    
        (modify_visitors_at_site, ":arena_scene"),    
        (reset_visitors),
    (set_visitor, "$g_duel_vis_point_opp", "$g_talk_troop"),
    (set_visitor, "$g_duel_vis_point_plyr", "trp_player"),

         (set_jump_mission, "mt_arena_duel_thing_std"),
         (jump_to_scene, ":arena_scene"),
         (change_screen_mission), 
        ]
       ),
      ("duel_again",[(neq, "$g_duel_result", 0)],"Duel again.",
       [
           (assign, "$g_duel_result", 0),
           (jump_to_menu, "mnu_duel_menu"),
	]
       ),
      ("leave",[],"Leave.",
       [(change_screen_map),
        ]
       ),
      ]
 ),


############################### Duel Mod End  ##############################

module_mission_templates.py

This is where the actual duel options are defined. I've used several different 'visitors' with different equipment. By assigning the player and his opponent to the different visitor numbers, they get different equipment. If you want to change the items you duel with, do it here. Of course you might have to change the dialog to reflect these changes. I've commented so you can see which one is which option.

Again, doesn't really matter where you put it, I've got it plugged in just under the "arena_challenge_fight" tuple.

Code:
##############################  # Duel Mod Start ##############################

# Below are 8 sets of 2 templates. These are selected by the choices in the dialog. You can change the weapons by adding/removing to the itm_ list
# Entry points are the same for all mounted options and also for all unmounted since only 2 players spawn at a time.
# Duel scores are only kept for duels against heroes (companions, lords and kings).

(    
"arena_duel_thing_std",mtf_arena_fight,-1,
"The duel begins!",    
[
# visitors 0 and 1 are completely standard
(0, mtef_visitor_source|mtef_team_0, 0, aif_start_alarmed, 1, []),      
(8, mtef_visitor_source|mtef_team_2, 0, aif_start_alarmed, 1, []),
#visitors 2 and 3 are override horse only
(56, mtef_visitor_source|mtef_team_0, af_override_horse, aif_start_alarmed, 1, []),
(58, mtef_visitor_source|mtef_team_2, af_override_horse, aif_start_alarmed, 1, []),
#vistiors 4 and 5 are sword/shield standard
(0, mtef_visitor_source|mtef_team_0, af_override_weapons, aif_start_alarmed, 1, [itm_sword_viking_2, itm_tab_shield_heater_c]),      
(8, mtef_visitor_source|mtef_team_2,af_override_weapons, aif_start_alarmed, 1, [itm_sword_viking_2, itm_tab_shield_heater_c]),
#visitors 6 and 7 are sword/shield no horse
(56, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_horse, aif_start_alarmed, 1, [itm_sword_viking_2, itm_tab_shield_heater_c]),      
(58, mtef_visitor_source|mtef_team_2,af_override_weapons|af_override_horse, aif_start_alarmed, 1, [itm_sword_viking_2, itm_tab_shield_heater_c]),
#vistiors 8 and 9 are 2-H standard
(0, mtef_visitor_source|mtef_team_0, af_override_weapons, aif_start_alarmed, 1, [itm_sword_of_war, itm_great_axe, itm_warhammer]),      
(8, mtef_visitor_source|mtef_team_2,af_override_weapons, aif_start_alarmed, 1, [itm_sword_of_war, itm_great_axe, itm_warhammer]),
#visitors 10 and 11 are 2-H no horse
(56, mtef_visitor_source|mtef_team_0, af_override_weapons|af_override_horse, aif_start_alarmed, 1, [itm_sword_of_war, itm_great_axe, itm_warhammer]),      
(58, mtef_visitor_source|mtef_team_2,af_override_weapons|af_override_horse, aif_start_alarmed, 1, [itm_sword_of_war, itm_great_axe, itm_warhammer]),
#vistiors 12 and 13 are ranged standard - note that armor is also changed to light leather stuff
(0, mtef_visitor_source|mtef_team_0, af_override_all_but_horse|af_override_foot, aif_start_alarmed, 1, [itm_hunting_bow, itm_bodkin_arrows, itm_nobleman_outfit, itm_skullcap, itm_light_leather_boots, itm_leather_gloves]),      
(8, mtef_visitor_source|mtef_team_2, af_override_all_but_horse|af_override_foot, aif_start_alarmed, 1, [itm_hunting_bow, itm_bodkin_arrows, itm_nobleman_outfit, itm_skullcap, itm_light_leather_boots, itm_leather_gloves]),
#visitors 14 and 15 are ranged no horse - note that armor is also changed to light leather stuff
(0, mtef_visitor_source|mtef_team_0, af_override_everything, aif_start_alarmed, 1, [itm_hunting_bow, itm_bodkin_arrows, itm_nobleman_outfit, itm_skullcap, itm_light_leather_boots, itm_leather_gloves]),      
(8, mtef_visitor_source|mtef_team_2, af_override_everything, aif_start_alarmed, 1, [itm_hunting_bow, itm_bodkin_arrows, itm_nobleman_outfit, itm_skullcap, itm_light_leather_boots, itm_leather_gloves]),


],   
[      
common_inventory_not_available,      
 
	(ti_tab_pressed, 0, 0, [],
       [(question_box,"@Do you wish to give up the fight?")]),
    (ti_question_answered, 0, 0, [],
       [(store_trigger_param_1,":answer"),
	    (eq,":answer",0),
 #add 1 to the slot for amount of duels the player lost against this troop if it is a tf_hero
		(try_begin),
			(troop_is_hero, "$g_talk_troop"),
			(assign, "$g_duel_result", -1),
			(troop_get_slot, ":duel_losses", "$g_talk_troop", slot_troop_duel_lost),
			(val_add, ":duel_losses", 1),
			(troop_set_slot, "$g_talk_troop", slot_troop_duel_lost, ":duel_losses"), 
		(try_end),
 #add 1 to the total amount of duels player lost if it is a tf_hero
		(try_begin),
			(troop_is_hero, "$g_talk_troop"),
			(troop_get_slot, ":duel_losses_player", "trp_player", slot_troop_duel_lost),
			(val_add, ":duel_losses_player", 1),
			(troop_set_slot, "trp_player", slot_troop_duel_lost, ":duel_losses_player"), 
			(assign, reg(2), ":duel_losses_player"),
			(display_message, "@You've lost a total number of {reg2} duels."),
		(try_end),
		(assign, "$g_duel_result", -1),
		(finish_mission),
	   ]),

(1,3, ti_once, [
    (all_enemies_defeated, 1),
    (neg|main_hero_fallen, 0)
    ],
 [
#add 1 to the slot for amount of duels the player won against this troop if it is a tf_hero
	(assign, "$g_duel_result", 1),
	(try_begin),
		(troop_is_hero, "$g_talk_troop"),
		(troop_get_slot, ":duel_wins", "$g_talk_troop", slot_troop_duel_won),
		(val_add, ":duel_wins", 1),
		(troop_set_slot, "$g_talk_troop", slot_troop_duel_won, ":duel_wins"),

	
#add 1 to the total amount of duels player won if it is a tf_hero

		(troop_get_slot, ":duel_wins_player", "trp_player", slot_troop_duel_won),
		(val_add, ":duel_wins_player", 1),
		(troop_set_slot, "trp_player", slot_troop_duel_won, ":duel_wins_player"),
		(assign, reg(2), ":duel_wins_player"),
		(display_message, "@You've won a total number of {reg2} duels"),
	(try_end),
    (finish_mission),
   ]),

(2, 3, ti_once, [
    (main_hero_fallen),
    ],       
   [
#add 1 to the slot for amount of duels the player lost against this troop if it is a tf_hero
    (assign, "$g_duel_result", -1),
	(try_begin),
		(troop_is_hero, "$g_talk_troop"),
		(troop_get_slot, ":duel_losses", "$g_talk_troop", slot_troop_duel_lost),
		(val_add, ":duel_losses", 1),
		(troop_set_slot, "$g_talk_troop", slot_troop_duel_lost, ":duel_losses"), 
		(assign, reg(1), ":duel_losses"),

#add 1 to the total amount of duels player lost if it is a tf_hero
		(troop_get_slot, ":duel_losses_player", "trp_player", slot_troop_duel_lost),
		(val_add, ":duel_losses_player", 1),
		(troop_set_slot, "trp_player", slot_troop_duel_lost, ":duel_losses_player"), 
		(assign, reg(2), ":duel_losses_player"),
		(display_message, "@You've lost a total number of {reg2} duels."),
	(try_end),
    (finish_mission),
    ]),    
 ],
),    

########################## Duel Mod End ##############################

If you've done all thise like I told you, it should work. Build and play, my friends!

Some observations:

Duelling on horseback is somewhat lame, the AI seems to mostly just run around in circles, for future versions I'll have to look at that, maybe include the jousting thing from janus' arena expansion. Problem with that is that I would have to include scenes and it wouldn't really be a 'kit' anymore but a proper mod.
Kings are evil :grin:
Some Lords are more equal than others.. I guess this should already be obvious in the game and from looking at the troops.py but it's VERY obvious when one is bashing your head in with dramatic fervor.
It's all quite a lot of fun.

Future features and fixes
  • Make the transition from dialog to duel more smooth
  • Defeating a lot of lords and kings without losing will give renown gain
  • Report option so you can see your duel results with the various lords
  • Result based dialog for companions
  • More expanded dialog for lords and kings, make them really worked up or smug depending on results.
  • more, different and more useful duel options

If you have any problems or questions please let me know. Any bugs also. I've tested it quite extensively but you never know what can pop up.

Have fun!
 
just when I was about to go to bed you post this and I feel I must try it out..... If I'm tired at work tomorrow I'm blaming you!  :wink:

edit 1: you might want to put your code in a code tag on the forum so long lines won't wrap around to new lines
edit 2: I only have 3 lords, the code was easy enough to fix, but maybe you could use a try_in_range and the kings_begin/end instead?

edit 3: this is AWESOME, nice work!!!



edit 4: more screenshots, this is really fun.

   
 
115010891136yk0.jpg


Yet another awesome script that I must add to my mod! Many thanks to all those involved.
 
HokieBT said:
just when I was about to go to bed you post this and I feel I must try it out..... If I'm tired at work tomorrow I'm blaming you!  :wink:

edit 1: you might want to put your code in a code tag on the forum so long lines won't wrap around to new lines
edit 2: I only have 3 lords, the code was easy enough to fix, but maybe you could use a try_in_range and the kings_begin/end instead?

edit 3: this is AWESOME, nice work!!!


Thanks mate.. yeah I think I had the try_in_range first, but it wasn't working properly.. something to do with the overlap of units but there's no reason it shouldn't work, so I'll change accordingly.

[edit] after looking at my own code, it must've been an oversight, cause I did use (is_between..) for the second bit of king code.. oops :smile: [/edit]

As for the <code>, when I use that, I lose all the indentations and when I cope/paste it all just comes out as one line but maybe that's a problem on my end so I'll change that as well.

[edit2] I also found a bug and fixed it so if you've already implemented the code, check it over. In the lord_decline_duel option in the dialog, it is supposed to say 'a lord' instead of 'a king', which is not such a big deal but also the dialog it refers to is wrong. It's supposed to be "lord_talk_ask_something_2" instead of whatever it said. Make sure you change it or the game will get stuck when you try to duel a lord and don't have enough renown.
 
hey, about the having to hit TAB to start the menu option, This is similar to the dialog for dueling on the lady's behalf.  in the code near the bottom,
  [anyone,"lord_challenge_duel_for_lady", [], "What accusations?\
Everyone knows that she beds her stable boys and anyone else she can lay hands on while her husband is away.\
I merely repeat the words of many.", "lord_challenge_duel_for_lady_2",[]],
  [anyone|plyr,"lord_challenge_duel_for_lady_2", [], "You will recant these lies, sirrah, or prove them against my sword!", "lord_challenge_duel_for_lady_3",[]],
  [anyone|plyr,"lord_challenge_duel_for_lady_2", [], "If you say so...", "lord_pretalk",[]],
  [anyone,"lord_challenge_duel_for_lady_3", [], "You are challenging me to a duel? How droll!\
As you wish, {playername}, it will be good sport to bash your head in.", "close_window",
  [(call_script, "script_change_player_relation_with_troop", "$g_talk_troop", -20),
    (assign, "$g_leave_encounter", 1),
    (try_begin),
      (is_between, "$g_encountered_party", towns_begin, towns_end),
      (party_get_slot, ":arena_scene", "$g_encountered_party", slot_town_arena),
    (else_try),
      (assign, ":closest_dist", 100000),
      (assign, ":closest_town", -1),
      (try_for_range, ":cur_town", towns_begin, towns_end),
        (store_distance_to_party_from_party, ":dist", ":cur_town", "p_main_party"),
        (lt, ":dist", ":closest_dist"),
        (assign, ":closest_dist", ":dist"),
        (assign, ":closest_town", ":cur_town"),
      (try_end),
      (party_get_slot, ":arena_scene", ":closest_town", slot_town_arena),
    (try_end),
    (modify_visitors_at_site, ":arena_scene"),
    (reset_visitors),
    (set_visitor, 0, "trp_player"),
    (set_visitor, 1, "$g_talk_troop"),
    (set_jump_mission, "mt_arena_challenge_fight"),
    (jump_to_scene, ":arena_scene"),
    (try_begin),
      (neq, "$talk_context", tc_court_talk),
      (jump_to_menu, "mnu_arena_duel_fight"),

    (try_end),
    ]],

they have this:
    (set_jump_mission, "mt_arena_challenge_fight"),
    (jump_to_scene, ":arena_scene"),
    (try_begin),
      (neq, "$talk_context", tc_court_talk),
      (jump_to_menu, "mnu_arena_duel_fight"),


I'm going to try this (the set_jump_mission thingie) with what I have right now.  It don't understand the tc_court_talk.  The constant equals 1, but not sure what this is testing.
 
yeah, not sure what that does either.

I moved that whole jump_to_scene bit to the game menu because of the way it's built, this was after a tip from jinnai. Can't think of the reason right now but it's in the other thread. I think it was to enable the 'duel again' function. In fact, come to think of it, I'm sure of it.

In the duel for lady quest, everything is done in the dialog and you go straight into the fight, there's no menu. But I wanted that as it's also where I show the scores and what not. Plus, the 'duel again' option means you don't have to go through the whole dialog again every time.

Anyway if you get it to work better, please let me know!
 
MartinF - thanks for the bug fix, I updated my code.  It would be cool if you could add the ability to bet money on the duel, probably limit that functionality to only kings and lords tho, since otherwise people could easily cheat by dueling their recruits.  :wink:  I was also wondering if you could use this concept in non-friendly encounters....  Like challenge the opposing leader to a duel before a battle, and if you win then your side gets a tactics bonus or something?  Or challenge a friendly lord and if you win you get to choose 5 soldiers from his army...  Not sure if either of those really make sense, but this is a really nice piece of code, so I'm just trying to think of other uses for it...

edit: it might be nice if we could choose to switch weapons after a duel, not sure if that is possible.
 
MartinF said:
yeah, not sure what that does either.

I moved that whole jump_to_scene bit to the game menu because of the way it's built, this was after a tip from jinnai. Can't think of the reason right now but it's in the other thread. I think it was to enable the 'duel again' function. In fact, come to think of it, I'm sure of it.
...
Anyway if you get it to work better, please let me know!

Well, leaving your menu changes alone, I added some of the stuff to my dialog.  Seems to work for both the end of the conversation going to the duel, and the duel again menu still there (though I need to clean that part out for the tutorial).  The code looks like this:
[trp_npc17,"geoffrey_hostile_7", [], "Coward?!?!  I will see you there shortly, {knave/wench}...","close_window",
  [(party_get_slot, ":arena_scene","p_mod_town", slot_town_arena),
    (modify_visitors_at_site, ":arena_scene"),
    (set_visitor, 0, "trp_player"),
    (set_visitor, 1, "$g_talk_troop"),
    (set_jump_mission, "mt_arena_duel_thing_std"),
    (jump_to_scene, ":arena_scene"),
    (assign, "$g_duel_result", 0),
(try_begin),
      (neq, "$talk_context", tc_court_talk),
      (jump_to_menu, "mnu_duel_menu"),
    (try_end),
  ]
  ],

ya, I hard coded the scene, and probably put too much in there since I could have just picked the scene, but this was just a test.  But it worked at both ends.

 
HokieBT said:
MartinF - thanks for the bug fix, I updated my code.  It would be cool if you could add the ability to bet money on the duel, probably limit that functionality to only kings and lords tho, since otherwise people could easily cheat by dueling their recruits.  :wink:  I was also wondering if you could use this concept in non-friendly encounters....  Like challenge the opposing leader to a duel before a battle, and if you win then your side gets a tactics bonus or something?  Or challenge a friendly lord and if you win you get to choose 5 soldiers from his army...  Not sure if either of those really make sense, but this is a really nice piece of code, so I'm just trying to think of other uses for it...

edit: it might be nice if we could choose to switch weapons after a duel, not sure if that is possible.

Hokie, thanks for the input. The betting is a good idea and will be easy to implement, I'll look at that tomorrow. I want to make it so your opponent will only take your bet if you haven't beaten him too many times more than he has beaten you. No one likes to be hussled after all :smile:

The other idea could be interesting.. settling a battle with a duel if army sizes are similar for instance. Not sure how easy that would be to implement, what with the hardcoded transition to battle in a hostile encounter, but it's worth testing.

Switching weapons for the next duel would be difficult with the way it works now. The way around that would be to move the whole duel setup process out of the dialog and into a game menu. However that would also make it somewhat less personal but I'll look into it.
 
thanks, this is a really great feature, I hope it gets integrated into a lot of mods.  Switching weapons wouldn't be a big priority for me but the betting would be very fun.  I like your idea to put some logic in there so you can only bet if you haven't beaten them a lot so far, but you should still leave a way to have a friendly duel without a bet.    I added the Blackjack mod into my star wars mod and when you win/lose your relationship goes down/up by 1 point, but your idea of changing the renown is probably better.  You could even have a bet option to wager a castle/town if you both owned one, but that is probably a bad idea since people could cheat pretty easily just by loading a saved game multiple times...  :smile:
 
Just checked out the new screenies from this kit in your topic here.

Looks really cool! It's great to see this implemented and the way you're adapting it great. Means I didn't waste all those hours coding the bastard :grin:

Can't wait to duel Darth Vader, hahaha!

BTW I will def make it so you can duel without betting, it's just going to be an extra option tacked on to the end.
 
I think betting should be a bit more complex.  I am looking to add that into my tournaments once my mod gets off the ground.

The amout they may wager should be based on a win/loss of money, not fight ratio.  If you do it that way, people will just throw some no bet matches and then bet big and smote the loser.  That's M&B hussling. :mrgreen:

I am hoping to implement betting of land in jousting, which I think I will move to after this week of updating the tutorial.  It's been a lot of work, and I have to keep passing up threads that would help me a lot in my mod.  I may end it for now at making a menu.

As to changing equipment between duels, why not have an inventory option from the menu screen.  This would mean that your first duel would be with what you have, but after that, go with what you want.

[EDIT]
Just thought of something and checked it out.  When you are confronted by a bandit, they offer to leave you alone for a sum of money.  If you pay it, the battle doesn't happen.  This is a hostile encounter, so there is a way out of a hostile encounter without going to a full out battle.  Here is the dialog, though since this just popped into my head, I haven't explored it at all. 
  [anyone,"bandit_barter_3a", [], "Heh, that wasn't so hard, was it? All right, we'll let you go now. Be off.", "close_window",[
    (store_current_hours,":protected_until"),
    (val_add, ":protected_until", 72),
    (party_set_slot,"$g_encountered_party",slot_party_ignore_player_until,":protected_until"),
    (party_ignore_player, "$g_encountered_party", 72),
    (assign, "$g_leave_encounter",1)
    ]],
But it may help with you confrontation with an enemy lord.  Maybe if your relation with him alone is good enough, or something.
 
jik - good find on the bandit encounter and paying money!  I can see the game menu now...  When a hostile encounter happens, you can choose a new option to duel the enemy lord.  If you lose then they attack, but if you win then they say they will be back later with reinforcements and you are  "protected_until" X hours.    :wink:
 
HokieBT said:
jik - good find on the bandit encounter and paying money!  I can see the game menu now...  When a hostile encounter happens, you can choose a new option to duel the enemy lord.  If you lose then they attack, but if you win then they say they will be back later with reinforcements and you are  "protected_until" X hours.    :wink:

Sounds good, but I would put more polish on it.  Sounds too easy, though with the way the things are in the star wars universe, the outcome of a duel between Jedi might go that way.  Allowing an ambush in which you quickly (maybe a timed trigger as well) take out the opponent's leader, the band falls apart.  Not sure, but adds some interesting twists.  Let's just not take it too far.  Also, this is from the dialogs, though, I don't see why it can't work from a menu...
 
Ok i got it to work, except one part!
THE MAIN ONE!
i talk to him and everything and then he says great ill meet you down there and just nothing happens! did i do something wrong or i have to do something?
BTW i found out how i can make jousting fights  :lol:
instead of horse archer fights i will put jousting :smile: and i will check where he spawns and thats how i will know where to put him!
 
I think it's a bit more complicated than just putting 2 units on the field with lances.  It's a start, but when you try it out, you will see why you need to do more.
 
MISHO said:
Ok i got it to work, except one part!
THE MAIN ONE!
i talk to him and everything and then he says great ill meet you down there and just nothing happens! did i do something wrong or i have to do something?

did you do this?  I modified my dialog to add a note that the player has to press Tab, just so I don't get questions on my forum.  :wink:

MartinF said:
Note: After the dialog closes, it will put you back into the party screen or the scene you were in when you addressed the NPC. Press <Tab> to exit the scene and go to the duel menu, or press close in the party screen.
 
HokieBT said:
MISHO said:
Ok i got it to work, except one part!
THE MAIN ONE!
i talk to him and everything and then he says great ill meet you down there and just nothing happens! did i do something wrong or i have to do something?

did you do this?  I modified my dialog to add a note that the player has to press Tab, just so I don't get questions on my forum.  :wink:

MartinF said:
Note: After the dialog closes, it will put you back into the party screen or the scene you were in when you addressed the NPC. Press <Tab> to exit the scene and go to the duel menu, or press close in the party screen.

I also posted the fix for that.  In my dialog, it jumps right to the duel, and will still go to the proper menu after. 
  [(modify_visitors_at_site, "scn_town_1_arena"),
    (set_visitor, 0, "trp_player"),
    (set_visitor, 1, "$g_talk_troop"),
    (set_jump_mission, "mt_arena_duel_thing_std"),
    (jump_to_scene, "scn_town_1_arena"),
(try_begin),
      (neq, "$talk_context", tc_court_talk),
      (jump_to_menu, "mnu_duel_menu"),
    (try_end),
  ]
  ],

 
Back
Top Bottom