Phantasy calradia trigger not working... help?

正在查看此主题的用户

guspav

Section Moderator
Hi there, my mod Phantasy Calradia is having some trouble with a mission templates script in particular.
The turn undead script has been known to cause some trouble before, but now, for the life of me can't find a way to solve an opcode error reported by the game when the trigger is fired.
The opcode errors are:

SCRIPT ERROR ON OPCODE 2190: Invalid Faction ID: 71429656; LINE NO: 75:
At Mission Template mst_castle_attack_walls_ladder_trigger no: 17 consequences.

and

At Mission Template mst_lead_charge trigger no: 16 consequences.

Here's the script:

#turn/destroy undead
common_battle_turn_undead = (
  37, 0, 0, [],
  [
    (try_for_agents,":cleric"),
        (store_random_in_range,":1d6",1,7),
        (le,":1d6",2),
        (agent_get_troop_id,":is_priest",":cleric"),
        (neg|troop_is_mounted,":is_priest"),
        (agent_is_alive,":cleric"),
        (this_or_next|eq,":is_priest","trp_uh_infantry"),
        (this_or_next|eq,":is_priest","trp_uh_inquisitor"),
        # (this_or_next|eq,":is_priest","trp_drow_priestess"),
        # (this_or_next|eq,":is_priest","trp_drow_high_priestess"),
        (this_or_next|eq,":is_priest","trp_npc12"),
        (this_or_next|eq,":is_priest","trp_dwarf_cleric"),
        (this_or_next|eq,":is_priest","trp_dwarf_high_priest"),
        (this_or_next|eq,":is_priest","trp_calradian_cleric"),
        (this_or_next|eq,":is_priest","trp_swadian_cleric"),
        (this_or_next|eq,":is_priest","trp_vaegir_cleric"),
        (this_or_next|eq,":is_priest","trp_khergit_cleric"),
        (this_or_next|eq,":is_priest","trp_nord_cleric"),
        (this_or_next|eq,":is_priest","trp_rhodok_cleric"),
        (this_or_next|eq,":is_priest","trp_sarranid_cleric"),
        (this_or_next|eq,":is_priest","trp_elf_cleric"),
        (this_or_next|eq,":is_priest","trp_elf_high_cleric"),
        #(this_or_next|eq,":is_priest","trp_player"),
        (eq,":is_priest","trp_orc_raider_shaman"),
       
        (agent_is_alive,":cleric"),
        (agent_get_team  ,":cleric_team",":cleric"),
        (agent_get_position,pos32,":cleric"),
        (try_for_agents,":undead"),
        (agent_is_human,":undead"),
        (agent_is_alive,":undead"),
        (agent_get_troop_id,":targettrpid", ":undead"),
            (try_begin),
              (this_or_next|eq,":targettrpid","trp_zombie"),
              (this_or_next|eq,":targettrpid","trp_necro_conscript"),
              (eq,":targettrpid","trp_skeleton"),
              (assign,":target_is_undead",1),
            (else_try),
              (this_or_next|eq,":targettrpid","trp_zombie_warrior"),
              (this_or_next|eq,":targettrpid","trp_skeleton_warrior"),
              (this_or_next|eq,":targettrpid","trp_necro_footman"),
              (this_or_next|eq,":targettrpid","trp_necro_skirmisher"),
              (eq,":targettrpid","trp_shadow"),
              (assign,":target_is_undead",2),
            (else_try),
              (this_or_next|eq,":targettrpid","trp_armored_zombie_warrior"),
              (this_or_next|eq,":targettrpid","trp_armored_skeleton_warrior"),
              (this_or_next|eq,":targettrpid","trp_necro_veteran_footman"),
              (this_or_next|eq,":targettrpid","trp_necro_archer"),
              (this_or_next|eq,":targettrpid","trp_necro_infantry"),
              (this_or_next|eq,":targettrpid","trp_necro_lesser_priest"),
                  (eq,":targettrpid","trp_shadow_warrior"),
              (assign,":target_is_undead",3),
            (else_try), 
              (this_or_next|eq,":targettrpid","trp_armored_shadow_warrior"),
              (this_or_next|eq,":targettrpid","trp_necro_heavy_infantry"),
              (this_or_next|eq,":targettrpid","trp_necro_master_archer"),
              (this_or_next|eq,":targettrpid","trp_necro_priest"),
              (eq,":targettrpid","trp_shadow_wizard"),
              (assign,":target_is_undead",4),
            (else_try), 
              (this_or_next|eq,":targettrpid","trp_shadow_knight"),
              (this_or_next|eq,":targettrpid","trp_skeleton_knight"),
              (this_or_next|eq,":targettrpid","trp_necro_high_priest"),
              (eq,":targettrpid","trp_zombie_knight"),
              (assign,":target_is_undead",5),
            (else_try), 
                  (this_or_next|eq,":targettrpid","trp_knight_12_1"),
              (this_or_next|eq,":targettrpid","trp_knight_12_2"),
              (this_or_next|eq,":targettrpid","trp_knight_12_3"),
              (eq,":targettrpid","trp_knight_12_4"),
              (assign,":target_is_undead",6),
            (else_try),
              (assign,":target_is_undead",0),
            (try_end),
           
            (agent_get_team  ,":undead_team",":undead"),
            (neq,":cleric_team",":undead_team"),
            (team_get_faction, ":target_fac", ":undead_team"),
            (team_get_faction, ":shooter_fac", ":cleric_team"),
            (store_relation,":shooter-target_rels",":shooter_fac",":target_fac"),
            (ge,":shooter-target_rels",0),

            (agent_is_alive,":undead"),
            (agent_get_position,pos33,":undead"),
            (get_distance_between_positions_in_meters,":dist",pos32,pos33),
            (le,":dist",4),
            (ge,":target_is_undead",1),
            (agent_play_sound, ":cleric","snd_holy_bolt"),
            (agent_set_animation, ":cleric", "anim_cheer",1),
            (particle_system_burst,"psys_moon_beam_paricle_1",pos33,100), 
            (store_character_level,":cleric_level",":is_priest"),
            (store_random_in_range,":1d100",1,101),
            (val_add,":1d100",":cleric_level"),
              (try_begin),
                  (eq,":target_is_undead",1),
                  (is_between,":1d100",40,60),
                  (agent_start_running_away, ":undead"),
              (else_try),
                  (eq,":target_is_undead",1),
                  (ge,":1d100",60),
                  (agent_deliver_damage_to_agent, ":cleric", ":undead", 400,),
              (else_try),
                  (eq,":target_is_undead",2),
                  (is_between,":1d100",65,85),
                  (agent_start_running_away, ":undead"),
              (else_try),
                  (eq,":target_is_undead",2),
                  (ge,":1d100",85),
                  (agent_deliver_damage_to_agent, ":cleric", ":undead", 400,),
              (else_try),
                  (eq,":target_is_undead",3),
                  (is_between,":1d100",80,105),
                  (agent_start_running_away, ":undead"),
              (else_try),
                  (eq,":target_is_undead",3),
                  (ge,":1d100",105),
                  (agent_deliver_damage_to_agent, ":cleric", ":undead", 400,),
              (else_try),
                  (eq,":target_is_undead",4),
                  (is_between,":1d100",100,120),
                  (agent_start_running_away, ":undead"),
              (else_try),
                  (eq,":target_is_undead",4),
                  (ge,":1d100",120),
                  (agent_deliver_damage_to_agent, ":cleric", ":undead", 400,),
              (else_try),
                  (eq,":target_is_undead",5),
                  (is_between,":1d100",110,130),
                  (agent_start_running_away, ":undead"),
              (else_try),
                  (eq,":target_is_undead",5),
                  (ge,":1d100",130),
                  (agent_deliver_damage_to_agent, ":cleric", ":undead", 400,),
              (else_try),
                  (eq,":target_is_undead",6),
                  (is_between,":1d100",120,140),
                  (agent_start_running_away, ":undead"),
              (else_try),
                  (eq,":target_is_undead",6),
                  (ge,":1d100",140),
                  (agent_deliver_damage_to_agent, ":cleric", ":undead", 400,),
              (try_end),           
            (try_end),
       
      (try_end),
      ])

Colored blue are some of the few lines and the most probable causes of the opcode error.
Help?
Thanks in advance
 
team_get_faction probably only makes sense from a multiplayer perspective - use either the troop's faction (if armies don't have mixed-faction troops) or the agent's party's faction (add in another case for the player). Or just use (teams_are_enemies) to determine the pre-set team relationships.

EDIT: Make sure the cleric agent is human, active, not a horse, etc. As it is, agent_get_troop_id WILL also activate for the horse of a cleric, returning the same troop id as its rider. troop_is_mounted will only check for tf_mounted (which affects the map speed) and not tf_guarantee_horse, nor will it check if the agent itself has a horse. You also have a duplicate (agent_is_alive,":undead"), check where checking :target_is_undead is not 0 should be (since you're trying to exclude non-undead troops). The level check of the cleric should also be placed OUTSIDE the undead agent check and added after the roll.

While you're at it, you should be making use of troop slots instead of checking the same troop ids every single loop. This should be used for both clerics and undeads - fetch :target_is_undead from a troop slot and use it to calculate thresholds instead of verifying if it's 1 to 6 inside individual checks.
 
Aha! So that's why.... stupid operation :grin:

I'll change that blue part to:

(agent_get_party_id,":cleric_p_id",":cleric"),
(store_faction_of_party, ":cleric_fac", ":cleric_p_id"),
(agent_get_party_id,":undead_p_id",":undead"),
(store_faction_of_party, ":undead_fac", ":undead_p_id"),
(store_relation,":cleric_undead_rels",":cleric_fac",":undead_fac"),
(lt,":cleric_undead_rels",0),


By the way, I just realized I made a mistake and those clerics were attacking FRIENDLY troops.. oops!  :mrgreen:
Let's see if it works that way.

THANKS!

EDIT: Thanks again, I'll optimize the code. I am still unsure on how to use slots, but I'll figure it out.
 
teams_are_enemies is a much simpler operation, although it won't work in multiplayer.
As for slots, it's really simple, do something like this
插入代码块:
slot_troop_is_cleric = 123
slot_troop_is_undead = 124
插入代码块:
(troop_set_slot, "trp_uh_infantry", slot_troop_is_cleric, 1),
...
(troop_set_slot, "trp_zombie_knight", slot_troop_is_undead, 5),
...
and call it like this
插入代码块:
(agent_is_alive,":cleric"),
(agent_get_troop_id,":is_priest",":cleric"),
(troop_slot_ge, ":is_priest", slot_troop_is_cleric, 1),
(neg|troop_is_mounted,":is_priest"),
(agent_get_team, ":cleric_team",":cleric"),
...
(agent_is_human,":undead"),
(agent_is_alive,":undead"),
(agent_get_troop_id,":targettrpid", ":undead"),
(troop_get_slot, ":target_is_undead", ":targettrpid", slot_troop_is_undead),
 
后退
顶部 底部