mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-16 21:05:06 +00:00
Combat Policy: Tactical Completed
- Added Normal / Reverse Button Tactical targets the strongest threat, while Reverse targets the weakest ones
This commit is contained in:
1 parent
d8f320f79c
commit
b17d95edde
4 files changed
+19
-3
No files matched your search
@@ -139,12 +139,14 @@ public class CombatHandler {
|
||||
return randomNum <= chance;
|
||||
}
|
||||
|
||||
public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget) {
|
||||
public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget, boolean reverse) {
|
||||
// Implement your Tactical Switcher conditions here
|
||||
// Example: Switch if the new target has a higher threat level
|
||||
float currentThreat = calculateThreatLevel(originalTarget);
|
||||
float newThreat = calculateThreatLevel(newTarget);
|
||||
|
||||
if(reverse){
|
||||
return newThreat < currentThreat;
|
||||
}
|
||||
return newThreat > currentThreat;
|
||||
}
|
||||
}
|
||||
@@ -80,6 +80,10 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
||||
getTextField(4).integersOnly = true;
|
||||
getTextField(4).setMinMaxDefault(1, 100, 5);
|
||||
}
|
||||
else if (ai.combatPolicy == EnumCombatPolicy.Tactical)
|
||||
{
|
||||
addButton(new GuiNpcButton(40, guiLeft + 295, guiTop + 160, 60, 20, new String[]{"stats.normal","stats.reverse"}, npc.ai.tacticalChance > 50 ? 1:0));
|
||||
}
|
||||
|
||||
getButton(17).setEnabled(this.ai.onAttack == 0);
|
||||
getButton(15).setEnabled(this.ai.onAttack == 0);
|
||||
@@ -156,6 +160,15 @@ public class GuiNpcAI extends GuiNPCInterface2 implements ITextfieldListener, IG
|
||||
ai.combatPolicy = EnumCombatPolicy.values()[button.getValue()];
|
||||
initGui();
|
||||
}
|
||||
else if (button.id == 40) {
|
||||
int val = button.getValue();
|
||||
if(val == 0){
|
||||
ai.tacticalChance = 0;
|
||||
} else {
|
||||
ai.tacticalChance = 100;
|
||||
}
|
||||
initGui();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -572,7 +572,7 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
break;
|
||||
case Tactical:
|
||||
if (attackingEntity != getAttackTarget() && combatHandler.shouldSwitchTactically(getAttackTarget(), attackingEntity)) {
|
||||
if (attackingEntity != getAttackTarget() && combatHandler.shouldSwitchTactically(getAttackTarget(), attackingEntity, ai.tacticalChance > 50)) {
|
||||
setAttackTarget(attackingEntity);
|
||||
}
|
||||
break;
|
||||
|
||||
Reference in new issue
Block a user