Skip to content

Commit

Permalink
fix(client): last target
Browse files Browse the repository at this point in the history
  • Loading branch information
Veradictus committed Sep 17, 2023
1 parent 81849fb commit 4dd3fcc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion packages/client/src/controllers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,10 @@ export default class EntitiesController {
}

// Something went wrong creating the entity.
if (!entity) return log.error(`Failed to create entity ${info.instance}`);
if (!entity) {
console.log(info);
return log.error(`Failed to create entity ${info.instance}`);
}

let sprite = entity.sprite || this.game.sprites.get(`${prefix}/${info.key}`);

Expand Down
3 changes: 3 additions & 0 deletions packages/client/src/controllers/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,9 @@ export default class InputController {
if (this.isAttackable(this.entity)) {
(this.entity as Character).addAttacker(this.player);

// Update the last target to the last clicked attackable entity.
this.player.lastTarget = this.entity.instance;

if (this.player.canAttackTarget())
this.game.socket.send(Packets.Target, [
Opcodes.Target.Attack,
Expand Down
2 changes: 0 additions & 2 deletions packages/client/src/entity/character/character.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,8 +779,6 @@ export default class Character extends Entity {

public setTarget(target: Entity): void {
this.target = target;

this.lastTarget = target.instance;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/server/data/plugins/mobs/piratecaptain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class PirateCaptain extends Default {
// Stop all players from attacking the pirate captain.
this.mob.world.cleanCombat(this.mob);

this.mob.attackRange = 16;
this.mob.attackRange = 11;

// Update the position and teleport the captain with an animation.
this.mob.teleport(position.x, position.y, true);
Expand Down

0 comments on commit 4dd3fcc

Please sign in to comment.