Auteur : Totomakers , Dernise
Avancement : 90% (Veillez faire remonter les bugs si vous en voyez)
Ce patch permet de configurer le killingstreak par AreaId le type d'annonce et les récompenses , pour le moment le script n'est fonctionnel que sur une Area car les kills ne sont pas reset lorsque vous quittez la zone ,
Les récompenses de points d'arènes ne fonctionnent peut être pas, le reste devrait être fonctionnel :D
ObjectMgr.h
Après:
[code=cpp]class Item; [/code]
Ajouter :
[code=cpp]struct killingstreak
{
uint32 areaId;
uint32 kill_required;
uint32 item_entry;
uint32 quantity;
uint32 arena_point;
uint32 honor_point;
uint32 notification_type;
std::string notification;
};
enum KSNotificationType
{
LANG_KS_WORLD_BROADCAST = 20000,
ZONE_BROADCAST = 1,
WORLD_BROADCAST = 2,
};
typedef UNORDERED_MAP<uint32, killingstreak> KillingsStreak;[/code]
Après :
[code=cpp] void LoadFactionChangeReputations();[/code]
Ajouter :
[code=cpp]bool IsKillingStreakArea(uint32 areaId);
killingstreak const* GetKillingStreak(uint32 areaId, uint32 kill) const;[/code]
Après :
[code=cpp]protected:[/code]
Ajouter :
[code=cpp]KillingsStreak m_killingstreak;[/code]
ObjectMgr.cpp
A la fin du fichier
[code=cpp]void ObjectMgr::LoadKillingstreak()
{
uint32 oldMSTime = getMSTime();
m_killingstreak.clear();
QueryResult result = WorldDatabase.Query("SELECT entry,areaId,numberOfKill,ItemEntryWin,quantity,ArenaPointWin,HonorPointWin,notificationType,notification FROM killingstreak");
if (!result)
{
sLog->outString(">> Loaded 0 KillingStreak.");
sLog->outString();
return;
}
uint32 count = 0;
do
{
Field *fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
killingstreak killingstreak;
killingstreak.areaId = fields[1].GetUInt32();
killingstreak.kill_required = fields[2].GetUInt32();
killingstreak.item_entry = fields[3].GetUInt32();
killingstreak.quantity = fields[4].GetUInt32();
killingstreak.arena_point = fields[5].GetUInt32();
killingstreak.honor_point = fields[6].GetUInt32();
killingstreak.notification_type = fields[7].GetUInt32();
killingstreak.notification = fields[8].GetString();
if (killingstreak.item_entry !=0 && killingstreak.quantity == 0)
sLog->outErrorDb("Killing Streak entry %u win token but quantity is 0", killingstreak);
if(killingstreak.notification_type != ZONE_BROADCAST && killingstreak.notification_type !=WORLD_BROADCAST)
sLog->outErrorDb("Killing Streak entry %u have unknown notification type", killingstreak);
m_killingstreak[entry] = killingstreak;
++count;
}
while (result->NextRow());
sLog->outString(">> Loaded %u Killingstreak in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
sLog->outString();
}
killingstreak const* ObjectMgr::GetKillingStreak(uint32 areaId, uint32 kill) const
{
const killingstreak* alt = NULL;
for (KillingsStreak::const_iterator itr = m_killingstreak.begin(); itr != m_killingstreak.end(); ++itr)
{
if (itr->second.areaId == areaId && itr->second.kill_required == kill)
return &itr->second;
}
return alt;
}
bool ObjectMgr::IsKillingStreakArea(uint32 areaId)
{
for (KillingsStreak::const_iterator itr = m_killingstreak.begin(); itr != m_killingstreak.end(); ++itr)
{
if (itr->second.areaId == areaId)
return true;
}
return false;
}[/code]
World.cpp
Après :
[code=cpp] sLog->outString("Loading SmartAI scripts...");
sSmartScriptMgr->LoadSmartAIFromDB();[/code]
Ajouter :
[code=cpp] sLog->outString("[Custom] Initialize KillingStreak...");
sObjectMgr->LoadKillingstreak();[/code]
Créez un nouveau fichier system_pvp.cpp
[code=cpp]#include "ScriptPCH.h"
class system_pvp : public PlayerScript
{
public:
system_pvp() : PlayerScript("system_pvp") {}
struct SystemInfo
{
uint32 KillStreak;
uint32 LastGUIDKill;
};
static std::map<uint32, SystemInfo> KillingStreak;
void OnPvPKill(Player *pKiller, Player *pVictim)
{
uint32 killer;
uint32 killed;
killer = pKiller->GetGUID();
killed = pVictim->GetGUID();
if(killer == killed) return;
if ((pKiller->getLevel() - pVictim->getLevel()) < 5) return;
KillingStreak[killer].KillStreak++;
KillingStreak[killed].KillStreak = 0;
KillingStreak[killer].LastGUIDKill = killed;
KillingStreak[killed].LastGUIDKill = 0;
const killingstreak *killingstreak = sObjectMgr->GetKillingStreak(pKiller->GetAreaId(), KillingStreak[killer].KillStreak);
if (killingstreak != NULL)
{
if (killingstreak->notification != "")
{
char msg[500];
switch (killingstreak->notification_type)
{
case ZONE_BROADCAST :
sprintf(msg, killingstreak->notification.c_str(), pKiller->GetName(), killingstreak->kill_required);
sWorld->SendZoneText(pKiller->GetZoneId(), msg);
break;
case WORLD_BROADCAST:
sprintf(msg, killingstreak->notification.c_str(), pKiller->GetName(), killingstreak->kill_required);
sWorld->SendWorldText(LANG_KS_WORLD_BROADCAST, msg);
break;
default:
sLog->outErrorDb("Unknown notification type for Killingstreak entry %u" , killingstreak);
break;
}
}
//honor point
if (killingstreak->honor_point !=0)
pKiller->ModifyHonorPoints(killingstreak->honor_point);
//arenapoint
if(killingstreak->arena_point !=0)
pKiller->ModifyArenaPoints(killingstreak->arena_point);
//if token
if (killingstreak->item_entry !=0 && killingstreak->quantity !=0)
{
ItemPosCountVec dest;
uint8 msg = pKiller->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, killingstreak->item_entry, killingstreak->quantity);
if (msg == EQUIP_ERR_OK)
pKiller->AddItem(killingstreak->item_entry, killingstreak->quantity);
}
}
}
};
void AddSC_system_pvp()
{
new system_pvp;
}
[/code]
N'oubliez pas d'ajouter le fichier au cmake et d'ajouter AddSC_system_pvp() au loader :)