Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mages auto-equip melee/ranged weapons #192

Merged
merged 2 commits into from Mar 19, 2021
Merged

Mages auto-equip melee/ranged weapons #192

merged 2 commits into from Mar 19, 2021

Conversation

szapp
Copy link
Collaborator

@szapp szapp commented Mar 14, 2021

Describe the bug
Trading with mages (e.g. Xardas or Cronos) will always result in them equipping weapons, because they typically do not wear any to begin with. As soon as the player sells them a weapon (of any type) they will have it equipped when the player returns to them even with #59 applied.

Expected behavior
Mages (NPCs fighting only with spells) no longer auto-equip weapons (e.g. after trading). Requires #59 to be active.

Steps to reproduce the issue

  1. Sell a weapon to Xardas
  2. Move out of spawn range and come back
  3. Xardas now has the weapon equipped (given the weapon does not require too much strength/dexterity)

Additional context

Building on #59:

Trading with mages (e.g. Xardas or Cronos) will always result in them equipping weapons, because they typically do not wear any to begin with. As soon as the player sells them a weapon (of any type) they will have it equipped when the player returns to them even with this fix. There is the option of disabling that for NPCs that exclusively use magic to fight:

func void G1CP_059_NpcEquipBestWeapons_Hook() {
G1CP_ReportFuncToSpy();
// Define possibly missing symbols locally
const int ITEM_KAT_NF = 2;
const int ITEM_KAT_FF = 4;
var C_Npc npc; npc = _^(ESI);
if (!Npc_HasEquippedMeleeWeapon(npc))
&& (!Npc_HasReadiedMeleeWeapon(npc)) {
G1CP_NpcEquipBestWeaponByType(npc, ITEM_KAT_NF);
};
if (!Npc_HasEquippedRangedWeapon(npc))
&& (!Npc_HasReadiedRangedWeapon(npc)) {
G1CP_NpcEquipBestWeaponByType(npc, ITEM_KAT_FF);
};
};

changed to

func void G1CP_059_NpcEquipBestWeapons_Hook() {
    G1CP_ReportFuncToSpy();

    // Define possibly missing symbols locally
    const int ITEM_KAT_NF = 2;
    const int ITEM_KAT_FF = 4;
    const int FAI_HUMAN_MAGE = -2;
    if (FAI_HUMAN_MAGE == -2) {
        FAI_HUMAN_MAGE = G1CP_GetIntVar("FAI_HUMAN_MAGE", 0, -1);
    };

    var C_Npc npc; npc = _^(ESI);

    if (!Npc_HasEquippedMeleeWeapon(npc))
    && (!Npc_HasReadiedMeleeWeapon(npc))
    && (npc.fight_tactic != FAI_HUMAN_MAGE) {
        G1CP_NpcEquipBestWeaponByType(npc, ITEM_KAT_NF);
    };

    if (!Npc_HasEquippedRangedWeapon(npc))
    && (!Npc_HasReadiedRangedWeapon(npc))
    && (npc.fight_tactic != FAI_HUMAN_MAGE) {
        G1CP_NpcEquipBestWeaponByType(npc, ITEM_KAT_FF);
    };
};

This should work great in the main game. In mods, however, it could cause issues. If a mod, for example, adds wands or staffs for mages but does not equip them (only adds them to the inventory), they would not show up in the game. Given that those NPCs would only fight with magic anyway it might only cause cosmetic issues - given that the fight AI was not adjusted such the mage-fighters switch to melee in close combat for example.

We could discuss this. In my opinion it would be nice not seeing Xardas with weird orc weapons on his back.

Originally posted by @szapp in #59 (comment)

@szapp szapp added compatibility: easy This issue is easy to make compatible. provided fix This issue has a fix provided in the comments. type: session fix The fix for this issues is persistent across a session. labels Mar 14, 2021
@szapp
Copy link
Collaborator Author

szapp commented Mar 14, 2021

I suggest to add this fix by modifying the function G1CP_059_NpcEquipBestWeapons_Hook of #59. The modification should only be applied if the fix was not disabled.

@szapp szapp added this to In Progress in v1.1.0 via automation Mar 14, 2021
@szapp szapp added this to the v1.1.0 milestone Mar 14, 2021
@szapp szapp added this to Other in Fix templates Mar 17, 2021
@szapp szapp added the impl: misc This issue requires unique/miscellaneous implementation. label Mar 17, 2021
@AmProsius AmProsius merged commit 3a05e2b into master Mar 19, 2021
@AmProsius AmProsius deleted the bug192 branch March 19, 2021 20:32
v1.1.0 automation moved this from In Progress to Done Mar 19, 2021
szapp added a commit that referenced this pull request Apr 19, 2021
@szapp szapp moved this from Other to NPC behavior in engine in Fix templates Apr 26, 2021
@szapp szapp moved this from Modify NPC behavior in engine to Some NPC Test? (Todo adjust name) in Fix templates Feb 6, 2022
@szapp szapp moved this from NPC manual test (TODO rename) to NPC auto test (TODO rename) in Fix templates Feb 6, 2022
@szapp szapp moved this from NPC auto test (TODO rename) to NPC manual test (TODO rename) in Fix templates Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility: easy This issue is easy to make compatible. impl: misc This issue requires unique/miscellaneous implementation. provided fix This issue has a fix provided in the comments. type: session fix The fix for this issues is persistent across a session.
Projects
Fix templates
NPC manual test (TODO rename)
v1.1.0
  
Done
Development

Successfully merging this pull request may close these issues.

None yet

2 participants