Skip to content

Commit

Permalink
Merge pull request #1442 from WinterSolstice8/base
Browse files Browse the repository at this point in the history
[PLD/RUN] Implement Crusade, [RUN] Implement Pflug, partially implement Foil.
  • Loading branch information
claywar authored Mar 21, 2022
2 parents 408ba2b + 4ef264c commit 74dad17
Show file tree
Hide file tree
Showing 14 changed files with 212 additions and 6 deletions.
3 changes: 2 additions & 1 deletion documentation/modifier.h ordered by ID.txt
Original file line number Diff line number Diff line change
Expand Up @@ -746,14 +746,15 @@ enum class Mod
INSPIRATION_FAST_CAST = 1021, // Inspiration Fast Cast, additive with Fast Cast with a combined cap beyond 80%
PARRY_SPIKES = 1022, // Battuta parry spikes rate
PARRY_SPIKES_DMG = 1023, // Battuta parry spikes damage
SPECIAL_ATTACK_EVASION = 1024, // Foil "Special Attack" evasion

// The spares take care of finding the next ID to use so long as we don't forget to list IDs that have been freed up by refactoring.
// 570 through 825 used by WS DMG mods these are not spares.
// Weaponskill %damage modifiers
// The following modifier should not ever be set, but %damage modifiers to weaponskills use the next 255 IDs (this modifier + the WSID)
// For example, +10% damage to Chant du Cygne would be ID 570 + 225 (795)

// SPARE = 1024,
// SPARE = 1025,
};

// temporary workaround for using enum class as unordered_map key until compilers support it
Expand Down
21 changes: 21 additions & 0 deletions scripts/globals/abilities/pflug.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-----------------------------------
-- Ability: Pflug
-- Enhances resistance. The types of resistance enhanced depend upon the runes you harbor.
-- Obtained: Rune Fencer Level 40
-- Recast Time: 3:00
-- Duration: 2:00
-----------------------------------
require("scripts/globals/status")
require("scripts/globals/job_utils/rune_fencer")
-----------------------------------
local ability_object = {}

ability_object.onAbilityCheck = function(player, target, ability)
return xi.job_utils.rune_fencer.checkHaveRunes(player)
end

ability_object.onUseAbility = function(player, target, ability, action)
return xi.job_utils.rune_fencer.usePflug(player, target, ability, action)
end

return ability_object
19 changes: 19 additions & 0 deletions scripts/globals/effects/foil.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-----------------------------------
-- xi.effect.FOIL
-----------------------------------
require("scripts/globals/status")
-----------------------------------
local effect_object = {}

effect_object.onEffectGain = function(target, effect)
effect:addMod(xi.mod.SPECIAL_ATTACK_EVASION, effect:getPower())
end

effect_object.onEffectTick = function(target, effect) -- TODO: Determine how Foil ticks down? It's description indicates this.
end

effect_object.onEffectLose = function(target, effect)
-- intentionally blank. mod removes itself in C++ due to being added to the effect.
end

return effect_object
20 changes: 20 additions & 0 deletions scripts/globals/effects/pflug.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-----------------------------------
-- xi.effect.PFLUG
-----------------------------------
require("scripts/globals/status")
require("scripts/globals/job_utils/rune_fencer")
-----------------------------------
local effect_object = {}

effect_object.onEffectGain = function(target, effect)
xi.job_utils.rune_fencer.onPflugEffectGain(target, effect)
end

effect_object.onEffectTick = function(target, effect)
end

effect_object.onEffectLose = function(target, effect)
xi.job_utils.rune_fencer.onPflugEffectLose(target, effect)
end

return effect_object
16 changes: 16 additions & 0 deletions scripts/globals/items/scroll_of_crusade.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-----------------------------------
-- ID: 5103
-- Scroll of Crusade
-- Teaches the white magic Crusade
-----------------------------------
local item_object = {}

item_object.onItemCheck = function(target)
return target:canLearnSpell(476)
end

item_object.onItemUse = function(target)
target:addSpell(476)
end

return item_object
16 changes: 16 additions & 0 deletions scripts/globals/items/scroll_of_foil.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-----------------------------------
-- ID: 5102
-- Scroll of Foil
-- Teaches the white magic Foil
-----------------------------------
local item_object = {}

item_object.onItemCheck = function(target)
return target:canLearnSpell(840)
end

item_object.onItemUse = function(target)
target:addSpell(840)
end

return item_object
56 changes: 56 additions & 0 deletions scripts/globals/job_utils/rune_fencer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -598,3 +598,59 @@ xi.job_utils.rune_fencer.useSwipeLunge = function(player, target, ability, actio

return cumulativeDamage
end

-- see http://wiki.ffo.jp/html/1720.html, the effects resisted are against the strong element.
-- for example, Amnesia is fire based, therefore water runes (Unda) add resist Amnesia.
-- These effects seem to match the "Resist X" traits that all jobs have, including unused player traits that made it into autotranslate; Resist Curse/Charm
local function addPflugResistType(type, effect, power)

if type >= xi.effect.IGNIS and type <= xi.effect.TENEBRAE then

local pflugResistTypes =
{
[xi.effect.IGNIS] = {xi.mod.PARALYZERES, xi.mod.BINDRES},
[xi.effect.GELUS] = {xi.mod.SILENCERES, xi.mod.GRAVITYRES},
[xi.effect.FLABRA] = {xi.mod.PETRIFYRES, xi.mod.SLOWRES},
[xi.effect.TELLUS] = {xi.mod.STUNRES},
[xi.effect.SULPOR] = {xi.mod.POISONRES},
[xi.effect.UNDA] = {xi.mod.AMNESIARES, xi.mod.PLAGUERES},
[xi.effect.LUX] = {xi.mod.SLEEPRES, xi.mod.BLINDRES, xi.mod.CURSERES},
[xi.effect.TENEBRAE] = {xi.mod.CHARMRES},
}

local resistTypes = pflugResistTypes[type]

for _, resistMod in pairs(resistTypes) do -- store mod in effect, this function is triggered from event onEffectGain so it adds to the player automatically.
effect:addMod(resistMod, power)
end

end
end


xi.job_utils.rune_fencer.onPflugEffectGain = function(target, effect)
local statusEffects = target:getStatusEffects()

for _, statusEffect in ipairs(statusEffects) do
local type = statusEffect:getType()
addPflugResistType(type, effect, effect:getPower() + effect:getSubPower())
end
end

xi.job_utils.rune_fencer.onPflugEffectLose = function(target, effect)
-- intentionally blank, the effect has a mod list that is deleted after this event is called in CStatusEffectContainer::RemoveStatusEffect
end

xi.job_utils.rune_fencer.usePflug = function(player, target, ability, action)
local highestRune = player:getHighestRuneEffect()
local baseStrength = 10
local meritBonus = player:getMerit(xi.merit.MERIT_PFLUG_EFFECT)

if player:getMainJob() == xi.job.RUN then
baseStrength = 15
end

action:speceffect(target:getID(), getSpecEffectElementWard(highestRune))

player:addStatusEffect(xi.effect.PFLUG, baseStrength, 0, 120, 0, meritBonus)
end
25 changes: 25 additions & 0 deletions scripts/globals/spells/white/crusade.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
-----------------------------------
-- Spell: Crusade
-----------------------------------
require("scripts/globals/magic")
require("scripts/globals/msg")
require("scripts/globals/status")
-----------------------------------
local spell_object = {}

spell_object.onMagicCastingCheck = function(caster, target, spell)
return 0
end

spell_object.onSpellCast = function(caster, target, spell)

if target:addStatusEffect(xi.effect.ENMITY_BOOST, 30, 0, 300) then
spell:setMsg(xi.msg.basic.MAGIC_GAIN_EFFECT)
else
spell:setMsg(xi.msg.basic.MAGIC_NO_EFFECT)
end

return xi.effect.ENMITY_BOOST
end

return spell_object
28 changes: 28 additions & 0 deletions scripts/globals/spells/white/foil.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
-----------------------------------
-- Spell: Foil
-----------------------------------
require("scripts/globals/magic")
require("scripts/globals/msg")
require("scripts/globals/status")
-----------------------------------
local spell_object = {}

spell_object.onMagicCastingCheck = function(caster, target, spell)
return 0
end

-- TODO: determine mechanics of how Foil's "Special Attack" evasion works.
-- Martel has a post about it here: https://www.bluegartr.com/threads/115399-Rune-Fencer-Findings?p=5665305&viewfull=1#post5665305
-- More testing is required (such as determining accuracy of the target used for testing)
spell_object.onSpellCast = function(caster, target, spell)

if target:addStatusEffect(xi.effect.FOIL, 0, 0, 300) then -- power set to 0 because true mechanics are unknown as of now. The primary use of Foil is for enmity anyway.
spell:setMsg(xi.msg.basic.MAGIC_GAIN_EFFECT)
else
spell:setMsg(xi.msg.basic.MAGIC_NO_EFFECT)
end

return xi.effect.FOIL
end

return spell_object
1 change: 1 addition & 0 deletions scripts/globals/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1234,6 +1234,7 @@ xi.mod =
INSPIRATION_FAST_CAST = 1021, -- Inspiration's fast cast, additive with normal fast cast for a cap beyond 80%
PARRY_SPIKES = 1022, -- Battuta parry spikes rate
PARRY_SPIKES_DMG = 1023, -- Battuta parry spikes damage
SPECIAL_ATTACK_EVASION = 1024, -- Foil "Special Attack" evasion

FIRE_AFFINITY_DMG = 347,
ICE_AFFINITY_DMG = 348,
Expand Down
4 changes: 2 additions & 2 deletions sql/item_basic.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4786,8 +4786,8 @@ INSERT INTO `item_basic` VALUES (5098,483,'scroll_of_boost-int','boost-int',1,34
INSERT INTO `item_basic` VALUES (5099,484,'scroll_of_boost-mnd','boost-mnd',1,34444,28,0,3875);
INSERT INTO `item_basic` VALUES (5100,485,'scroll_of_boost-chr','boost-chr',1,34444,28,0,3997);
INSERT INTO `item_basic` VALUES (5101,494,'scroll_of_arise','arise',1,34444,28,0,0);
INSERT INTO `item_basic` VALUES (5102,840,'scroll_of_foil','foil',1,34444,28,0,0);
INSERT INTO `item_basic` VALUES (5103,0,'scroll_of_crusade','crusade',1,34444,28,0,0);
INSERT INTO `item_basic` VALUES (5102,840,'scroll_of_foil','foil',1,1676,28,0,0);
INSERT INTO `item_basic` VALUES (5103,476,'scroll_of_crusade','crusade',1,1676,28,0,0);
INSERT INTO `item_basic` VALUES (5104,845,'scroll_of_flurry','flurry',1,1548,28,0,43);
INSERT INTO `item_basic` VALUES (5105,846,'scroll_of_flurry_ii','flurry_ii',1,34316,28,0,43);
INSERT INTO `item_basic` VALUES (5106,0,'scroll_of_inundation','inundation',1,34444,28,0,0);
Expand Down
2 changes: 2 additions & 0 deletions sql/item_usable.sql
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,8 @@ INSERT INTO `item_usable` VALUES (5097,'scroll_of_boost-agi',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5098,'scroll_of_boost-int',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5099,'scroll_of_boost-mnd',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5100,'scroll_of_boost-chr',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5102,'scroll_of_foil',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5103,'scroll_of_crusade',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5104,'scroll_of_flurry',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5105,'scroll_of_flurry_ii',1,1,11,5,0,0,0,0);
INSERT INTO `item_usable` VALUES (5120,'titanic_sawfish',1,1,25,0,0,0,0,0);
Expand Down
4 changes: 2 additions & 2 deletions sql/spell_list.sql
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ INSERT INTO `spell_list` VALUES (471,'foe_lullaby_ii',0x000000000000000000530000
INSERT INTO `spell_list` VALUES (473,'refresh_ii',0x00000000520000000000000000000000000000000000,6,29,7,0,3,34,60,5000,27000,0,0,118,2000,0,0,1.00,1,165,0,204,'ABYSSEA');
INSERT INTO `spell_list` VALUES (474,'cura_ii',0x00005300000000000000000000000000000000000000,6,20,7,0,1,33,45,3000,40000,0,0,298,2000,1,0,1.00,75,75,0,0,'ABYSSEA');
INSERT INTO `spell_list` VALUES (475,'cura_iii',0x00006000000000000000000000000000000000000000,6,20,7,0,1,33,60,3000,50000,0,0,298,2000,1,0,1.00,100,100,0,0,'ABYSSEA');
-- INSERT INTO `spell_list` VALUES (476,'crusade',0x00000000000058000000000000000000000000000000,6,7,0,1,34,18,3000,5000,230,0,53,4000,4,0,1.00,0,0,0,204,NULL);
INSERT INTO `spell_list` VALUES (476,'crusade',0x00000000000058000000000000000000000000000058,6,4,8,0,1,34,18,3000,10000,230,0,825,2000,0,0,1.00,0,0,0,204,'SOA');
INSERT INTO `spell_list` VALUES (477,'regen_iv',0x000056000000000000000000000000000000004F0000,6,28,7,0,3,34,82,2250,24000,0,0,140,2000,4,0,1.00,1,165,0,204,'ABYSSEA');
INSERT INTO `spell_list` VALUES (478,'embrava',0x00000000000000000000000000000000000000050000,6,0,7,0,27,36,1,3000,3000,230,0,121,2000,4,1,1.00,1,165,8,204,'ABYSSEA');
INSERT INTO `spell_list` VALUES (479,'boost-str',0x00005D00000000000000000000000000000000000000,6,140,1,0,1,34,36,5000,10000,0,0,0,2000,1,0,1.00,1,80,0,204,'ABYSSEA');
Expand Down Expand Up @@ -810,7 +810,7 @@ INSERT INTO `spell_list` VALUES (836,'thundara',0x000000000000000000000000000000
INSERT INTO `spell_list` VALUES (837,'thundara_ii',0x00000000000000000000000000000000000000005F00,2,152,5,0,4,36,253,3000,15000,2,0,900,2000,1,0,1.00,0,0,0,120,'SOA');
INSERT INTO `spell_list` VALUES (838,'watera',0x00000000000000000000000000000000000000001E00,2,153,6,0,4,36,66,1500,5000,2,0,901,2000,1,0,1.00,0,0,0,120,'SOA');
INSERT INTO `spell_list` VALUES (839,'watera_ii',0x00000000000000000000000000000000000000004B00,2,153,6,0,4,36,163,3000,15000,2,0,902,2000,1,0,1.00,0,0,0,120,'SOA');
-- INSERT INTO `spell_list` VALUES (840,'foil',0x0000000000000000000000000000000000000000003A,6,4,0,1,0,48,1000,30000,0,0,0,4000,0,0,1.00,20,80,0,204,'SOA');
INSERT INTO `spell_list` VALUES (840,'foil',0x0000000000000000000000000000000000000000003A,6,4,3,0,1,34,48,3000,45000,230,0,903,2000,0,0,1.00,880,320,0,204,'SOA');
INSERT INTO `spell_list` VALUES (841,'distract',0x00000000230000000000000000000000000000000000,2,154,2,0,4,35,32,3000,10000,0,0,933,2000,0,0,1.00,1,320,0,204,'SOA');
INSERT INTO `spell_list` VALUES (842,'distract_ii',0x00000000550000000000000000000000000000000000,2,154,2,0,4,35,58,3000,10000,0,0,934,4000,0,0,1.00,1,320,0,204,'SOA');
INSERT INTO `spell_list` VALUES (843,'frazzle',0x000000002A0000000000000000000000000000000000,2,155,8,0,4,35,38,3000,10000,0,0,935,4000,0,0,1.00,1,320,0,204,'SOA');
Expand Down
3 changes: 2 additions & 1 deletion src/map/modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -610,6 +610,7 @@ enum class Mod
INSPIRATION_FAST_CAST = 1021, // Inspiration Fast Cast, additive with Fast Cast with a combined cap beyond 80%
PARRY_SPIKES = 1022, // Battuta parry spikes rate
PARRY_SPIKES_DMG = 1023, // Battuta parry spikes damage
SPECIAL_ATTACK_EVASION = 1024, // Foil "Special Attack" evasion

// Stores the amount of elemental affinity (elemental staves mostly) - damage, acc, and perpetuation is all handled separately
FIRE_AFFINITY_DMG = 347, // They're stored separately due to Magian stuff - they can grant different levels of
Expand Down Expand Up @@ -880,7 +881,7 @@ enum class Mod
// 888
// 936
//
// SPARE = 1024, and onward
// SPARE = 1025, and onward
};

// temporary workaround for using enum class as unordered_map key until compilers support it
Expand Down

0 comments on commit 74dad17

Please sign in to comment.