Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions Maple2.Server.Game/Model/Field/Actor/Actor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,27 @@ public virtual void ApplyEffect(IActor caster, IActor owner, SkillEffectMetadata
}

public virtual void ApplyDamage(IActor caster, DamageRecord damage, SkillMetadataAttack attack) {
// Determine the source position.
// For region/trigger skills, the caster is FieldActor at origin - use damage.Position (the skill region's position) instead.
Vector3 sourcePosition = caster.Position;
if (sourcePosition.LengthSquared() < 0.001f && damage.Position.LengthSquared() > 0.001f) {
sourcePosition = damage.Position;
}

var targetRecord = new DamageRecordTarget(this) {
Position = caster.Position,
Direction = caster.Rotation, // Idk why this is wrong
Position = sourcePosition,
Direction = caster.Transform.FrontAxis,
};

if (attack.Damage.Push != null) {
// Direction should point from source toward the target (the push direction).
Vector3 offset = Position - sourcePosition;
if (offset.LengthSquared() > 0.001f) {
targetRecord.Direction = Vector3.Normalize(offset);
} else if (damage.Direction.LengthSquared() > 0.001f) {
targetRecord.Direction = Vector3.Normalize(damage.Direction);
}
}
damage.Targets.TryAdd(ObjectId, targetRecord);

if (attack.Damage.Count <= 0) {
Expand Down
3 changes: 2 additions & 1 deletion Maple2.Server.Game/Model/Field/Entity/FieldSkill.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ public override void Update(long tickCount) {
SkillMetadataAttack attack = record.Attack;
record.TargetUid++;
var damage = new DamageRecord(record.Metadata, attack) {
CasterId = Caster.ObjectId,
CasterId = ObjectId,
OwnerId = ObjectId,
SkillId = Value.Id,
Level = Value.Level,
MotionPoint = record.MotionPoint,
AttackPoint = record.AttackPoint,
Position = Position,
Direction = Rotation,
};
var targetRecords = new List<TargetRecord>();
Expand Down
2 changes: 1 addition & 1 deletion Maple2.Server.Game/Packets/RegionSkillPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public static ByteWriter Add(FieldSkill fieldSkill) {
var pWriter = Packet.Of(SendOp.RegionSkill);
pWriter.Write<Command>(Command.Add);
pWriter.WriteInt(fieldSkill.ObjectId);
pWriter.WriteInt(fieldSkill.Caster.ObjectId);
pWriter.WriteInt(fieldSkill.ObjectId);
pWriter.WriteInt(fieldSkill.NextTick.Truncate32());
pWriter.WriteByte((byte) fieldSkill.Points.Length);
foreach (Vector3 point in fieldSkill.Points) {
Expand Down
Loading