OP Code Does not exist

Users who are viewing this thread

cwr

I am trying to fix script errors that show during the game, but this is proving difficult because the opcode 1073742364 does not exist. Opcode 540 is troop_set_slot, which is very ubiquitous. Additionally, it refers to an invalid troop id that appears to have been valid earlier in the script.

Here is the error copy pasted from rgl log:

SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 87:
At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady. SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 88:
At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady. SCRIPT ERROR ON OPCODE 540: Invalid Troop ID: -1; LINE NO: 89:
At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady.
Saving Game... Creating new savegame file... Saving header... Saving game state... Closing new save game file... Starting checksum control... Performing checksum control... Savegame checksum control succeeded...
Backing up old file name... Removing old backup file. Renaming old savegame to backup file. Renaming new savegame file. Savegame succeded...
SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 87:
At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady. SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 88:
At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady. SCRIPT ERROR ON OPCODE 540: Invalid Troop ID: -1; LINE NO: 89:
At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady. At script: courtship_event_troop_court_lady.

And here is script_courtship_event_troop_court_lady:
("courtship_event_troop_court_lady",
[
(store_script_param, ":suitor", 1),
(store_script_param, ":lady", 2),


#(try_begin),
#(eq, "$cheat_mode", 1),
#(str_store_troop_name, s4, ":suitor"),
#(str_store_troop_name, s5, ":lady"),
#(troop_get_slot, ":lady_location", ":lady", slot_troop_cur_center),
#(str_store_party_name, s7, ":lady_location"),
#(display_message, "str_s4_pursues_suit_with_s5_in_s7"),
#(try_end),

(troop_get_slot, ":previous_suitor", ":lady", slot_lady_last_suitor),
(troop_set_slot, ":lady", slot_lady_last_suitor, ":suitor"), #can determine quarrels

(try_begin),
(eq, ":previous_suitor", "trp_player"),

(troop_slot_ge, ":lady", slot_troop_met, 2),
(call_script, "script_troop_get_relation_with_troop", ":suitor", "trp_player"), #add this to list of quarrels
(assign, ":suitor_relation_w_player", reg0),

(try_begin),
(this_or_next|troop_slot_eq, ":suitor", slot_lord_reputation_type, lrep_selfrighteous),
(this_or_next|troop_slot_eq, ":suitor", slot_lord_reputation_type, lrep_quarrelsome),
(troop_slot_eq, ":suitor", slot_lord_reputation_type, lrep_debauched),
(gt, ":suitor_relation_w_player", -20),
(call_script, "script_add_log_entry", logent_lords_quarrel_over_woman, ":suitor", "trp_player", ":lady", 0),
(else_try),
(is_between, ":suitor_relation_w_player", -5, -25),
(call_script, "script_add_log_entry", logent_lords_quarrel_over_woman, ":suitor", "trp_player", ":lady", 0),
(try_end),
(else_try),
(neq, ":previous_suitor", "trp_player"), #not the player

(neq, ":suitor", ":previous_suitor"),
(ge, ":previous_suitor", active_npcs_begin),

(call_script, "script_cf_test_lord_incompatibility_to_s17", ":suitor", ":previous_suitor"),
(call_script, "script_add_log_entry", logent_lords_quarrel_over_woman, ":suitor", ":previous_suitor", ":lady", 0),

(call_script, "script_troop_get_relation_with_troop", ":suitor", ":previous_suitor"), #add this to list of quarrels
(ge, reg0, 0),
(call_script, "script_troop_change_relation_with_troop", ":suitor", ":previous_suitor", -20),
(val_add, "$total_courtship_quarrel_changes", -20),
(else_try), #quarrelsome lords quarrel anyway
(troop_slot_eq, ":suitor", slot_lord_reputation_type, lrep_quarrelsome),
(neq, ":suitor", ":previous_suitor"),
(ge, ":previous_suitor", active_npcs_begin),

# (neq, ":previous_suitor", "trp_player"),

(call_script, "script_troop_get_relation_with_troop", ":suitor", ":previous_suitor"), #add this to list of quarrels
(lt, reg0, 10),
(call_script, "script_add_log_entry", logent_lords_quarrel_over_woman, ":suitor", ":previous_suitor", ":lady", 0),
(ge, reg0, 0),
(call_script, "script_troop_change_relation_with_troop", ":suitor", ":previous_suitor", -20),
(val_add, "$total_courtship_quarrel_changes", -20),

(try_end),


# (call_script, "script_troop_get_relation_with_troop", ":lady", ":suitor"),
# (assign, ":eek:rig_relation", reg0),

(call_script, "script_lady_evaluate_troop_as_suitor", ":lady", ":suitor"),

(store_random_in_range, ":random", 5, 16),
(store_div, ":relationship_change", reg0, ":random"),

(call_script, "script_troop_get_relation_with_troop", ":lady", ":suitor"),
(assign, ":eek:rig_relation", reg0),

(call_script, "script_troop_change_relation_with_troop", ":lady", ":suitor", ":relationship_change"),

(call_script, "script_troop_get_relation_with_troop", ":lady", ":suitor"),
(assign, ":lady_suitor_relation", reg0),

(try_begin),
(ge, ":lady_suitor_relation", 10),
(lt, ":eek:rig_relation", 10),
(call_script, "script_add_log_entry", logent_lady_favors_suitor, ":lady", 0, ":suitor", 0),

(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_note__favor_event_logged"),
(try_end),

(else_try),
(this_or_next|lt, ":lady_suitor_relation", -20),
(ge, ":lady_suitor_relation", 20),

(call_script, "script_get_kingdom_lady_social_determinants", ":lady"),
(assign, ":guardian", reg0),
(call_script, "script_troop_get_relation_with_troop", ":suitor", ":guardian"),
(assign, ":suitor_guardian_relation", reg0),
#things come to a head, one way or another

(assign, ":highest_competitor_lady_score", -1),
(assign, ":competitor_preferred_by_lady", -1),

(assign, ":highest_competitor_guardian_score", ":suitor_guardian_relation"),
(assign, ":competitor_preferred_by_guardian", -1),

#log potential competitors
(try_for_range, ":possible_competitor", lords_begin, lords_end),
(neq, ":possible_competitor", ":suitor"),

(this_or_next|troop_slot_eq, ":possible_competitor", slot_troop_love_interest_1, ":lady"),
(this_or_next|troop_slot_eq, ":possible_competitor", slot_troop_love_interest_2, ":lady"),
(troop_slot_eq, ":possible_competitor", slot_troop_love_interest_3, ":lady"),

(try_begin),
(call_script, "script_troop_get_relation_with_troop", ":possible_competitor", ":lady"),
(gt, reg0, ":highest_competitor_lady_score"),
(assign, ":competitor_preferred_by_lady", ":possible_competitor"),
(assign, ":highest_competitor_lady_score", reg0),
(try_end),

(try_begin),
(call_script, "script_troop_get_relation_with_troop", ":possible_competitor", ":guardian"),
(gt, reg0, ":highest_competitor_guardian_score"),
(assign, ":competitor_preferred_by_guardian", ":possible_competitor"),
(assign, ":highest_competitor_guardian_score", reg0),
(try_end),
(try_end),

#RESULTS
#Guardian forces lady to be betrothed to suitor now
(try_begin),
(lt, ":lady_suitor_relation", -20),
(this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_selfrighteous),
(this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_debauched),
(troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_quarrelsome),
(eq, ":competitor_preferred_by_guardian", -1),

(this_or_next|troop_slot_eq, ":suitor", slot_lord_reputation_type, lrep_selfrighteous),
(this_or_next|troop_slot_eq, ":suitor", slot_lord_reputation_type, lrep_debauched),
(troop_slot_eq, ":suitor", slot_lord_reputation_type, lrep_quarrelsome),

(troop_slot_eq, ":suitor", slot_troop_betrothed, -1),
(troop_slot_eq, ":lady", slot_troop_betrothed, -1),

(call_script, "script_add_log_entry", logent_lady_betrothed_to_suitor_by_family, ":lady", 0, ":suitor", 0),
(troop_set_slot, ":suitor", slot_troop_betrothed, ":lady"),
(troop_set_slot, ":lady", slot_troop_betrothed, ":suitor"),
(store_current_hours, ":hours"),
(troop_set_slot, ":lady", slot_troop_betrothal_time, ":hours"),
(troop_set_slot, ":suitor", slot_troop_betrothal_time, ":hours"),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_result_lady_forced_to_agree_to_engagement"),
(try_end),

#Lady rejects the suitor
(else_try),
(lt, ":lady_suitor_relation", -20),

(call_script, "script_add_log_entry", logent_lady_rejects_suitor, ":lady", 0, ":suitor", 0),
(call_script, "script_courtship_event_lady_break_relation_with_suitor", ":lady", ":suitor"),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_result_lady_rejects_suitor"),
(try_end),

#A happy engagement, with parental blessing
(else_try),
(gt, ":lady_suitor_relation", 20),
(gt, ":suitor_guardian_relation", 0),
(eq, ":competitor_preferred_by_lady", -1),

(troop_slot_eq, ":suitor", slot_troop_betrothed, -1),
(troop_slot_eq, ":lady", slot_troop_betrothed, -1),

(call_script, "script_add_log_entry", logent_lady_betrothed_to_suitor_by_choice, ":lady", 0, ":suitor", 0),
(troop_set_slot, ":suitor", slot_troop_betrothed, ":lady"),
(troop_set_slot, ":lady", slot_troop_betrothed, ":suitor"),
(store_current_hours, ":hours"),
(troop_set_slot, ":lady", slot_troop_betrothal_time, ":hours"),
(troop_set_slot, ":suitor", slot_troop_betrothal_time, ":hours"),

(try_begin),
(eq, "$cheat_mode", 1),
(str_store_troop_name, s4, ":lady"),
(str_store_troop_name, s5, ":suitor"),
(display_message, "str_result_happy_engagement_between_s4_and_s5"),
(try_end),

#Lady elopes
(else_try),
(gt, ":lady_suitor_relation", 20),

(eq, ":competitor_preferred_by_lady", -1),
##diplomacy start+
##Fix Native bug, the following line should be checking ":lady", not ":guardian"
##OLD:
#(this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_adventurous),
# (troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_ambitious),
##NEW:
(this_or_next|troop_slot_eq, ":lady", slot_lord_reputation_type, lrep_adventurous),
(troop_slot_eq, ":lady", slot_lord_reputation_type, lrep_ambitious),
##diplomacy end+

(troop_slot_eq, ":suitor", slot_troop_betrothed, -1),
(troop_slot_eq, ":lady", slot_troop_betrothed, -1),

#lady elopes
(call_script, "script_courtship_event_bride_marry_groom", ":lady", ":suitor", 1),
#add elopements to quarrel descriptions

(try_begin),
(eq, "$cheat_mode", 1),
(str_store_troop_name, s4, ":lady"),
(str_store_troop_name, s5, ":suitor"),
(display_message, "str_result_s4_elopes_with_s5"),
(try_end),

#Lady reluctantly agrees to marry under pressure from family
(else_try),
(troop_slot_eq, ":lady", slot_lord_reputation_type, lrep_conventional),
(eq, ":competitor_preferred_by_guardian", -1),
(gt, ":suitor_guardian_relation", 4),

(store_random_in_range, ":random", 0, 5),
(eq, ":random", 0),

(troop_slot_eq, ":suitor", slot_troop_betrothed, -1),
(troop_slot_eq, ":lady", slot_troop_betrothed, -1),

(call_script, "script_add_log_entry", logent_lady_betrothed_to_suitor_by_pressure, ":lady", 0, ":suitor", 0),
(troop_set_slot, ":suitor", slot_troop_betrothed, ":lady"),
(troop_set_slot, ":lady", slot_troop_betrothed, ":suitor"),
(store_current_hours, ":hours"),
(troop_set_slot, ":lady", slot_troop_betrothal_time, ":hours"),
(troop_set_slot, ":suitor", slot_troop_betrothal_time, ":hours"),
(try_begin),
(eq, "$cheat_mode", 1),
(str_store_troop_name, s4, ":lady"),
(str_store_troop_name, s5, ":suitor"),
(display_message, "str_result_s4_reluctantly_agrees_to_engagement_with_s5"),
(try_end),

#Stalemate -- make patience roll
(else_try),
(gt, ":lady_suitor_relation", 20),

(store_random_in_range, reg3, 0, 3),
(try_begin),
(eq, "$cheat_mode", 1),
(display_message, "str_result_stalemate_patience_roll_=_reg3"),
(try_end),

(eq, reg3, 0),
(call_script, "script_add_log_entry", logent_lady_rejected_by_suitor, ":lady", 0, ":suitor", 0),
(call_script, "script_courtship_event_lady_break_relation_with_suitor", ":lady", ":suitor"),
(try_end),

(try_end),

]),

I believe the error is caused by these three lines:
(this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_selfrighteous),
(this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_debauched),
(troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_quarrelsome),
With 'guardian' being the troop that is -1 and invalid.
That may explain the crazy opcode because of the this_or_next.

However, the local variable guardian was used with no issues earlier in the script:
(call_script, "script_troop_get_relation_with_troop", ":suitor", ":guardian"),

I am very confused by this. There are 2 new factions (with lady troops made) so could this be causing the problem? Is there something more to do with adding ladies than putting them in module_troops?
 
Solution
I am trying to fix script errors that show during the game, but this is proving difficult because the opcode 1073742364 does not exist. Opcode 540 is troop_set_slot, which is very ubiquitous. Additionally, it refers to an invalid troop id that appears to have been valid earlier in the script.
Actually it exists, but it is represented in hexadecimal in header_operations:
Code:
SCRIPT ERROR ON OPCODE this_or_next|troop_slot_eq:
this_or_next  = 0x40000000
troop_slot_eq = 540
(HEX(0x40000000)=DEC(1073741824)‬)+DEC(540) = 1073742364

SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 87:
SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 88:
SCRIPT ERROR ON OPCODE 540: Invalid Troop ID: -1; LINE NO...
I am trying to fix script errors that show during the game, but this is proving difficult because the opcode 1073742364 does not exist. Opcode 540 is troop_set_slot, which is very ubiquitous. Additionally, it refers to an invalid troop id that appears to have been valid earlier in the script.
Actually it exists, but it is represented in hexadecimal in header_operations:
Code:
SCRIPT ERROR ON OPCODE this_or_next|troop_slot_eq:
this_or_next  = 0x40000000
troop_slot_eq = 540
(HEX(0x40000000)=DEC(1073741824)‬)+DEC(540) = 1073742364

SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 87:
SCRIPT ERROR ON OPCODE 1073742364: Invalid Troop ID: -1; LINE NO: 88:
SCRIPT ERROR ON OPCODE 540: Invalid Troop ID: -1; LINE NO: 89:
At script: courtship_event_troop_court_lady

Anyway, lines 87,88,89 correspond to:
Python:
                    (this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_selfrighteous),
                    (this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_debauched),
                    (troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_quarrelsome),
the local variable 'guardian' is set to -1, why?
the 'script_get_kingdom_lady_social_determinants' is where it takes the value of -1, but, correct me if I'm wrong, shouldn't it be set with a value of any of these slots?
slot_troop_spouse
slot_troop_father
slot_troop_mother
slot_troop_guardian
Python:
    # script_get_kingdom_lady_social_determinants
    # Calradian society is rather patriarchal, at least among the upper classes
    ("get_kingdom_lady_social_determinants",
        [
            (store_script_param_1, ":kingdom_lady"),
           
            (store_troop_faction, ":faction_of_lady", ":kingdom_lady"),
            (assign, ":center", -1),
            (assign, ":closest_male_relative", -1),
            (assign, ":best_center_score", 0),
           
            ##diplomacy start+
            ##TODO: Re-implement, disabled for now.  "Don't get stuck attached to a MIA relative"
            (try_begin),
                (troop_slot_ge, ":kingdom_lady", slot_troop_spouse, 0),
                (troop_get_slot, ":closest_male_relative", ":kingdom_lady", slot_troop_spouse),
                # (neg|troop_slot_ge, ":closest_male_relative", slot_troop_occupation, slto_retirement), #added: has not been removed from play
            (else_try),
                (troop_slot_ge, ":kingdom_lady", slot_troop_father, 0),
                (troop_get_slot, ":closest_male_relative", ":kingdom_lady", slot_troop_father),
                # (neg|troop_slot_ge, ":closest_male_relative", slot_troop_occupation, slto_retirement), #added: has not been removed from play
            (else_try),
                #added
                (troop_slot_ge, ":kingdom_lady", slot_troop_mother, 0),
                (troop_get_slot, ":closest_male_relative", ":kingdom_lady", slot_troop_mother),
                (troop_slot_eq, ":closest_male_relative", slot_troop_occupation, slto_kingdom_hero),
            (else_try),
                (troop_slot_ge, ":kingdom_lady", slot_troop_guardian, 0),
                (troop_get_slot, ":closest_male_relative", ":kingdom_lady", slot_troop_guardian),
                # (neg|troop_slot_ge, ":closest_male_relative", slot_troop_occupation, slto_retirement), #added: has not been removed from play
            (try_end),
            ##diplomacy end+
           
            ##diplomacy start+
            #Avoid strange problems if the argument is not a kingdom lady.
            (try_begin),
                (this_or_next|is_between, ":kingdom_lady", kingdom_ladies_begin, kingdom_ladies_end),
                (troop_slot_eq, ":kingdom_lady", slot_troop_occupation, slto_kingdom_lady),
                (neg|troop_slot_eq, ":kingdom_lady", slot_troop_occupation, slto_kingdom_hero),
                (assign, ":is_lady", 1),
            (else_try),
                (assign, ":is_lady", 0),
                (assign, ":closest_male_relative", ":kingdom_lady"), #is doing this useful for the way this script is used, or should we just set it to -1?
            (try_end),
           
            ##OLD:
            # (try_begin), #if ongoing social event (maybe add if not besieged)
            ##NEW:
            (try_begin),
                (eq, ":is_lady", 0),
                (call_script, "script_lord_get_home_center", ":kingdom_lady"),
                (assign, ":center", reg0),
                (is_between, ":center", walled_centers_begin, walled_centers_end),
            (else_try), #if ongoing social event (maybe add if not besieged)
                ##diplomacy end+
                (faction_slot_eq, ":faction_of_lady", slot_faction_ai_state, sfai_feast),
                (faction_get_slot, ":feast_center", ":faction_of_lady", slot_faction_ai_object),
               
                (gt, ":closest_male_relative", -1),
                (troop_get_slot, ":closest_male_party", ":closest_male_relative", slot_troop_leaded_party),
                (party_is_active, ":closest_male_party"),
                (party_get_attached_to, ":closest_male_cur_location", ":closest_male_party"),
               
                (eq, ":closest_male_cur_location", ":feast_center"),
                (is_between, ":feast_center", walled_centers_begin, walled_centers_end),
               
                (assign, ":center", ":feast_center"),
            (else_try),
unless 'kingdom_lady' doesn't have a spouse, or a father, or a mother, or a brother to act as her guardian... (the 'script_initialize_aristocracy' takes care of this at the beginning of the game)
... the part of the script I show belongs to the native module updated with the diplomacy mod.

You could also add a conditional, but I think it's better to find out what's going on with that -1:
Python:
                #RESULTS
                #Guardian forces lady to be betrothed to suitor now
                (try_begin),
                    (lt, ":lady_suitor_relation", -20),
                    (neq, ":guardian", -1), #conditinal
                   
                    (this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_selfrighteous),
                    (this_or_next|troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_debauched),
                    (troop_slot_eq, ":guardian", slot_lord_reputation_type, lrep_quarrelsome),
                    (eq, ":competitor_preferred_by_guardian", -1),
 
Last edited:
Upvote 0
Solution
Thanks to both of you. I'll look at initialize_aristocracy and the social determinant script.
 
Upvote 0
Back
Top Bottom