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 #1469 from MarianArlt/severe-mob-mod
Browse files Browse the repository at this point in the history
Add SEVERE_SPELL_CHANCE mob modifier
  • Loading branch information
zach2good authored Nov 4, 2020
2 parents 547f7ce + 949b8e2 commit 4ccff3f
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 76 deletions.
8 changes: 5 additions & 3 deletions scripts/globals/status.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2217,6 +2217,8 @@ tpz.auraTarget =

------------------------------------
-- MOBMODs
-- maps src/map/mob_modifier.h
-- always edit both
------------------------------------

tpz.mobMod =
Expand All @@ -2234,7 +2236,7 @@ tpz.mobMod =
SUBLINK = 10, -- sub link group
LINK_RADIUS = 11, -- link radius
DRAW_IN = 12, -- 1 - player draw in, 2 - alliance draw in -- only add as a spawn mod!
-- 13 Available for use
SEVERE_SPELL_CHANCE = 13, -- % chance to use a severe spell like death or impact
SKILL_LIST = 14, -- uses given mob skill list
MUG_GIL = 15, -- amount gil carried for mugging
-- 16 Available for use
Expand All @@ -2245,8 +2247,8 @@ tpz.mobMod =
PET_SPELL_LIST = 21, -- set pet spell list
NA_CHANCE = 22, -- % chance to cast -na
IMMUNITY = 23, -- immune to set status effects. This only works from the db, not scripts
-- 24 Available for use
BUILD_RESIST = 25, -- builds resistance to given effects -- not impl
GRADUAL_RAGE = 24, -- (!) TODO: NOT YET IMPLEMENTED -- gradually rages
BUILD_RESIST = 25, -- (!) TODO: NOT YET IMPLEMENTED -- builds resistance to given effects
SUPERLINK = 26, -- super link group. Only use this in mob_spawn_mods / scripts!
SPELL_LIST = 27, -- set spell list
EXP_BONUS = 28, -- bonus exp (bonus / 100) negative values reduce exp.
Expand Down
143 changes: 72 additions & 71 deletions src/map/mob_modifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,81 +23,82 @@

/*
This is a list of mob specific modifiers. They can be added to pools / families / spawn points.
Gets mapped for convenience in scripts/globals/status.lua#2223+ -- always edit both
*/

enum MOBMODIFIER : int
{
MOBMOD_NONE = 0,
MOBMOD_GIL_MIN = 1, // minimum gil drop -- spawn mod only
MOBMOD_GIL_MAX = 2, // maximum gil drop -- spawn mod only
MOBMOD_MP_BASE = 3, // Give mob mp. Used for mobs that are not mages, wyverns, avatars
MOBMOD_SIGHT_RANGE = 4, // sight range
MOBMOD_SOUND_RANGE = 5, // sound range
MOBMOD_BUFF_CHANCE = 6, // % chance to buff (combat only)
MOBMOD_GA_CHANCE = 7, // % chance to use -ga spell
MOBMOD_HEAL_CHANCE = 8, // % chance to use heal
MOBMOD_HP_HEAL_CHANCE = 9, // can cast cures below this HP %
MOBMOD_SUBLINK = 10, // sub link group
MOBMOD_LINK_RADIUS = 11, // link radius
MOBMOD_DRAW_IN = 12, // 1 - player draw in, 2 - alliance draw in -- only add as a spawn mod!
MOBMOD_RAGE = 13, // define rage timer -- only add as a spawn mod! (OBSOLETE - use rage mixin)
MOBMOD_SKILL_LIST = 14, // uses given mob skill list
MOBMOD_MUG_GIL = 15, // amount gil carried for mugging
MOBMOD_MAIN_2HOUR = 16, // give mob its main job two hour, value can maybe be sent to skill (OBSOLETE - use job_special mixin)
MOBMOD_NO_DESPAWN = 17, // do not despawn when too far from spawn. Gob Diggers have this.
MOBMOD_VAR = 18, // temp var for whatever. Gets cleared on spawn
MOBMOD_SUB_2HOUR = 19, // give mob its sub job two hour (dynamis NM) (OBSOLETE - use job_special mixin)
MOBMOD_TP_USE_CHANCE = 20, // % chance to use tp
MOBMOD_PET_SPELL_LIST = 21, // set pet spell list
MOBMOD_NA_CHANCE = 22, // % chance to cast -na
MOBMOD_IMMUNITY = 23, // immune to set status effects. This only works from the db, not scripts
MOBMOD_GRADUAL_RAGE = 24, // gradually rages -- not impl
MOBMOD_BUILD_RESIST = 25, // builds resistance to given effects -- not impl
MOBMOD_SUPERLINK = 26, // super link group. Only use this in mob_spawn_mods / scripts!
MOBMOD_SPELL_LIST = 27, // set spell list
MOBMOD_EXP_BONUS = 28, // bonus exp (bonus / 100) negative values reduce exp.
MOBMOD_ASSIST = 29, // mobs will assist me
MOBMOD_SPECIAL_SKILL = 30, // give special skill
MOBMOD_ROAM_DISTANCE = 31, // distance allowed to roam from spawn
MOBMOD_MULTI_2HOUR = 32, // can use two hour multiple times (OBSOLETE - use job_special mixin)
MOBMOD_SPECIAL_COOL = 33, // cool down for special
MOBMOD_MAGIC_COOL = 34, // cool down for magic
MOBMOD_STANDBACK_COOL = 35, // cool down time for standing back (casting spell while not in attack range)
MOBMOD_ROAM_COOL = 36, // cool down time in seconds after roaming
MOBMOD_ALWAYS_AGGRO = 37, // aggro regardless of level. Spheroids
MOBMOD_NO_DROPS = 38, // If set monster cannot drop any items, not even seals.
MOBMOD_SHARE_POS = 39, // share a pos with another mob (eald'narche exoplates)
MOBMOD_TELEPORT_CD = 40, // cooldown for teleport abilities (tarutaru AA, angra mainyu, eald'narche)
MOBMOD_TELEPORT_START = 41, // mobskill ID to begin teleport
MOBMOD_TELEPORT_END = 42, // mobskill ID to end teleport
MOBMOD_TELEPORT_TYPE = 43, // teleport type - 1: on cooldown, 2 - to close distance
MOBMOD_DUAL_WIELD = 44, // enables a mob to use their offhand in attacks
MOBMOD_ADD_EFFECT = 45, // enables additional effect script to process on mobs attacks
MOBMOD_AUTO_SPIKES = 46, // enables additional effect script to process when mob is attacked
MOBMOD_SPAWN_LEASH = 47, // forces a mob to not move farther from its spawn than its leash distance
MOBMOD_SHARE_TARGET = 48, // mob always targets same target as ID in this var
MOBMOD_CHECK_AS_NM = 49, // If set , mob will check as a NM
MOBMOD_PROC_2HOUR = 50, // chance of mob's 2 hour activating 0-100% (OBSOLETE - use job_special mixin)
MOBMOD_ROAM_TURNS = 51, // Maximum amount of turns during a roam
MOBMOD_ROAM_RATE = 52, // Roaming frequency. roam_cool - rand(roam_cool / (roam_rate / 10))
MOBMOD_BEHAVIOR = 53, // Add behaviors to mob
MOBMOD_GIL_BONUS = 54, // Allow mob to drop gil. Multiplier to gil dropped by mob (bonus / 100) * total
MOBMOD_IDLE_DESPAWN = 55, // Time (in seconds) to despawn after being idle
MOBMOD_HP_STANDBACK = 56, // mob will always standback with hp % higher to value
MOBMOD_MAGIC_DELAY = 57, // Amount of seconds mob waits before casting first spell
MOBMOD_SPECIAL_DELAY = 58, // Amount of seconds mob waits before using first special
MOBMOD_WEAPON_BONUS = 59, // Add a bonus percentage to mob weapon damage ( bonus / 100 )
MOBMOD_SPAWN_ANIMATIONSUB = 60, // reset animationsub to this on spawn
MOBMOD_HP_SCALE = 61, // Scale the mobs max HP. ( hp_scale / 100 ) * maxhp
MOBMOD_NO_STANDBACK = 62, // Mob will never standback
MOBMOD_ATTACK_SKILL_LIST = 63, // skill list to use in place of regular attacks
MOBMOD_CHARMABLE = 64, // mob is charmable
MOBMOD_NO_MOVE = 65, // Mob will not be able to move
MOBMOD_MULTI_HIT = 66, // Mob will have as many swings as defined.
MOBMOD_NO_AGGRO = 67, // If set, mob cannot aggro until unset.
MOBMOD_ALLI_HATE = 68, // Range around target to add alliance member to enmity list.
MOBMOD_NO_LINK = 69, // If set, mob cannot link until unset.
MOBMOD_NO_REST = 70, // Mob cannot regain hp (e.g. re-burrowing antlions during ENM).
MOBMOD_NONE = 0,
MOBMOD_GIL_MIN = 1, // minimum gil drop -- spawn mod only
MOBMOD_GIL_MAX = 2, // maximum gil drop -- spawn mod only
MOBMOD_MP_BASE = 3, // Give mob mp. Used for mobs that are not mages, wyverns, avatars
MOBMOD_SIGHT_RANGE = 4, // sight range
MOBMOD_SOUND_RANGE = 5, // sound range
MOBMOD_BUFF_CHANCE = 6, // % chance to buff (combat only)
MOBMOD_GA_CHANCE = 7, // % chance to use -ga spell
MOBMOD_HEAL_CHANCE = 8, // % chance to use heal
MOBMOD_HP_HEAL_CHANCE = 9, // can cast cures below this HP %
MOBMOD_SUBLINK = 10, // sub link group
MOBMOD_LINK_RADIUS = 11, // link radius
MOBMOD_DRAW_IN = 12, // 1 - player draw in, 2 - alliance draw in -- only add as a spawn mod!
MOBMOD_SEVERE_SPELL_CHANCE = 13, // % chance to use a severe spell like death or impact
MOBMOD_SKILL_LIST = 14, // uses given mob skill list
MOBMOD_MUG_GIL = 15, // amount gil carried for mugging
// 16 Available for use
MOBMOD_NO_DESPAWN = 17, // do not despawn when too far from spawn. Gob Diggers have this.
MOBMOD_VAR = 18, // temp var for whatever. Gets cleared on spawn
// 19 Available for use
MOBMOD_TP_USE_CHANCE = 20, // % chance to use tp
MOBMOD_PET_SPELL_LIST = 21, // set pet spell list
MOBMOD_NA_CHANCE = 22, // % chance to cast -na
MOBMOD_IMMUNITY = 23, // immune to set status effects. This only works from the db, not scripts
MOBMOD_GRADUAL_RAGE = 24, // (!) TODO: NOT YET IMPLEMENTED -- gradually rages
MOBMOD_BUILD_RESIST = 25, // (!) TODO: NOT YET IMPLEMENTED -- builds resistance to given effects
MOBMOD_SUPERLINK = 26, // super link group. Only use this in mob_spawn_mods / scripts!
MOBMOD_SPELL_LIST = 27, // set spell list
MOBMOD_EXP_BONUS = 28, // bonus exp (bonus / 100) negative values reduce exp.
MOBMOD_ASSIST = 29, // mobs will assist me
MOBMOD_SPECIAL_SKILL = 30, // give special skill
MOBMOD_ROAM_DISTANCE = 31, // distance allowed to roam from spawn
// 32 Available for use
MOBMOD_SPECIAL_COOL = 33, // cool down for special
MOBMOD_MAGIC_COOL = 34, // cool down for magic
MOBMOD_STANDBACK_COOL = 35, // cool down time for standing back (casting spell while not in attack range)
MOBMOD_ROAM_COOL = 36, // cool down time in seconds after roaming
MOBMOD_ALWAYS_AGGRO = 37, // aggro regardless of level. Spheroids
MOBMOD_NO_DROPS = 38, // If set monster cannot drop any items, not even seals.
MOBMOD_SHARE_POS = 39, // share a pos with another mob (eald'narche exoplates)
MOBMOD_TELEPORT_CD = 40, // cooldown for teleport abilities (tarutaru AA, angra mainyu, eald'narche)
MOBMOD_TELEPORT_START = 41, // mobskill ID to begin teleport
MOBMOD_TELEPORT_END = 42, // mobskill ID to end teleport
MOBMOD_TELEPORT_TYPE = 43, // teleport type - 1: on cooldown, 2 - to close distance
MOBMOD_DUAL_WIELD = 44, // enables a mob to use their offhand in attacks
MOBMOD_ADD_EFFECT = 45, // enables additional effect script to process on mobs attacks
MOBMOD_AUTO_SPIKES = 46, // enables additional effect script to process when mob is attacked
MOBMOD_SPAWN_LEASH = 47, // forces a mob to not move farther from its spawn than its leash distance
MOBMOD_SHARE_TARGET = 48, // mob always targets same target as ID in this var
MOBMOD_CHECK_AS_NM = 49, // If set , mob will check as a NM
// 50 Available for use
MOBMOD_ROAM_TURNS = 51, // Maximum amount of turns during a roam
MOBMOD_ROAM_RATE = 52, // Roaming frequency. roam_cool - rand(roam_cool / (roam_rate / 10))
MOBMOD_BEHAVIOR = 53, // Add behaviors to mob
MOBMOD_GIL_BONUS = 54, // Allow mob to drop gil. Multiplier to gil dropped by mob (bonus / 100) * total
MOBMOD_IDLE_DESPAWN = 55, // Time (in seconds) to despawn after being idle
MOBMOD_HP_STANDBACK = 56, // mob will always standback with hp % higher to value
MOBMOD_MAGIC_DELAY = 57, // Amount of seconds mob waits before casting first spell
MOBMOD_SPECIAL_DELAY = 58, // Amount of seconds mob waits before using first special
MOBMOD_WEAPON_BONUS = 59, // Add a bonus percentage to mob weapon damage ( bonus / 100 )
MOBMOD_SPAWN_ANIMATIONSUB = 60, // reset animationsub to this on spawn
MOBMOD_HP_SCALE = 61, // Scale the mobs max HP. ( hp_scale / 100 ) * maxhp
MOBMOD_NO_STANDBACK = 62, // Mob will never standback
MOBMOD_ATTACK_SKILL_LIST = 63, // skill list to use in place of regular attacks
MOBMOD_CHARMABLE = 64, // mob is charmable
MOBMOD_NO_MOVE = 65, // Mob will not be able to move
MOBMOD_MULTI_HIT = 66, // Mob will have as many swings as defined.
MOBMOD_NO_AGGRO = 67, // If set, mob cannot aggro until unset.
MOBMOD_ALLI_HATE = 68, // Range around target to add alliance member to enmity list.
MOBMOD_NO_LINK = 69, // If set, mob cannot link until unset.
MOBMOD_NO_REST = 70, // Mob cannot regain hp (e.g. re-burrowing antlions during ENM).
};

#endif
27 changes: 25 additions & 2 deletions src/map/mob_spell_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,15 @@ void CMobSpellContainer::AddSpell(SpellID spellId)
m_gaList.push_back(spellId);

}
else if(spell->canTargetEnemy()){
else if (spell->isSevere())
{
// select spells like death and impact
m_severeList.push_back(spellId);
}
else if (spell->canTargetEnemy() && !spell->isSevere())
{
// add to damage list
m_damageList.push_back(spellId);

}
else if(spell->isNa()){
// na spell and erase
Expand Down Expand Up @@ -136,6 +141,12 @@ std::optional<SpellID> CMobSpellContainer::GetSpell()
}
}

// try something really destructive
if (HasSevereSpells() && tpzrand::GetRandomNumber(100) < m_PMob->getMobMod(MOBMOD_SEVERE_SPELL_CHANCE))
{
return GetSevereSpell();
}

// try ga spell
if(HasGaSpells() && tpzrand::GetRandomNumber(100) < m_PMob->getMobMod(MOBMOD_GA_CHANCE)){
return GetGaSpell();
Expand Down Expand Up @@ -236,6 +247,13 @@ std::optional<SpellID> CMobSpellContainer::GetNaSpell()
return {};
}

std::optional<SpellID> CMobSpellContainer::GetSevereSpell()
{
if(m_severeList.empty()) return {};

return m_severeList[tpzrand::GetRandomNumber(m_severeList.size())];
}

bool CMobSpellContainer::HasGaSpells() const
{
return !m_gaList.empty();
Expand All @@ -261,6 +279,11 @@ bool CMobSpellContainer::HasNaSpells() const
return !m_naList.empty();
}

bool CMobSpellContainer::HasSevereSpells() const
{
return !m_severeList.empty();
}

bool CMobSpellContainer::HasNaSpell(SpellID spellId) const
{

Expand Down
3 changes: 3 additions & 0 deletions src/map/mob_spell_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class CMobSpellContainer
std::optional<SpellID> GetBuffSpell(); // stoneskin, utsusemi, blink
std::optional<SpellID> GetHealSpell(); // cures, regen, armys paeon
std::optional<SpellID> GetNaSpell(); // silena, blindna etc
std::optional<SpellID> GetSevereSpell(); // select spells like death, impact, meteor
std::optional<SpellID> GetSpell(); // return a random spell

bool HasSpells() const;
Expand All @@ -55,6 +56,7 @@ class CMobSpellContainer
bool HasBuffSpells() const;
bool HasHealSpells() const;
bool HasNaSpells() const;
bool HasSevereSpells() const;

void ClearSpells();
void AddSpell(SpellID spellId);
Expand All @@ -66,6 +68,7 @@ class CMobSpellContainer
std::vector<SpellID> m_buffList;
std::vector<SpellID> m_healList;
std::vector<SpellID> m_naList;
std::vector<SpellID> m_severeList;

private:
CMobEntity* m_PMob;
Expand Down
5 changes: 5 additions & 0 deletions src/map/spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ bool CSpell::isNa()
return (static_cast<uint16>(m_ID) >= 14 && static_cast<uint16>(m_ID) <= 20) || m_ID == SpellID::Erase;
}

bool CSpell::isSevere()
{
return m_ID == SpellID::Death || m_ID == SpellID::Impact || m_ID == SpellID::Meteor || m_ID == SpellID::Meteor_II || m_ID == SpellID::Comet;
}

bool CSpell::canHitShadow()
{
return m_ID != SpellID::Meteor_II && canTargetEnemy();
Expand Down
1 change: 1 addition & 0 deletions src/map/spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -923,6 +923,7 @@ class CSpell

bool canTargetEnemy();
bool isBuff();
bool isSevere(); // damage spells that have severe effects like Death or Impact
bool dealsDamage(); // checks if the spell deals hp damage to target, this is relative to message

uint16 getTotalTargets();
Expand Down
2 changes: 2 additions & 0 deletions src/map/utils/mobutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ void SetupJob(CMobEntity* PMob)
PMob->defaultMobMod(MOBMOD_MAGIC_COOL, 35);
PMob->defaultMobMod(MOBMOD_GA_CHANCE, 40);
PMob->defaultMobMod(MOBMOD_BUFF_CHANCE, 15);
PMob->defaultMobMod(MOBMOD_SEVERE_SPELL_CHANCE, 20);
break;
case JOB_PLD:
PMob->defaultMobMod(MOBMOD_MAGIC_COOL, 35);
Expand Down Expand Up @@ -888,6 +889,7 @@ void GetAvailableSpells(CMobEntity* PMob) {
PMob->defaultMobMod(MOBMOD_MAGIC_COOL, 35);
PMob->defaultMobMod(MOBMOD_GA_CHANCE, 35);
PMob->defaultMobMod(MOBMOD_NA_CHANCE, 40);
PMob->defaultMobMod(MOBMOD_SEVERE_SPELL_CHANCE, 20);
PMob->defaultMobMod(MOBMOD_BUFF_CHANCE, 35);
PMob->defaultMobMod(MOBMOD_HEAL_CHANCE, 40);
PMob->defaultMobMod(MOBMOD_HP_HEAL_CHANCE, 40);
Expand Down

0 comments on commit 4ccff3f

Please sign in to comment.