From 94e89ea8b310adb2087bcca2f40dd4ace5142341 Mon Sep 17 00:00:00 2001
From: Jesusaves <cpntb1@ymail.com>
Date: Sat, 15 Jan 2022 10:54:48 -0300
Subject: Hocus Commands. Might be more fun with three colors, maybe?
 :thinking_face:

---
 npc/001-14/ctrl.txt  | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 npc/001-14/hocus.txt |   2 +-
 2 files changed, 153 insertions(+), 2 deletions(-)

diff --git a/npc/001-14/ctrl.txt b/npc/001-14/ctrl.txt
index 5f1ae2481..e76421cc0 100644
--- a/npc/001-14/ctrl.txt
+++ b/npc/001-14/ctrl.txt
@@ -38,6 +38,7 @@ OnInit:
     if (askyesno() == ASK_NO) close;
     @moly_tick = gettimetick(2) + 60;
     @moly_score = 0;
+    @moly_chall = 1;
     .m$=getmap();
     @map$=getmap();
     .@m=areamonster(.m$, 108, 43, 118, 48, "Target", YellowSpark, 1, "Hocus#MOLY0100::OnClick");
@@ -76,6 +77,7 @@ OnTimer60000:
 
 OnClick:
     if (gettimetick(2) > @moly_tick) end;
+    if (@moly_chall != 1) end;
     @moly_score+=1;
     .@m=areamonster(@map$, 108, 43, 118, 48, "Target", YellowSpark, 1, "Hocus#MOLY0100::OnClick");
     .@hp=rand2(50, 100);
@@ -106,15 +108,18 @@ OnCheck:
             @moly_tick = 0;
             dispbottom col(l("You have been disqualified - illegal weapon: %s", getitemname(.@wp)), 1);
             stopnpctimer;
+            killmonsterall(getmap());
             end;
     }
     addtimer 2000, instance_npcname("Hocus#MOLY0100")+"::OnCheck";
     end;
 
 OnEnd:
+    if (@moly_chall != 1) end;
     dispbottom l("End! Score this time: %d", @moly_score);
     FYMOLY_ENBALL = max(FYMOLY_ENBALL, @moly_score);
     @moly_score = 0;
+    @moly_chall = 0;
     end;
 
 OnInit:
@@ -219,11 +224,157 @@ OnInit:
 
 // FIXME
 001-14,37,84,0	script	Hocus#MOLY0900	NPC_BLACKWIZARD,{
-    npctalk l("Hocus Said So Challenge");
+    mes ".:: " + l("Hocus Said So Challenge") + ":: .";
+    mes l("Description: There'll be differently colored sparks and you must kill ONLY those of the color I say so! Failure to do so will cause immediate disqualification!");
+    mesc l("PS. No equipment restriction");
+    mes "";
+    mesc l("Your progress thus far: %s sparks killed", fnum(FYMOLY_HOCUSM)), 3;
+    next;
+    mesc l("Begin campaign?"), 1;
+    if (askyesno() == ASK_NO) close;
+    @moly_tick = gettimetick(2) + 60;
+    @moly_score = 0;
+    @moly_chall = 9;
+    .m$=getmap();
+    @map$=getmap();
+    .@m=areamonster(.m$, 38, 85, 40, 90, strmobinfo(1, YellowSpark), YellowSpark, 1, "Hocus#MOLY0900::OnClY");
+    setunitdata(.@m, UDT_HP, 1);
+    setunitdata(.@m, UDT_MAXHP, 1);
+    setunitdata(.@m, UDT_LEVEL, 1);
+    setunitdata(.@m, UDT_SPEED, 60);
+    .@m=areamonster(.m$, 38, 85, 40, 90, strmobinfo(1, MagentaSpark), MagentaSpark, 1, "Hocus#MOLY0900::OnClM");
+    setunitdata(.@m, UDT_HP, 1);
+    setunitdata(.@m, UDT_MAXHP, 1);
+    setunitdata(.@m, UDT_LEVEL, 1);
+    setunitdata(.@m, UDT_SPEED, 60);
+    .@m=areamonster(.m$, 38, 85, 40, 90, strmobinfo(1, YellowSpark), YellowSpark, 1, "Hocus#MOLY0900::OnClY");
+    setunitdata(.@m, UDT_HP, 1);
+    setunitdata(.@m, UDT_MAXHP, 1);
+    setunitdata(.@m, UDT_LEVEL, 1);
+    setunitdata(.@m, UDT_SPEED, 60);
+    .@m=areamonster(.m$, 38, 85, 40, 90, strmobinfo(1, MagentaSpark), MagentaSpark, 1, "Hocus#MOLY0900::OnClM");
+    setunitdata(.@m, UDT_HP, 1);
+    setunitdata(.@m, UDT_MAXHP, 1);
+    setunitdata(.@m, UDT_LEVEL, 1);
+    setunitdata(.@m, UDT_SPEED, 60);
+    @cl=any(YellowSpark, MagentaSpark);
+    npctalk3 l("Countdown: 1 minute - Kill %s!", strmobinfo(1, @cl));
+    initnpctimer;
+    closeclientdialog;
+    close;
+
+OnTimer9000:
+    npctalk "Hocus commands...";
+    end;
+
+OnTimer10000:
+    maptimer2(.m$, 10, "Hocus#MOLY0900::OnSeed");
+    npctalk sprintf("Time left = 50 seconds");
+    end;
+
+OnTimer19000:
+    npctalk "Hocus commands...";
+    end;
+
+OnTimer20000:
+    maptimer2(.m$, 10, "Hocus#MOLY0900::OnSeed");
+    npctalk sprintf("Time left = 40 seconds");
+    end;
+
+OnTimer29000:
+    npctalk "Hocus commands...";
+    end;
+
+OnTimer30000:
+    maptimer2(.m$, 10, "Hocus#MOLY0900::OnSeed");
+    npctalk sprintf("Time left = 30 seconds");
+    end;
+
+OnTimer39000:
+    npctalk "Hocus commands...";
+    end;
+
+OnTimer40000:
+    maptimer2(.m$, 10, "Hocus#MOLY0900::OnSeed");
+    npctalk sprintf("Time left = 20 seconds");
+    end;
+
+OnTimer49000:
+    npctalk "Hocus commands...";
+    end;
+
+OnTimer50000:
+    maptimer2(.m$, 10, "Hocus#MOLY0900::OnSeed");
+    npctalk sprintf("Time left = 10 seconds");
+    end;
+
+OnTimer55000:
+    npctalk col("5 seconds", 1);
+    end;
+
+OnTimer60000:
+    killmonsterall(.m$);
+    maptimer2(.m$, 10, "Hocus#MOLY0900::OnEnd");
+    npctalk col("Time out!", 1);
+    stopnpctimer;
+    end;
+
+OnSeed:
+    @cl=any(YellowSpark, MagentaSpark);
+    dispbottom l("Kill %s!", strmobinfo(1, @cl));
+    end;
+
+OnClY:
+    if (gettimetick(2) > @moly_tick) end;
+    if (@moly_chall != 9) end;
+    if (@cl != YellowSpark) {
+        @moly_score = -1;
+        @moly_tick = 0;
+        @moly_chall = 0;
+        dispbottom col(l("You have been disqualified - target was: %s", strmobinfo(1, @cl)), 1);
+        killmonsterall(getmap());
+        // FIXME: Stop npc timer
+        end;
+    }
+    @moly_score+=1;
+    .@m=areamonster(getmap(), 38, 85, 40, 90, strmobinfo(1, YellowSpark), YellowSpark, 1, "Hocus#MOLY0900::OnClY");
+    setunitdata(.@m, UDT_HP, 1);
+    setunitdata(.@m, UDT_MAXHP, 1);
+    setunitdata(.@m, UDT_LEVEL, 1);
+    setunitdata(.@m, UDT_SPEED, 60);
+    end;
+
+OnClM:
+    if (gettimetick(2) > @moly_tick) end;
+    if (@moly_chall != 9) end;
+    if (@cl != MagentaSpark) {
+        @moly_score = -1;
+        @moly_tick = 0;
+        dispbottom col(l("You have been disqualified - target was: %s", strmobinfo(1, @cl)), 1);
+        killmonsterall(getmap());
+        // FIXME: Stop npc timer
+        end;
+    }
+    @moly_score+=1;
+    .@m=areamonster(getmap(), 38, 85, 40, 90, strmobinfo(1, MagentaSpark), MagentaSpark, 1, "Hocus#MOLY0900::OnClM");
+    setunitdata(.@m, UDT_HP, 1);
+    setunitdata(.@m, UDT_MAXHP, 1);
+    setunitdata(.@m, UDT_LEVEL, 1);
+    setunitdata(.@m, UDT_SPEED, 60);
+    end;
+
+OnEnd:
+    if (@moly_chall != 9) end;
+    dispbottom l("End! Score this time: %d", @moly_score);
+    FYMOLY_HOCUSM = max(FYMOLY_HOCUSM, @moly_score);
+    @moly_score = 0;
+    @moly_chall = 0;
     end;
 
 OnInit:
     .distance=7;
+    .m$="001-14";
+    .cl=Dummy;
     end;
 }
 
diff --git a/npc/001-14/hocus.txt b/npc/001-14/hocus.txt
index ae438c893..04835bf72 100644
--- a/npc/001-14/hocus.txt
+++ b/npc/001-14/hocus.txt
@@ -62,7 +62,7 @@ function showScores {
     //parseScores("Magic Power Challenge",    "$@moly06_n$", "$@moly06_v");
     parseScores("Mana Exp Challenge",       "$@moly07_n$", "$@moly07_v");
     //parseScores("Obstacle Race Challenge",  "$@moly08_n$", "$@moly08_v", t());
-    //parseScores("Hocus Commands Challenge", "$@moly09_n$", "$@moly09_v");
+    parseScores("Hocus Commands Challenge", "$@moly09_n$", "$@moly09_v");
     //parseScores("Survive! Challenge",       "$@moly10_n$", "$@moly10_v", t());
     parseScores("Friendship Challenge",     "$@moly11_n$", "$@moly11_v");
     parseScores("Intensive Mage Challenge", "$@moly12_n$", "$@moly12_v");
-- 
cgit v1.2.3-70-g09d2