Skip to content

Commit 0573193

Browse files
authored
Merge pull request LandSandBoat#10532 from Skold177/Refactor-Tiamat
[lua] Refactor Tiamat
2 parents 540b63a + 8f24765 commit 0573193

2 files changed

Lines changed: 68 additions & 77 deletions

File tree

scripts/zones/Attohwa_Chasm/mobs/Tiamat.lua

Lines changed: 66 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,20 @@ entity.spawnPoints =
5959
{ x = -549.802, y = -8.944, z = -24.848 },
6060
}
6161

62+
-----------------------------------
63+
-- Enter/Exit Flight Functions
64+
-----------------------------------
6265
local function enterFlight(mob)
63-
mob:setAnimationSub(1) -- Change to flight.
64-
mob:addStatusEffect(xi.effect.ALL_MISS, { power = 1, origin = mob, icon = 0 })
6566
mob:setMobSkillAttack(730)
67+
mob:addStatusEffect(xi.effect.ALL_MISS, { power = 1, origin = mob, icon = 0 })
68+
mob:setAnimationSub(1)
69+
mob:setLocalVar('flightTime', GetSystemTime() + 120)
70+
mob:setLocalVar('changeHP', mob:getHP() - 10000)
71+
end
72+
73+
local function exitFlight(mob)
74+
mob:useMobAbility(xi.mobSkill.TOUCHDOWN_3)
75+
mob:setBehavior(bit.bor(mob:getBehavior(), xi.behavior.NO_TURN))
6676
mob:setLocalVar('flightTime', GetSystemTime() + 120)
6777
mob:setLocalVar('changeHP', mob:getHP() - 10000)
6878
end
@@ -76,7 +86,6 @@ entity.onMobInitialize = function(mob)
7686
end
7787

7888
entity.onMobSpawn = function(mob)
79-
-- Ensure Tiamat spawns with correct ground status
8089
mob:setMobSkillAttack(0)
8190
mob:setAnimationSub(0)
8291
mob:delStatusEffect(xi.effect.ALL_MISS)
@@ -114,17 +123,16 @@ entity.onMobRoam = function(mob)
114123
end
115124

116125
entity.onMobEngage = function(mob, target)
117-
local flightTime = mob:getLocalVar('flightTime')
126+
local currentTime = GetSystemTime()
127+
local flightTime = mob:getLocalVar('flightTime')
118128

119-
-- Set flight time to two min if fresh spawn
120129
if flightTime == 0 then
121-
mob:setLocalVar('flightTime', GetSystemTime() + 120)
122-
-- Otherwise, set how many seconds left to fly from last pull
130+
mob:setLocalVar('flightTime', currentTime + 120)
123131
else
124-
mob:setLocalVar('flightTime', GetSystemTime() + flightTime)
132+
mob:setLocalVar('flightTime', currentTime + flightTime)
125133
end
126134

127-
mob:setLocalVar('twohourTime', GetSystemTime() + 210)
135+
mob:setLocalVar('twohourTime', currentTime + 210)
128136
mob:setLocalVar('changeHP', mob:getHP() - 10000)
129137
end
130138

@@ -163,82 +171,63 @@ entity.onMobFight = function(mob, target)
163171
end
164172

165173
-- Gains a delay reduction (from 210 to 160) when health is under 10%
166-
if hpp <= 10 and mob:getLocalVar('appliedDelayReduction') == 0 then
167-
mob:addMod(xi.mod.DELAY, -833)
168-
mob:setLocalVar('appliedDelayReduction', 1)
169-
elseif hpp > 10 and mob:getLocalVar('appliedDelayReduction') == 1 then
170-
mob:delMod(xi.mod.DELAY, -833)
171-
mob:setLocalVar('appliedDelayReduction', 0)
174+
if hpp <= 10 then
175+
mob:setDelay(160)
176+
else
177+
mob:setDelay(210)
172178
end
173179

174-
-- Animation (Ground or flight mode) logic.
175-
if
176-
not mob:hasStatusEffect(xi.effect.MIGHTY_STRIKES) and
177-
not xi.combat.behavior.isEntityBusy(mob)
178-
then
179-
local flightTime = mob:getLocalVar('flightTime')
180-
local twohourTime = mob:getLocalVar('twohourTime')
181-
local changeHP = mob:getLocalVar('changeHP')
182-
local animation = mob:getAnimationSub()
183-
184-
-- Initial grounded mode.
185-
if
186-
animation == 0 and
187-
(GetSystemTime() > flightTime and mob:getHP() < changeHP)
188-
then
189-
enterFlight(mob)
190-
191-
-- Flight mode.
192-
elseif
193-
animation == 1 and
194-
(GetSystemTime() > flightTime and mob:getHP() < changeHP)
195-
then
196-
mob:useMobAbility(1282) -- This ability also handles animation change to 2.
197-
mob:setBehavior(bit.bor(mob:getBehavior(), xi.behavior.NO_TURN))
198-
mob:setLocalVar('flightTime', GetSystemTime() + 120)
199-
mob:setLocalVar('changeHP', mob:getHP() - 10000)
200-
201-
-- Subsequent grounded mode.
202-
elseif animation == 2 then
203-
-- 2-Hour logic.
204-
if GetSystemTime() > twohourTime then
205-
mob:useMobAbility(688) -- Mighty Strikes
206-
mob:setLocalVar('twohourTime', GetSystemTime() + 210)
207-
208-
elseif
209-
GetSystemTime() > flightTime or
210-
mob:getHP() < changeHP
211-
then
212-
enterFlight(mob)
213-
end
214-
end
215-
end
180+
local animationSub = mob:getAnimationSub()
216181

217182
-- Tiamat wakes from sleep in air
218183
if
219-
(mob:hasStatusEffect(xi.effect.SLEEP_I) or
220-
mob:hasStatusEffect(xi.effect.SLEEP_II) or
221-
mob:hasStatusEffect(xi.effect.LULLABY)) and
222-
mob:getAnimationSub() == 1
184+
animationSub == 1 and
185+
mob:hasStatusEffect(xi.effect.SLEEP_I)
223186
then
224187
mob:wakeUp()
225188
end
226-
end
227189

228-
entity.onMobMobskillChoose = function(mob, target, skillId)
229-
if mob:getAnimationSub() == 1 then
230-
mob:setLocalVar('skill_tp', mob:getTP())
190+
-- If Mighty Strikes is active, cannot fly until it ends.
191+
if
192+
mob:hasStatusEffect(xi.effect.MIGHTY_STRIKES) or
193+
xi.combat.behavior.isEntityBusy(mob)
194+
then
195+
return
231196
end
232-
end
233197

234-
entity.onMobWeaponSkill = function(mob, target, skill, action)
235-
-- Don't lose TP from autos during flight
236-
if skill:getID() == 1278 then
237-
mob:addTP(64) -- Needs to gain TP from flight auto attacks
238-
mob:setLocalVar('skill_tp', 0)
239-
elseif skill:getID() == 1282 then -- Don't consume TP on touchdown
240-
mob:addTP(mob:getLocalVar('skill_tp'))
241-
mob:setLocalVar('skill_tp', 0)
198+
-- Landing / Flying logic
199+
local currentTime = GetSystemTime()
200+
local flightTime = mob:getLocalVar('flightTime')
201+
local twohourTime = mob:getLocalVar('twohourTime')
202+
local changeHP = mob:getLocalVar('changeHP')
203+
local currentHP = mob:getHP()
204+
205+
if
206+
animationSub == 0 and
207+
currentTime > flightTime or
208+
currentHP < changeHP
209+
then
210+
enterFlight(mob)
211+
212+
elseif
213+
animationSub == 1 and
214+
currentTime > flightTime or
215+
currentHP < changeHP
216+
then
217+
exitFlight(mob)
218+
219+
elseif animationSub == 2 then
220+
-- 2-Hour logic.
221+
if currentTime > twohourTime then
222+
mob:useMobAbility(xi.mobSkill.MIGHTY_STRIKES_1)
223+
mob:setLocalVar('twohourTime', currentTime + 210)
224+
225+
elseif
226+
currentTime > flightTime or
227+
currentHP < changeHP
228+
then
229+
enterFlight(mob)
230+
end
242231
end
243232
end
244233

@@ -259,12 +248,14 @@ entity.onMobDisengage = function(mob)
259248
-- Reset Tiamat back to the ground on wipe
260249
if mob:getAnimationSub() == 1 then
261250
local flightTime = mob:getLocalVar('flightTime')
262-
mob:setLocalVar('flightTime', flightTime - GetSystemTime()) -- Get seconds left to fly for next pull
251+
mob:setLocalVar('flightTime', math.max(flightTime - GetSystemTime(), 1)) -- Get seconds left to fly for next pull
263252
mob:setAnimationSub(0)
264253
mob:delStatusEffect(xi.effect.ALL_MISS)
265254
mob:setBehavior(bit.bor(mob:getBehavior(), xi.behavior.NO_TURN))
266255
mob:setMobSkillAttack(0)
267256
mob:setLocalVar('changeHP', 0)
257+
else
258+
mob:setLocalVar('flightTime', 0)
268259
end
269260
end
270261

sql/mob_skills.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1310,7 +1310,7 @@ INSERT INTO `mob_skills` VALUES (1278,652,'inferno_blast_alt',0,0.0,18.0,2000,0,
13101310
INSERT INTO `mob_skills` VALUES (1279,653,'tebbad_wing',1,0.0,30.0,2000,1500,4,0,0,0,0,0,0);
13111311
INSERT INTO `mob_skills` VALUES (1280,654,'spike_flail',1,0.0,23.0,2000,2000,4,0,0,0,0,0,0);
13121312
INSERT INTO `mob_skills` VALUES (1281,655,'fiery_breath',4,0.0,18.0,2000,1500,4,0,0,0,0,0,0);
1313-
INSERT INTO `mob_skills` VALUES (1282,656,'touchdown',1,0.0,30.0,2000,0,4,@SKILLFLAG_ALWAYS_ANIMATE,0,0,0,0,0);
1313+
INSERT INTO `mob_skills` VALUES (1282,656,'touchdown',1,0.0,30.0,2000,0,4,@SKILLFLAG_NO_TP_COST + @SKILLFLAG_ALWAYS_ANIMATE,0,0,0,0,0);
13141314
INSERT INTO `mob_skills` VALUES (1283,657,'inferno_blast',1,0.0,23.0,2000,2000,4,0,0,0,0,0,0);
13151315
INSERT INTO `mob_skills` VALUES (1284,658,'tebbad_wing_air',1,0.0,30.0,2000,1500,4,0,0,0,0,0,0);
13161316
INSERT INTO `mob_skills` VALUES (1285,659,'absolute_terror',0,0.0,18.0,2000,1500,4,0,0,0,0,0,0);
@@ -1320,7 +1320,7 @@ INSERT INTO `mob_skills` VALUES (1288,963,'sleet_blast_alt',0,0.0,18.0,2000,0,4,
13201320
INSERT INTO `mob_skills` VALUES (1289,653,'gregale_wing',1,0.0,30.0,2000,1500,4,0,0,0,0,0,0);
13211321
INSERT INTO `mob_skills` VALUES (1290,654,'spike_flail',1,0.0,23.0,2000,2000,4,0,0,0,0,0,0);
13221322
INSERT INTO `mob_skills` VALUES (1291,962,'glacial_breath',4,0.0,18.0,2000,1500,4,0,0,0,0,0,0);
1323-
INSERT INTO `mob_skills` VALUES (1292,656,'touchdown',1,0.0,30.0,2000,0,4,@SKILLFLAG_ALWAYS_ANIMATE,0,0,0,0,0);
1323+
INSERT INTO `mob_skills` VALUES (1292,656,'touchdown',1,0.0,30.0,2000,0,4,@SKILLFLAG_NO_TP_COST + @SKILLFLAG_ALWAYS_ANIMATE,0,0,0,0,0);
13241324
INSERT INTO `mob_skills` VALUES (1293,964,'sleet_blast',1,0.0,23.0,2000,2000,4,0,0,0,0,0,0);
13251325
INSERT INTO `mob_skills` VALUES (1294,658,'gregale_wing_air',1,0.0,30.0,2000,1500,4,0,0,0,0,0,0);
13261326
INSERT INTO `mob_skills` VALUES (1295,659,'absolute_terror',0,0.0,18.0,4000,1500,4,0,0,0,0,0,0);

0 commit comments

Comments
 (0)