Working on projectiles
This commit is contained in:
@@ -3617,7 +3617,10 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
sourceId = e.SourceId,
|
||||
targetType = e.TargetType.ToString().ToLower(),
|
||||
targetId = e.TargetId,
|
||||
damage = e.Damage
|
||||
damage = e.Damage,
|
||||
damageTypeKey = e.DamageTypeKey,
|
||||
wasResisted = e.WasResisted,
|
||||
wasWeakness = e.WasWeakness
|
||||
}),
|
||||
deaths = tickResult.DeathEvents.Select(e => new
|
||||
{
|
||||
@@ -3628,6 +3631,21 @@ public sealed partial class DungeonHandler : IClientMessageHandler
|
||||
killerId = e.KillerId,
|
||||
killerName = e.KillerName,
|
||||
xp = e.XpReward
|
||||
}),
|
||||
projectileHits = tickResult.ProjectileHitEvents.Select(e => new
|
||||
{
|
||||
projectileId = e.ProjectileId,
|
||||
targetType = e.TargetType.ToString().ToLower(),
|
||||
targetId = e.TargetId,
|
||||
x = e.X,
|
||||
y = e.Y
|
||||
}),
|
||||
projectileExpired = tickResult.ProjectileExpiredEvents.Select(e => new
|
||||
{
|
||||
projectileId = e.ProjectileId,
|
||||
x = e.X,
|
||||
y = e.Y,
|
||||
reason = e.Reason
|
||||
})
|
||||
},
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ public partial class DungeonSimulation
|
||||
private readonly List<DamageEvent> _pendingDamageEvents = new();
|
||||
private readonly List<DeathEvent> _pendingDeathEvents = new();
|
||||
private readonly List<AbilityEvent> _pendingAbilityEvents = new();
|
||||
private readonly List<ProjectileHitEvent> _pendingProjectileHitEvents = new();
|
||||
private readonly List<ProjectileExpiredEvent> _pendingProjectileExpiredEvents = new();
|
||||
|
||||
private int _nextDroppedItemId = 1;
|
||||
private readonly Dictionary<int, DungeonMobDefinition> _mobDefinitions;
|
||||
@@ -332,6 +334,8 @@ public partial class DungeonSimulation
|
||||
_pendingDamageEvents.Clear();
|
||||
_pendingDeathEvents.Clear();
|
||||
_pendingAbilityEvents.Clear();
|
||||
_pendingProjectileHitEvents.Clear();
|
||||
_pendingProjectileExpiredEvents.Clear();
|
||||
|
||||
// Update all mobs (AI)
|
||||
foreach (var mob in Mobs.Values.Where(m => m.IsAlive))
|
||||
@@ -377,6 +381,8 @@ public partial class DungeonSimulation
|
||||
DamageEvents = new List<DamageEvent>(_pendingDamageEvents),
|
||||
DeathEvents = new List<DeathEvent>(_pendingDeathEvents),
|
||||
AbilityEvents = new List<AbilityEvent>(_pendingAbilityEvents),
|
||||
ProjectileHitEvents = new List<ProjectileHitEvent>(_pendingProjectileHitEvents),
|
||||
ProjectileExpiredEvents = new List<ProjectileExpiredEvent>(_pendingProjectileExpiredEvents),
|
||||
Phase = Phase
|
||||
};
|
||||
}
|
||||
@@ -538,6 +544,13 @@ public partial class DungeonSimulation
|
||||
// Check max range
|
||||
if (projectile.MaxRange > 0 && projectile.DistanceTraveled > projectile.MaxRange)
|
||||
{
|
||||
_pendingProjectileExpiredEvents.Add(new ProjectileExpiredEvent
|
||||
{
|
||||
ProjectileId = projectile.Id,
|
||||
X = projectile.X,
|
||||
Y = projectile.Y,
|
||||
Reason = "range"
|
||||
});
|
||||
toRemove.Add(projectile.Id);
|
||||
continue;
|
||||
}
|
||||
@@ -621,6 +634,16 @@ public partial class DungeonSimulation
|
||||
});
|
||||
}
|
||||
|
||||
// Add projectile hit event
|
||||
_pendingProjectileHitEvents.Add(new ProjectileHitEvent
|
||||
{
|
||||
ProjectileId = projectile.Id,
|
||||
TargetType = EntityType.Mob,
|
||||
TargetId = mob.Id,
|
||||
X = projectile.X,
|
||||
Y = projectile.Y
|
||||
});
|
||||
|
||||
toRemove.Add(projectile.Id);
|
||||
break;
|
||||
}
|
||||
@@ -650,6 +673,17 @@ public partial class DungeonSimulation
|
||||
ApplyDamageToPlayer(sourceMob, player, result.FinalDamage, projectile.DamageTypeKey, result.WasResisted, result.WasWeakness);
|
||||
}
|
||||
}
|
||||
|
||||
// Add projectile hit event
|
||||
_pendingProjectileHitEvents.Add(new ProjectileHitEvent
|
||||
{
|
||||
ProjectileId = projectile.Id,
|
||||
TargetType = EntityType.Player,
|
||||
TargetId = (int)player.CharacterId,
|
||||
X = projectile.X,
|
||||
Y = projectile.Y
|
||||
});
|
||||
|
||||
toRemove.Add(projectile.Id);
|
||||
break;
|
||||
}
|
||||
@@ -663,6 +697,14 @@ public partial class DungeonSimulation
|
||||
{
|
||||
ProcessAoeAbilityAtLocation(projectile, projectile.X, projectile.Y);
|
||||
}
|
||||
|
||||
_pendingProjectileExpiredEvents.Add(new ProjectileExpiredEvent
|
||||
{
|
||||
ProjectileId = projectile.Id,
|
||||
X = projectile.X,
|
||||
Y = projectile.Y,
|
||||
Reason = "wall"
|
||||
});
|
||||
toRemove.Add(projectile.Id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,8 @@ public class TickResult
|
||||
public List<DamageEvent> DamageEvents { get; set; } = new();
|
||||
public List<DeathEvent> DeathEvents { get; set; } = new();
|
||||
public List<AbilityEvent> AbilityEvents { get; set; } = new();
|
||||
public List<ProjectileHitEvent> ProjectileHitEvents { get; set; } = new();
|
||||
public List<ProjectileExpiredEvent> ProjectileExpiredEvents { get; set; } = new();
|
||||
public DungeonPhase Phase { get; set; }
|
||||
}
|
||||
|
||||
@@ -54,3 +56,20 @@ public enum EntityType
|
||||
Mob,
|
||||
Chest
|
||||
}
|
||||
|
||||
public class ProjectileHitEvent
|
||||
{
|
||||
public int ProjectileId { get; set; }
|
||||
public EntityType TargetType { get; set; }
|
||||
public int TargetId { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
}
|
||||
|
||||
public class ProjectileExpiredEvent
|
||||
{
|
||||
public int ProjectileId { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public string Reason { get; set; } = "range"; // "range", "wall", or "hit"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user