Skip to content

Commit

Permalink
[AMK][Lua] Cardian orb drop mechanic (#4800)
Browse files Browse the repository at this point in the history
* AMK6: Added mechanic to drop KI orbs for cardians

* Fixed null player check
  • Loading branch information
Flibe-XI authored and zach2good committed May 23, 2024
1 parent e56130b commit e3676fd
Show file tree
Hide file tree
Showing 37 changed files with 194 additions and 0 deletions.
38 changes: 38 additions & 0 deletions scripts/missions/amk/helpers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,44 @@ xi.amk.helpers.helmTrade = function(player, helmType, broke)
end
end

-- AMK 6 (index 5) - An Errand! The Professor's Price
-- Cardian orb KI logic: All or nothing drop of the orb is handled by
-- a local var that is set once by the first player is called by onMobDeath
-- The rest of the players in alliance get the same outcome as the first
xi.amk.helpers.cardianOrbDrop = function(mob, player, orb)
if
player == nil or
player:getCurrentMission(xi.mission.log_id.AMK) < xi.mission.id.amk.AN_ERRAND_THE_PROFESSORS_PRICE
then
return
end

-- Chance of drop increases both based on size of party and level of mob killed
if mob:getLocalVar('Mission[10][5]cardianOrbDrop') == 0 then
local partySize = 0
for _, member in pairs(player:getAlliance()) do
if member:getZoneID() == xi.zone.OUTER_HORUTOTO_RUINS then
partySize = partySize + 1
end
end

-- Chance ranges from 4% to 25.8% (based on max mob lvl of 44)
local dropChance = (3 * mob:getMainLvl()) + (30 * utils.clamp(partySize, 1, 6)) - 10
local roll = math.random(1000)

if roll < dropChance then
mob:setLocalVar('Mission[10][5]cardianOrbDrop', 1)
else
mob:setLocalVar('Mission[10][5]cardianOrbDrop', 2)
end
end

-- Give orb
if mob:getLocalVar('Mission[10][5]cardianOrbDrop') == 1 then
npcUtil.giveKeyItem(player, orb)
end
end

-- AMK 7 (index 6) - Select/lookup the digging zone
local digZoneIds =
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
xi.regime.checkRegime(player, mob, 667, 2, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Eight_of_Coins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
xi.regime.checkRegime(player, mob, 667, 4, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Eight_of_Cups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
xi.regime.checkRegime(player, mob, 667, 1, xi.regime.type.GROUNDS)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
xi.regime.checkRegime(player, mob, 667, 3, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Five_of_Batons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
xi.regime.checkRegime(player, mob, 664, 2, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Five_of_Coins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
xi.regime.checkRegime(player, mob, 664, 4, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Five_of_Cups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
xi.regime.checkRegime(player, mob, 664, 1, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Five_of_Swords.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
xi.regime.checkRegime(player, mob, 664, 3, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Four_of_Batons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
xi.regime.checkRegime(player, mob, 663, 2, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Four_of_Coins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
xi.regime.checkRegime(player, mob, 663, 4, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Four_of_Cups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
xi.regime.checkRegime(player, mob, 663, 1, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Four_of_Swords.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
xi.regime.checkRegime(player, mob, 663, 3, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Nine_of_Batons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
xi.regime.checkRegime(player, mob, 668, 2, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Nine_of_Coins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
xi.regime.checkRegime(player, mob, 668, 4, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Nine_of_Cups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
xi.regime.checkRegime(player, mob, 668, 1, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Nine_of_Swords.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
xi.regime.checkRegime(player, mob, 668, 3, xi.regime.type.GROUNDS)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
xi.regime.checkRegime(player, mob, 666, 2, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Seven_of_Coins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
xi.regime.checkRegime(player, mob, 666, 4, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Seven_of_Cups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
xi.regime.checkRegime(player, mob, 666, 1, xi.regime.type.GROUNDS)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
xi.regime.checkRegime(player, mob, 666, 3, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Six_of_Batons.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
xi.regime.checkRegime(player, mob, 665, 2, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Six_of_Coins.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
xi.regime.checkRegime(player, mob, 665, 4, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Six_of_Cups.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
xi.regime.checkRegime(player, mob, 665, 1, xi.regime.type.GROUNDS)
end

Expand Down
1 change: 1 addition & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Six_of_Swords.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
xi.regime.checkRegime(player, mob, 665, 3, xi.regime.type.GROUNDS)
end

Expand Down
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Ten_of_Batons.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Ten of Batons
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Ten_of_Coins.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Ten of Coins
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Ten_of_Cups.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Ten of Cups
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Ten_of_Swords.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Ten of Swords
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Three_of_Batons.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Three of Batons
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Three_of_Coins.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Three of Coins
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Three_of_Cups.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Three of Cups
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Three_of_Swords.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Three of Swords
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Two_of_Batons.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Two of Batons
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_BATONS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Two_of_Coins.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Two of Coins
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_COINS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Two_of_Cups.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Two of Cups
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_CUPS)
end

return entity
11 changes: 11 additions & 0 deletions scripts/zones/Outer_Horutoto_Ruins/mobs/Two_of_Swords.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-----------------------------------
-- Area: Outer Horutoto Ruins
-- Mob: Two of Swords
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
xi.amk.helpers.cardianOrbDrop(mob, player, xi.ki.ORB_OF_SWORDS)
end

return entity

0 comments on commit e3676fd

Please sign in to comment.