Implement SE_SummonCorpseZone (SPA 388).

- This SPA summons all of a targeted group or raid group member's corpses from anywhere in the world.
- Example Spell 16247 (Summon Remains)
This commit is contained in:
Kinglykrab 2020-01-20 20:20:06 -05:00
parent f6ed4bb888
commit 8e6dd638ff
5 changed files with 98 additions and 1 deletions

View File

@ -607,7 +607,7 @@ typedef enum {
#define SE_LimitSpellGroup 385 // implemented - Limits to spell group(ie type 3 reuse reduction augs that are class specific and thus all share s SG)
#define SE_CastOnCurer 386 // implemented - Casts a spell on the person curing
#define SE_CastOnCure 387 // implemented - Casts a spell on the cured person
//#define SE_SummonCorpseZone 388 // *not implemented - summons a corpse from any zone(nec AA)
#define SE_SummonCorpseZone 388 // implemented - summons a corpse from any zone(nec AA)
#define SE_FcTimerRefresh 389 // implemented - Refresh spell icons
//#define SE_FcTimerLockout 390 // *not implemented - Sets recast timers to specific value, focus limited.
#define SE_LimitManaMax 391 // implemented

View File

@ -1820,6 +1820,58 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
break;
}
case SE_SummonCorpseZone:
{
if (IsClient()) {
Client* client_target = this->CastToClient();
if(client_target->IsGrouped()) {
Group* group = client_target->GetGroup();
if(!group->IsGroupMember(caster)) {
if (caster != this) {
caster->MessageString(Chat::Red, SUMMON_ONLY_GROUP_CORPSE);
break;
}
}
} else if (caster) {
if(caster->IsRaidGrouped()) {
Raid *raid = caster->GetRaid();
uint32 group_id = raid->GetGroup(caster->GetName());
if(group_id > 0 && group_id < MAX_RAID_GROUPS) {
if(raid->GetGroup(client_target->GetName()) != group_id) {
caster->MessageString(Chat::Red, SUMMON_ONLY_GROUP_CORPSE);
break;
}
}
} else {
if(caster != this) {
caster->MessageString(Chat::Red, SUMMON_ONLY_GROUP_CORPSE);
break;
}
}
}
if(client_target) {
if(database.CountCharacterCorpses(client_target->CharacterID()) == 0) {
if (caster == this) {
Message(Chat::Yellow, "You have no corpses to summon.");
} else {
caster->Message(Chat::Yellow, "%s has no corpses to summon.", client_target->GetCleanName());
}
} else {
if (caster == this) {
Message(Chat::Spells, "Summoning your corpses.");
} else {
caster->MessageString(Chat::Spells, SUMMONING_CORPSE_ZONE, client_target->GetCleanName());
}
client_target->SummonAllCorpses(client_target->GetPosition());
}
} else {
MessageString(Chat::Spells, TARGET_NOT_FOUND);
LogError("[{}] attempted to cast spell id [{}] with spell effect SE_SummonCorpseZone, but could not cast target into a Client object", GetCleanName(), spell_id);
}
}
break;
}
case SE_AddMeleeProc:
case SE_WeaponProc:
{

View File

@ -65,6 +65,7 @@
#define SILENCED_STRING 207 //You *CANNOT* cast spells, you have been silenced!
#define CANNOT_AFFECT_PC 210 //That spell can not affect this target PC.
#define SPELL_NEED_TAR 214 //You must first select a target for this spell!
#define SUMMON_ONLY_GROUP_CORPSE 215 //You must first target a living group member whose corpse you wish to summon.
#define ONLY_ON_CORPSES 221 //This spell only works on corpses.
#define CANT_DRAIN_SELF 224 //You can't drain yourself!
#define CORPSE_NOT_VALID 230 //This corpse is not valid.
@ -169,6 +170,7 @@
#define PVP_ON 552 //You are now player kill and follow the ways of Discord.
#define GENERIC_STRINGID_SAY 554 //%1 says '%T2'
#define CANNOT_WAKE 555 //%1 tells you, 'I am unable to wake %2, master.'
#define SUMMONING_CORPSE_ZONE 596 //Summoning %1's corpse(s).
#define PET_HOLD_SET_ON 698 //The pet hold mode has been set to on.
#define PET_HOLD_SET_OFF 699 //The pet hold mode has been set to off.
#define PET_FOCUS_SET_ON 700 //The pet focus mode has been set to on.

View File

@ -4707,6 +4707,47 @@ bool ZoneDatabase::SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zone_id
return (CorpseCount > 0);
}
int ZoneDatabase::CountCharacterCorpses(uint32 char_id) {
std::string query = fmt::format(
SQL(
SELECT
COUNT(*)
FROM
character_corpses
WHERE
charid = '{}'
),
char_id
);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]);
}
return 0;
}
int ZoneDatabase::CountCharacterCorpsesByZoneID(uint32 char_id, uint32 zone_id) {
std::string query = fmt::format(
SQL(
SELECT
COUNT(*)
FROM
character_corpses
WHERE
charid = '{}'
AND
zone_id = '{}'
),
char_id,
zone_id
);
auto results = QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
return atoi(row[0]);
}
return 0;
}
bool ZoneDatabase::UnburyCharacterCorpse(uint32 db_id, uint32 new_zone_id, uint16 new_instance_id, const glm::vec4& position) {
std::string query = StringFormat("UPDATE `character_corpses` "
"SET `is_buried` = 0, `zone_id` = %u, `instance_id` = %u, "

View File

@ -356,6 +356,8 @@ public:
bool DeleteCharacterCorpse(uint32 dbid);
bool SummonAllCharacterCorpses(uint32 char_id, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position);
bool SummonAllGraveyardCorpses(uint32 cur_zoneid, uint32 dest_zoneid, uint16 dest_instanceid, const glm::vec4& position);
int CountCharacterCorpses(uint32 char_id);
int CountCharacterCorpsesByZoneID(uint32 char_id, uint32 zone_id);
bool UnburyCharacterCorpse(uint32 dbid, uint32 new_zoneid, uint16 dest_instanceid, const glm::vec4& position);
bool LoadCharacterCorpses(uint32 iZoneID, uint16 iInstanceID);
bool DeleteGraveyard(uint32 zone_id, uint32 graveyard_id);