Skip to content

Commit

Permalink
Merge pull request #4381 from CatsAndBoats/chigoes
Browse files Browse the repository at this point in the history
Implement Chigoe "Pets" on ToAU Mobs
  • Loading branch information
TeoTwawki authored Oct 22, 2023
2 parents b61c149 + f8037e3 commit d359b3b
Show file tree
Hide file tree
Showing 16 changed files with 223 additions and 27 deletions.
21 changes: 11 additions & 10 deletions scripts/enum/detects.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ xi = xi or {}

xi.detects =
{
NONE = 0x000,
SIGHT = 0x001,
HEARING = 0x002,
LOWHP = 0x004,
NONE1 = 0x008,
NONE2 = 0x010,
MAGIC = 0x020,
WEAPONSKILL = 0x040,
JOBABILITY = 0x080,
SCENT = 0x100,
NONE = 0x000,
SIGHT = 0x001,
HEARING = 0x002,
SIGHT_AND_HEARING = 0x003,
LOWHP = 0x004,
NONE1 = 0x008,
NONE2 = 0x010,
MAGIC = 0x020,
WEAPONSKILL = 0x040,
JOBABILITY = 0x080,
SCENT = 0x100,
}
33 changes: 33 additions & 0 deletions scripts/mixins/families/chigoe.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ require('scripts/globals/mixins')
g_mixins = g_mixins or {}
g_mixins.families = g_mixins.families or {}

local jobAbilities = set{
xi.jobAbility.SHIELD_BASH,
xi.jobAbility.JUMP,
xi.jobAbility.HIGH_JUMP,
xi.jobAbility.WEAPON_BASH,
xi.jobAbility.CHI_BLAST,
xi.jobAbility.TOMAHAWK,
xi.jobAbility.ANGON,
xi.jobAbility.QUICKSTEP,
xi.jobAbility.BOXSTEP,
xi.jobAbility.STUTTER_STEP,
xi.jobAbility.FEATHER_STEP,
}

g_mixins.families.chigoe = function(chigoeMob)
chigoeMob:addListener('SPAWN', 'CHIGOE_SPAWN', function(mob)
mob:hideName(true)
Expand All @@ -20,6 +34,25 @@ g_mixins.families.chigoe = function(chigoeMob)
mob:hideName(true)
mob:setUntargetable(true)
end)

chigoeMob:addListener('CRITICAL_TAKE', 'CHIGOE_CRITICAL_TAKE', function(mob)
mob:setMobMod(xi.mobMod.EXP_BONUS, -100)
mob:setHP(0)
end)

chigoeMob:addListener('WEAPONSKILL_TAKE', 'CHIGOE_WEAPONSKILL_TAKE', function(mob, wsid)
if wsid then
mob:setMobMod(xi.mobMod.EXP_BONUS, -100)
mob:setHP(0)
end
end)

chigoeMob:addListener('ABILITY_TAKE', 'CHIGOE_ABILITY_TAKE', function(mob, user, ability)
if jobAbilities[ability:getID()] then
mob:setMobMod(xi.mobMod.EXP_BONUS, -100)
mob:setHP(0)
end
end)
end

return g_mixins.families.chigoe
70 changes: 70 additions & 0 deletions scripts/mixins/families/chigoe_pet.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
-- Chigoe(pet) family mixin

require('scripts/globals/mixins')

g_mixins = g_mixins or {}
g_mixins.families = g_mixins.families or {}

local jobAbilities = set{
xi.jobAbility.SHIELD_BASH,
xi.jobAbility.JUMP,
xi.jobAbility.HIGH_JUMP,
xi.jobAbility.WEAPON_BASH,
xi.jobAbility.CHI_BLAST,
xi.jobAbility.TOMAHAWK,
xi.jobAbility.ANGON,
xi.jobAbility.QUICKSTEP,
xi.jobAbility.BOXSTEP,
xi.jobAbility.STUTTER_STEP,
xi.jobAbility.FEATHER_STEP,
}

g_mixins.families.chigoe_pet = function(hostMob)
local ID = zones[hostMob:getZoneID()]

hostMob:addListener('WEAPONSKILL_USE', 'MOB_SPAWN_CHIGOE', function(mob)
local mobName = mob:getName()

if ID.mob.CHIGOES[mobName] == nil then
return
end

for _, mobID in pairs(ID.mob.CHIGOES[mobName]) do
local chigoe = GetMobByID(mobID)

if not chigoe:isSpawned() then
chigoe:setSpawn(hostMob:getXPos() + math.random(-2, 2), hostMob:getYPos() + math.random(-2, 2), hostMob:getZPos() + math.random(-2, 2), hostMob:getRotPos())
chigoe:spawn()

chigoe:addListener('CRITICAL_TAKE', 'CHIGOE_CRITICAL_TAKE', function(chigoeMob)
chigoeMob:setMobMod(xi.mobMod.EXP_BONUS, -100)
chigoeMob:setHP(0)
end)

chigoe:addListener('WEAPONSKILL_TAKE', 'CHIGOE_WEAPONSKILL_TAKE', function(chigoeMob, wsid)
if wsid then
chigoeMob:setMobMod(xi.mobMod.EXP_BONUS, -100)
chigoeMob:setHP(0)
end
end)

chigoe:addListener('ABILITY_TAKE', 'CHIGOE_ABILITY_TAKE', function(chigoeMob, user, ability, action)
if jobAbilities[ability:getID()] then
chigoeMob:setMobMod(xi.mobMod.EXP_BONUS, -100)
chigoeMob:setHP(0)
end
end)

chigoe:addListener('DEATH', 'CHIGOE_DEATH', function(chigoeMob)
chigoeMob:removeListener('CHIGOE_CRITICAL_TAKE')
chigoeMob:removeListener('CHIGOE_WEAPONSKILL_TAKE')
chigoeMob:removeListener('CHIGOE_ABILITY_TAKE')
end)

return
end
end
end)
end

return g_mixins.families.chigoe_pet
15 changes: 15 additions & 0 deletions scripts/zones/Aydeewa_Subterrane/mobs/Aydeewa_Diremite.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----------------------------------
-- Area: Aydeewa Subterrane
-- Mob: Aydeewa Diremite
-----------------------------------
mixins = { require('scripts/mixins/families/chigoe_pet') }
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
end

entity.onMobDespawn = function(mob)
end

return entity
7 changes: 6 additions & 1 deletion scripts/zones/Bhaflau_Thickets/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,12 @@ zones[xi.zone.BHAFLAU_THICKETS] =
},
mob =
{
MAHISHASURA_PH =
CHIGOES =
{
['Marid'] = GetTableOfIDs('Chigoe', 5),
['Grand_Marid'] = GetTableOfIDs('Chigoe', 5),
},
MAHISHASURA_PH =
{
[16990296] = 16990306, -- 215.000 -18.000 372.000
},
Expand Down
15 changes: 15 additions & 0 deletions scripts/zones/Bhaflau_Thickets/mobs/Grand_Marid.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----------------------------------
-- Area: Bhaflau Thickets
-- Mob: Grand Marid
-----------------------------------
mixins = { require('scripts/mixins/families/chigoe_pet') }
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
end

entity.onMobDespawn = function(mob)
end

return entity
1 change: 1 addition & 0 deletions scripts/zones/Bhaflau_Thickets/mobs/Marid.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-- Mob: Marid
-- Note: Place holder Mahishasura
-----------------------------------
mixins = { require('scripts/mixins/families/chigoe_pet') }
local ID = zones[xi.zone.BHAFLAU_THICKETS]
-----------------------------------
local entity = {}
Expand Down
8 changes: 6 additions & 2 deletions scripts/zones/Caedarva_Mire/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ zones[xi.zone.CAEDARVA_MIRE] =
},
mob =
{
PEALLAIDH_PH =
CHIGOES =
{
['Wild_Karakul'] = GetTableOfIDs('Chigoe', 5),
['Mosshorn'] = GetTableOfIDs('Chigoe', 5, 5),
},
PEALLAIDH_PH =
{
[17100870] = 17101143, -- 333.885 -9.646 -447.557
[17100871] = 17101143, -- 309.638 -8.548 -447.557
Expand All @@ -55,7 +60,6 @@ zones[xi.zone.CAEDARVA_MIRE] =
[17100875] = 17101143, -- 315.793 -16.336 -402.407
[17100876] = 17101143, -- 321.809 -16.843 -373.780
},

AYNU_KAYSEY = 17101099,
CAEDARVA_TOAD = 17101145,
JAZARAAT = 17101146,
Expand Down
15 changes: 15 additions & 0 deletions scripts/zones/Caedarva_Mire/mobs/Mosshorn.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----------------------------------
-- Area: Caedarva Mire
-- Mob: Mosshorn
-----------------------------------
mixins = { require('scripts/mixins/families/chigoe_pet') }
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
end

entity.onMobDespawn = function(mob)
end

return entity
1 change: 1 addition & 0 deletions scripts/zones/Caedarva_Mire/mobs/Wild_Karakul.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
-- Mob: Wild Karakul
-- Note: PH for Peallaidh
-----------------------------------
mixins = { require('scripts/mixins/families/chigoe_pet') }
local ID = zones[xi.zone.CAEDARVA_MIRE]
-----------------------------------
local entity = {}
Expand Down
4 changes: 4 additions & 0 deletions scripts/zones/Wajaom_Woodlands/IDs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ zones[xi.zone.WAJAOM_WOODLANDS] =
},
mob =
{
CHIGOES =
{
['Marid'] = GetTableOfIDs('Chigoe', 5),
},
JADED_JODY_PH =
{
[16986376] = 16986378, -- -560 -8 -360
Expand Down
15 changes: 15 additions & 0 deletions scripts/zones/Wajaom_Woodlands/mobs/Grand_Marid.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----------------------------------
-- Area: Wajaom Woodlands
-- Mob: Grand Marid
-----------------------------------
mixins = { require('scripts/mixins/families/chigoe_pet') }
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
end

entity.onMobDespawn = function(mob)
end

return entity
15 changes: 15 additions & 0 deletions scripts/zones/Wajaom_Woodlands/mobs/Marid.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
-----------------------------------
-- Area: Wajaom Woodlands
-- Mob: Marid
-----------------------------------
mixins = { require('scripts/mixins/families/chigoe_pet') }
-----------------------------------
local entity = {}

entity.onMobDeath = function(mob, player, optParams)
end

entity.onMobDespawn = function(mob)
end

return entity
5 changes: 3 additions & 2 deletions sql/mob_groups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2483,7 +2483,7 @@ INSERT INTO `mob_groups` VALUES (3,3344,51,'Red_Osculator',0,128,174,0,0,67,71,0
INSERT INTO `mob_groups` VALUES (4,2269,51,'Kissing_Leech',0,128,174,0,0,67,71,0);
INSERT INTO `mob_groups` VALUES (5,2616,51,'Mercurial_Makara',0,128,607,0,0,68,70,0);

INSERT INTO `mob_groups` VALUES (6,714,51,'Chigoe',330,0,466,0,0,71,73,0);
INSERT INTO `mob_groups` VALUES (6,714,51,'Chigoe_pet',330,128,466,0,0,71,73,0);
INSERT INTO `mob_groups` VALUES (7,2396,51,'Lesser_Colibri',330,0,1509,0,0,63,65,0);
INSERT INTO `mob_groups` VALUES (8,4650,51,'Fomor_Thief',330,1,0,0,0,63,65,0);
INSERT INTO `mob_groups` VALUES (9,6518,51,'Fomor_Beastmaster',330,1,0,0,0,63,65,0);
Expand Down Expand Up @@ -2613,7 +2613,7 @@ INSERT INTO `mob_groups` VALUES (14,4275,52,'Wajaom_Tiger',330,0,2602,0,0,67,69,
INSERT INTO `mob_groups` VALUES (15,4650,52,'Fomor_Thief',330,1,0,0,0,63,65,0);
INSERT INTO `mob_groups` VALUES (16,5137,52,'Harvestman',7200,0,2891,10000,0,72,72,0);
INSERT INTO `mob_groups` VALUES (17,3991,52,'Treant_Sapling',330,0,2464,0,0,66,68,0);
INSERT INTO `mob_groups` VALUES (18,714,52,'Chigoe',330,0,466,0,0,71,73,0);
INSERT INTO `mob_groups` VALUES (18,714,52,'Chigoe_pet',330,128,466,0,0,71,73,0);
INSERT INTO `mob_groups` VALUES (19,1787,52,'Grand_Marid',0,32,1214,0,0,78,79,0);
INSERT INTO `mob_groups` VALUES (20,2562,52,'Marid',330,0,3206,0,0,77,78,0);
INSERT INTO `mob_groups` VALUES (21,765,52,'Colibri',330,0,500,0,0,71,73,0);
Expand Down Expand Up @@ -4182,6 +4182,7 @@ INSERT INTO `mob_groups` VALUES (67,5208,79,'Chorus_Toad',0,128,0,0,20000,95,96,
INSERT INTO `mob_groups` VALUES (68,6554,79,'Guard_Skeleton_war',330,1,1247,0,0,66,69,0);
INSERT INTO `mob_groups` VALUES (69,6758,79,'Shedu',0,128,0,0,0,99,99,0);
INSERT INTO `mob_groups` VALUES (70,0,79,'Vidhuwa_the_Wrathborn',0,128,0,0,0,0,0,0);
INSERT INTO `mob_groups` VALUES (71,714,79,'Chigoe_pet',330,128,466,0,0,62,66,0);

-- ------------------------------------------------------------
-- Southern_San_dOria_[S] (Zone 80)
Expand Down
20 changes: 10 additions & 10 deletions sql/mob_spawn_points.sql
Original file line number Diff line number Diff line change
Expand Up @@ -20389,16 +20389,16 @@ INSERT INTO `mob_spawn_points` VALUES (17100803,'Suhur_Mas','Suhur Mas',3,1.000,
INSERT INTO `mob_spawn_points` VALUES (17100804,'Llamhigyn_Y_Dwr','Llamhigyn Y Dwr',4,1.000,1.000,1.000,0);
INSERT INTO `mob_spawn_points` VALUES (17100805,'Llamhigyn_Y_Dwr','Llamhigyn Y Dwr',4,1.000,1.000,1.000,0);

INSERT INTO `mob_spawn_points` VALUES (17100806,'Chigoe','Chigoe',5,237.115,-8.949,-352.812,20);
INSERT INTO `mob_spawn_points` VALUES (17100807,'Chigoe','Chigoe',5,314.347,-8.709,-446.945,110);
INSERT INTO `mob_spawn_points` VALUES (17100808,'Chigoe','Chigoe',5,318.988,-10.787,-455.924,43);
INSERT INTO `mob_spawn_points` VALUES (17100809,'Chigoe','Chigoe',5,318.605,-10.500,-453.678,232);
INSERT INTO `mob_spawn_points` VALUES (17100810,'Chigoe','Chigoe',5,239.320,-8.268,-353.714,25);
INSERT INTO `mob_spawn_points` VALUES (17100811,'Chigoe','Chigoe',5,270.933,-20.099,-328.418,152);
INSERT INTO `mob_spawn_points` VALUES (17100812,'Chigoe','Chigoe',5,270.459,-20.098,-328.045,151);
INSERT INTO `mob_spawn_points` VALUES (17100813,'Chigoe','Chigoe',5,0.000,0.000,0.000,0);
INSERT INTO `mob_spawn_points` VALUES (17100814,'Chigoe','Chigoe',5,0.000,0.000,0.000,0);
INSERT INTO `mob_spawn_points` VALUES (17100815,'Chigoe','Chigoe',5,0.000,0.000,0.000,0);
INSERT INTO `mob_spawn_points` VALUES (17100806,'Chigoe','Chigoe',71,237.115,-8.949,-352.812,20);
INSERT INTO `mob_spawn_points` VALUES (17100807,'Chigoe','Chigoe',71,314.347,-8.709,-446.945,110);
INSERT INTO `mob_spawn_points` VALUES (17100808,'Chigoe','Chigoe',71,318.988,-10.787,-455.924,43);
INSERT INTO `mob_spawn_points` VALUES (17100809,'Chigoe','Chigoe',71,318.605,-10.5,-453.678,232);
INSERT INTO `mob_spawn_points` VALUES (17100810,'Chigoe','Chigoe',71,239.320,-8.268,-353.714,25);
INSERT INTO `mob_spawn_points` VALUES (17100811,'Chigoe','Chigoe',71,270.933,-20.099,-328.418,152);
INSERT INTO `mob_spawn_points` VALUES (17100812,'Chigoe','Chigoe',71,270.459,-20.098,-328.045,151);
INSERT INTO `mob_spawn_points` VALUES (17100813,'Chigoe','Chigoe',71,1,1,1,0);
INSERT INTO `mob_spawn_points` VALUES (17100814,'Chigoe','Chigoe',71,1,1,1,0);
INSERT INTO `mob_spawn_points` VALUES (17100815,'Chigoe','Chigoe',71,1,1,1,0);
INSERT INTO `mob_spawn_points` VALUES (17100816,'Puktrap','Puktrap',6,77.643,-0.004,-662.026,64);
INSERT INTO `mob_spawn_points` VALUES (17100817,'Marsh_Murre','Marsh Murre',7,69.789,-1.395,-686.672,10);
INSERT INTO `mob_spawn_points` VALUES (17100818,'Marsh_Murre','Marsh Murre',7,97.524,-2.660,-702.212,202);
Expand Down
5 changes: 3 additions & 2 deletions src/map/lua/luautils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,7 @@ namespace luautils

std::unordered_map<std::string, sol::table> idLuaTables;

lua.set_function("GetTableOfIDs", [&](std::string const& name, std::optional<int> optRange) -> sol::table
lua.set_function("GetTableOfIDs", [&](std::string const& name, std::optional<int> optRange, std::optional<int> optOffset) -> sol::table
{
// Is it already built and cached?
if (idLuaTables.find(name) != idLuaTables.end())
Expand Down Expand Up @@ -909,7 +909,8 @@ namespace luautils
return table;
}

uint32 startId = entriesVec.front();
uint32 offset = optOffset.value_or(0);
uint32 startId = entriesVec.front() + offset;
uint32 endId = startId + range;

// TODO: Set this up to be able to iterate negatively too
Expand Down

0 comments on commit d359b3b

Please sign in to comment.