
I am trying to add AI to a new tribe with new heroes and abilities, but got stuck on a point where the AI simply cannot research/upgrade abilities.
The original function in prodai_lib.bhs is the following:
Inside the function, it first calculates next_spell_type
Then it checks
Then it adds it to the shopping list
I debugged the first two steps by printing the result to the screen, where in the first step "next_spell_type" is correctly obtained from craftrule.xml settings, but the second check returns 0(false) so it's indicating the upgrade is not available.
Also if I change the code to bypass the second check and add to the shopping list anyway, the AI still does not research so there must be something fundamentally wrong.
My xml setting contains a copied Lenora, with the ability "Boost" being exactly same as the original except
1. typename changed to "Boostm"
2. CODETAG removed
3. ICONGRAFT added
And the copied Lenora herself is exactly same as the original except
1. used reference_style="copy" from the original Lenora
2. typename changed to "Lenora, Pirata Princessm"
3. CODETAG removed
4. Attack and HP values changed (which I'm pretty sure is irrelevant)
Even this boost ability is not being researched by the AI. I hope it is not hard-coded for only the original heroes to work. If anyone has experienced similar issue please share your experience with me.
PS: I am also willing to accept any workaround, so if someone knows how to directly enable/upgrade an ability to a hero during run-time, I want to know as well. (tried to use leader_gain_tech does not work.)
The original function in prodai_lib.bhs is the following:
int function sf_research_hero_spell(SpellType spell_type, Leader the_leader)
Inside the function, it first calculates next_spell_type
SpellType next_spell_type = get_next_spell_type_upgrade (spell_type, the_leader);
Then it checks
is_type_avail_to_research (next_spell_type, the_leader)
Then it adds it to the shopping list
shopping_list_add(next_spell_type,1);
I debugged the first two steps by printing the result to the screen, where in the first step "next_spell_type" is correctly obtained from craftrule.xml settings, but the second check returns 0(false) so it's indicating the upgrade is not available.
Also if I change the code to bypass the second check and add to the shopping list anyway, the AI still does not research so there must be something fundamentally wrong.
My xml setting contains a copied Lenora, with the ability "Boost" being exactly same as the original except
1. typename changed to "Boostm"
2. CODETAG removed
3. ICONGRAFT added
And the copied Lenora herself is exactly same as the original except
1. used reference_style="copy" from the original Lenora
2. typename changed to "Lenora, Pirata Princessm"
3. CODETAG removed
4. Attack and HP values changed (which I'm pretty sure is irrelevant)
Even this boost ability is not being researched by the AI. I hope it is not hard-coded for only the original heroes to work. If anyone has experienced similar issue please share your experience with me.
PS: I am also willing to accept any workaround, so if someone knows how to directly enable/upgrade an ability to a hero during run-time, I want to know as well. (tried to use leader_gain_tech does not work.)
[This message has been edited by modder00 (edited 09-16-2020 @ 07:48 AM).]