Skip to content

Commit

Permalink
CHG disable NPC level in network packet like in vanilla
Browse files Browse the repository at this point in the history
  • Loading branch information
MeikelLP committed Oct 22, 2023
1 parent 85d5994 commit a16a030
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions Executables/Game/World/Entities/MonsterEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ public override byte HealthPercentage {
}

public MonsterData Proto { get { return _proto; } }

public MonsterGroup Group { get; set; }

private readonly MonsterData _proto;
private IBehaviour _behaviour;
private bool _behaviourInitialized;
private double _deadTime = 5000;
public MonsterEntity(IMonsterManager monsterManager, IAnimationManager animationManager, IWorld world, ILogger logger, uint id, int x, int y, float rotation = 0)

public MonsterEntity(IMonsterManager monsterManager, IAnimationManager animationManager, IWorld world, ILogger logger, uint id, int x, int y, float rotation = 0)
: base(animationManager, world.GenerateVid())
{
_logger = logger;
Expand All @@ -48,7 +48,7 @@ public MonsterEntity(IMonsterManager monsterManager, IAnimationManager animation
Rotation = rotation;

MovementSpeed = (byte) _proto.MoveSpeed;

Health = _proto.Hp;
EntityClass = id;

Expand All @@ -73,7 +73,7 @@ public async override Task Update(double elapsedTime)
await Map.DespawnEntity(this);
}
}

if (!_behaviourInitialized)
{
_behaviour?.Init(this);
Expand All @@ -91,9 +91,9 @@ public async override Task Update(double elapsedTime)
public override async Task Goto(int x, int y)
{
Rotation = (float) MathUtils.Rotation(x - PositionX, y - PositionY);

await base.Goto(x, y);

// Send movement to nearby players
var movement = new CharacterMoveOut {
Vid = Vid,
Expand Down Expand Up @@ -188,7 +188,7 @@ public override async ValueTask Die()
{
return;
}

await base.Die();

var dead = new CharacterDead { Vid = Vid };
Expand All @@ -204,7 +204,7 @@ await ForEachNearbyEntity(async entity =>
protected override ValueTask OnNewNearbyEntity(IEntity entity)
{
_behaviour?.OnNewNearbyEntity(entity);

return ValueTask.CompletedTask;
}

Expand All @@ -223,7 +223,7 @@ public override ValueTask OnDespawn()
(Map as Map)?.EnqueueGroupRespawn(Group);
}
}

return ValueTask.CompletedTask;
}

Expand All @@ -233,7 +233,7 @@ public override async Task ShowEntity(IConnection connection)
{
return; // no need to send dead entities to new players
}

await connection.Send(new SpawnCharacter
{
Vid = Vid,
Expand All @@ -252,12 +252,12 @@ await connection.Send(new SpawnCharacter
await connection.Send(new CharacterInfo {
Vid = Vid,
Empire = _proto.Empire,
Level = _proto.Level,
Level = 0,
Name = _proto.TranslatedName
});
}
}

public async override Task HideEntity(IConnection connection)
{
await connection.Send(new RemoveCharacter
Expand All @@ -271,4 +271,4 @@ public override string ToString()
return $"{_proto.TranslatedName.Trim((char) 0x00)} ({_proto.Id})";
}
}
}
}

0 comments on commit a16a030

Please sign in to comment.