Merge pull request #313 from addtheice/data_bundling

Data bundling
This commit is contained in:
Michael Cook (mackal)
2015-01-17 17:30:14 -05:00
60 changed files with 1772 additions and 1974 deletions
+42 -52
View File
@@ -9,7 +9,7 @@
extern volatile bool ZoneLoaded;
// This constructor is used during the bot create command
Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, 0, 0, 0, 0, 0, 0, false), rest_timer(1) {
Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, nullptr, xyz_heading::Origin(), 0, false), rest_timer(1) {
if(botOwner) {
this->SetBotOwner(botOwner);
this->_botOwnerCharacterID = botOwner->CharacterID();
@@ -99,7 +99,7 @@ Bot::Bot(NPCType npcTypeData, Client* botOwner) : NPC(&npcTypeData, 0, 0, 0, 0,
}
// This constructor is used when the bot is loaded out of the database
Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType npcTypeData) : NPC(&npcTypeData, 0, 0, 0, 0, 0, 0, false), rest_timer(1) {
Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double totalPlayTime, uint32 lastZoneId, NPCType npcTypeData) : NPC(&npcTypeData, nullptr, xyz_heading::Origin(), 0, false), rest_timer(1) {
this->_botOwnerCharacterID = botOwnerCharacterID;
if(this->_botOwnerCharacterID > 0) {
@@ -3354,7 +3354,7 @@ void Bot::AI_Process() {
if(GetHasBeenSummoned()) {
if(IsBotCaster() || IsBotArcher()) {
if (AImovement_timer->Check()) {
if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistNoRootNoZ(GetPreSummonX(), GetPreSummonY()) < 10)) {
if(!GetTarget() || (IsBotCaster() && !IsBotCasterCombatRange(GetTarget())) || (IsBotArcher() && IsArcheryRange(GetTarget())) || (DistNoRootNoZ(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y) < 10)) {
if(GetTarget())
FaceTarget(GetTarget());
SetHasBeenSummoned(false);
@@ -3363,8 +3363,8 @@ void Bot::AI_Process() {
if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this)
{
mlog(AI__WAYPOINTS, "Returning to location prior to being summoned.");
CalculateNewPosition2(GetPreSummonX(), GetPreSummonY(), GetPreSummonZ(), GetRunspeed());
SetHeading(CalculateHeadingToTarget(GetPreSummonX(), GetPreSummonY()));
CalculateNewPosition2(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y, m_PreSummonLocation.m_Z, GetRunspeed());
SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.m_X, m_PreSummonLocation.m_Y));
return;
}
}
@@ -4105,9 +4105,9 @@ void Bot::Spawn(Client* botCharacterOwner, std::string* errorMessage) {
this->GetBotOwner()->CastToClient()->Message(13, "%s save failed!", this->GetCleanName());
// Spawn the bot at the bow owner's loc
this->x_pos = botCharacterOwner->GetX();
this->y_pos = botCharacterOwner->GetY();
this->z_pos = botCharacterOwner->GetZ();
this->m_Position.m_X = botCharacterOwner->GetX();
this->m_Position.m_Y = botCharacterOwner->GetY();
this->m_Position.m_Z = botCharacterOwner->GetZ();
// Make the bot look at the bot owner
FaceTarget(botCharacterOwner);
@@ -9076,7 +9076,7 @@ void Bot::DoBuffTic(uint16 spell_id, int slot, uint32 ticsremaining, uint8 caste
bool Bot::CastSpell(uint16 spell_id, uint16 target_id, uint16 slot, int32 cast_time, int32 mana_cost, uint32* oSpellWillFinish, uint32 item_slot, int16 *resist_adjust) {
bool Result = false;
if(zone && !zone->IsSpellBlocked(spell_id, GetX(), GetY(), GetZ())) {
if(zone && !zone->IsSpellBlocked(spell_id, GetPosition())) {
mlog(SPELLS__CASTING, "CastSpell called for spell %s (%d) on entity %d, slot %d, time %d, mana %d, from item slot %d",
spells[spell_id].name, spell_id, target_id, slot, cast_time, mana_cost, (item_slot==0xFFFFFFFF)?999:item_slot);
@@ -10663,12 +10663,12 @@ void Bot::BotGroupSummon(Group* group, Client* client) {
if(botMember->GetBotOwnerCharacterID() == client->CharacterID()) {
botMember->SetTarget(botMember->GetBotOwner());
botMember->WipeHateList();
botMember->Warp(botMember->GetBotOwner()->GetX(), botMember->GetBotOwner()->GetY(), botMember->GetBotOwner()->GetZ());
botMember->Warp(botMember->GetBotOwner()->GetPosition());
if(botMember->HasPet() && botMember->GetPet()) {
botMember->GetPet()->SetTarget(botMember);
botMember->GetPet()->WipeHateList();
botMember->GetPet()->Warp(botMember->GetBotOwner()->GetX(), botMember->GetBotOwner()->GetY(), botMember->GetBotOwner()->GetZ());
botMember->GetPet()->Warp(botMember->GetBotOwner()->GetPosition());
}
}
}
@@ -11677,7 +11677,7 @@ void Bot::ProcessBotCommands(Client *c, const Seperator *sep) {
else
{
b->SetTarget(c->CastToMob());
b->Warp(c->GetX(), c->GetY(), c->GetZ());
b->Warp(c->GetPosition());
}
}
}
@@ -15741,47 +15741,39 @@ std::list<Bot*> EntityList::GetBotsByBotOwnerCharacterID(uint32 botOwnerCharacte
void EntityList::BotPickLock(Bot* rogue)
{
auto it = door_list.begin();
for (auto it = door_list.begin(); it != door_list.end(); ++it) {
Doors *cdoor = it->second;
if(cdoor && !cdoor->IsDoorOpen()) {
float zdiff = rogue->GetZ() - cdoor->GetZ();
if(zdiff < 0)
zdiff = 0 - zdiff;
float curdist = 0;
float tmp = rogue->GetX() - cdoor->GetX();
curdist += (tmp * tmp);
tmp = rogue->GetY() - cdoor->GetY();
curdist += (tmp * tmp);
if((zdiff < 10) && (curdist <= 130)) {
// All rogue items with lock pick bonuses are hands or primary
const ItemInst* item1 = rogue->GetBotItem(MainHands);
const ItemInst* item2 = rogue->GetBotItem(MainPrimary);
if(!cdoor || cdoor->IsDoorOpen())
continue;
float bonus1 = 0.0f;
float bonus2 = 0.0f;
float skill = rogue->GetSkill(SkillPickLock);
auto diff = rogue->GetPosition() - cdoor->GetPosition();
diff.ABS_XYZ();
if(item1) { // Hand slot item
if(item1->GetItem()->SkillModType == SkillPickLock) {
bonus1 = skill * (((float)item1->GetItem()->SkillModValue) / 100.0f);
}
}
float curdist = diff.m_X * diff.m_X + diff.m_Y * diff.m_Y;
if(item2) { // Primary slot item
if(item2->GetItem()->SkillModType == SkillPickLock) {
bonus2 = skill * (((float)item2->GetItem()->SkillModValue) / 100.0f);
}
}
if((diff.m_Z * diff.m_Z >= 10) || (curdist > 130))
continue;
if((skill+bonus1+bonus2) >= cdoor->GetLockpick()) {
cdoor->ForceOpen(rogue);
}
else {
rogue->Say("I am not skilled enough for this lock.");
}
}
}
// All rogue items with lock pick bonuses are hands or primary
const ItemInst* item1 = rogue->GetBotItem(MainHands);
const ItemInst* item2 = rogue->GetBotItem(MainPrimary);
float bonus1 = 0.0f;
float bonus2 = 0.0f;
float skill = rogue->GetSkill(SkillPickLock);
if(item1) // Hand slot item
if(item1->GetItem()->SkillModType == SkillPickLock)
bonus1 = skill * (((float)item1->GetItem()->SkillModValue) / 100.0f);
if(item2) // Primary slot item
if(item2->GetItem()->SkillModType == SkillPickLock)
bonus2 = skill * (((float)item2->GetItem()->SkillModValue) / 100.0f);
if((skill+bonus1+bonus2) >= cdoor->GetLockpick())
cdoor->ForceOpen(rogue);
else
rogue->Say("I am not skilled enough for this lock.");
}
}
@@ -16168,11 +16160,9 @@ bool Bot::HasOrMayGetAggro() {
void Bot::SetHasBeenSummoned(bool wasSummoned) {
_hasBeenSummoned = wasSummoned;
if(!wasSummoned) {
_preSummonX = 0;
_preSummonY = 0;
_preSummonZ = 0;
}
if(!wasSummoned)
m_PreSummonLocation = xyz_location::Origin();
}
void Bot::SetDefaultBotStance() {