From 3bca48abe405c81e76e9de4f8881d0ec394fcc20 Mon Sep 17 00:00:00 2001
From: FatBoy-DOTC <justin.chucksinsulating@gmail.com>
Date: Thu, 20 Mar 2025 19:55:44 -0500
Subject: [PATCH] PvE flagged system

---
 src/engine/gameManager/CombatManager.java |  4 ++
 src/engine/gameManager/PowersManager.java |  9 ++-
 src/engine/objects/PlayerCharacter.java   | 11 ++--
 src/engine/powers/ActionsBase.java        | 77 +++++++++++++++++------
 4 files changed, 73 insertions(+), 28 deletions(-)

diff --git a/src/engine/gameManager/CombatManager.java b/src/engine/gameManager/CombatManager.java
index 51e95243..8017be06 100644
--- a/src/engine/gameManager/CombatManager.java
+++ b/src/engine/gameManager/CombatManager.java
@@ -101,6 +101,10 @@ 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
diff --git a/src/engine/gameManager/PowersManager.java b/src/engine/gameManager/PowersManager.java
index f121bdd3..08488432 100644
--- a/src/engine/gameManager/PowersManager.java
+++ b/src/engine/gameManager/PowersManager.java
@@ -173,8 +173,7 @@ public enum PowersManager {
         if(!pc.isFlying() && powersBaseByToken.get(msg.getPowerUsedID()) != null && powersBaseByToken.get(msg.getPowerUsedID()).isSpell) //cant be sitting if flying
             CombatManager.toggleSit(false,origin);
 
-        if(pc.isMoving())
-            pc.stopMovement(pc.getMovementLoc());
+
         if(msg.getPowerUsedID() != 421084024 && origin.getPlayerCharacter().getPromotionClassID() != 2513) {
             if (!origin.getPlayerCharacter().getPowers().containsKey(msg.getPowerUsedID())) {
                 Logger.error(origin.getPlayerCharacter().getFirstName() + " attempted to cast a power they do not have");
@@ -1094,7 +1093,7 @@ public enum PowersManager {
                     continue;
                 // If something blocks the action, then stop
 
-                if (ab.blocked(target, pb, trains)) {
+                if (ab.blocked(target, pb, trains,playerCharacter)) {
 
                     PowersManager.sendEffectMsg(playerCharacter, 5, ab, pb);
                     continue;
@@ -1281,7 +1280,7 @@ public enum PowersManager {
                     continue;
                 // If something blocks the action, then stop
 
-                if (ab.blocked(target, pb, trains))
+                if (ab.blocked(target, pb, trains,caster))
                     continue;
                 // TODO handle overwrite stack order here
                 String stackType = ab.getStackType();
@@ -1900,7 +1899,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))
+            if (ab.blocked(target, pb, trains,ac))
                 // sendPowerMsg(pc, 5, msg);
                 continue;
             // TODO handle overwrite stack order here
diff --git a/src/engine/objects/PlayerCharacter.java b/src/engine/objects/PlayerCharacter.java
index f42fc281..31d301fc 100644
--- a/src/engine/objects/PlayerCharacter.java
+++ b/src/engine/objects/PlayerCharacter.java
@@ -5145,9 +5145,7 @@ public class PlayerCharacter extends AbstractCharacter {
     @Override
     public void update(Boolean newSystem) {
 
-        if(!newSystem)
-            this.updateLocation();
-
+        this.updateLocation();
         this.updateMovementState();
 
         if(!newSystem)
@@ -5198,8 +5196,11 @@ public class PlayerCharacter extends AbstractCharacter {
                             }
                         }
 
-                        if (this.isBoxed && !this.containsEffect(1672601862)) {
-                            PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, 1672601862, 40, false);
+                        if (this.isBoxed && !this.containsEffect(-654906771)) {
+                            PowersManager.applyPower(this, this, Vector3fImmutable.ZERO, -935138707, 40, false);
+                        }else if(!this.isBoxed && this.containsEffect(-654906771)){
+                            this.effects.remove("PvE-Flagged");
+                            this.effects.remove("1258");
                         }
                     }
                     if (this.isFlying()) {
diff --git a/src/engine/powers/ActionsBase.java b/src/engine/powers/ActionsBase.java
index 5264d18b..4bad4ad6 100644
--- a/src/engine/powers/ActionsBase.java
+++ b/src/engine/powers/ActionsBase.java
@@ -9,6 +9,7 @@
 
 package engine.powers;
 
+import engine.Enum;
 import engine.Enum.ModType;
 import engine.Enum.SourceType;
 import engine.Enum.StackType;
@@ -237,32 +238,72 @@ public class ActionsBase {
     }
 
     //Add blocked types here
-    public boolean blocked(AbstractWorldObject awo, PowersBase pb, int trains) {
+    public boolean blocked(AbstractWorldObject awo, PowersBase pb, int trains, AbstractCharacter source) {
+        if(!pb.getName().contains("Summon")) {
+            if (AbstractWorldObject.IsAbstractCharacter(awo)) {
+                AbstractCharacter target = (AbstractCharacter) awo;
+                if (source.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
+                    PlayerCharacter pc = (PlayerCharacter) source;
+                    if (target.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)) {
+                        if (pc.isBoxed && pc.getObjectUUID() != target.getObjectUUID()) {
+                            return true;
+                        }
+                    }
+                }
+            }
+        }
+        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) {
+                            if (this.stackType.equals("NoStun")) {
+                                return true;
+                            }
+                        }
+                        if (sameRank) {
+                            if (this.greaterThan && trains <= eff.getTrains())
+                                return true;
+                            if (this.greaterThanEqual && trains < eff.getTrains())
+                                return true;
+                        }
+                    }
+                }
+            }
             PlayerBonuses bonus = ac.getBonuses();
             if (bonus == null)
                 return false;
-
-            //TODO make this more efficient then testing strings
-            if (this.stackType.equals("Stun") && bonus.getBool(ModType.ImmuneTo, SourceType.Stun))
-                return true; //Currently stun immune. Skip stun
-            else if (this.stackType.equals("Snare") && bonus.getBool(ModType.ImmuneTo, SourceType.Snare))
-                return true; //Currently snare immune. Skip snare
-            else if (this.stackType.equals("Blindness") && bonus.getBool(ModType.ImmuneTo, SourceType.Blind))
-                return true; //Currently blind immune. Skip blind
-            else if (this.stackType.equals("PowerInhibitor") && bonus.getBool(ModType.ImmuneTo, SourceType.Powerblock))
-                return true; //Currently power block immune. Skip power block
-            else if (this.stackType.equals("Root") && bonus.getBool(ModType.ImmuneTo, SourceType.Root))
+            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;
+            if(ac.getObjectType().equals(Enum.GameObjectType.PlayerCharacter)){
+                PlayerCharacter pc = (PlayerCharacter)ac;
+                if(this.stackType.equals("Blindness") && pc.getRace().getName().contains("Shade"))
+                    return true;
+                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;
-                //			else if (pb.isHeal() && (bonus.getByte("immuneTo.Heal")) >= trains)
-                //				return true; //Currently shadowmantled. Skip heals
-            else if (this.stackType.equals("Flight") && bonus.getBool(ModType.NoMod, SourceType.Fly))
+            if (this.stackType.equals("Track") && bonus.getBool(ModType.CannotTrack, SourceType.None))
                 return true;
-            else if (this.stackType.equals("Track") && bonus.getBool(ModType.CannotTrack, SourceType.None))
+            if (this.stackType.equals("PowerInhibitor") && bonus.getBool(ModType.ImmuneTo, SourceType.Powerblock))
                 return true;
-            else
-                return pb.vampDrain() && bonus.getBool(ModType.BlockedPowerType, SourceType.VAMPDRAIN);
         }
         return false;
     }