diff options
Diffstat (limited to 'npc/005-1-1/main.txt')
-rw-r--r-- | npc/005-1-1/main.txt | 413 |
1 files changed, 413 insertions, 0 deletions
diff --git a/npc/005-1-1/main.txt b/npc/005-1-1/main.txt new file mode 100644 index 000000000..026f11647 --- /dev/null +++ b/npc/005-1-1/main.txt @@ -0,0 +1,413 @@ +// TMW2 Scripts +// Author: +// Jesusalva +// Description: +// Candor - Maggot Extermination Quest + +// Added for GonzoDark + +005-1-1,30,20,0 script Nylo#Marggo NPC_PLAYER,{ + // Returns the crop ID to disable + // getcropid(x,y) + function getcropid { + .@x=getarg(0); + .@y=getarg(1); + .@w=12; // Width of a row + .@offx=23; // First X + .@offy=22; // First Y + .@i=0; + // 0 is: 23,22 + // width: 35-23=12 + // height is not relevant + + // .@x / .@y + // .@w = 12 + // .@i → Real value + + // For each Y beyond .@offy we add .@w to i + .@i+=(.@y-.@offy)*.@w; + // Now we add any X beyond .@offx + .@i+=(.@x-.@offx); + return(sprintf("%03d", .@i)) + } + + npctalk l("Go kill the maggots!"); + end; + +OnStart: + initnpctimer; + addtimer(60000, "Nylo#Marggo::OnBegin"); + mesn; + mesq l("The maggots will spawn in @@ at random.", b(l("60 seconds"))); + mes l("Read the instructions carefully."); + next; + mesn l("Time Limit"); + mes l("Campaign starts after 60 seconds. Eight maggots will spawn on the next 100 seconds."); + mes l("Four minutes after the warp, or when the last maggot die, it'll be over."); + next; + mesn l("Victory Conditions"); + mes l("If you save 80% from the crops or more, you'll get a @@.", getitemlink(RoundLeatherShield)); + mes l("If you save 60% from the crops or more, you'll get @@ GP.", 300); + mes l("== If you decide to complete the quest you cannot repeat it."); + next; + mes l("Good luck!"); + close; + +OnTimer10000: + npctalk "50 seconds!"; + end; + +OnTimer20000: + npctalk "40 seconds!"; + end; + +OnTimer30000: + npctalk "30 seconds!"; + end; + +OnTimer40000: + npctalk "20 seconds!"; + end; + +OnTimer50000: + npctalk "10 seconds!"; + end; + +OnTimer55000: + npctalk "5 seconds!"; + end; + +OnTimer60000: + npctalk "Start!"; + stopnpctimer; + end; + +OnBegin: + // @MARGGO → (MaggotID, IsAlive) + // IsAlive: 1 → yes + @MARGGO=htnew; + @TOTAL_MRG=0; + //@DESTROY=0; // Array of all lost crops + // 8 maggots + // Minimum 80 sec + // Maximum 100 sec + addtimer(10, "Nylo#Marggo::OnSpawn"); + addtimer(850, "Nylo#Marggo::OnInteract"); + addtimer(180000, "Nylo#Marggo::OnFinish"); + end; + +// Spawn a new maggot until eight maggots were spawn +OnSpawn: + .@ID=getcharid(0); + .@MAP$="MRGO@"+str(.@ID); + @TOTAL_MRG+=1; + if (@TOTAL_MRG < 8) + addtimer(rand(10000, 12500), "Nylo#Marggo::OnSpawn"); + + .@mobID=areamonster(.@MAP$, 23, 22, 35, 34, l("Maggot"), Maggot, 1, "Nylo#Marggo::OnMurder"); + htput @MARGGO, .@mobID, 1; + end; + +// Move all maggots +OnInteract: + .@hti = htiterator(@MARGGO); + for(.@key$ = htinextkey(.@hti); hticheck(.@hti); .@key$ = htinextkey(.@hti)) { + .@alive=htget(@MARGGO, .@key$); + /* + if (.@alive == 2) + continue; + */ + .@mobId=atoi(.@key$); + getmapxy(.@m$, .@x, .@y, UNITTYPE_MOB, .@mobId); + + // Destroy the crop if needed + .@cropId$=getcropid(.@x, .@y); + if (array_find(@DESTROYED, .@cropId$) == -1) { + array_push(@DESTROYED, .@cropId$); + disablenpc instance_npcname("#Marggo"+.@cropId$); + } + + // Tell the Maggot to walk to a random coordinate + // (it may walk backwards due not preserving old data) + // This will cause maggot to abort a counter attack and to never stop + // If it hits an edge, it'll start moving to the center, may cause odd behavior + unitstop(.@mobId); + if (.@x == 22 || .@y == 22 || .@x == 36 || .@y == 34) + unitwalk(.@mobId, 30, 30); + else + unitwalk(.@mobId, .@x+any(1, -1), .@y+any(1, -1)); + } + htidelete(.@hti); + + // Continue the cycle + if (getmap() ~= "MRGO*" || getmap() ~= "005-1-1") + addtimer(850, "Nylo#Marggo::OnInteract"); + end; + +// A maggot was killed +OnMurder: + // I don't know which one was killed, so I cycle every one until I find the dead one + .@hti = htiterator(@MARGGO); + for(.@key$ = htinextkey(.@hti); hticheck(.@hti); .@key$ = htinextkey(.@hti)) { + .@alive=htget(@MARGGO, .@key$); + /* + if (.@alive == 2) + continue; + */ + .@mobId=atoi(.@key$); + if (getmapxy(.@m$, .@x, .@y, UNITTYPE_MOB, .@mobId) >= 0) + continue; + + // We found the dead monster, mark it as dead and stop this meaningless loop + htput .@key$, 0; + break; + } + htidelete(.@hti); + if (@TOTAL_MRG >= 8) { + if (htsize(@MARGGO) == 0) + doevent("Nylo#Marggo::OnFinish"); + } + end; + +// You killed all maggots or ran out of time +OnFinish: + htdelete @MARGGO; + deltimer("Nylo#Marggo::OnInteract"); + deltimer("Nylo#Marggo::OnSpawn"); + deltimer("Nylo#Marggo::OnFinish"); + .@trueratio=100*getarraysize(@DESTROYED)/169; + .@ratio=100-.@trueratio; + debugmes l("Player lost @@ crops", getarraysize(@DESTROYED)); + mesn l("Nylo"); + mes l("You managed to save @@ % of my crops!", .@ratio); + next; + if (.@ratio >= 60) { + inventoryplace RoundLeatherShield, 1; + mesc l("Complete Quest?"); + mesc l("You won't be able to aim for a better record!"); + if (askyesno() == ASK_YES) { + setq CandorQuest_Marggo, 1; + Zeny=Zeny+300; + getexp .@ratio*8/10, (.@ratio/3); + if (.@ratio >= 80) + getitem RoundLeatherShield, 1; + } + mes ""; + } + mesn l("Nylo"); + mes l("Thanks for the help!"); + warp "Save", 0, 0; + close; + +// Cosmetic +OnInit: + .@npcId = getnpcid(.name$); + setunitdata(.@npcId, UDT_HEADTOP, CreasedShirt); + setunitdata(.@npcId, UDT_HEADMIDDLE, CreasedShorts); + setunitdata(.@npcId, UDT_HEADBOTTOM, NPCEyes); + setunitdata(.@npcId, UDT_WEAPON, CandorBoots); + setunitdata(.@npcId, UDT_HAIRSTYLE, 26); + setunitdata(.@npcId, UDT_HAIRCOLOR, 0); + + .sex = G_MALE; + .distance = 4; + end; +OnInstanceInit: + .@npcId = getnpcid(instance_npcname(.name$)); + setunitdata(.@npcId, UDT_HEADTOP, CreasedShirt); + setunitdata(.@npcId, UDT_HEADMIDDLE, CreasedShorts); + setunitdata(.@npcId, UDT_HEADBOTTOM, NPCEyes); + setunitdata(.@npcId, UDT_WEAPON, CandorBoots); + setunitdata(.@npcId, UDT_HAIRSTYLE, 26); + setunitdata(.@npcId, UDT_HAIRCOLOR, 0); + end; + +} + +/* python +i=0 +x=23 +y=22 +x2=35 +y2=34 +while y <= y2: + print("005-1-1,%d,%d,0 script #Marggo%03d NPC_CROPS,{ end; }"% (x, y, i)) + x+=1 + if (x > x2): + x=23 + y+=1 + i+=1 + +*/ + +005-1-1,23,22,0 script #Marggo000 NPC_CROPS,{ end; } +005-1-1,24,22,0 script #Marggo001 NPC_CROPS,{ end; } +005-1-1,25,22,0 script #Marggo002 NPC_CROPS,{ end; } +005-1-1,26,22,0 script #Marggo003 NPC_CROPS,{ end; } +005-1-1,27,22,0 script #Marggo004 NPC_CROPS,{ end; } +005-1-1,28,22,0 script #Marggo005 NPC_CROPS,{ end; } +005-1-1,29,22,0 script #Marggo006 NPC_CROPS,{ end; } +005-1-1,30,22,0 script #Marggo007 NPC_CROPS,{ end; } +005-1-1,31,22,0 script #Marggo008 NPC_CROPS,{ end; } +005-1-1,32,22,0 script #Marggo009 NPC_CROPS,{ end; } +005-1-1,33,22,0 script #Marggo010 NPC_CROPS,{ end; } +005-1-1,34,22,0 script #Marggo011 NPC_CROPS,{ end; } +005-1-1,35,22,0 script #Marggo012 NPC_CROPS,{ end; } +005-1-1,23,23,0 script #Marggo013 NPC_CROPS,{ end; } +005-1-1,24,23,0 script #Marggo014 NPC_CROPS,{ end; } +005-1-1,25,23,0 script #Marggo015 NPC_CROPS,{ end; } +005-1-1,26,23,0 script #Marggo016 NPC_CROPS,{ end; } +005-1-1,27,23,0 script #Marggo017 NPC_CROPS,{ end; } +005-1-1,28,23,0 script #Marggo018 NPC_CROPS,{ end; } +005-1-1,29,23,0 script #Marggo019 NPC_CROPS,{ end; } +005-1-1,30,23,0 script #Marggo020 NPC_CROPS,{ end; } +005-1-1,31,23,0 script #Marggo021 NPC_CROPS,{ end; } +005-1-1,32,23,0 script #Marggo022 NPC_CROPS,{ end; } +005-1-1,33,23,0 script #Marggo023 NPC_CROPS,{ end; } +005-1-1,34,23,0 script #Marggo024 NPC_CROPS,{ end; } +005-1-1,35,23,0 script #Marggo025 NPC_CROPS,{ end; } +005-1-1,23,24,0 script #Marggo026 NPC_CROPS,{ end; } +005-1-1,24,24,0 script #Marggo027 NPC_CROPS,{ end; } +005-1-1,25,24,0 script #Marggo028 NPC_CROPS,{ end; } +005-1-1,26,24,0 script #Marggo029 NPC_CROPS,{ end; } +005-1-1,27,24,0 script #Marggo030 NPC_CROPS,{ end; } +005-1-1,28,24,0 script #Marggo031 NPC_CROPS,{ end; } +005-1-1,29,24,0 script #Marggo032 NPC_CROPS,{ end; } +005-1-1,30,24,0 script #Marggo033 NPC_CROPS,{ end; } +005-1-1,31,24,0 script #Marggo034 NPC_CROPS,{ end; } +005-1-1,32,24,0 script #Marggo035 NPC_CROPS,{ end; } +005-1-1,33,24,0 script #Marggo036 NPC_CROPS,{ end; } +005-1-1,34,24,0 script #Marggo037 NPC_CROPS,{ end; } +005-1-1,35,24,0 script #Marggo038 NPC_CROPS,{ end; } +005-1-1,23,25,0 script #Marggo039 NPC_CROPS,{ end; } +005-1-1,24,25,0 script #Marggo040 NPC_CROPS,{ end; } +005-1-1,25,25,0 script #Marggo041 NPC_CROPS,{ end; } +005-1-1,26,25,0 script #Marggo042 NPC_CROPS,{ end; } +005-1-1,27,25,0 script #Marggo043 NPC_CROPS,{ end; } +005-1-1,28,25,0 script #Marggo044 NPC_CROPS,{ end; } +005-1-1,29,25,0 script #Marggo045 NPC_CROPS,{ end; } +005-1-1,30,25,0 script #Marggo046 NPC_CROPS,{ end; } +005-1-1,31,25,0 script #Marggo047 NPC_CROPS,{ end; } +005-1-1,32,25,0 script #Marggo048 NPC_CROPS,{ end; } +005-1-1,33,25,0 script #Marggo049 NPC_CROPS,{ end; } +005-1-1,34,25,0 script #Marggo050 NPC_CROPS,{ end; } +005-1-1,35,25,0 script #Marggo051 NPC_CROPS,{ end; } +005-1-1,23,26,0 script #Marggo052 NPC_CROPS,{ end; } +005-1-1,24,26,0 script #Marggo053 NPC_CROPS,{ end; } +005-1-1,25,26,0 script #Marggo054 NPC_CROPS,{ end; } +005-1-1,26,26,0 script #Marggo055 NPC_CROPS,{ end; } +005-1-1,27,26,0 script #Marggo056 NPC_CROPS,{ end; } +005-1-1,28,26,0 script #Marggo057 NPC_CROPS,{ end; } +005-1-1,29,26,0 script #Marggo058 NPC_CROPS,{ end; } +005-1-1,30,26,0 script #Marggo059 NPC_CROPS,{ end; } +005-1-1,31,26,0 script #Marggo060 NPC_CROPS,{ end; } +005-1-1,32,26,0 script #Marggo061 NPC_CROPS,{ end; } +005-1-1,33,26,0 script #Marggo062 NPC_CROPS,{ end; } +005-1-1,34,26,0 script #Marggo063 NPC_CROPS,{ end; } +005-1-1,35,26,0 script #Marggo064 NPC_CROPS,{ end; } +005-1-1,23,27,0 script #Marggo065 NPC_CROPS,{ end; } +005-1-1,24,27,0 script #Marggo066 NPC_CROPS,{ end; } +005-1-1,25,27,0 script #Marggo067 NPC_CROPS,{ end; } +005-1-1,26,27,0 script #Marggo068 NPC_CROPS,{ end; } +005-1-1,27,27,0 script #Marggo069 NPC_CROPS,{ end; } +005-1-1,28,27,0 script #Marggo070 NPC_CROPS,{ end; } +005-1-1,29,27,0 script #Marggo071 NPC_CROPS,{ end; } +005-1-1,30,27,0 script #Marggo072 NPC_CROPS,{ end; } +005-1-1,31,27,0 script #Marggo073 NPC_CROPS,{ end; } +005-1-1,32,27,0 script #Marggo074 NPC_CROPS,{ end; } +005-1-1,33,27,0 script #Marggo075 NPC_CROPS,{ end; } +005-1-1,34,27,0 script #Marggo076 NPC_CROPS,{ end; } +005-1-1,35,27,0 script #Marggo077 NPC_CROPS,{ end; } +005-1-1,23,28,0 script #Marggo078 NPC_CROPS,{ end; } +005-1-1,24,28,0 script #Marggo079 NPC_CROPS,{ end; } +005-1-1,25,28,0 script #Marggo080 NPC_CROPS,{ end; } +005-1-1,26,28,0 script #Marggo081 NPC_CROPS,{ end; } +005-1-1,27,28,0 script #Marggo082 NPC_CROPS,{ end; } +005-1-1,28,28,0 script #Marggo083 NPC_CROPS,{ end; } +005-1-1,29,28,0 script #Marggo084 NPC_CROPS,{ end; } +005-1-1,30,28,0 script #Marggo085 NPC_CROPS,{ end; } +005-1-1,31,28,0 script #Marggo086 NPC_CROPS,{ end; } +005-1-1,32,28,0 script #Marggo087 NPC_CROPS,{ end; } +005-1-1,33,28,0 script #Marggo088 NPC_CROPS,{ end; } +005-1-1,34,28,0 script #Marggo089 NPC_CROPS,{ end; } +005-1-1,35,28,0 script #Marggo090 NPC_CROPS,{ end; } +005-1-1,23,29,0 script #Marggo091 NPC_CROPS,{ end; } +005-1-1,24,29,0 script #Marggo092 NPC_CROPS,{ end; } +005-1-1,25,29,0 script #Marggo093 NPC_CROPS,{ end; } +005-1-1,26,29,0 script #Marggo094 NPC_CROPS,{ end; } +005-1-1,27,29,0 script #Marggo095 NPC_CROPS,{ end; } +005-1-1,28,29,0 script #Marggo096 NPC_CROPS,{ end; } +005-1-1,29,29,0 script #Marggo097 NPC_CROPS,{ end; } +005-1-1,30,29,0 script #Marggo098 NPC_CROPS,{ end; } +005-1-1,31,29,0 script #Marggo099 NPC_CROPS,{ end; } +005-1-1,32,29,0 script #Marggo100 NPC_CROPS,{ end; } +005-1-1,33,29,0 script #Marggo101 NPC_CROPS,{ end; } +005-1-1,34,29,0 script #Marggo102 NPC_CROPS,{ end; } +005-1-1,35,29,0 script #Marggo103 NPC_CROPS,{ end; } +005-1-1,23,30,0 script #Marggo104 NPC_CROPS,{ end; } +005-1-1,24,30,0 script #Marggo105 NPC_CROPS,{ end; } +005-1-1,25,30,0 script #Marggo106 NPC_CROPS,{ end; } +005-1-1,26,30,0 script #Marggo107 NPC_CROPS,{ end; } +005-1-1,27,30,0 script #Marggo108 NPC_CROPS,{ end; } +005-1-1,28,30,0 script #Marggo109 NPC_CROPS,{ end; } +005-1-1,29,30,0 script #Marggo110 NPC_CROPS,{ end; } +005-1-1,30,30,0 script #Marggo111 NPC_CROPS,{ end; } +005-1-1,31,30,0 script #Marggo112 NPC_CROPS,{ end; } +005-1-1,32,30,0 script #Marggo113 NPC_CROPS,{ end; } +005-1-1,33,30,0 script #Marggo114 NPC_CROPS,{ end; } +005-1-1,34,30,0 script #Marggo115 NPC_CROPS,{ end; } +005-1-1,35,30,0 script #Marggo116 NPC_CROPS,{ end; } +005-1-1,23,31,0 script #Marggo117 NPC_CROPS,{ end; } +005-1-1,24,31,0 script #Marggo118 NPC_CROPS,{ end; } +005-1-1,25,31,0 script #Marggo119 NPC_CROPS,{ end; } +005-1-1,26,31,0 script #Marggo120 NPC_CROPS,{ end; } +005-1-1,27,31,0 script #Marggo121 NPC_CROPS,{ end; } +005-1-1,28,31,0 script #Marggo122 NPC_CROPS,{ end; } +005-1-1,29,31,0 script #Marggo123 NPC_CROPS,{ end; } +005-1-1,30,31,0 script #Marggo124 NPC_CROPS,{ end; } +005-1-1,31,31,0 script #Marggo125 NPC_CROPS,{ end; } +005-1-1,32,31,0 script #Marggo126 NPC_CROPS,{ end; } +005-1-1,33,31,0 script #Marggo127 NPC_CROPS,{ end; } +005-1-1,34,31,0 script #Marggo128 NPC_CROPS,{ end; } +005-1-1,35,31,0 script #Marggo129 NPC_CROPS,{ end; } +005-1-1,23,32,0 script #Marggo130 NPC_CROPS,{ end; } +005-1-1,24,32,0 script #Marggo131 NPC_CROPS,{ end; } +005-1-1,25,32,0 script #Marggo132 NPC_CROPS,{ end; } +005-1-1,26,32,0 script #Marggo133 NPC_CROPS,{ end; } +005-1-1,27,32,0 script #Marggo134 NPC_CROPS,{ end; } +005-1-1,28,32,0 script #Marggo135 NPC_CROPS,{ end; } +005-1-1,29,32,0 script #Marggo136 NPC_CROPS,{ end; } +005-1-1,30,32,0 script #Marggo137 NPC_CROPS,{ end; } +005-1-1,31,32,0 script #Marggo138 NPC_CROPS,{ end; } +005-1-1,32,32,0 script #Marggo139 NPC_CROPS,{ end; } +005-1-1,33,32,0 script #Marggo140 NPC_CROPS,{ end; } +005-1-1,34,32,0 script #Marggo141 NPC_CROPS,{ end; } +005-1-1,35,32,0 script #Marggo142 NPC_CROPS,{ end; } +005-1-1,23,33,0 script #Marggo143 NPC_CROPS,{ end; } +005-1-1,24,33,0 script #Marggo144 NPC_CROPS,{ end; } +005-1-1,25,33,0 script #Marggo145 NPC_CROPS,{ end; } +005-1-1,26,33,0 script #Marggo146 NPC_CROPS,{ end; } +005-1-1,27,33,0 script #Marggo147 NPC_CROPS,{ end; } +005-1-1,28,33,0 script #Marggo148 NPC_CROPS,{ end; } +005-1-1,29,33,0 script #Marggo149 NPC_CROPS,{ end; } +005-1-1,30,33,0 script #Marggo150 NPC_CROPS,{ end; } +005-1-1,31,33,0 script #Marggo151 NPC_CROPS,{ end; } +005-1-1,32,33,0 script #Marggo152 NPC_CROPS,{ end; } +005-1-1,33,33,0 script #Marggo153 NPC_CROPS,{ end; } +005-1-1,34,33,0 script #Marggo154 NPC_CROPS,{ end; } +005-1-1,35,33,0 script #Marggo155 NPC_CROPS,{ end; } +005-1-1,23,34,0 script #Marggo156 NPC_CROPS,{ end; } +005-1-1,24,34,0 script #Marggo157 NPC_CROPS,{ end; } +005-1-1,25,34,0 script #Marggo158 NPC_CROPS,{ end; } +005-1-1,26,34,0 script #Marggo159 NPC_CROPS,{ end; } +005-1-1,27,34,0 script #Marggo160 NPC_CROPS,{ end; } +005-1-1,28,34,0 script #Marggo161 NPC_CROPS,{ end; } +005-1-1,29,34,0 script #Marggo162 NPC_CROPS,{ end; } +005-1-1,30,34,0 script #Marggo163 NPC_CROPS,{ end; } +005-1-1,31,34,0 script #Marggo164 NPC_CROPS,{ end; } +005-1-1,32,34,0 script #Marggo165 NPC_CROPS,{ end; } +005-1-1,33,34,0 script #Marggo166 NPC_CROPS,{ end; } +005-1-1,34,34,0 script #Marggo167 NPC_CROPS,{ end; } +005-1-1,35,34,0 script #Marggo168 NPC_CROPS,{ end; } + + |