I added a map with a spot of 10 monsters.
Each monster has a ready skill every 3 seconds.
Skill is created by:
const event = map.createDynamicEvent({
x: attacker.position.x,
y: attacker.position.y,
z: 1000,
event: FlyingEyeAttackEvent,
});
Next, I have:
const clearAttackAnimation = (event: RpgEvent) => {
event.stopMoveTo();
event.showAnimation('flying-eye-skill', 'attack', true);
setTimeout(() => {
event.getCurrentMap()?.removeEvent(event.id)
}, 200);
}
and
event.moveTo(victim, {
onStuck: () => clearAttackAnimation(event)
}).subscribe({
complete: () => clearAttackAnimation(event),
});
Also here is the definition of an event:
export default class FlyingEyeAttackEvent extends RpgEvent {
onInit() {
this.speed = Speed.Fastest;
this.setGraphic('flying-eye-skill');
this.through = true;
this.throughOtherPlayer = true;
}
}
It gets laggy very fast. Skill stucks between tiles with collision even though I put this code:
this.through = true;
this.throughOtherPlayer = true;
Is there a simpler way than using RpgEvent
?
I need this because of moveTo(attacker)
method