mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-18 10:19:08 +00:00
Tactical Switcher
This commit is contained in:
1 parent
2b5567aab7
commit
173bf91342
2 files changed
+21
-7
No files matched your search
@@ -132,4 +132,19 @@ public class CombatHandler {
|
||||
|
||||
return threatLevel;
|
||||
}
|
||||
|
||||
public boolean shouldChangeTarget(double chance) {
|
||||
// Assuming randomNum is a random number between 0 and 100
|
||||
double randomNum = Math.random() * 100; // Generates a random number between 0 and 100
|
||||
return randomNum <= chance;
|
||||
}
|
||||
|
||||
public boolean shouldSwitchTactically(EntityLivingBase originalTarget, EntityLivingBase newTarget) {
|
||||
// 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);
|
||||
|
||||
return newThreat > currentThreat;
|
||||
}
|
||||
}
|
||||
@@ -535,7 +535,12 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
break;
|
||||
case Stubborn:
|
||||
if (closerTargetFound && shouldChangeTarget(5.0)) {
|
||||
if (closerTargetFound && combatHandler.shouldChangeTarget(5.0)) {
|
||||
setAttackTarget(attackingEntity);
|
||||
}
|
||||
break;
|
||||
case Tactical:
|
||||
if (attackingEntity != getAttackTarget() && combatHandler.shouldSwitchTactically(getAttackTarget(), attackingEntity)) {
|
||||
setAttackTarget(attackingEntity);
|
||||
}
|
||||
break;
|
||||
@@ -1927,10 +1932,4 @@ public abstract class EntityNPCInterface extends EntityCreature implements IEnti
|
||||
}
|
||||
|
||||
protected void updateLeashedState(){}
|
||||
|
||||
private boolean shouldChangeTarget(double chance) {
|
||||
// Assuming randomNum is a random number between 0 and 100
|
||||
double randomNum = Math.random() * 100; // Generates a random number between 0 and 100
|
||||
return randomNum <= chance;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user