AI lords won't apply skill

Users who are viewing this thread

John25-

Sergeant at Arms
Hello,

After giving AI lords 'knows_surgery_7', the skill does appear in their character window, but it is not applied in battles. Here is an example:

MM5wIYN.png


Based on this post I thought it would be fine, but I guess it only works when the lord is a member of player's party; player then benefits higher skills.


Isn't there a way to apply this to AI parties as well?
 
Solution
So, what I gave you is an example of a named or defined trigger. I don't really know the accepted nomenclature. These are beneficial for readability or when a trigger needs to be used in multiple mission like what we need here.

In Native there are plenty already in the game you can refer to so that you can see how they are added to missions like common_battle_tab_press, common_battle_init_banner or common_battle_inventory.

The game does not automatically add these triggers to missions. We need to add it to the list of triggers for missions where it would be appropriate. In this case all missions that are battles between two or more parties like "lead_charge", "village_attack_bandits", etc.

Code:
# This is...
Code:
ai_surgery = (ti_on_agent_killed_or_wounded, 0, 0, [],
[
(store_trigger_param, ":agent", 1),    # Who has fallen

(try_begin),
    (agent_get_party_id, ":party", ":agent"), # What is their origin party?
    (party_is_active, ":party"),              # Is it a valid party?
    (neq, ":party", "p_main_party"),          # And not the player's?
   
    (store_random_in_range, ":wounded_chance", 0, 25), # This should make each level worth 4%
   
    (party_get_num_companion_stacks, ":total_stacks", ":party"), # How many stacks exist
    (assign, ":surgery", 0),    # Assign 0 as default

    (try_for_range, ":stack", 0, ":total_stacks"),
        (party_stack_get_troop_id, ":troop", ":party", ":stack"), # Check the troop at each stack

        (store_skill_level, ":t_surgery", skl_surgery, ":troop"), # Get that troop's surgery skill
        (gt, ":t_surgery", ":surgery"), # If larger than the previous top surgery
        (assign, ":surgery", ":t_surgery"), # Make it the top surgery
    (try_end),

    (le, ":wounded_chance", ":surgery"), # If the random chance is lower than the surgery level
    (set_trigger_result, 2), # Force Wounded
(try_end),
]),

I just wrote this real quick without testing it. May cause some errors with agents not associated with a party.
 
Upvote 0
Thanks for your quick reply. I've tested after updating module_mission_templates but it didn't work; all non-hero enemies still get killed.

+ For some reason I had the following issue when compiling:
0wuuDXj.png


I'm quite surprised it requires to be written "skl_surgery" to be compiled without error, for we can find the same writing in module_scripts ("get_quest"):
(store_skill_level, ":cur_surgery_skill", skl_surgery, ":stack_troop"),

Anyway, I've tested both but writing either skl_surgery or "skl_surgery" doesn't affect the final result: it doesn't seem to work.. :sad:
 
Upvote 0
skl_surgery is getting defined in header_skills.py, so you will need to add the following line at the top of module_mission_templates.py (assuming here that you added the trigger there):
Code:
from header_skills import *
as you can find it also in module_scripts.py. Alternatively you could use a 10 instead of skl_surgery as that is the value for it.
 
Upvote 0
Thanks for your quick reply. I've tested after updating module_mission_templates but it didn't work; all non-hero enemies still get killed.

+ For some reason I had the following issue when compiling:
0wuuDXj.png


I'm quite surprised it requires to be written "skl_surgery" to be compiled without error, for we can find the same writing in module_scripts ("get_quest"):


Anyway, I've tested both but writing either skl_surgery or "skl_surgery" doesn't affect the final result: it doesn't seem to work.. :sad:
Add a test display message at a few points to make sure it is firing. It should work as written, after importing header_skills of course.

Just to make sure, you know how to add new triggers to missions, right?
 
Upvote 0
I've added the import line at the top of module_mission_templates, solves the "skl_surgery" issue. Thanks

Add a test display message at a few points to make sure it is firing. It should work as written, after importing header_skills of course.

Just to make sure, you know how to add new triggers to missions, right?

But no change on the battlefield. I reckon I am not familiar with triggers and missions, what should I do exactly?
 
Upvote 0
So, what I gave you is an example of a named or defined trigger. I don't really know the accepted nomenclature. These are beneficial for readability or when a trigger needs to be used in multiple mission like what we need here.

In Native there are plenty already in the game you can refer to so that you can see how they are added to missions like common_battle_tab_press, common_battle_init_banner or common_battle_inventory.

The game does not automatically add these triggers to missions. We need to add it to the list of triggers for missions where it would be appropriate. In this case all missions that are battles between two or more parties like "lead_charge", "village_attack_bandits", etc.

Code:
# This is an example of a mission template
  (
    "mission_template_id", mission_template_flags, mission_type,
    "description text",
    [
    # spawn record list
    (1, mtef_defenders|mtef_team_0, 0, aif_start_alarmed, 30, []), # Example of a spawn record
    ],
    [
     # mission trigger list
    (0, 0, 0, [], []),             # This is an example of a trigger written inside the template's trigger list
    common_battle_tab_press,    # This is an example of a common/named/defined trigger being used inside the template's trigger list
    ai_surgery,                    # You want to put yours somewhere in this block, but be careful not to put it inside another trigger
    ],
  ),

Conveniently the mission_type of party battles will always feature charge or charge_with_ally to help you identify them.



Just to confirm, I have tested it just now and it works like a charm! This version is identical except I swapped the gt to ge so I didn't get uninitialized values in the message

Code:
ai_surgery = (ti_on_agent_killed_or_wounded, 0, 0, [],
[
(store_trigger_param, ":agent", 1),    # Who has fallen

(try_begin),
    (agent_get_party_id, ":party", ":agent"), # What is their origin party?
    (party_is_active, ":party"),              # Is it a valid party?
    (neq, ":party", "p_main_party"),          # And not the player's?
 
    (store_random_in_range, ":wounded_chance", 0, 25), # This should make each level worth 4%
 
    (party_get_num_companion_stacks, ":total_stacks", ":party"), # How many stacks exist
    (assign, ":surgery", 0),    # Assign 0 as default
    (str_store_agent_name, s1, ":agent"),
    (try_for_range, ":stack", 0, ":total_stacks"),
        (party_stack_get_troop_id, ":troop", ":party", ":stack"), # Check the troop at each stack

        (store_skill_level, ":t_surgery", skl_surgery, ":troop"), # Get that troop's surgery skill
        (ge, ":t_surgery", ":surgery"), # If larger than the previous top surgery, I had to make it greater than or equal because if everyone is 0 the registers were going unassigned
        (assign, ":surgery", ":t_surgery"), # Make it the top surgery
        (assign, reg1, ":surgery"),
        (str_store_troop_name, s2, ":troop"),
    (try_end),

    (le, ":wounded_chance", ":surgery"), # If the random chance is lower than the surgery level
    (set_trigger_result, 2), # Force Wounded
    (display_message, "@{s1} had their life saved because {s2}'s Surgery Skill of {reg1}"),
(try_end),
])
 
Last edited:
Upvote 0
Solution
Back
Top Bottom