From f655a11e93dff8daab4acd040ac92c662eea1719 Mon Sep 17 00:00:00 2001
From: FatBoy-DOTC <justin.chucksinsulating@gmail.com>
Date: Thu, 20 Mar 2025 20:21:47 -0500
Subject: [PATCH] fixup 2

---
 src/engine/gameManager/CombatManager.java | 29 +++++++++++---
 src/engine/gameManager/PowersManager.java | 49 ++++++++---------------
 src/engine/powers/ActionsBase.java        | 14 +++++++
 3 files changed, 54 insertions(+), 38 deletions(-)

diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java
index 78fd0dd8..60a9e4e8 100644
--- a/src/engine/gameManager/CombatManager.java
+++ b/src/engine/gameManager/CombatManager.java
@@ -101,10 +101,6 @@ public enum CombatManager {
 
     public static void AttackTarget(PlayerCharacter playerCharacter, AbstractWorldObject target) {
 
-        if(playerCharacter != null && playerCharacter.isBoxed)
-            if(target.getObjectType().equals(GameObjectType.PlayerCharacter))
-                return;
-
         boolean swingOffhand = false;
 
         //check my weapon can I do an offhand attack
@@ -316,6 +312,7 @@ public enum CombatManager {
                     if(pet.combatTarget == null && pet.assist)
                         pet.setCombatTarget(attacker.combatTarget);
                 }
+
             }
 
 
@@ -484,6 +481,7 @@ public enum CombatManager {
                 }
             }
 
+            range += 2;
             if (NotInRange(abstractCharacter, target, range)) {
 
                 //target is in stealth and can't be seen by source
@@ -507,6 +505,16 @@ public enum CombatManager {
                 }
             }
 
+            if(abstractCharacter.getObjectType().equals(GameObjectType.PlayerCharacter)){
+                PlayerCharacter pc = (PlayerCharacter)abstractCharacter;
+                if(pc.isBoxed){
+                    if(target.getObjectType().equals(GameObjectType.PlayerCharacter)) {
+                        ChatManager.chatSystemInfo(pc, "You Are PvE Flagged: Cannot Attack Players.");
+                        attackFailure = true;
+                    }
+                }
+            }
+
             //TODO Verify attacker has los (if not ranged weapon).
 
             if (!attackFailure) {
@@ -933,6 +941,11 @@ public enum CombatManager {
 
                 float d = 0f;
 
+                int originalDamage = (int)damage;
+                if(ac != null && ac.getObjectType().equals(GameObjectType.PlayerCharacter)){
+                    damage *= ((PlayerCharacter)ac).ZergMultiplier;
+                } // Health modifications are modified by the ZergMechanic
+
                 errorTrack = 12;
 
                 //Subtract Damage from target's health
@@ -949,9 +962,13 @@ public enum CombatManager {
                         ac.setHateValue(damage * MBServerStatics.PLAYER_COMBAT_HATE_MODIFIER);
                         ((Mob) tarAc).handleDirectAggro(ac);
                     }
-
-                    if (tarAc.getHealth() > 0)
+                    if (tarAc.getHealth() > 0) {
                         d = tarAc.modifyHealth(-damage, ac, false);
+                        if(tarAc != null && tarAc.getObjectType().equals(GameObjectType.PlayerCharacter) && ((PlayerCharacter)ac).ZergMultiplier != 1.0f){
+                            PlayerCharacter debugged = (PlayerCharacter)tarAc;
+                            ChatManager.chatSystemInfo(debugged, "ZERG DEBUG: " + ac.getName() + " Hits You For: " + (int)damage + " instead of " + originalDamage);
+                        }
+                    }
 
                     tarAc.cancelOnTakeDamage();
 
diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java
index 08488432..262fa084 100644
--- a/src/engine/gameManager/PowersManager.java
+++ b/src/engine/gameManager/PowersManager.java
@@ -1093,7 +1093,7 @@ public enum PowersManager {
                     continue;
                 // If something blocks the action, then stop
 
-                if (ab.blocked(target, pb, trains,playerCharacter)) {
+                if (ab.blocked(target, pb, trains, playerCharacter)) {
 
                     PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb);
                     continue;
@@ -1280,7 +1280,7 @@ public enum PowersManager {
                     continue;
                 // If something blocks the action, then stop
 
-                if (ab.blocked(target, pb, trains,caster))
+                if (ab.blocked(target, pb, trains, caster))
                     continue;
                 // TODO handle overwrite stack order here
                 String stackType = ab.getStackType();
@@ -1481,7 +1481,7 @@ public enum PowersManager {
         // Handle Accepting or Denying a summons.
         // set timer based on summon type.
         boolean wentThrough = false;
-        if (msg.accepted())
+        if (msg.accepted()) {
             // summons accepted, let's move the player if within time
             if (source.isAlive()) {
 
@@ -1527,14 +1527,14 @@ public enum PowersManager {
                     duration = 45000; // Belgosh Summons, 45 seconds
 
                 boolean enemiesNear = false;
-                for(AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(pc.loc,MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER)){
-                    PlayerCharacter playerCharacter = (PlayerCharacter)awo;
-                    if(!playerCharacter.guild.getNation().equals(pc.guild.getNation())){
+                for (AbstractWorldObject awo : WorldGrid.getObjectsInRangePartial(pc.loc, MBServerStatics.CHARACTER_LOAD_RANGE, MBServerStatics.MASK_PLAYER)) {
+                    PlayerCharacter playerCharacter = (PlayerCharacter) awo;
+                    if (!playerCharacter.guild.getNation().equals(pc.guild.getNation())) {
                         enemiesNear = true;
                     }
                 }
 
-                if(enemiesNear && !pc.isInSafeZone())
+                if (enemiesNear && !pc.isInSafeZone())
                     duration += 60000;
 
                 // Teleport to summoners location
@@ -1545,7 +1545,10 @@ public enum PowersManager {
                     timers.put("Summon", jc);
                 wentThrough = true;
             }
-
+        }else{
+            // recycle summons power
+            finishRecycleTime(428523680, source, true);
+        }
         // Summons failed
         if (!wentThrough)
             // summons refused. Let's be nice and reset recycle timer
@@ -1834,6 +1837,10 @@ public enum PowersManager {
     private static void applyPowerA(AbstractCharacter ac, AbstractWorldObject target,
                                     Vector3fImmutable targetLoc, PowersBase pb, int trains,
                                     boolean fromItem) {
+
+        if(fromItem && pb.token == 429021400)
+            trains = 40;
+
         int time = pb.getCastTime(trains);
         if (!fromItem)
             finishApplyPowerA(ac, target, targetLoc, pb, trains, false);
@@ -1899,7 +1906,7 @@ public enum PowersManager {
             if (trains < ab.getMinTrains() || trains > ab.getMaxTrains())
                 continue;
             // If something blocks the action, then stop
-            if (ab.blocked(target, pb, trains,ac))
+            if (ab.blocked(target, pb, trains, ac))
                 // sendPowerMsg(pc, 5, msg);
                 continue;
             // TODO handle overwrite stack order here
@@ -1975,31 +1982,9 @@ public enum PowersManager {
     public static void runPowerAction(AbstractCharacter source, AbstractWorldObject awo, Vector3fImmutable targetLoc, ActionsBase ab, int trains, PowersBase pb) {
         AbstractPowerAction pa = ab.getPowerAction();
         if (pa == null) {
-            Logger.error(
-                    "runPowerAction(): PowerAction not found of IDString: "
-                            + ab.getEffectID());
+            Logger.error("runPowerAction(): PowerAction not found of IDString: " + ab.getEffectID());
             return;
         }
-
-        if(AbstractCharacter.IsAbstractCharacter(awo)) {
-            try {
-                boolean immune = false;
-                AbstractCharacter absChar = (AbstractCharacter) awo;
-                for (AbstractEffectModifier mod : ab.getPowerAction().getEffectsBase().getModifiers()) {
-                    if (absChar.getBonuses() != null) {
-                        if (absChar.getBonuses().getBool(ModType.ImmuneTo, mod.sourceType) || absChar.getBonuses().getBool(ModType.NoMod, mod.sourceType))
-                            immune = true;
-                    }
-                }
-
-                if (immune)
-                    return;
-            }catch(Exception e){
-
-            }
-        }
-
-
         pa.startAction(source, awo, targetLoc, trains, ab, pb);
     }
 
diff --git a/src/engine/powers/ActionsBase.java b/src/engine/powers/ActionsBase.java
index 4bad4ad6..1dd3b2f8 100644
--- a/src/engine/powers/ActionsBase.java
+++ b/src/engine/powers/ActionsBase.java
@@ -239,6 +239,7 @@ public class ActionsBase {
 
     //Add blocked types here
     public boolean blocked(AbstractWorldObject awo, PowersBase pb, int trains, AbstractCharacter source) {
+
         if(!pb.getName().contains("Summon")) {
             if (AbstractWorldObject.IsAbstractCharacter(awo)) {
                 AbstractCharacter target = (AbstractCharacter) awo;
@@ -252,17 +253,22 @@ public class ActionsBase {
                 }
             }
         }
+
         if(pb.isChant)
             return false;
+
         if (AbstractWorldObject.IsAbstractCharacter(awo)) {
             AbstractCharacter ac = (AbstractCharacter) awo;
+
             if(ac.effects.containsKey(this.stackType)) {
                 Boolean sameRank = false;
                 Effect eff = ac.effects.get(this.stackType);
+
                 String currentEffect = eff.getEffectsBase().getIDString();
                 String newEffect = this.effectID;
                 if (currentEffect.equals(newEffect) && !this.stackType.equals("Stun"))
                     return false;
+
                 if (eff != null) {
                     for (ActionsBase action : eff.getPower().getActions()) {
                         if (this.stackType.equals(action.stackType) && this.stackOrder == action.stackOrder) {
@@ -270,9 +276,11 @@ public class ActionsBase {
                                 return true;
                             }
                         }
+
                         if (sameRank) {
                             if (this.greaterThan && trains <= eff.getTrains())
                                 return true;
+
                             if (this.greaterThanEqual && trains < eff.getTrains())
                                 return true;
                         }
@@ -282,10 +290,12 @@ public class ActionsBase {
             PlayerBonuses bonus = ac.getBonuses();
             if (bonus == null)
                 return false;
+
             SourceType sourceType = null;
             try {
                 sourceType = SourceType.GetSourceType(this.stackType);
             }catch(Exception ignored){
+
             }
             if(sourceType != null && (bonus.getBool(ModType.ImmuneTo,sourceType) || bonus.getBool(ModType.NoMod,sourceType)))
                 return true;
@@ -296,12 +306,16 @@ public class ActionsBase {
                 if(this.stackType.equals("Stun") && pc.getRace().getName().contains("Minotaur"))
                     return true;
             }
+
             if(this.stackType.equals("Stun") && bonus.getBool(ModType.ImmuneTo,SourceType.Stun))
                 return true;
+
             if(pb.vampDrain() && bonus.getBool(ModType.BlockedPowerType, SourceType.VAMPDRAIN))
                 return true;
+
             if (this.stackType.equals("Track") && bonus.getBool(ModType.CannotTrack, SourceType.None))
                 return true;
+
             if (this.stackType.equals("PowerInhibitor") && bonus.getBool(ModType.ImmuneTo, SourceType.Powerblock))
                 return true;
         }