Skip to content
This repository has been archived by the owner on Dec 4, 2020. It is now read-only.

Commit

Permalink
Merge pull request #571 from hooksta4/Ziphius
Browse files Browse the repository at this point in the history
Implement Ziphus spawn
  • Loading branch information
ibm2431 authored May 14, 2020
2 parents 7fdc91e + 78a0aa3 commit 935b3f1
Show file tree
Hide file tree
Showing 9 changed files with 192 additions and 11 deletions.
8 changes: 8 additions & 0 deletions scripts/zones/Misareaux_Coast/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ zones[tpz.zone.MISAREAUX_COAST] =
CONQUEST_BASE = 7171, -- Tallying conquest results...
DOOR_CLOSED = 7347, -- The door is locked tight.
LOGGING_IS_POSSIBLE_HERE = 7601, -- Logging is possible here if you have <item>.
NOTHING_HERE_YET = 7660; -- There is nothing here yet. Check again in the morning.
ALREADY_BAITED = 7661; -- The trap already contains <item>.
APPEARS_TO_BE_TRAP = 7662; -- There appears to be some kind of trap here. Bits of fish are lying around the area.
DID_NOT_CATCH_ANYTHING = 7663; -- You did not catch anything.
PUT_IN_TRAP = 7664; -- You put <item> in the trap.
COMMON_SENSE_SURVIVAL = 8635, -- It appears that you have arrived at a new survival guide provided by the Adventurers' Mutual Aid Network. Common sense dictates that you should now be able to teleport here from similar tomes throughout the world.
HOMEPOINT_SET = 8858, -- Home point set!
},
Expand All @@ -32,6 +37,8 @@ zones[tpz.zone.MISAREAUX_COAST] =
PM6_2_MOB_OFFSET = 16879893,
BOGGELMANN = 16879897,
GRATION = 16879899,
ZIPHIUS = 16879900,

},
npc =
{
Expand All @@ -44,6 +51,7 @@ zones[tpz.zone.MISAREAUX_COAST] =
16879976,
16879977,
},
ZIPHIUS_QM_BASE = 16879919,
},
}

Expand Down
31 changes: 20 additions & 11 deletions scripts/zones/Misareaux_Coast/Zone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,41 @@
-- Zone: Misareaux_Coast (25)
--
-----------------------------------
local ID = require("scripts/zones/Misareaux_Coast/IDs")
require("scripts/globals/conquest")
require("scripts/globals/helm")
local ID = require("scripts/zones/Misareaux_Coast/IDs")
local MISAREAUX_COAST = require("scripts/zones/Misareaux_Coast/globals")
-----------------------------------

function onInitialize(zone)
tpz.helm.initZone(zone, tpz.helm.type.LOGGING)
end;
MISAREAUX_COAST.ziphiusHandleQM()
end

function onConquestUpdate(zone, updatetype)
tpz.conq.onConquestUpdate(zone, updatetype)
end;
end

function onZoneIn(player,prevZone)
local cs = -1;
if (player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0) then
player:setPos(567.624,-20,280.775,120);
local cs = -1
if player:getXPos() == 0 and player:getYPos() == 0 and player:getZPos() == 0 then
player:setPos(567.624, -20, 280.775, 120)
end
return cs;
end;
return cs
end

function onRegionEnter(player,region)
end;
end

function onGameHour(zone)
local vHour = VanadielHour()
if vHour >= 22 or vHour <= 7 then
MISAREAUX_COAST.ziphiusHandleQM()
end
end

function onEventUpdate(player,csid,option)
end;
end

function onEventFinish(player,csid,option)
end;
end
80 changes: 80 additions & 0 deletions scripts/zones/Misareaux_Coast/globals.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
-----------------------------------
-- Zone: Misareaux_Coast (25)
-- Desc: this file contains functions that are shared by multiple luas in this zone's directory
-----------------------------------
local ID = require("scripts/zones/Misareaux_Coast/IDs")
require("scripts/globals/npc_util")
-----------------------------------

local MISAREAUX_COAST = {
------------------------------------------
-- Handle spawn/despawn for Ziphius NM QMs
------------------------------------------
ziphiusHandleQM = function()
local vHour = VanadielHour()
if vHour >= 7 and vHour < 22 then -- Despawn traps for Ziphius
for i = ID.npc.ZIPHIUS_QM_BASE, ID.npc.ZIPHIUS_QM_BASE+5 do
GetNPCByID(i):setStatus(tpz.status.DISAPPEAR)
GetNPCByID(i):resetLocalVars()
end
elseif vHour >= 22 or vHour < 4 then -- Spawn traps for Ziphius
local random = GetNPCByID(ID.npc.ZIPHIUS_QM_BASE + math.random(0, 5))
if random:getStatus() == tpz.status.DISAPPEAR then
random:setLocalVar("[Ziphius]Spawn", 1)
end
for i = ID.npc.ZIPHIUS_QM_BASE, ID.npc.ZIPHIUS_QM_BASE+5 do
GetNPCByID(i):setStatus(tpz.status.NORMAL)
end
elseif vHour == 4 then -- Despawn non-baited traps
for i = ID.npc.ZIPHIUS_QM_BASE, ID.npc.ZIPHIUS_QM_BASE+5 do
if GetNPCByID(i):getLocalVar("[Ziphius]Baited") == 0 then
GetNPCByID(i):setStatus(tpz.status.DISAPPEAR)
end
end
end
end,
------------------------------------
-- Trade function for Ziphius NM QMs
------------------------------------
ziphiusOnTrade = function(player, npc, trade)
local baited = npc:getLocalVar("[Ziphius]Baited") == 1
if not baited and npcUtil.tradeHas(trade, 16994) then -- Trade Slice of Carp
npc:setLocalVar("[Ziphius]Bait"..player:getName(), 1)
npc:setLocalVar("[Ziphius]Baited", 1)
player:confirmTrade()
player:messageSpecial(ID.text.PUT_IN_TRAP, 16994)
end
end,
------------------------------------
-- Spawn function for Ziphius NM QMs
------------------------------------
ziphiusOnTrigger = function(player, npc)
local baited = npc:getLocalVar("[Ziphius]Baited") == 1
local baitedByPlayer = npc:getLocalVar("[Ziphius]Bait"..player:getName()) == 1
local vHour = VanadielHour()
if vHour >= 22 or vHour < 4 then
if not baited then
player:messageSpecial(ID.text.APPEARS_TO_BE_TRAP)
elseif baited and baitedByPlayer then
player:messageSpecial(ID.text.NOTHING_HERE_YET)
else
player:messageSpecial(ID.text.ALREADY_BAITED, 16994)
end
elseif vHour >= 4 and vHour < 7 then
if baitedByPlayer then
if npc:getLocalVar("[Ziphius]Spawn") == 1 then
npc:resetLocalVars()
npc:setStatus(tpz.status.DISAPPEAR)
SpawnMob(ID.mob.ZIPHIUS):updateClaim(player)
GetMobByID(ID.mob.ZIPHIUS):setPos(npc:getXPos(), npc:getYPos(), npc:getZPos()-1)
else
player:messageSpecial(ID.text.DID_NOT_CATCH_ANYTHING)
end
else
player:messageSpecial(ID.text.ALREADY_BAITED, 16994)
end
end
end,
}

return MISAREAUX_COAST
14 changes: 14 additions & 0 deletions scripts/zones/Misareaux_Coast/npcs/qm2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----------------------------------
-- Area: Misareaux_Coast
-- NPC: ??? (Spawn Ziphius)
-- !pos 76 -16 534 25
-----------------------------------
local MISAREAUX_COAST = require("scripts/zones/Misareaux_Coast/globals")

function onTrade(player,npc,trade)
MISAREAUX_COAST.ziphiusOnTrade(player, npc, trade)
end

function onTrigger(player,npc)
MISAREAUX_COAST.ziphiusOnTrigger(player, npc)
end
14 changes: 14 additions & 0 deletions scripts/zones/Misareaux_Coast/npcs/qm3.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----------------------------------
-- Area: Misareaux_Coast
-- NPC: ??? (Spawn Ziphius)
-- !pos 102.5 -16 525 25
-----------------------------------
local MISAREAUX_COAST = require("scripts/zones/Misareaux_Coast/globals")

function onTrade(player,npc,trade)
MISAREAUX_COAST.ziphiusOnTrade(player, npc, trade)
end

function onTrigger(player,npc)
MISAREAUX_COAST.ziphiusOnTrigger(player, npc)
end
14 changes: 14 additions & 0 deletions scripts/zones/Misareaux_Coast/npcs/qm4.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----------------------------------
-- Area: Misareaux_Coast
-- NPC: ??? (Spawn Ziphius)
-- !pos 144.5 -16 520 25
-----------------------------------
local MISAREAUX_COAST = require("scripts/zones/Misareaux_Coast/globals")

function onTrade(player,npc,trade)
MISAREAUX_COAST.ziphiusOnTrade(player, npc, trade)
end

function onTrigger(player,npc)
MISAREAUX_COAST.ziphiusOnTrigger(player, npc)
end
14 changes: 14 additions & 0 deletions scripts/zones/Misareaux_Coast/npcs/qm5.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----------------------------------
-- Area: Misareaux_Coast
-- NPC: ??? (Spawn Ziphius)
-- !pos 184.5 -16 517.5 25
-----------------------------------
local MISAREAUX_COAST = require("scripts/zones/Misareaux_Coast/globals")

function onTrade(player,npc,trade)
MISAREAUX_COAST.ziphiusOnTrade(player, npc, trade)
end

function onTrigger(player,npc)
MISAREAUX_COAST.ziphiusOnTrigger(player, npc)
end
14 changes: 14 additions & 0 deletions scripts/zones/Misareaux_Coast/npcs/qm6.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----------------------------------
-- Area: Misareaux_Coast
-- NPC: ??? (Spawn Ziphius)
-- !pos 207 -16 479 25
-----------------------------------
local MISAREAUX_COAST = require("scripts/zones/Misareaux_Coast/globals")

function onTrade(player,npc,trade)
MISAREAUX_COAST.ziphiusOnTrade(player, npc, trade)
end

function onTrigger(player,npc)
MISAREAUX_COAST.ziphiusOnTrigger(player, npc)
end
14 changes: 14 additions & 0 deletions scripts/zones/Misareaux_Coast/npcs/qm7.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-----------------------------------
-- Area: Misareaux_Coast
-- NPC: ??? (Spawn Ziphius)
-- !pos 253 -16 411.5 25
-----------------------------------
local MISAREAUX_COAST = require("scripts/zones/Misareaux_Coast/globals")

function onTrade(player,npc,trade)
MISAREAUX_COAST.ziphiusOnTrade(player, npc, trade)
end

function onTrigger(player,npc)
MISAREAUX_COAST.ziphiusOnTrigger(player, npc)
end

0 comments on commit 935b3f1

Please sign in to comment.