mirror of
https://github.com/gooba42/adventureland.git
synced 2026-10-14 18:39:27 -05:00
search for items with consume skill if no item provided
switch snowball to use consume as well
This commit is contained in:
+1
-1
@@ -145,7 +145,7 @@ skills={
|
|||||||
"snowball":{
|
"snowball":{
|
||||||
"type":"skill",
|
"type":"skill",
|
||||||
"skin":"snowball",
|
"skin":"snowball",
|
||||||
"inventory":["snowball"],
|
"consume":"snowball",
|
||||||
"name":"Snowball",
|
"name":"Snowball",
|
||||||
"explanation":"Throw a snowball at someone!",
|
"explanation":"Throw a snowball at someone!",
|
||||||
"condition":"frozen",
|
"condition":"frozen",
|
||||||
|
|||||||
+18
-23
@@ -8216,14 +8216,27 @@ function init_io() {
|
|||||||
|
|
||||||
// Consume item check
|
// Consume item check
|
||||||
if (gSkill.consume) {
|
if (gSkill.consume) {
|
||||||
const item = player.items[data.num]
|
let item;
|
||||||
|
if(data.num === undefined || data.num === null) {
|
||||||
|
// No item was provided, search for one
|
||||||
|
for (let i = player.isize - 1; i >= 0; i--) {
|
||||||
|
const potentialItem = player.items[i]
|
||||||
|
if(!potentialItem) continue
|
||||||
|
if(potentialItem.name !== gSkill.consume) continue
|
||||||
|
|
||||||
|
// We found the item
|
||||||
|
data.num = i
|
||||||
|
item = potentialItem
|
||||||
|
break
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
item = player.items[data.num]
|
||||||
|
}
|
||||||
if (!item || item.name != gSkill.consume) {
|
if (!item || item.name != gSkill.consume) {
|
||||||
return fail_response("skill_cant_item", data.name);
|
return fail_response("skill_cant_item", data.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Can we consume_mp here?
|
|
||||||
|
|
||||||
if ([
|
if ([
|
||||||
"attack",
|
"attack",
|
||||||
"heal",
|
"heal",
|
||||||
@@ -8237,7 +8250,8 @@ function init_io() {
|
|||||||
"zapperzap",
|
"zapperzap",
|
||||||
"burst",
|
"burst",
|
||||||
"piercingshot",
|
"piercingshot",
|
||||||
"selfheal"
|
"selfheal",
|
||||||
|
"snowball"
|
||||||
].includes(data.name)) {
|
].includes(data.name)) {
|
||||||
const attack = commence_attack(player, target, data.name);
|
const attack = commence_attack(player, target, data.name);
|
||||||
if (!attack.failed) {
|
if (!attack.failed) {
|
||||||
@@ -8434,25 +8448,6 @@ function init_io() {
|
|||||||
reject = attack;
|
reject = attack;
|
||||||
cool = false;
|
cool = false;
|
||||||
}
|
}
|
||||||
} else if (data.name == "snowball") {
|
|
||||||
let found = false;
|
|
||||||
for (let i = player.isize - 1; i >= 0; i--) {
|
|
||||||
if (player.items[i] && player.items[i].name == "snowball") {
|
|
||||||
consume_one(player, i);
|
|
||||||
found = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
return fail_response("skill_cant_item", data.name);
|
|
||||||
}
|
|
||||||
const attack = commence_attack(player, target, "snowball");
|
|
||||||
if (!attack.failed) {
|
|
||||||
resolve = attack;
|
|
||||||
} else {
|
|
||||||
reject = attack;
|
|
||||||
cool = false;
|
|
||||||
}
|
|
||||||
} else if (data.name == "entangle" || data.name == "tangle") {
|
} else if (data.name == "entangle" || data.name == "tangle") {
|
||||||
if (target.s.invincible) {
|
if (target.s.invincible) {
|
||||||
return fail_response("target_invincible", data.name);
|
return fail_response("target_invincible", data.name);
|
||||||
|
|||||||
Reference in New Issue
Block a user