Všechna monstra, dynamický targeting. Bugfixy u monster.
This commit is contained in:
parent
55fd052072
commit
4fdff0a0cc
18 changed files with 345 additions and 43 deletions
|
|
@ -19,14 +19,18 @@ public class LurkEnemy : Enemy {
|
|||
// private double movementChance => (2 + Math.Pow(1.5f, Difficulty)) / CHANCE_DENOMINATOR; // chance scales exponentially using a constant multiplier
|
||||
|
||||
private MovementOpportunity movementOpportunity;
|
||||
|
||||
public ServerPlayer? Target{ get; set; }
|
||||
|
||||
public LurkEnemy(int difficulty) : base(difficulty) {
|
||||
pathfinder = new LurkPathfinder(this, 1);
|
||||
movementOpportunity = new MovementOpportunity(5000);
|
||||
Target = null;
|
||||
SetDifficulty(difficulty);
|
||||
}
|
||||
public override void Spawn(MapTile location) {
|
||||
base.Spawn(location);
|
||||
// stopwatch.Start();
|
||||
movementOpportunity = new MovementOpportunity(5000, ((2 + Math.Pow(1.5f, Difficulty)) * Math.Sign(Difficulty)) / (2 + Math.Pow(1.5f, 10)));
|
||||
movementOpportunity.Start();
|
||||
pathfinder.takenPath.Add(Location);
|
||||
Server.SendUpdateToAll([GameEvent.ENEMY_SPAWN(TypeId, Id, Difficulty, Location.Id)]);
|
||||
|
|
@ -35,17 +39,34 @@ public class LurkEnemy : Enemy {
|
|||
public override void Reset() {
|
||||
pathfinder.takenPath.Clear();
|
||||
pathfinder.takenPath.Add(Location);
|
||||
|
||||
Target.state.power -= 30;
|
||||
|
||||
MapTile[] resetLocations = new[]{MapManager.Get(7), MapManager.Get(12), MapManager.Get(17)}.Where(t => EnemyManager.GetByLocation(t).Length == 0).ToArray();
|
||||
Location = resetLocations[new Random().Next(resetLocations.Length)];
|
||||
Server.SendUpdateToAll([GameEvent.ENEMY_RESET(Id, Location.Id)]);
|
||||
}
|
||||
|
||||
public override void SetDifficulty(int difficulty) {
|
||||
Difficulty = difficulty;
|
||||
movementOpportunity.MovementChance = ((2 + Math.Pow(1.5f, Difficulty)) * Math.Sign(Difficulty)) / (2 + Math.Pow(1.5f, 10));
|
||||
}
|
||||
|
||||
public override void Update() {
|
||||
base.Update();
|
||||
|
||||
if (movementOpportunity.CheckAndRoll()){
|
||||
Pathfinder.Decision decision = pathfinder.DecideNext(MapManager.Get(10));
|
||||
if (Server.P1.state.power > Server.P2.state.power){
|
||||
Target = Server.P1;
|
||||
}
|
||||
else if (Server.P1.state.power < Server.P2.state.power){
|
||||
Target = Server.P2;
|
||||
}
|
||||
else{
|
||||
return;
|
||||
}
|
||||
|
||||
Pathfinder.Decision decision = pathfinder.DecideNext(MapManager.Get(Target.state.officeTileId));
|
||||
switch (decision.type){
|
||||
case Pathfinder.Decision.MoveType:
|
||||
Location = decision.nextTile!;
|
||||
|
|
@ -65,10 +86,6 @@ public class LurkEnemy : Enemy {
|
|||
}
|
||||
|
||||
private class LurkPathfinder : RoamingPathfinder {
|
||||
// public override List<MapTile> FindPath(MapTile start, MapTile end) {
|
||||
// throw new NotImplementedException();
|
||||
// }
|
||||
|
||||
private Random random = new();
|
||||
|
||||
private int tolerance;
|
||||
|
|
@ -88,8 +105,8 @@ public class LurkEnemy : Enemy {
|
|||
if (Enemy.Location.GetConnector(goal)!.Blocked){
|
||||
return Decision.Reset();
|
||||
}
|
||||
|
||||
return Decision.Attack(Server.P1); // TODO: un-hardcode this
|
||||
|
||||
return Decision.Attack(((LurkEnemy)Enemy).Target);
|
||||
}
|
||||
|
||||
if (closerTiles.Count != 0 && closerTiles.All(t => takenPath.Contains(t))){
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue