Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
@HyperCharge:
There is also this code too, in case you still need it: http://forums.taleworlds.com/index.php/topic,87851.msg2320543.html#msg2320543

-----

A question if I may, I've been playing with Davee's knock rider off horse code (can be found here)... which works excellently, except this error log which appears every a few seconds (not sure if it appears only when agent got hit or repeatedly)

tTxRu7s.jpg

It's the

Code:
SCRIPT ERROR ON OPCODE 1671: Invalid Party ID: -1; LINE NO: 10
At Mission Template mst_lead_charge trigger no:0 consequences

Tried Googling around to see what's the issue... found no clue though. Could I ask for help to direct me how to resolve this error? I'd really appreciate the help.
 
@xaliber that warning is not caused by knock rider off horse code.
Opcode 1671 means party_get_morale. Open module mission templates, then go to mission lead_charge. Then look at the first trigger, line no 10 (first line is line no 0). There is the error.
 
Ugh, just get back to modding after weeks of toiling of real life stuff.

Anyways, I want to ask a question regarding custom battle scenes in the singleplayer campaign. Now, I've did search around the board regarding adding custom battle scenes but I can't find any topics about that. I'd like to replace the 'randomness' of the battle scenes with either all custom made ones(100% custom), or a mix of both (50%custom, 50%random).
So I'd like to ask if anyone can point me a direction towards inserting custom scenes into the world map?

Now, I assume that the random terrain generated meets certain criteria such as 1)which terrain piece you are standing on, 2)how close are you near another terrain and 3)how high is said terrain, is that right?
 
Terrain bumpiness is determined by how close/far you are from mountain terrain tiles.

Here's what I did to combat this:
jacobhinds said:
What I did was to create a script that generates 8 parties in a square around the player, checking whether there are mountains on each of them. It works pretty well:

Code:
    #script_create_terrain_octagon
    # This script will spawn 8 parties in an octagon around the player, then check for mountains.
    # INPUT: none
    # OUTPUT: reg0 = mountains are around party
    ("create_terrain_octagon", [
		(party_get_position, pos1, "p_main_party"),
#pos1 = party
#pos2 = dummy
#pos3 = final destination
#pos9 = transform direction
		(try_begin),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_x, pos9, -10), #go 10 meters west
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),
		(else_try),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_x, pos9, 10), #go 100 meters east
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),

		(else_try),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_y, pos9, 10), #go 100 meters north
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),
		(else_try),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_y, pos9, -10), #go 100 meters south
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),

		(else_try),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_x, pos9, 10), #go 100 meters northwest
			(position_set_y, pos9, 10),
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),
		(else_try),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_x, pos9, 10), #go 100 meters southwest
			(position_set_y, pos9, -10),
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),

		(else_try),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_x, pos9, -10), #go 100 meters northeast
			(position_set_y, pos9, 10),
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),
		(else_try),
			(copy_position, pos2, pos1), #copies pos1 (party) to pos2 (dummy)
			(init_position, pos9),
			(position_set_x, pos9, -10), #go 100 meters southeast
			(position_set_y, pos9, -10),
			(position_transform_position_to_parent, pos3, pos2, pos9),
			(party_set_position, "p_terrain_octagon_1", pos3),
			(party_get_current_terrain, ":terrain", "p_terrain_octagon_1"),
			(eq, ":terrain", rt_mountain),
			(assign, reg10, 1),
		(else_try),
			(assign, reg10, 0),
		(try_end),

		# (try_begin), #debug test
			# (eq, reg10, 1),
			# (display_message, "@mountains detected: TRUE"),
		# (else_try),
			# (display_message, "@mountains detected: FALSE"),
		# (try_end),
			
    ]),

The output is a reg10 (reg0 is too volatile on the world map due to its use in creating the date text).

I then use this:

Code:
#mountains
		(call_script, "script_create_terrain_octagon"),
		(eq, reg10, 1),
		(try_begin),
			(eq, ":terrain_type", rt_snow),
			(assign, ":scene_to_use", "scn_valley_4"),
		(else_try),
			(eq, ":terrain_type", rt_snow_forest),
			(assign, ":scene_to_use", "scn_random_scene_snow_forest"),
		(else_try),
			(this_or_next|eq, ":terrain_type", rt_desert_forest),
			(eq, ":terrain_type", rt_desert),
			(assign, ":scene_to_use", "scn_crossing_desert"),
		(else_try),
			(store_random_in_range, ":scene_to_use", "scn_valley_1", "scn_valley_end"),
		(try_end),

In script_setup_random_scene.
 
The_dragon said:
@xaliber that warning is not caused by knock rider off horse code.
Opcode 1671 means party_get_morale. Open module mission templates, then go to mission lead_charge. Then look at the first trigger, line no 10 (first line is line no 0). There is the error.
Thanks, I appreciate it! Especially for translating the error (whew, is there a documentation somewhere I can find what the errors supposed to mean?)...

Line #10 in the first trigger is something from Native though. Something to indicate party morale, I suppose (it checks party courage). Just in case I'm not being clear, here's the trigger
Code:
(ti_on_agent_spawn, 0, 0, [],
       [
         (store_trigger_param_1, ":agent_no"),
         (call_script, "script_agent_reassign_team", ":agent_no"),

         (assign, ":initial_courage_score", 5000),
                  
         (agent_get_troop_id, ":troop_id", ":agent_no"),
         (store_character_level, ":troop_level", ":troop_id"),
         (val_mul, ":troop_level", 35),
         (val_add, ":initial_courage_score", ":troop_level"), #average : 20 * 35 = 700
         
         (store_random_in_range, ":randomized_addition_courage", 0, 3000), #average : 1500
         (val_add, ":initial_courage_score", ":randomized_addition_courage"), 
                   
         (agent_get_party_id, ":agent_party", ":agent_no"),         
         (party_get_morale, ":cur_morale", ":agent_party"),
         
         (store_sub, ":morale_effect_on_courage", ":cur_morale", 70),
         (val_mul, ":morale_effect_on_courage", 30), #this can effect morale with -2100..900
         (val_add, ":initial_courage_score", ":morale_effect_on_courage"), 
         
         #average = 5000 + 700 + 1500 = 7200; min : 5700, max : 8700
         #morale effect = min : -2100(party morale is 0), average : 0(party morale is 70), max : 900(party morale is 100)
         #min starting : 3600, max starting  : 9600, average starting : 7200
         (agent_set_slot, ":agent_no", slot_agent_courage_score, ":initial_courage_score"), 
         ]),

Line #10 is
Code:
(party_get_morale, ":cur_morale", ":agent_party"),

The other non-native codes I've been playing around with this is Diplomacy 4.2 and Somebody's Camel Kit, which I modified. I call  the knock rider off horse (common_horse_fall) inside Diplo's trigger and when I commented common_horse_fall everything went fine. :???: Could it be interfering with something?
 
jacobhinds said:
What you said.

Ah ok, I think I have miswrote about my question, but that info is handy to know, thanks.

  I'd like to know how I can change the random generating battle scenes into custom ones. Instead of a random generated terrain, I can make the game select from a set of scenes depending on the terrain the player is at, and have a variety of those type of scenes so as not to always have the same scene for every battle. The ACOK mod actually did that with 50% chance of a custom scene in place. Can anyone tell me how is this achieved? I believe the options to edit the battle is at the module_missions_templates.py but I have no idea where to continue form there.
 
is there any possibility to make a music don't play before an event happened ? when event was happened, after that music will start to play where ever it needs to play. Before that event, it'll never play.
 
HyperCharge said:
is there any possibility to make a music don't play before an event happened ? when event was happened, after that music will start to play where ever it needs to play. Before that event, it'll never play.
What exactly do you mean by "event"?
 
@xaliber yes, the knock rider off horse code interferes with the native code.
I think that if you add '(agent_is_human, ":agent_no"),' before '(assign, ":initial_courage_score", 5000),', it should fix the issue.
Native code spawns only troop agents (not horses; actually it does spawn horses, but the trigger ti_on_agent_spawn won't fire for them because they spawn with their rider), and the devs forgot to put additional checks (because 'hey... it works, so let it this way').
The code that you added spawns a horse each time it's rider needs to be thrown off. The horse spawning triggers native code that wasn't designed to support horses agents, so that's why you get those errors.
Interesting (and I don't understand why this happens) is the fact that you should get an error on 'store_character_level' operation, because the horse's troop id is -1, which is an invalid troop id, but as I can see, you got no error regarding the troop id.
 
Johao said:
I'd like to know how I can change the random generating battle scenes into custom ones.

The second code block I provided does exactly that. Go to module_scripts and find setup_random_scene. ":scene_to_use" is the local variable that gets chosen at the end of the code block. It's fairly self explanatory and you can make it random, or add a condition -- like the proximity to mountains -- I did.
 
Reus said:
HyperCharge said:
is there any possibility to make a music don't play before an event happened ? when event was happened, after that music will start to play where ever it needs to play. Before that event, it'll never play.
What exactly do you mean by "event"?

Like an age's start, think it there is two ages. The one is old, other is new, in the old, battle musics are occurs from drums, in the new, battle musics are occurs from classic music. When in old, classic musics was not have, because the "An age's start" event is not happened, so these musics not playing on battle. While in the new, classic music coming and drums are not playing. Because "An age's start" event happened.

I don't know how can i explain that more in a different way.
 
HyperCharge said:
Like an age's start, think it there is two ages. The one is old, other is new, in the old, battle musics are occurs from drums, in the new, battle musics are occurs from classic music. When in old, classic musics was not have, because the "An age's start" event is not happened, so these musics not playing on battle. While in the new, classic music coming and drums are not playing. Because "An age's start" event happened.

I don't know how can i explain that more in a different way.
I'm not sure how that'd work. Like, you can find the declarations and flags in header_music.py, but I don't think it's possible to add new flags that way, so it'd have to be done in some other way. Can't help ya there, seems quite advanced.
 
Reus said:
HyperCharge said:
Like an age's start, think it there is two ages. The one is old, other is new, in the old, battle musics are occurs from drums, in the new, battle musics are occurs from classic music. When in old, classic musics was not have, because the "An age's start" event is not happened, so these musics not playing on battle. While in the new, classic music coming and drums are not playing. Because "An age's start" event happened.

I don't know how can i explain that more in a different way.
I'm not sure how that'd work. Like, you can find the declarations and flags in header_music.py, but I don't think it's possible to add new flags that way, so it'd have to be done in some other way. Can't help ya there, seems quite advanced.

Im testing recently the music_set_situation,  e.g. there is mtf_module_track and mtf_sit_town, and music_set_situation sets the situation like mtf_sit_town, so if sit_town is can be set, then module_track also needs to be set.

So, if i dont set the mtf_module_track in module_musics, so it'll never played. But when i called the music_set_situation, it has to be able to play.

And of course, music_set_situation works on "current music". So, i'll use stop_all_sounds and use play_track. then I'll call the music_set_situation.
 
jacobhinds said:
The second code block I provided does exactly that. Go to module_scripts and find setup_random_scene. ":scene_to_use" is the local variable that gets chosen at the end of the code block. It's fairly self explanatory and you can make it random, or add a condition -- like the proximity to mountains -- I did.

Ah ok, excuse my lazy mind, I should have look more into it before replying.

I'm in a rush here so I'll try to summerize this while quick reading onto the code,

  So for each 'party' that is spawned in each part of the code indicates 1 direction of the squares of the world map around the player. (Assuming that this is related to the polygonal grids that one can see at the map editor), and the mountains detected thing will indicate whether or not the map will be spawned as a 'higher' variant of the set of maps.

  Now, I'm not sure of the next part, but I persume that means 1 out of the 8 directions will be chosen for the battle map. The second code will fill in which scene fits into which catergory of the terrain, and I believe the last part of the code is to get any random map if all else didnt work? I dont get the last part since it's the last else_try code.

In short,
- Identify 8 directions of terrain
- Choose 1 randomly
- Is that a mountain terrain?
- Select map from 2nd code 


Also:

(eq, ":terrain_type", rt_snow_forest),
(assign, ":scene_to_use", "scn_random_scene_snow_forest", "Blahblahblah add extra map here"),
(else_try),

I believe that I can add in extra maps on this line to allow map variations to randomize the custom battle scenes? I don't believe my interpretation will work usually....



 
While playing the mod, after when i went to party named "vidin way", i fighting with a party, like steppe bandits, after battle is over, while passing the loot screen, game plays the "denar win" sound again and again.


FİXED
 
Faruk Özkar said:
While playing the mod, after when i went to party named "vidin way", i fighting with a party, like steppe bandits, after battle is over, while passing the loot screen, game plays the "denar win" sound again and again.

Which mod is it?
 
FİXED

first, im going to vidin way, saving the kursad, and with kursad, that dialog goes. After that dialog we passing to "kursad_kurtarildi" menu. from this menu we're backing to map. after that, after when we won a battle, going to loot screen, when i pressed to return, thousands of denar sounds playing, and the game crashing.
                       
Module_game_menus;
    "vidin",mnf_scale_picture,
    "haydut siginagi",
    "none",
    [],
    [

        ("haydut_saldiri",[],"Haydutlara saldir",[
            (modify_visitors_at_site,"scn_lair_forest_bandits"),
(reset_visitors),
            (set_visitor, 2, "trp_kursad",1),
            (set_visitor, 3, "trp_forest_bandit",1),
            (set_visitors, 4, "trp_forest_bandit",1),
            (set_visitors, 5, "trp_forest_bandit",1),
            (set_visitors, 6, "trp_forest_bandit",1),
            (set_visitors, 7, "trp_forest_bandit",1),
            (set_visitors, 8, "trp_forest_bandit",1),
(set_jump_mission,"mt_kursad_temp"),
(jump_to_scene,"scn_lair_forest_bandits"),
(change_screen_mission)]),
      ("leave",[],"Ayril",[(leave_encounter),(change_screen_map)]),
    ]
  ),

                                (
    "kursad_kurtarildi",mnf_scale_picture,
    "Ayriliyosunuz",
    "none",
    [],
    [


      ("leave",[],"Ayril",[(leave_encounter),(change_screen_map)]),
    ]
  ),

dialogs;

[trp_kursad, "start", [], "blablabla","kursad",[]],
[trp_kursad|plyr, "kursad", [], "blablabla","kursad1",[]],
[trp_kursad, "kursad1", [], "blablabla","kursad2",[]],
[trp_kursad|plyr, "kursad2", [], "blablabla","kursad3",[(set_spawn_radius,1),(spawn_around_party,"p_kursad_koyu","pt_kursad_koyu")]],
[trp_kursad, "kursad3", [], "blablabla","close_window",[(jump_to_menu, "mnu_kursad"),(finish_mission,0)]],

mission_template;



    (
    "kursad_temp",0,-1,
    "You start training.",
    [
#    (0,0,af_override_horse,aif_start_alarmed,1,[]),
##    (0,0,0,aif_start_alarmed,30,[]),
            (0,mtef_leader_only,af_override_horse,aif_start_alarmed,1,[]),
    (1,mtef_visitor_source,af_override_horse,0,1,[]),
    (2,mtef_visitor_source,af_override_horse,0,1,[]),
    (3,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (4,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (5,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (6,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (7,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (8,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (9,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (10,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (11,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (12,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (13,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (14,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (15,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (16,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (17,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (18,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (19,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (20,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (21,mtef_visitor_source,af_override_horse,0,1,[]),
    (22,mtef_visitor_source,af_override_horse,0,1,[]),
    (23,mtef_visitor_source,af_override_horse,0,1,[]),
    (24,mtef_visitor_source,af_override_horse,0,1,[]),
    (25,mtef_visitor_source,af_override_horse,0,1,[]),
    (26,mtef_visitor_source,af_override_horse,0,1,[]),
    (27,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (28,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (29,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (30,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (31,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (32,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (33,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (34,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (35,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (36,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,7,[]),
    (37,mtef_visitor_source,af_override_horse,0,1,[]),
    (38,mtef_visitor_source,af_override_horse,0,1,[]),
    (39,mtef_visitor_source,af_override_horse,0,1,[]),
    (40,mtef_visitor_source,af_override_horse,0,1,[]),
    (41,mtef_visitor_source,af_override_horse,0,1,[]),
    (42,mtef_visitor_source,af_override_horse,0,1,[]),
    (43,mtef_visitor_source,af_override_horse,0,1,[]),
    (44,mtef_visitor_source,af_override_horse,0,1,[]),
    (45,mtef_visitor_source,af_override_horse,0,1,[]),
    (46,mtef_visitor_source,af_override_horse,0,1,[]),
    (47,mtef_visitor_source,af_override_horse,0,1,[]),
    (48,mtef_visitor_source,af_override_horse,0,1,[]),
    (49,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,10,[]),
    (50,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,10,[]),
    (51,mtef_visitor_source|mtef_team_1,af_override_horse,aif_start_alarmed,10,[]),
    (52,mtef_visitor_source,af_override_horse,0,1,[]),
    (53,mtef_visitor_source,af_override_horse,0,1,[]),
    (54,mtef_visitor_source,af_override_horse,0,1,[]),
   
#    (1,mtef_no_leader,0,0|aif_start_alarmed,5,[]),
#    (0,mtef_no_leader,0,0|aif_start_alarmed,0,[]),
#    (3,mtef_enemy_party|mtef_reverse_order,0,aif_start_alarmed,6,[]),
#    (4,mtef_enemy_party|mtef_reverse_order,0,aif_start_alarmed,0,[]),
    ],
    [

        (1, 4, ti_once,  [
                  (this_or_next|main_hero_fallen),
                  (num_active_teams_le, 1)],
  [
      (try_begin),
        (neg|main_hero_fallen),
      (else_try),
        (jump_to_menu, "mnu_yenilgi"),
      (finish_mission,0),
      (try_end),
      ]),

    ],
  ),
 
Status
Not open for further replies.
Back
Top Bottom