Returning to the global map after mission

Users who are viewing this thread

Hey, guys. I was literally stuck on level ground. When making mission of assassination, where player is attacked by special party of enemies (at the mission), i have mystic problem with returning to the global map after completing the mission.

First, assassins can find the target both in the travelling or when resting in the location, but for now it jumps to one scene in both situations.

Second and main, if mission starts when resting in the locality, when dying player returns to the global map correctly on pressing "Continue" button, but when winning, the game on each pressing the button instead of returning to the global map creates the same menu (with the same variants, as we have global variable for check). If mission starts in travelling, vice versa - works for win and does not work for loss. Mystic, yap?

I have tried to find the way out with different types of code for entire ****ing day, always giving almost the same mistake. The only difference is that successful returning to the map can be performed on the win or on the loss, but not in both situations. Current code can look unobvious, but it sends the player to scene and creates menu with only "Continue..." button at the finishing the mission.

First - the script. It counts magic skills and assigns global variable and creates menu, if we have enough high sum of skills.

Code:
   ("sun_inquisition",
    [
	(assign, "$assasin_inq_atmpt", 0),
	#counting sum of magic skills
	(assign, ":attackchance", 0),
	(store_skill_level, ":skill_value", "skl_rm_glorit", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_ironflesh", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_power_strike", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_en_manip", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_arcane_magic", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_mana_reservoire", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_mana_restore", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_athletics", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_rm_ritu", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_rm_alchemy", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_rm_encha", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_persuasion", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_illusion", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_adv_elem_magic", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_necromancy", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_holy_magic", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, ":skill_value", 0),
	(store_skill_level, ":skill_value", "skl_clairvoyance", "trp_player"),
	(val_add,":attackchance",":skill_value"),
	(assign, reg1, ":attackchance"),
	(display_message, "@Magic power attracts attention of powerful eastern monk order, called Inquisition of the Sun. Their spies refresh lists of the magicians of Calradia every day, and their reports provoke a deadly reaction from military units of the Inquisition of the Sun."),
	(display_message, "@Your total magic power as sum of your all magic skills is equal to {reg1} of 170 nominal points."),
	#set Inquisition report
	(try_begin),
		(lt, ":attackchance", 10),
		(display_message, "@According to the opinion of the Inquisition of the Sun, your magic skills and your danger are both insignificant. When sum of your all magic skill will be 10 or above, military units of Inquisition of the Sun will try to assassinate you."),
	(else_try),
		(lt, ":attackchance", 20),
		(display_message, "@According to the opinion of the Inquisition of the Sun, your are trivial apprentice of magic and you worth only a little attention."),
		#(store_random_in_range, ":atcha", 1, 7),
		#(eq, ":atcha", 1),
		(assign, "$assasin_inq_atmpt", 1),
	(else_try),
		(lt, ":attackchance", 30),
		(display_message, "@According to the opinion of the Inquisition of the Sun, your are equal-in-rights member of a Calradian magic order and you are dangerous enough to be killed while seen, but not dangerous enough to be specially chased."),
		(store_random_in_range, ":atcha", 1, 6),
		(eq, ":atcha", 1),
		(assign, "$assasin_inq_atmpt", 1),
	(else_try),
		(lt, ":attackchance", 40),
		(display_message, "@According to the opinion of the Inquisition of the Sun, your are master of magic and you are dangerous enough to be killed while seen and worthy chasing by small groups of assassins."),
		(store_random_in_range, ":atcha", 1, 5),
		(eq, ":atcha", 1),
		(assign, "$assasin_inq_atmpt", 1),
	(else_try),
		(lt, ":attackchance", 50),
		(display_message, "@According to the opinion of the Inquisition of the Sun, your are high mage and you are very dangerous, being worthy chasing by medium-sized groups of assassins."),
		(store_random_in_range, ":atcha", 1, 4),
		(eq, ":atcha", 1),
		(assign, "$assasin_inq_atmpt", 1),
	(else_try),
		(lt, ":attackchance", 60),
		(display_message, "@According to the opinion of the Inquisition of the Sun, your are Archmage and you are incredibly dangerous, being worthy chasing by large groups of assassins."),
		(store_random_in_range, ":atcha", 1, 3),
		(eq, ":atcha", 1),
		(assign, "$assasin_inq_atmpt", 1),
	(else_try),
		(ge, ":attackchance", 60),
		(display_message, "@According to the opinion of the Inquisition of the Sun, you are Archmage of incredible magic power. They consider it their duty to send assassins to you almost daily."),
		(assign, "$assasin_inq_atmpt", 1),
	(try_end),
	#set Inquisition attack
	(try_begin),
		(eq, "$assasin_inq_atmpt", 1),
		(jump_to_menu, "mnu_inq_attack_menu"),
	(try_end),
		
    ]),

Second- the menu. It checks global variable and creates menu with the only 1 variant - "Try to find the way out.", which sends player to the fight, or 'Continue', which must return him to the global map.

Code:
  ("inq_attack_menu",0,
   "Suddenly you find yourself in the strange building among assassins of the Inquisition of the Sun.",
   "none",
   [],
   [
      
      ("continueinq1",
      [
		(eq, "$assasin_inq_atmpt", 1),
      ],
      "Try to find a way out.",
      [
		#counting sum of magic skills
		(assign, ":attackchance", 0),
		(store_skill_level, ":skill_value", "skl_rm_glorit", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_ironflesh", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_power_strike", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_en_manip", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_arcane_magic", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_mana_reservoire", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_mana_restore", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_athletics", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_rm_ritu", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_rm_alchemy", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_rm_encha", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_persuasion", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_illusion", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_adv_elem_magic", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_necromancy", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_holy_magic", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		(assign, ":skill_value", 0),
		(store_skill_level, ":skill_value", "skl_clairvoyance", "trp_player"),
		(val_add,":attackchance",":skill_value"),
		
		(modify_visitors_at_site, "scn_inq_attack_scene"),
		(reset_visitors),
		(set_visitor, 0, "trp_player"),
		(val_div,":attackchance",10),
		(try_begin),
			(lt,":attackchance",2),
			(set_visitors, 1,"trp_inq_friar",1),
			(set_visitors, 1,"trp_inq_prelate",1),
		(else_try),
			(ge,":attackchance",2),
			(store_random_in_range, ":random", 1, ":attackchance"),
			(set_visitors, 1,"trp_inq_friar",":random"),
			(val_sub,":attackchance",":random"),
			(ge,":attackchance",1),
			(set_visitors, 1,"trp_inq_prelate",":attackchance"),
		(try_end),
		(set_jump_mission, "mt_inq_attack"),
		(jump_to_scene, "scn_inq_attack_scene"),
		(change_screen_mission),
      ]),
	  
	  
     ("continueinq2",[
		(eq, "$assasin_inq_atmpt", 0),
		],
		"Continue...",
      [
		(change_screen_return),
      ]),
    ]
  ),


Third- the mission. It for win or loss, in both situations assings global variable to zero for "Continue...' button and finishes the mission.

Code:
 (
    "inq_attack",mtf_battle_mode|mtf_commit_casualties,-1,
    "Suddenly you find yourself among assassins of the Inquisition of the Sun.",
    [    
	  (0, mtef_visitor_source|mtef_team_0,0,aif_start_alarmed,1,[]),
	  (1, mtef_visitor_source|mtef_team_1,0,aif_start_alarmed,1,[]),
    ],
    [
      common_inventory_not_available,
      (ti_tab_pressed, 0, 0, [(display_message, "str_cannot_leave_now")], []),
      (ti_before_mission_start, 0, 0, [], [(call_script, "script_change_banners_and_chest")]),

      (0, 0, ti_once, [],
       [
         (call_script, "script_music_set_situation_with_culture", mtf_sit_arena),
         ]),

#starting global check
	(0, 0, ti_once, 
	[], 
	[(call_script, "script_smc_starting_global_check"),]),

#60 seconds global check
	(60, 0, 0, 
	[], 
	[(call_script, "script_smc_minute_global_check"),]),

#1/10 second global check
	(0.1, 0, 0, 
	[], 
	[(call_script, "script_smc_onetenth_sec_global_check"),]),

#1 second global check
#1 second check player trigger
	(1, 0, 0, 
	[],
	[(call_script, "script_smc_second_global_check"),
	 (call_script, "script_smc_1sec_player_check"),]),

#2 seconds check non-player trigger
#2 seconds check trigger for everyone
    (2, 0, 0, 
    [],
    [(call_script, "script_smc_2sec_plandai_check"),
     (call_script, "script_smc_2sec_ai_check"),]),	


      (1, 4, ti_once, [
			(this_or_next|main_hero_fallen),
			(num_active_teams_le,1),
		],
       [
		(try_begin),
			(main_hero_fallen),
			(display_message, "@You, almost unconscious, suddenly hear someone approaching you and your opponents. The assassins who defeated you run away from sudden visitors. This way you survived attention of the Inquisition of the Sun."),
		(else_try),
			(num_active_teams_le,1),
			(display_message, "@You inspect the bodies of defeated enemies, taking away the best preserved weapon as a souvenir. You survived attention of the Inquisition of the Sun, and their soldiers did not survived your attention."),
			(store_random_in_range, ":atcha", 1, 3),
			(try_begin),
				(eq, ":atcha", 1),
				(troop_add_item, "trp_player", "itm_inq_dagger"),
			(else_try),
				(eq, ":atcha", 2),
				(troop_add_item, "trp_player", "itm_inq_staff"),
			(try_end),
		(try_end),
		(assign, "$assasin_inq_atmpt", 0),
		(finish_mission),
	   ]),
    ],
  ), 


Do you have any ideas, guys?
 
I dodged this problem by making the script only assigning global variable, which checks in towns and castles (disabling other interactions until the missions won't be completed), so the game correctly sends and returns player in/from mission. But i am still wondering, what the mistake i did. Or is it engine issue?
 
Just stopping by to give you a couple of tips to improve your code. I see you're not very much in favor of the 'try_for_range' operation.
If you have to iterate between many elements of the same list, for example in your case the list 'skills', it is best to use the operation 'try_for_range', you save time and especially blocks of repetitive code.
Code:
			(assign, ":attackchance", 0),
			(try_for_range, ":skill", "skl_trade", "skl_reserved_14"),
				# (neq, ":skill", "skl_skill_name"), #to skip any skill
				
				(store_skill_level, ":value", ":skill", "trp_player"),
				(val_add, ":attackchance", ":value"),
			(try_end),
			(assign, reg1, ":attackchance"),
boom, 50 lines less code...

"According to the opinion of the Inquisition of the Sun" - is repeated in all messages... save the string in {s1}, for example, and then attach it to all your messages.
(str_store_string, s1, "@According to the opinion of the Inquisition of the Sun"),
(display_message, "@{s1}, your magic skills and your danger...
I've seen you launch your mod's v.1.0.0, good luck with that.
Greetings
 
Dj_FRedy said:
Just stopping by to give you a couple of tips to improve your code.

Thanks for the advice, mate)

As a rule, i am just skipping optimization of things like that, which are player-only windows. But in-battle scripts are really should be optimized by any means)
And i am coding on Python outside M&B modding, so I'm used to sacrificing speed to my comfort:smile:))))

But thanks) This is valuable)
 
Back
Top Bottom