Skip to content

Instantly share code, notes, and snippets.

@saqirmdev
Last active December 17, 2015 06:18
Show Gist options
  • Save saqirmdev/5563790 to your computer and use it in GitHub Desktop.
Save saqirmdev/5563790 to your computer and use it in GitHub Desktop.
float SpellEffectInfo::CalcRadius(bool positive, Unit* caster, Spell* spell) const
{
uint32 oldMSTime = getMSTime();
float radius;
// 1 2
QueryResult result = WorldDatabase.Query("SELECT id, radius FROM spell_radius");
if (result)
do
{
Field* fields = result->Fetch();
uint32 spell_id = fields[0].GetUInt32();
float custom_radius = fields[1].GetFloat();
if (spell_id && _spellInfo->Id && _spellInfo->Id == spell_id && !HasRadius())
radius = custom_radius;
else if (!HasRadius())
radius = 0.0f;
} while (result->NextRow());
if(positive)
radius = RadiusEntry->radiusFriend;
else
radius = RadiusEntry->radiusHostile;
if (!radius)
radius = 0.0f
if (caster)
if (Player* modOwner = caster->GetSpellModOwner())
modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_RADIUS, radius, spell);
return radius;
}
// SQL
CREATE TABLE `spell_radius` (
`id` mediumint( 8) UNSIGNED NOT NULL ,
`radius` float() UNSIGNED NOT NULL ,
PRIMARY KEY (`id`)
);
INSERT INTO `spell_radius` (`Id`, `radius`) VALUES
(81261, 5.0),
(93974, 4.0),
(93987, 4.0),
(93986, 4.0),
(93975, 4.0),
(102173, 60.0),
(86041, 8.0),
(52212, 10.0),
(81280, 15.0),
(8349, 10.0),
(88466, 8.0),
(88453, 8.0),
(73921, 10.0),
(77478, 8.0),
(86261, 6.0),
(97463, 30.0),
(94472, 15.0),
(81297, 8.0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment