forked from MagicBane/Server
				
			
				 16 changed files with 190 additions and 11 deletions
			
			
		| @ -1,8 +0,0 @@@@ -1,8 +0,0 @@ | ||||
| { | ||||
| 	"folders": [ | ||||
| 		{ | ||||
| 			"path": "." | ||||
| 		} | ||||
| 	], | ||||
| 	"settings": {} | ||||
| } | ||||
| @ -0,0 +1,42 @@@@ -0,0 +1,42 @@ | ||||
| package engine.jobs; | ||||
| 
 | ||||
| import engine.job.AbstractJob; | ||||
| import engine.objects.AbstractCharacter; | ||||
| import engine.math.Vector3fImmutable; | ||||
| import engine.server.MBServerStatics; | ||||
| 
 | ||||
| import java.util.Random; | ||||
| 
 | ||||
| public class FearWanderJob extends AbstractJob { | ||||
|     private final AbstractCharacter target; | ||||
|     private final Random rand = new Random(); | ||||
| 
 | ||||
|     public FearWanderJob(AbstractCharacter target) { | ||||
|         super(); | ||||
|         this.target = target; | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void doJob() { | ||||
|         // Only wander if still feared
 | ||||
|         if (target == null || !target.getBonuses().getBool(engine.Enum.ModType.Fear, engine.Enum.SourceType.None)) | ||||
|             return; | ||||
| 
 | ||||
|         // Pick a random direction and distance
 | ||||
|         float angle = rand.nextFloat() * (float)Math.PI * 2f; | ||||
|         float distance = 5f + rand.nextFloat() * 10f; // 5-15 units
 | ||||
| 
 | ||||
|         Vector3fImmutable current = target.getLoc(); | ||||
|         float newX = current.x + (float)Math.cos(angle) * distance; | ||||
|         float newZ = current.z + (float)Math.sin(angle) * distance; | ||||
| 
 | ||||
|         // Clamp to world bounds if needed
 | ||||
|         newX = (float) Math.max(0, Math.min(newX, MBServerStatics.MAX_WORLD_WIDTH)); | ||||
|         newZ = (float) Math.max(0, Math.min(newZ, MBServerStatics.MAX_WORLD_HEIGHT)); | ||||
| 
 | ||||
|         Vector3fImmutable dest = new Vector3fImmutable(newX, current.y, newZ); | ||||
| 
 | ||||
|         // Issue movement (implement setEndLoc or similar in your AbstractCharacter)
 | ||||
|         target.setEndLoc(dest); | ||||
|     } | ||||
| } | ||||
| @ -0,0 +1,58 @@@@ -0,0 +1,58 @@ | ||||
| // • ▌ ▄ ·.  ▄▄▄·  ▄▄ • ▪   ▄▄· ▄▄▄▄·  ▄▄▄·  ▐▄▄▄  ▄▄▄ .
 | ||||
| // ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌·
 | ||||
| // ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀
 | ||||
| // ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌
 | ||||
| // ▀▀  █▪▀▀▀ ▀  ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀  ▀  ▀ ▀▀  █▪ ▀▀▀
 | ||||
| //      Magicbane Emulator Project © 2013 - 2022
 | ||||
| //                www.magicbane.com
 | ||||
| 
 | ||||
| 
 | ||||
| package engine.powers.effectmodifiers; | ||||
| 
 | ||||
| import engine.Enum.GameObjectType; | ||||
| import engine.Enum.ModType; | ||||
| import engine.Enum.SourceType; | ||||
| import engine.jobs.FearWanderJob; | ||||
| import engine.job.JobContainer; | ||||
| import engine.job.JobScheduler; | ||||
| import engine.jobs.AbstractEffectJob; | ||||
| import engine.objects.*; | ||||
| 
 | ||||
| import java.sql.ResultSet; | ||||
| import java.sql.SQLException; | ||||
| 
 | ||||
| public class FearEffectModifier extends AbstractEffectModifier { | ||||
| 
 | ||||
|     public FearEffectModifier(ResultSet rs) throws SQLException { | ||||
|         super(rs); | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     protected void _applyEffectModifier(AbstractCharacter source, AbstractWorldObject awo, int trains, AbstractEffectJob effect) { | ||||
|         // Optional: custom logic when fear is applied
 | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void applyBonus(AbstractCharacter ac, int trains) { | ||||
|         PlayerBonuses bonus = ac.getBonuses(); | ||||
| 
 | ||||
|         bonus.setBool(this.modType, this.sourceType, true); | ||||
|         ac.cancelOnFear(); | ||||
|         ac.setIsCasting(false); | ||||
|         ac.stopMovement(ac.getLoc()); | ||||
|          | ||||
|         // Schedule the wander job if not already scheduled
 | ||||
|         if (ac.getTimers().get("FearWander") == null) { | ||||
|             JobContainer wanderJob = JobScheduler.getInstance().scheduleJob( | ||||
|                 new FearWanderJob(ac), 2000 | ||||
|             ); | ||||
| 
 | ||||
|             ac.getTimers().put("FearWander", wanderJob); | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     @Override | ||||
|     public void applyBonus(Item item, int trains) {} | ||||
|     @Override | ||||
|     public void applyBonus(Building building, int trains) {} | ||||
| } | ||||
					Loading…
					
					
				
		Reference in new issue