Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: support custom attack animations via 'attack_ability' item property #577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions assets/dbs/items_db.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -40,6 +41,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand Down Expand Up @@ -68,6 +70,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand Down Expand Up @@ -103,6 +106,7 @@
}
],
"element": "venus",
"attack_ability": "",
"unleash_ability": "titan_blade",
"unleash_rate": 0.35,
"use_ability": "",
Expand All @@ -129,6 +133,7 @@
}
],
"element": "jupiter",
"attack_ability": "",
"unleash_ability": "vorpal_slash",
"unleash_rate": 0.35,
"use_ability": "",
Expand All @@ -153,6 +158,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -176,6 +182,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -199,6 +206,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -222,6 +230,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand Down Expand Up @@ -255,6 +264,7 @@
}
],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -274,6 +284,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "cookie",
Expand All @@ -293,6 +304,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "antidote",
Expand All @@ -312,6 +324,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "elixir",
Expand All @@ -331,6 +344,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "herb",
Expand All @@ -350,6 +364,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "nut",
Expand All @@ -369,6 +384,7 @@
"carry_up_to_30": false,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -388,6 +404,7 @@
"carry_up_to_30": false,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -407,6 +424,7 @@
"carry_up_to_30": false,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -432,6 +450,7 @@
}
],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -458,6 +477,7 @@
}
],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "sarcophagus",
"unleash_rate": 0.35,
"use_ability": "",
Expand Down Expand Up @@ -487,6 +507,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -507,6 +528,7 @@
"carry_up_to_30": false,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "wish_well",
Expand All @@ -527,6 +549,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -551,6 +574,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -575,6 +599,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand Down Expand Up @@ -602,6 +627,7 @@
"quantity": 2,
"operator": "divide"}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand Down Expand Up @@ -630,6 +656,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -654,6 +681,7 @@
"operator": "plus"
}],
"element": "mars",
"attack_ability": "",
"unleash_ability": "flare_burst",
"unleash_rate": 35,
"use_ability": "",
Expand All @@ -679,6 +707,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -700,6 +729,7 @@
"carry_up_to_30": false,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -720,6 +750,7 @@
"carry_up_to_30": false,
"effects": [],
"attribute": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -739,6 +770,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "oil_drop",
Expand All @@ -758,6 +790,7 @@
"carry_up_to_30": true,
"effects": [],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "smoke_bomb",
Expand All @@ -781,6 +814,7 @@
"operator": "plus"
}],
"element": "no_element",
"attack_ability": "",
"unleash_ability": "aura_gloves",
"unleash_rate": 0,
"use_ability": "",
Expand All @@ -800,6 +834,7 @@
"carry_up_to_30": false,
"effects": [],
"attribute": "no_element",
"attack_ability": "",
"unleash_ability": "",
"unleash_rate": 0,
"use_ability": "",
Expand Down
3 changes: 3 additions & 0 deletions base/Item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class Item {
public carry_up_to_30: boolean;
public effects: any;
public element: elements;
public attack_ability: string;
public unleash_ability: string;
public unleash_rate: number;
public use_ability: string;
Expand Down Expand Up @@ -85,6 +86,7 @@ export class Item {
carry_up_to_30,
effects,
element,
attack_ability,
unleash_ability,
unleash_rate,
use_ability,
Expand All @@ -108,6 +110,7 @@ export class Item {
this.carry_up_to_30 = carry_up_to_30;
this.effects = effects;
this.element = element;
this.attack_ability = attack_ability;
this.unleash_ability = unleash_ability;
this.unleash_rate = unleash_rate;
this.use_ability = use_ability;
Expand Down
34 changes: 21 additions & 13 deletions base/battle/Battle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -733,8 +733,8 @@ export class Battle {
//gets item's name in the case this ability is related to an item
let item_name = action.item_slot ? this.data.info.items_list[action.item_slot.key_name].name : "";

//change the current ability to unleash ability from weapon
const unleash_info = await this.check_if_ability_will_unleash(action, ability, item_name);
//change the current ability to custom animation or unleash ability if necessary
const unleash_info = await this.check_weapon_ability(action, ability, item_name);
ability = unleash_info.ability;
item_name = unleash_info.item_name;

Expand Down Expand Up @@ -1237,19 +1237,26 @@ export class Battle {
return ability;
}

async check_if_ability_will_unleash(action: PlayerAbility, ability: Ability, item_name: string) {
if (
action.caster.fighter_type === fighter_types.ALLY &&
ability !== undefined &&
ability.can_switch_to_unleash
) {
async check_weapon_ability(action: PlayerAbility, ability: Ability, item_name: string) {
if (action.caster.fighter_type === fighter_types.ALLY && ability !== undefined) {
const caster = action.caster as MainChar;
if (
caster.equip_slots.weapon &&
this.data.info.items_list[caster.equip_slots.weapon.key_name].unleash_ability
) {
const weapon = this.data.info.items_list[caster.equip_slots.weapon.key_name];
const weapon = this.data.info.items_list[caster.equip_slots.weapon.key_name];

if (!caster.equip_slots.weapon) {
return {
ability: ability,
item_name: item_name,
};
}

if (weapon.attack_ability) {
action.key_name = weapon.attack_ability;
ability = this.data.info.abilities_list[weapon.attack_ability];

await this.set_action_animation_settings(action, ability);
}

if (ability.can_switch_to_unleash && weapon.unleash_ability) {
if (Math.random() < weapon.unleash_rate) {
item_name = weapon.name;
action.key_name = weapon.unleash_ability;
Expand All @@ -1259,6 +1266,7 @@ export class Battle {
}
}
}

return {
ability: ability,
item_name: item_name,
Expand Down
1 change: 1 addition & 0 deletions base/initializers/items.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function initialize_items(game: Phaser.Game, data: GoldenSun, items_db: a
item_data.carry_up_to_30,
item_data.effects,
item_data.element,
item_data.attack_ability,
item_data.unleash_ability,
item_data.unleash_rate,
item_data.use_ability,
Expand Down