From 65fb1748a71755dac5a0e64f97889fa542c6a0c9 Mon Sep 17 00:00:00 2001 From: Jordan Irwin Date: Tue, 9 Jul 2024 00:10:58 -0700 Subject: [PATCH] Add transformation effect to vampires --- data/sprites/entity/overlay/transform.png | Bin 0 -> 380 bytes doc/CHANGES.txt | 1 + doc/contributors.md | 1 + doc/contributors/contributors.json | 4 ++++ doc/sources/graphics-entity.txt | 1 + src/js/stendhal/entity/Creature.ts | 15 +++++++++++++++ src/js/stendhal/entity/RPEntity.ts | 11 +++++++++++ 7 files changed, 33 insertions(+) create mode 100644 data/sprites/entity/overlay/transform.png diff --git a/data/sprites/entity/overlay/transform.png b/data/sprites/entity/overlay/transform.png new file mode 100644 index 0000000000000000000000000000000000000000..0bbcd5b92259f27ac9b5445682a953174971ac1e GIT binary patch literal 380 zcmV-?0fYXDP)w}>z$)tV#h0ak>g zdgY*01$lWVos@JA`+4~71RssVnoL0>MhE{f{LSyC6PYST zpFA{lh8_ecjF8b2Xg7z3qzKn4l+qz!ZPH*Tb~;1+1c+&}9XE@GGc{p^iY;K{Les&RjmvvG!UBWk+>qEy7+5c}v$5Dv-30u2SIiYUH1 zH*SPp=y6V6419l^E<);7KVb8dIZ^cuhVy{^Y|%Z@vXnjCE0p-3JNw)4cFhHEx3_S! atF~`E8h)?jp}H{u0000 diff --git a/doc/contributors/contributors.json b/doc/contributors/contributors.json index 3e90c4f83c..3d9e51f2bc 100644 --- a/doc/contributors/contributors.json +++ b/doc/contributors/contributors.json @@ -4773,6 +4773,10 @@ "fullname": "David Kvistorf", "link": "https://soundcloud.com/david-kvistorf", "link_alt": "https://opengameart.org/users/fluffclipse" + }, + { + "name": "Aidan Walker", + "link": "https://opengameart.org/users/aidanwalker" } ] } diff --git a/doc/sources/graphics-entity.txt b/doc/sources/graphics-entity.txt index 3e2e3eb8d2..5ef5a337da 100644 --- a/doc/sources/graphics-entity.txt +++ b/doc/sources/graphics-entity.txt @@ -773,6 +773,7 @@ flame* DkuCook, Jordan Irwin (AntumDeluge); CC0; https://opengameart.or ice_sparkles* Jordan Irwin (AntumDeluge); OGA BY 3.0 or newer; Stendhal magic_sparkles Rawdanitsu, olonu; CC0; https://opengameart.org/node/18068 necro_flames Wolf W. (Ouren), Jordan Irwin (AntumDeluge); CC BY 3.0; https://opengameart.org/node/45981 +transform Aidan Walker; CC0; https://opengameart.org/node/160840 data/sprites/entity/ratfolk/ diff --git a/src/js/stendhal/entity/Creature.ts b/src/js/stendhal/entity/Creature.ts index 28ac435dcc..7b58ebfbe3 100644 --- a/src/js/stendhal/entity/Creature.ts +++ b/src/js/stendhal/entity/Creature.ts @@ -15,6 +15,8 @@ import { EntityOverlayRegistry } from "../data/EntityOverlayRegistry"; import { Color } from "../data/color/Color"; +import { SkillEffect } from "../sprite/action/SkillEffect"; + declare var marauroa: any; declare var stendhal: any; @@ -53,4 +55,17 @@ export class Creature extends RPEntity { return "url(" + stendhal.paths.sprites + "/cursor/attack.png) 1 3, auto"; } + /** + * Shows a temporary animation overlay for certain entities. + * + * FIXME: does not restore previous overlay + */ + protected override onTransformed() { + if (!this["name"].startsWith("vampire")) { + return; + } + const delay = 100; + const frames = 5; + this.overlay = new SkillEffect("transform", delay, delay * frames); + } } diff --git a/src/js/stendhal/entity/RPEntity.ts b/src/js/stendhal/entity/RPEntity.ts index c131aff7bb..8d33d0a4a0 100644 --- a/src/js/stendhal/entity/RPEntity.ts +++ b/src/js/stendhal/entity/RPEntity.ts @@ -102,6 +102,8 @@ export class RPEntity extends ActiveEntity { this.onLevelChanged(key, value, oldValue); } else if (["title", "name", "class", "type"].indexOf(key) >-1) { this.createTitleTextSprite(); + } else if (key === "subclass" && typeof(oldValue) !== "undefined" && value !== oldValue) { + this.onTransformed(); } } @@ -848,4 +850,13 @@ export class RPEntity extends ActiveEntity { this._target.onAttackStopped(this); } } + + /** + * Called when entity's subclass is changed. + * + * Does nothing in this implementation. + */ + protected onTransformed() { + // do nothing + } }