Ancient Warfare 2

Ancient Warfare 2

6M Downloads

Engineers from different non-player NPC factions can't apply damage to each other[Fix Included]

AndySawyerSWE opened this issue ยท 0 comments

commented

Context Environment

Minecraft version: 1.12.2

Ancient Warfare 2 version: 2.7.0.1038

Minecraft Forge version: 2854

Clean build with only the mod itself and its dependencies.

Expected Behavior

Engineers from different non-player NPC factions can apply damage to each other.

Current Behavior

Engineers from different NPC factions do not apply damage to each other due to faulty use of isOwnerOrSameTeamOrFriend() in /src/main/java/net/shadowmage/ancientwarfare/vehicle/missiles/Ammo.java

Steps to Reproduce

  1. Create a clean build with curseForge
  2. Place two faction NPCs (not player owned) and give one of them a ballista
  3. See that the ballista's projectile does not apply damage

Definitive Solutions (Tested with IntelliJ build environment)

The issues could be caused by misuse of the concept of ownership in Ammo.java. Each Ammo object compares the ownership of its spawning NpcBase object (which is the parent class of all faction NPCs such as witchbane and empire) to the NpcBase object it hits. This assumes that the ownership is based on faction; however, if a faction NPC is spawned by a player in creative mode, they could have the same owner as its enemy counterpart regardless of their respective factions.

There are two fixes. Set friendly fire to true in config. This circumvents the conditional in shouldEffectEntity.

A better fix that worked for me: method shouldEffectEntity in missiles/Ammo.java should compare the factions of NpcBase instead of ownership.

Go to /npc/entity/faction/NpcFaction.java and add a getter that exposes factionName. Then invoke the method in Ammo.java. Compare the strings and there you go.