From 9763d45d204e074d106172f6779b96dfdc899abb Mon Sep 17 00:00:00 2001
From: Jesusaves <cpntb1@ymail.com>
Date: Fri, 21 Feb 2020 00:10:14 -0300
Subject: Doomsday Event Framework (#544)

* Mana Guardian
Common Monster, Level 180
HP: 20,000 ATK: 360~374 EXP: 21,000
DEF: 28 MDEF: 70 Attack Range: 2

Drop List:
| Drop             | DR    |
| ---------------- | ----- |
| Tiny Mana Elixir | 5.00% |
| Silk Robe        | 1.00% |
| Caramel Candy    | 0.20% |
| Silk Gloves      | 0.20% |
| Silk Pants       | 0.15% |
| Golden D. Apple  | 0.05% |
| Paladin's Helmet | 0.01% |

Note: Paladin's Helmet: Unreleased (only Prsm has one)
Def +19, no penalties.

This is part of Doomsday Event (Nov 2019 ~ Jul 2020)
This patch also adds a controller for these event spawns.
---
 world/map/db/mob_db_over_100.txt     |   2 +
 world/map/npc/commands/numa.txt      |  13 ++++
 world/map/npc/functions/doomsday.txt | 140 +++++++++++++++++++++++++++++++++++
 world/map/npc/scripts.conf           |   1 +
 4 files changed, 156 insertions(+)
 create mode 100644 world/map/npc/functions/doomsday.txt

(limited to 'world')

diff --git a/world/map/db/mob_db_over_100.txt b/world/map/db/mob_db_over_100.txt
index cedb4f13..c085904b 100644
--- a/world/map/db/mob_db_over_100.txt
+++ b/world/map/db/mob_db_over_100.txt
@@ -40,3 +40,5 @@
 1135,   LovelyMaggot,           LovelyMaggot,           1,      50,     0,      1,      1,      1,      69,     6969,   0,      5,      5,      5,      1,      0,      6,      5,      1,      1,      1,      3,      21,     133,    200,    1872,   672,    480,    505,    400,    501,    70,     518,    200,    533,    75,     502,    30,     0,      0,     0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0
 1136,   LesserGhost,            LesserGhost,            1,      1,      0,      1,      1,      0,      150,    300,    0,      0,      0,      0,      0,      0,      0,      0,      2,      2,      1,      1,      29,     131,    340,    1800,   672,    950,    0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      4,      20
 1137,   Tormenta,               Tormenta,               200,    18000,  60, 500000,      5000,  5,      360,    374,    48,     90,     1,      32,     60,     255,    255,    255,    31,     30,     1,      0,      69,     181,    210,    1200,   672,    50,     0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0
+//ID,   Name,                   Jname,                  LV,     HP,     SP,     EXP,    JEXP,   Range1, ATK1,   ATK2,   DEF,    MDEF,   STR,    AGI,    VIT,    INT,    DEX,    LUK,    Range2, Range3, Scale,  Race,   Element,Mode,   Speed,  Adelay, Amotion,Dmotion,Drop1id,Drop1per,Drop2id,Drop2%, Drop3id,Drop3%, Drop4id,Drop4%, Drop5id,Drop5%, Drop6id,Drop6%, Drop7id,Drop7%, Drop8id,Drop8%, Item1,  Item2,  MEXP,   ExpPer, MVP1id, MVP1per,MVP2id, MVP2per,MVP3id, MVP3per,mutationcount,mutationstrength
+1138,  ManaGuard,           ManaGuardian,               180,    20000, 280,  21000,      5000,  2,      360,    374,    28,     70,    31,      22,     90,     127,    255,    245,    31,     30,     1,      0,      69,     181,    210,    1200,   672,    50,   759,      1,   5237,     20,   1253,      5,    720,    100,    825,    500,    868,     20,   1172,     15,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0,      0
diff --git a/world/map/npc/commands/numa.txt b/world/map/npc/commands/numa.txt
index 78746a26..5d6f64f0 100644
--- a/world/map/npc/commands/numa.txt
+++ b/world/map/npc/commands/numa.txt
@@ -103,6 +103,7 @@ L_ChooseContinent:
     next;
     menu
         "Argeas", L_Argeas,
+        "World", L_World,
         "Close", L_Return;
 
 L_Argeas:
@@ -121,6 +122,14 @@ L_Woodland:
         "Choose an area", L_Argeas,
         "Close", L_Return;
 
+L_World:
+    mes "Choose an event.";
+    next;
+    menu
+        "Doomsday", L_Doomsday,
+        "Choose a continent", L_ChooseContinent,
+        "Close", L_Return;
+
 L_Return:
     return;
 
@@ -129,4 +138,8 @@ L_Return:
 L_Valia:
     callfunc "IlliaDebug";
     goto L_Return;
+
+L_Doomsday:
+    callfunc "DoomsdayDebug";
+    goto L_Return;
 }
diff --git a/world/map/npc/functions/doomsday.txt b/world/map/npc/functions/doomsday.txt
new file mode 100644
index 00000000..db8eca50
--- /dev/null
+++ b/world/map/npc/functions/doomsday.txt
@@ -0,0 +1,140 @@
+// Evol script
+// Controls Doomsday Event
+//
+// A really long event (months), controlling and being written by
+// every event which happens since doomsday program officialy started
+// in Halloween 2019 with Tormenta's release.
+//
+// This file history is written by GMs and players as the events happen
+// and therefore it is not possible to predict or add code for things which
+// are too far away from happening.
+//
+// Please keep Doomsday System simple.
+// Revert it to anything to stage once it is over.
+// It can be epic. But it doesn't needs to be.
+// But above all, this should NOT affect the merge.
+// The event purpose is to give players background history.
+
+function|script|DoomsdayDebug
+{
+    mes "$DOOMSDAY: "+$DOOMSDAY; // Event Status
+    mes "$DOOMSDAY_CNT: "+$DOOMSDAY_CNT; // Meaning Varies
+    next;
+    // Only GM 80 and above can modify Doomsday
+    // ...Yes, G_ADMIN is 80 while G_SYSOP is 99.
+    if (GM < G_ADMIN) goto L_Close;
+    mes "Setting $DOOMSDAY event state";
+    menu
+        "[0] Tormenta's Seal",L_Seal,
+        "[1] Jande's Army",L_Army,
+        "[-] Close",L_Close;
+
+L_Close:
+    return;
+
+L_Seal:
+    set $DOOMSDAY, 0;
+    donpcevent "Doomsday::OnJanitor";
+    gmlog strcharinfo(0) + " changed doomsday to Act 1: Tormenta's Seal.";
+    return;
+
+L_Army:
+    set $DOOMSDAY, 1;
+    donpcevent "Doomsday::OnJanitor";
+    gmlog strcharinfo(0) + " changed doomsday to Act 2: Jande's Army.";
+    return;
+}
+
+// Doomsday script controller
+-|script|Doomsday|32767
+{
+    close;
+
+// Destroy any artifact as doomsday mode changes
+OnJanitor:
+    // TODO: Kill monsters?
+    setnpctimer 0;
+    stopnpctimer;
+    goto OnInit;
+
+// Check for our current doomsday state
+OnInit:
+    if ($DOOMSDAY == 1)
+        goto L_Doomsday1;
+    // goto L_Check2;
+    end;
+
+L_Doomsday1:
+    // 1138 - Mana Guardian
+    // Argaes Invasion (1)
+    areamonster "017-1", 169, 49, 198, 77, "", 1138, 1, "Doomsday::OnDeathMapname";
+    // Argaes Invasion (2)
+    areamonster "012-1", 20, 47, 74, 77, "", 1138, 3, "Doomsday::OnDeathMapname";
+    // Argaes Invasion (3)
+    areamonster "057-1", 115, 50, 140, 75, "", 1138, 4, "Doomsday::OnDeathMapname";
+    // Kaizei Invasion (I)
+    areamonster "046-1", 58, 49, 92, 70, "", 1138, 2, "Doomsday::OnDeathMapname";
+    // Kaizei Invasion (II)
+    areamonster "034-1", 83, 51, 121, 98, "", 1138, 6, "Doomsday::OnDeathMapname";
+    // Tonori Invasion
+    areamonster "003-4", 20, 20, 85, 60, "", 1138, 7, "Doomsday::OnDeathMapname";
+    end;
+
+L_Doomsday1Respawn:
+    // Argaes Invasion (1)
+    set $@DoomsdayMc, mobcount("017-1", "Doomsday::OnDeathMapname")+1;
+    if ($@DoomsdayMc < 1)
+        areamonster "017-1", 169, 49, 198, 77, "", 1138, 1-$@DoomsdayMc, "Doomsday::OnDeathMapname";
+
+    // Argaes Invasion (2)
+    set $@DoomsdayMc, mobcount("012-1", "Doomsday::OnDeathMapname")+1;
+    if ($@DoomsdayMc < 3)
+        areamonster "012-1", 20, 47, 74, 77, "", 1138, 3-$@DoomsdayMc, "Doomsday::OnDeathMapname";
+
+    // Argaes Invasion (3)
+    set $@DoomsdayMc, mobcount("012-1", "Doomsday::OnDeathMapname")+1;
+    if ($@DoomsdayMc < 4)
+        areamonster "057-1", 115, 50, 140, 75, "", 1138, 4-$@DoomsdayMc, "Doomsday::OnDeathMapname";
+
+    // Kaizei Invasion (I)
+    set $@DoomsdayMc, mobcount("046-1", "Doomsday::OnDeathMapname")+1;
+    if ($@DoomsdayMc < 2)
+        areamonster "046-1", 58, 49, 92, 70, "", 1138, 2-$@DoomsdayMc, "Doomsday::OnDeathMapname";
+
+    // Kaizei Invasion (II)
+    set $@DoomsdayMc, mobcount("034-1", "Doomsday::OnDeathMapname")+1;
+    if ($@DoomsdayMc < 6)
+        areamonster "034-1", 83, 51, 121, 98, "", 1138, 6-$@DoomsdayMc, "Doomsday::OnDeathMapname";
+
+    // Tonori Invasion
+    set $@DoomsdayMc, mobcount("003-4", "Doomsday::OnDeathMapname")+1;
+    if ($@DoomsdayMc < 7)
+        areamonster "003-4", 20, 20, 85, 60, "", 1138, 7-$@DoomsdayMc, "Doomsday::OnDeathMapname";
+    // goto L_TimerCheck2;
+    goto L_TimerFinish;
+
+// Respawn logic (5 minutes)
+OnTimer300000:
+    if ($DOOMSDAY == 1)
+        goto L_Doomsday1Respawn;
+    // goto L_TimerCheck2;
+    goto L_TimerFinish;
+
+// Once all timer checks are over
+L_TimerFinish:
+    set $@DoomsdayMc, 0;
+    setnpctimer 0;
+    stopnpctimer;
+    end;
+
+// Puppet labels
+OnDeathMapname:
+    if ($DOOMSDAY == 1)
+        set $DOOMSDAY_CNT, $DOOMSDAY_CNT+1;
+    startnpctimer;
+    end;
+
+}
+
+
+
diff --git a/world/map/npc/scripts.conf b/world/map/npc/scripts.conf
index e8743cd7..ee63f684 100644
--- a/world/map/npc/scripts.conf
+++ b/world/map/npc/scripts.conf
@@ -5,6 +5,7 @@ npc: npc/functions/banker.txt
 npc: npc/functions/barber.txt
 npc: npc/functions/clear_vars.txt
 npc: npc/functions/dailyquest.txt
+npc: npc/functions/doomsday.txt
 npc: npc/functions/ferry.txt
 npc: npc/functions/miriam.txt
 npc: npc/functions/travelers.txt
-- 
cgit v1.2.3-70-g09d2