From 14f7af0b7b3839f0e1b35c31bf3bd17e70cf366f Mon Sep 17 00:00:00 2001 From: Jesusaves Date: Sat, 17 Apr 2021 16:07:04 -0300 Subject: Refactor Sagatha functions. Add shear spell (reusing ML code) --- db/pre-re/skill_db.conf | 23 +++++++++++ db/pre-re/skill_tree.conf | 1 + npc/002-1/elanore.txt | 12 ------ npc/013-1/sagatha.txt | 27 ++----------- npc/functions/global_event_handler.txt | 2 +- npc/functions/mob_points.txt | 72 +++++++++++++--------------------- npc/functions/quests.txt | 37 +++++++++++++++++ npc/magic/final.txt | 2 + npc/magic/level2-shear.txt | 54 +++++++++++++++++++++++++ npc/scripts.conf | 2 + 10 files changed, 151 insertions(+), 81 deletions(-) create mode 100644 npc/functions/quests.txt create mode 100644 npc/magic/level2-shear.txt diff --git a/db/pre-re/skill_db.conf b/db/pre-re/skill_db.conf index 54a9a278..b9d6eb2c 100644 --- a/db/pre-re/skill_db.conf +++ b/db/pre-re/skill_db.conf @@ -39331,6 +39331,29 @@ skill_db: ( } } }, +{ + Id: 20055 + Name: "SKILL_CHIPCHIP" + Description: "Chipchip" + MaxLevel: 10 + Range: 1 + SkillType: { + Enemy: true + } + SkillInfo: { + Quest: true + } + Hit: "BDT_SKILL" + AttackType: "Magic" + Element: "Ele_Neutral" + DamageType: { + NoDamage: true + } + CoolDown: 1000 + Requirements: { + SPCost: 23 + } +}, // FlyingBackpack(?) Shear ) diff --git a/db/pre-re/skill_tree.conf b/db/pre-re/skill_tree.conf index 822f5e32..2f08134b 100644 --- a/db/pre-re/skill_tree.conf +++ b/db/pre-re/skill_tree.conf @@ -81,6 +81,7 @@ Talpan: { // Level 2 SKILL_INMA: 9 + SKILL_CHIPCHIP: 9 SKILL_KALAKARENK: 9 SKILL_KALBOO: 9 SKILL_KALGINA: 9 diff --git a/npc/002-1/elanore.txt b/npc/002-1/elanore.txt index 67018a3f..cc9ce146 100644 --- a/npc/002-1/elanore.txt +++ b/npc/002-1/elanore.txt @@ -1,16 +1,4 @@ -function script elanore_decrease_exp { - .@heal_exp = getq2(MagicQuest_Healing); - - if (.@heal_exp < 8) - .@heal_exp = 0; - else - .@heal_exp -= 8; - - setq2(MagicQuest_Healing, .@heal_exp); - return; -} - 002-1,75,62,0 script Elanore#_M NPC108,{ @has_magic = getskilllv(SKILL_MAGIC); diff --git a/npc/013-1/sagatha.txt b/npc/013-1/sagatha.txt index 786da773..702e261c 100644 --- a/npc/013-1/sagatha.txt +++ b/npc/013-1/sagatha.txt @@ -1,26 +1,4 @@ - -function script QuestSagathaHappy { - .@value = getarg(0, @value); - .@unhappiness = (QUEST_MAGIC & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT; - if (.@unhappiness < .@value) - .@unhappiness = 0; - - .@unhappiness = .@unhappiness - .@value; - - QUEST_MAGIC = (QUEST_MAGIC & ~NIBBLE_3_MASK) | (.@unhappiness << NIBBLE_3_SHIFT); - return; -} - -function script QuestSagathaAnnoy { - .@value = getarg(0, @value); - .@unhappiness = (QUEST_MAGIC & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT; - if ((.@unhappiness + .@value) > 15) - .@unhappiness = 15; - - .@unhappiness = .@unhappiness + .@value; - QUEST_MAGIC = (QUEST_MAGIC & ~NIBBLE_3_MASK) | (.@unhappiness << NIBBLE_3_SHIFT); - return; -} +// (C) The Mana World Developers function script SagathaStatus { if (isequippedcnt(MoubooHead, FluffyHat)) @@ -242,7 +220,8 @@ L_Teach_N14: mes "\"Some forest creatures sometimes overgrow their fur or hide. That makes them uncomfortable.\""; next; mesn .@n$; - mesq l("You can help them with shearing magic. Press your hands together and say '" + get(.invocation$, "shear") + "'. Then touch them with your hands, and brush off any excess."); + mesq l("You can help them with shearing magic. Press your hands together and say '%s'. Then touch them with your hands, and brush off any excess.", b("Chipchip")); + learnskill SKILL_CHIPCHIP; next; mesn .@n$; mesq l("The spell is strong, so you only need to do this once. Be careful not to cut them. Some things they shed are useful. Often they will leave them to you as a thank-you."); diff --git a/npc/functions/global_event_handler.txt b/npc/functions/global_event_handler.txt index e832623f..d0014b87 100644 --- a/npc/functions/global_event_handler.txt +++ b/npc/functions/global_event_handler.txt @@ -13,7 +13,7 @@ OnPCLoginEvent: end; OnPCKillEvent: - callfunc "elanore_decrease_exp"; // decrease heal exp for doing bad things + elanore_decrease_exp(); // decrease heal exp for doing bad things end; OnNPCKillEvent: diff --git a/npc/functions/mob_points.txt b/npc/functions/mob_points.txt index 2a39fbee..a9f6f1d4 100644 --- a/npc/functions/mob_points.txt +++ b/npc/functions/mob_points.txt @@ -48,50 +48,34 @@ function script MobPoints { callfunc("AddValonCntMask"); - if ((@mobId == 1003) || (@mobId == 1004) || (@mobId == 1009) || (@mobId == 1057) - || (@mobId == 1104) || (@mobId == 1105) || (@mobId == 1106) || (@mobId == 1107)) - goto L_Good; - - // Attitude adjustment for the witch (can we refactor this to another function? Not sure about max. recursion depth) - - @value = 0; - if (@mobId == 1018) - @value = 3; - - if (@mobId == 1020) - @value = 3; - if (@mobId == 1027) - @value = 3; - if (@mobId == 1028) - @value = 4; - if (@mobId == 1038) - @value = 2; - if (@mobId == 1094) - @value = 3; - if (@mobId == 1112) - @value = 3; - if (@mobId == 1113) - @value = 3; - - if (@value == 0) - goto L_Celestia; - - callfunc "QuestSagathaAnnoy"; - goto L_Celestia; - -L_Good: - @value = 1; - callfunc "QuestSagathaHappy"; - goto L_Celestia; - -L_Celestia: - if (QL_CELESTIA < 5 || QL_CELESTIA >= 205 || @mobId != 1072) goto L_Return; - QL_CELESTIA = QL_CELESTIA + 1; - if (QL_CELESTIA == 205) - message strcharinfo(0), "Yeti : ##3This should be enough yetis killed to please Celestia."; - goto L_Return; + // Attitude adjustment for Sagatha + switch (@mobId) { + case 1018: + case 1020: + case 1027: + case 1094: + case 1112: + case 1113: + QuestSagathaAnnoy(3); break; + case 1028: + QuestSagathaAnnoy(4); break; + case 1038: + QuestSagathaAnnoy(2); break; + case 1003: + case 1004: + case 1009: + case 1057: + case 1104: + case 1105: + case 1106: + case 1107: + QuestSagathaHappy(1); break; + } -L_Return: - @value = 0; + if (QL_CELESTIA >= 5 && QL_CELESTIA < 205 && @mobId == Yeti) { + QL_CELESTIA = QL_CELESTIA + 1; + if (QL_CELESTIA == 205) + message strcharinfo(0), "Yeti : ##3This should be enough yetis killed to please Celestia."; + } return; } diff --git a/npc/functions/quests.txt b/npc/functions/quests.txt new file mode 100644 index 00000000..3f0c40ef --- /dev/null +++ b/npc/functions/quests.txt @@ -0,0 +1,37 @@ +// The Mana World quest functions script + +function script QuestSagathaHappy { + .@value = getarg(0, @value); + .@unhappiness = (QUEST_MAGIC & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT; + if (.@unhappiness < .@value) + .@unhappiness = 0; + + .@unhappiness = .@unhappiness - .@value; + + QUEST_MAGIC = (QUEST_MAGIC & ~NIBBLE_3_MASK) | (.@unhappiness << NIBBLE_3_SHIFT); + return; +} + +function script QuestSagathaAnnoy { + .@value = getarg(0, @value); + .@unhappiness = (QUEST_MAGIC & NIBBLE_3_MASK) >> NIBBLE_3_SHIFT; + if ((.@unhappiness + .@value) > 15) + .@unhappiness = 15; + + .@unhappiness = .@unhappiness + .@value; + QUEST_MAGIC = (QUEST_MAGIC & ~NIBBLE_3_MASK) | (.@unhappiness << NIBBLE_3_SHIFT); + return; +} + +function script elanore_decrease_exp { + .@heal_exp = getq2(MagicQuest_Healing); + + if (.@heal_exp < 8) + .@heal_exp = 0; + else + .@heal_exp -= 8; + + setq2(MagicQuest_Healing, .@heal_exp); + return; +} + diff --git a/npc/magic/final.txt b/npc/magic/final.txt index 78c171b6..87971b65 100644 --- a/npc/magic/final.txt +++ b/npc/magic/final.txt @@ -59,6 +59,8 @@ function script HUB_SkillInvoke { // Level 2 case SKILL_INMA: SK_Inma(); break; + case SKILL_CHIPCHIP: + SK_Shear(); break; case SKILL_KALAKARENK: case SKILL_KALBOO: case SKILL_KALGINA: diff --git a/npc/magic/level2-shear.txt b/npc/magic/level2-shear.txt new file mode 100644 index 00000000..f848b36d --- /dev/null +++ b/npc/magic/level2-shear.txt @@ -0,0 +1,54 @@ +// The Mana World script +// Author: Jesusalva +// +// Magic Script: SKILL_CHIPCHIP (Level 1) +// School: Nature 2 + +function script SK_Shear { + .@mobGD=getarg(0, @skillTarget); + if (.@mobGD <= 0) + return; + + // We only want monsters + if (getunittype(.@mobGD) != UNITTYPE_MOB) { + dispbottom l("This skill can only be used on monsters!"); + return; + } + + // Global data + setarray .@valid, Fluffy, EasterFluffy, SpikyMushroom, Mouboo, MauvePlant, CobaltPlant, GambogePlant, AlizarinPlant, Silkworm, Pinkie; + setarray .@prize, WhiteFur, WhiteFur, HardSpike, CottonCloth, MauveHerb, CoblatHerb, GambogeHerb, AlizarinHerb, SilkCocoon, PinkAntenna; + setarray .@score, 300, 300, 250, 175, 700, 700, 700, 700, 300, 180; + + // Specific data + .@mobID=getunitdata(.@mobGD, UDT_CLASS); + .@matk=AdjustSpellpower(40+(10*@skillLv)); + .@idx=array_find(.@valid, .@mobID); + + // Invalid target + if (.@idx < 0) return; + + // Not yet sheared + if (array_rfind(@shear, .@mobGD) < 0) { + array_push(@shear, @mobGD); + if (.@matk > .@score[.@idx]) + getitem .@prize[.@idx], 1; + } + + // Sagratha bonus + if (.@mobId == Fluffy || .@mobId == Mouboo || .@mobId == Pinkie) + QuestSagathaHappy(any(true, true, false)); + + // Special effect + specialeffect(FX_MAGIC_SHEAR_CAST, AREA, getcharid(3)); + specialeffect(FX_MAGIC_SHEAR_CAST, AREA, .@mobGD); + + // Truncate. + // We're saving the GID so it must be "big enough" + // But not too big so rfind() is not expensive + if (getarraysize(@study) > 99) { + deletearray(@study, 30); + } + return; +} + diff --git a/npc/scripts.conf b/npc/scripts.conf index c975d301..7f3980e6 100644 --- a/npc/scripts.conf +++ b/npc/scripts.conf @@ -19,6 +19,7 @@ "npc/functions/inc_sc_bonus.txt", "npc/commands/kami.txt", "npc/functions/filters.txt", +"npc/functions/quests.txt", // Main Functions "npc/functions/banker.txt", @@ -85,6 +86,7 @@ "npc/magic/level2-magic-knuckles.txt", "npc/magic/level2-protect.txt", "npc/magic/level2-rain.txt", +"npc/magic/level2-shear.txt", "npc/magic/level2-summon-monsters.txt", "npc/magic/level2-toxic-dart.txt", "npc/magic/final.txt", -- cgit v1.2.3-60-g2f50