From 8c775d55084fb07732d765be2a803e69d14b9bd4 Mon Sep 17 00:00:00 2001
From: "hoang.tran12" <99.hoangtran@gmail.com>
Date: Thu, 12 Sep 2024 23:10:50 +0700
Subject: [PATCH] teemo R bounced
---
src/game/gameObject/spells/Teemo_R.js | 53 +++++++++++++++++++++++----
1 file changed, 46 insertions(+), 7 deletions(-)
diff --git a/src/game/gameObject/spells/Teemo_R.js b/src/game/gameObject/spells/Teemo_R.js
index 0719755..b206a81 100644
--- a/src/game/gameObject/spells/Teemo_R.js
+++ b/src/game/gameObject/spells/Teemo_R.js
@@ -11,7 +11,7 @@ export default class Teemo_R extends Spell {
image = AssetManager.getAsset('spell_teemo_r');
name = 'Bẫy Độc Noxus (Teemo_R)';
description =
- 'Đặt 1 bẫy độc tàng hình sau 1 giây, tồn tại trong 20 giây, phát nổ khi kẻ địch dẫm phải, Làm Chậm 70% các kẻ địch trong 2 giây và gây 30 sát thương';
+ 'Đặt 1 bẫy độc tàng hình sau 1 giây, tồn tại trong 20 giây, phát nổ khi kẻ địch dẫm phải, Làm Chậm 70% các kẻ địch trong 2 giây và gây 30 sát thương (sẽ nảy nếu đặt trên bẫy độc khác)';
coolDown = 3000;
@@ -33,6 +33,7 @@ export default class Teemo_R extends Spell {
obj.invisibleAfter = invisibleAfter;
obj.lifeTime = lifeTime;
obj.explodeRange = explodeRange;
+ obj.throwRange = throwRange;
this.game.objectManager.addObject(obj);
}
@@ -54,8 +55,11 @@ export class Teemo_R_Object extends SpellObject {
moveSpeed = 6;
explodeRange = 200;
explodeLifeTime = 1500;
+ throwRange = 100;
+ bouncedOn = [];
size = 50;
+ curSize = this.size;
angle = 0;
mushroom_spots = [
{ x: 0, y: 0, r: 16 },
@@ -73,14 +77,48 @@ export class Teemo_R_Object extends SpellObject {
phase = Teemo_R_Object.PHASES.MOVING;
update() {
+ if (!this.originalPosition) {
+ this.originalPosition = this.position.copy();
+ }
+
+ // update size
+ this.curSize = lerp(this.curSize, this.size, 0.1);
+
// moving phase
if (this.phase === Teemo_R_Object.PHASES.MOVING) {
VectorUtils.moveVectorToVector(this.position, this.destination, this.moveSpeed);
if (this.position.dist(this.destination) < this.moveSpeed) {
- this.position = this.destination.copy();
- this.isMissile = false; // yasuo W cant block this
- this.phase = Teemo_R_Object.PHASES.INVISIBLE;
+ // check collide with other teemo R
+ let others = this.game.objectManager.queryObjects({
+ area: new Circle({
+ x: this.destination.x,
+ y: this.destination.y,
+ r: this.size / 2,
+ }),
+ filters: [
+ o =>
+ o instanceof Teemo_R_Object &&
+ o.phase === Teemo_R_Object.PHASES.INVISIBLE &&
+ o !== this &&
+ this.bouncedOn.indexOf(o) === -1,
+ ],
+ });
+ if (others?.length > 0) {
+ const newDest = VectorUtils.moveVectorToVector(
+ this.originalPosition,
+ this.destination,
+ this.throwRange * 2
+ );
+ this.originalPosition = this.position.copy();
+ this.destination = newDest.copy();
+ this.bouncedOn.push(others[0]);
+ this.curSize = this.size + 10;
+ } else {
+ this.position = this.destination.copy();
+ this.isMissile = false; // yasuo W cant block this
+ this.phase = Teemo_R_Object.PHASES.INVISIBLE;
+ }
}
}
@@ -150,11 +188,12 @@ export class Teemo_R_Object extends SpellObject {
let alpha =
this.phase === Teemo_R_Object.PHASES.INVISIBLE && this.age > this.invisibleAfter ? 25 : 255;
push();
- // stroke(100, alpha);
- noStroke();
+ stroke(150, alpha);
+ strokeWeight(this.curSize - this.size);
fill(40, 97, 40, alpha);
- circle(this.position.x, this.position.y, this.size);
+ circle(this.position.x, this.position.y, this.curSize);
+ noStroke();
fill(114, 63, 127, alpha);
for (let spot of this.mushroom_spots) {
let x = spot.x * cos(this.angle) - spot.y * sin(this.angle);