本文整理汇总了C++中GetCreatureInfo函数的典型用法代码示例。如果您正苦于以下问题:C++ GetCreatureInfo函数的具体用法?C++ GetCreatureInfo怎么用?C++ GetCreatureInfo使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetCreatureInfo函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetCreatureInfo
void Creature::generateMoneyLoot()
{
uint32 maxgold = GetCreatureInfo()->maxgold;
if (GetCreatureInfo()->maxgold > 0)
{
uint32 mingold = GetCreatureInfo()->mingold;
if (maxgold <= mingold)
loot.gold = uint32(maxgold * sWorld.getRate(RATE_DROP_MONEY));
else
loot.gold = uint32(rand32(mingold, maxgold) * sWorld.getRate(RATE_DROP_MONEY));
}
}
开发者ID:chrayn,项目名称:mangos-06,代码行数:14,代码来源:Creature.cpp
示例2: GetOwner
void Totem::Update(uint32 update_diff, uint32 time )
{
Unit *owner = GetOwner();
if (!owner || !owner->isAlive() || !isAlive())
{
UnSummon(); // remove self
return;
}
if (m_duration <= update_diff)
{
UnSummon(); // remove self
return;
}
else
m_duration -= update_diff;
// Grounding totem + polymorph = unsummon
if(GetCreatureInfo()->Entry == 5925 && HasAuraType(SPELL_AURA_MOD_CONFUSE))
{
UnSummon(); // remove self
return;
}
Creature::Update( update_diff, time );
}
开发者ID:Nedj,项目名称:Mysteria4,代码行数:26,代码来源:Totem.cpp
示例3: SetInstanceId
void Totem::Summon(Unit* owner)
{
sLog.outDebug("AddObject at Totem.cpp line 49");
SetInstanceId(owner->GetInstanceId());
owner->GetMap()->Add((Creature*)this);
// select totem model in dependent from owner team
CreatureInfo const *cinfo = GetCreatureInfo();
if(owner->GetTypeId()==TYPEID_PLAYER && cinfo)
{
uint32 display_id = objmgr.ChooseDisplayId(((Player*)owner)->GetTeam(),cinfo);
CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
if (minfo)
display_id = minfo->modelid;
SetDisplayId(display_id);
}
WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);
data << GetGUID();
SendMessageToSet(&data,true);
AIM_Initialize();
switch(m_type)
{
case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); break;
case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break;
default: break;
}
}
开发者ID:Aemu,项目名称:mangos,代码行数:31,代码来源:Totem.cpp
示例4: GetCreatureInfo
void Totem::InitStats(uint32 duration)
{
Minion::InitStats(duration);
CreatureInfo const *cinfo = GetCreatureInfo();
if(m_owner->GetTypeId() == TYPEID_PLAYER && cinfo)
{
uint32 display_id = objmgr.ChooseDisplayId(((Player*)m_owner)->GetTeam(), cinfo);
CreatureModelInfo const *minfo = objmgr.GetCreatureModelRandomGender(display_id);
if (minfo)
display_id = minfo->modelid;
SetDisplayId(display_id);
}
// Get spell casted by totem
SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell());
if (totemSpell)
{
// If spell have cast time -> so its active totem
if (GetSpellCastTime(totemSpell))
m_type = TOTEM_ACTIVE;
}
if(GetEntry() == SENTRY_TOTEM_ENTRY)
SetReactState(REACT_AGGRESSIVE);
m_duration = duration;
SetLevel(m_owner->getLevel());
}
开发者ID:executor,项目名称:riboncore,代码行数:30,代码来源:Totem.cpp
示例5: SetMapId
bool Vehicle::Create(uint32 guidlow, Map *map, uint32 Entry, uint32 vehicleId, uint32 team)
{
SetMapId(map->GetId());
SetInstanceId(map->GetInstanceId());
Object::_Create(guidlow, Entry, HIGHGUID_VEHICLE);
if(!InitEntry(Entry, team))
return false;
m_defaultMovementType = IDLE_MOTION_TYPE;
AIM_Initialize();
SetVehicleId(vehicleId);
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
CreatureInfo const *ci = GetCreatureInfo();
setFaction(team == ALLIANCE ? ci->faction_A : ci->faction_H);
SetMaxHealth(ci->maxhealth);
SelectLevel(ci);
SetHealth(GetMaxHealth());
return true;
}
开发者ID:Aemu,项目名称:mangos,代码行数:27,代码来源:Vehicle.cpp
示例6: GetCreatureInfo
void Totem::InitStats(uint32 duration)
{
Minion::InitStats(duration);
CreatureTemplate const *cinfo = GetCreatureInfo();
if (m_owner->GetTypeId() == TYPEID_PLAYER && cinfo)
{
uint32 displayID = sObjectMgr->ChooseDisplayId(m_owner->ToPlayer()->GetTeam(), cinfo);
sObjectMgr->GetCreatureModelRandomGender(&displayID);
switch (m_owner->ToPlayer()->GetTeam())
{
case ALLIANCE:
displayID = cinfo->Modelid1;
break;
case HORDE:
if (cinfo->Modelid3)
displayID = cinfo->Modelid3;
else
displayID = cinfo->Modelid1;
switch (((Player*)m_owner)->getRace())
{
case RACE_ORC:
if (cinfo->Modelid2)
displayID = cinfo->Modelid2;
else
displayID = cinfo->Modelid1;
break;
case RACE_TROLL:
if (cinfo->Modelid4)
displayID = cinfo->Modelid4;
else
displayID = cinfo->Modelid1;
break;
default:
break;
}
break;
default:
break;
}
SetDisplayId(displayID);
}
// Get spell casted by totem
SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell());
if (totemSpell)
{
// If spell have cast time -> so its active totem
if (GetSpellCastTime(totemSpell))
m_type = TOTEM_ACTIVE;
}
if (GetEntry() == SENTRY_TOTEM_ENTRY)
SetReactState(REACT_AGGRESSIVE);
m_duration = duration;
SetLevel(m_owner->getLevel());
}
开发者ID:CrAzY666,项目名称:TrinityCore,代码行数:60,代码来源:Totem.cpp
示例7: RemoveSpellsCausingAura
void Vehicle::RemovePassenger(Unit *unit)
{
SeatMap::iterator seat;
for(seat = m_Seats.begin(); seat != m_Seats.end(); ++seat)
{
if((seat->second.flags & (SEAT_FULL | SEAT_VEHICLE_FREE | SEAT_VEHICLE_FULL)) && seat->second.passenger == unit)
{
unit->SetVehicleGUID(0);
if(seat->second.vs_flags & SF_MAIN_RIDER)
{
RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE);
if(unit->GetTypeId() == TYPEID_PLAYER)
{
((Player*)unit)->SetMover(unit);
((Player*)unit)->SetClientControl(unit, 1);
((Player*)unit)->SetMoverInQueve(NULL);
((Player*)unit)->RemovePetActionBar();
if(((Player*)unit)->GetGroup())
((Player*)unit)->SetGroupUpdateFlag(GROUP_UPDATE_VEHICLE);
}
unit->SetCharm(NULL);
SetCharmerGUID(NULL);
setFaction(GetCreatureInfo()->faction_A);
}
if(GetVehicleFlags() & VF_NON_SELECTABLE)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if(seat->second.vs_flags & SF_UNATTACKABLE)
unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
// restore player control
if(unit->GetTypeId() == TYPEID_PLAYER)
{
((Player*)unit)->GetCamera().ResetView();
if(seat->second.vs_flags & SF_CAN_CAST)
{
WorldPacket data0(SMSG_FORCE_MOVE_UNROOT, 10);
data0 << unit->GetPackGUID();
data0 << (uint32)(2); // can rotate
unit->SendMessageToSet(&data0,true);
}
else
{
WorldPacket data1(SMSG_FORCE_MOVE_UNROOT, 10);
data1 << unit->GetPackGUID();
data1 << (uint32)(0); // cannot rotate
unit->SendMessageToSet(&data1,true);
}
}
unit->m_movementInfo.ClearTransportData();
seat->second.passenger = NULL;
seat->second.flags = SEAT_FREE;
unit->m_movementInfo.RemoveMovementFlag(MOVEFLAG_ONTRANSPORT);
EmptySeatsCountChanged();
break;
}
}
}
开发者ID:3raZar3,项目名称:Dark-Ice,代码行数:60,代码来源:Vehicle.cpp
示例8: GetCreatureInfo
void Totem::Summon(Unit* owner)
{
owner->GetMap()->Add((Creature*)this);
// select totem model in dependent from owner team
CreatureInfo const *cinfo = GetCreatureInfo();
if(owner->GetTypeId() == TYPEID_PLAYER && cinfo)
{
uint32 display_id = sObjectMgr.ChooseDisplayId(((Player*)owner)->GetTeam(), cinfo);
CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
if (minfo)
display_id = minfo->modelid;
SetDisplayId(display_id);
}
AIM_Initialize();
// there are some totems, which exist just for their visual appeareance
if (!GetSpell())
return;
switch(m_type)
{
case TOTEM_PASSIVE:
CastSpell(this, GetSpell(), true);
break;
case TOTEM_STATUE:
CastSpell(GetOwner(), GetSpell(), true);
break;
default: break;
}
}
开发者ID:AdharRuafo,项目名称:mangos,代码行数:32,代码来源:Totem.cpp
示例9: npc_unworthy_initiateAI
npc_unworthy_initiateAI(Creature *c) : ScriptedAI(c)
{
me->SetReactState(REACT_PASSIVE);
if (!me->GetEquipmentId())
if (const CreatureInfo *info = GetCreatureInfo(28406))
if (info->equipmentId)
const_cast<CreatureInfo*>(me->GetCreatureInfo())->equipmentId = info->equipmentId;
}
开发者ID:1024wow,项目名称:TrinityCore,代码行数:8,代码来源:chapter1.cpp
示例10: GetCreatureInfo
void Totem::Summon(Unit* owner)
{
CreatureInfo const *cinfo = GetCreatureInfo();
if (owner->GetTypeId()==TYPEID_PLAYER && cinfo)
{
uint32 modelid = 0;
if(((Player*)owner)->GetTeam() == HORDE)
{
if(cinfo->Modelid_H1)
modelid = cinfo->Modelid_H1;
else if(cinfo->Modelid_H2)
modelid = cinfo->Modelid_H2;
}
else
{
if(cinfo->Modelid_A1)
modelid = cinfo->Modelid_A1;
else if(cinfo->Modelid_A2)
modelid = cinfo->Modelid_A2;
}
if (modelid)
SetDisplayId(modelid);
else
sLog.outErrorDb("Totem::Summon: Missing modelid information for entry %u, team %u, totem will use default values.",GetEntry(),((Player*)owner)->GetTeam());
}
// Only add if a display exists.
sLog.outDebug("AddObject at Totem.cpp line 49");
SetInstanceId(owner->GetInstanceId());
owner->GetMap()->Add((Creature*)this);
WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);
data << GetGUID();
SendMessageToSet(&data,true);
AIM_Initialize();
switch(m_type)
{
case TOTEM_PASSIVE: CastSpell(this, GetSpell(), true); break;
case TOTEM_STATUE: CastSpell(GetOwner(), GetSpell(), true); break;
default: break;
}
if(GetEntry() == SENTRY_TOTEM_ENTRY)
SetReactState(REACT_AGGRESSIVE);
}
开发者ID:Bootz,项目名称:TC-One,代码行数:47,代码来源:Totem.cpp
示例11: GetCreatureInfo
void Totem::InitStats(uint32 duration)
{
Minion::InitStats(duration);
CreatureInfo const *cinfo = GetCreatureInfo();
if (m_owner->GetTypeId() == TYPEID_PLAYER && cinfo)
{
uint32 modelid = 0;
if (m_owner->ToPlayer()->GetTeam() == HORDE)
{
if (cinfo->Modelid_H1)
modelid = cinfo->Modelid_H1;
else if (cinfo->Modelid_H2)
modelid = cinfo->Modelid_H2;
}
else
{
if (cinfo->Modelid_A1)
modelid = cinfo->Modelid_A1;
else if (cinfo->Modelid_A2)
modelid = cinfo->Modelid_A2;
}
if (modelid)
SetDisplayId(modelid);
else
sLog.outErrorDb("Totem::Summon: Missing modelid information for entry %u, team %u, totem will use default values.",GetEntry(),m_owner->ToPlayer()->GetTeam());
}
// Get spell casted by totem
SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell());
if (totemSpell)
{
// If spell have cast time -> so its active totem
if (GetSpellCastTime(totemSpell))
m_type = TOTEM_ACTIVE;
}
if (GetEntry() == SENTRY_TOTEM_ENTRY)
SetReactState(REACT_AGGRESSIVE);
m_duration = duration;
SetLevel(m_owner->getLevel());
}
开发者ID:deremix,项目名称:darmixcore,代码行数:44,代码来源:Totem.cpp
示例12: SetInstanceId
void Totem::Summon(Unit* owner)
{
sLog.outDebug("AddObject at Totem.cpp line 49");
SetInstanceId(owner->GetInstanceId());
owner->GetMap()->Add((Creature*)this);
// select totem model in dependent from owner team [-ZERO] not implemented/useful
CreatureInfo const *cinfo = GetCreatureInfo();
if(owner->GetTypeId() == TYPEID_PLAYER && cinfo)
{
uint32 display_id = sObjectMgr.ChooseDisplayId(((Player*)owner)->GetTeam(), cinfo);
CreatureModelInfo const *minfo = sObjectMgr.GetCreatureModelRandomGender(display_id);
if (minfo)
display_id = minfo->modelid;
SetDisplayId(display_id);
}
WorldPacket data(SMSG_GAMEOBJECT_SPAWN_ANIM_OBSOLETE, 8);
data << GetGUID();
SendMessageToSet(&data,true);
AIM_Initialize();
if (owner->GetTypeId() == TYPEID_UNIT && ((Creature*)owner)->AI())
((Creature*)owner)->AI()->JustSummoned((Creature*)this);
// there are some totems, which exist just for their visual appeareance
if (!GetSpell())
return;
switch(m_type)
{
case TOTEM_PASSIVE:
CastSpell(this, GetSpell(), true);
break;
case TOTEM_STATUE:
CastSpell(GetOwner(), GetSpell(), true);
break;
default: break;
}
}
开发者ID:dythzer,项目名称:mangoszero,代码行数:42,代码来源:Totem.cpp
示例13: GetModifierValue
void Creature::UpdateDamagePhysical(WeaponAttackType attType)
{
if(attType > BASE_ATTACK)
return;
UnitMods unitMod = UNIT_MOD_DAMAGE_MAINHAND;
float base_value = GetModifierValue(unitMod, BASE_VALUE) + GetTotalAttackPowerValue(attType);
float base_pct = GetModifierValue(unitMod, BASE_PCT);
float total_value = GetModifierValue(unitMod, TOTAL_VALUE);
float total_pct = GetModifierValue(unitMod, TOTAL_PCT);
float dmg_multiplier = GetCreatureInfo()->dmg_multiplier;
float weapon_mindamage = GetWeaponDamageRange(BASE_ATTACK, MINDAMAGE);
float weapon_maxdamage = GetWeaponDamageRange(BASE_ATTACK, MAXDAMAGE);
float mindamage = ((base_value + weapon_mindamage) * base_pct + total_value) * total_pct * dmg_multiplier;
float maxdamage = ((base_value + weapon_maxdamage) * base_pct + total_value) * total_pct * dmg_multiplier;
SetStatFloatValue(UNIT_FIELD_MINDAMAGE, mindamage);
SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, maxdamage);
}
开发者ID:Nerador,项目名称:mangos,代码行数:22,代码来源:StatSystem.cpp
示例14: RemoveSpellsCausingAura
void Vehicle::RemovePassenger(Unit *unit)
{
SeatMap::iterator seat;
for(seat = m_Seats.begin(); seat != m_Seats.end(); ++seat)
{
if((seat->second.flags & (SEAT_FULL | SEAT_VEHICLE_FREE | SEAT_VEHICLE_FULL)) && seat->second.passenger == unit)
{
unit->SetVehicleGUID(0);
if(seat->second.vs_flags & SF_MAIN_RIDER)
{
RemoveSpellsCausingAura(SPELL_AURA_CONTROL_VEHICLE);
if(unit->GetTypeId() == TYPEID_PLAYER)
{
((Player*)unit)->SetMover(unit);
((Player*)unit)->SetClientControl(unit, 1);
((Player*)unit)->SetMoverInQueve(NULL);
((Player*)unit)->RemovePetActionBar();
if(((Player*)unit)->GetGroup())
((Player*)unit)->SetGroupUpdateFlag(GROUP_UPDATE_VEHICLE);
}
unit->SetCharm(NULL);
SetCharmerGUID(NULL);
setFaction(GetCreatureInfo()->faction_A);
}
if(GetVehicleFlags() & VF_NON_SELECTABLE)
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
if(GetVehicleFlags() & VF_CAST_AURA && m_VehicleData && m_VehicleData->v_spells[0] != 0)
unit->RemoveAurasDueToSpell(m_VehicleData->v_spells[0]);
if(seat->second.vs_flags & SF_UNATTACKABLE)
unit->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
// restore player control
if(unit->GetTypeId() == TYPEID_PLAYER)
{
((Player*)unit)->SetFarSightGUID(NULL);
if(seat->second.vs_flags & SF_CAN_CAST)
{
WorldPacket data0(SMSG_FORCE_MOVE_UNROOT, 10);
data0 << unit->GetPackGUID();
data0 << (uint32)(2); // can rotate
unit->SendMessageToSet(&data0,true);
}
else
{
WorldPacket data1(SMSG_FORCE_MOVE_UNROOT, 10);
data1 << unit->GetPackGUID();
data1 << (uint32)(0); // cannot rotate
unit->SendMessageToSet(&data1,true);
}
}
unit->m_SeatData.OffsetX = 0.0f;
unit->m_SeatData.OffsetY = 0.0f;
unit->m_SeatData.OffsetZ = 0.0f;
unit->m_SeatData.Orientation = 0.0f;
unit->m_SeatData.c_time = 0;
unit->m_SeatData.dbc_seat = 0;
unit->m_SeatData.seat = 0;
unit->m_SeatData.s_flags = 0;
unit->m_SeatData.v_flags = 0;
seat->second.passenger = NULL;
seat->second.flags = SEAT_FREE;
EmptySeatsCountChanged();
break;
}
}
}
开发者ID:X-Core,项目名称:X-core-addons,代码行数:69,代码来源:Vehicle.cpp
示例15: ON
bool Creature::LoadFromDB(uint32 guid, QueryResult *result, uint32 InstanceId)
{
bool external = (result != NULL);
if (!external)
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
result = sDatabase.PQuery("SELECT `id`,`map`,`position_x`,`position_y`,`position_z`,`orientation`,`spawntimesecs`,`spawndist`,`spawn_position_x`,`spawn_position_y`,`spawn_position_z`,`curhealth`,`curmana`,`respawntime`,`DeathState`,`MovementType`,`auras` "
"FROM `creature` LEFT JOIN `creature_respawn` ON ((`creature`.`guid`=`creature_respawn`.`guid`) AND (`creature_respawn`.`instance` = '%u')) WHERE `creature`.`guid` = '%u'", InstanceId, guid);
if(!result)
{
sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ",guid);
return false;
}
Field *fields = result->Fetch();
uint32 stored_guid = guid;
if (InstanceId != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_UNIT);
SetInstanceId(InstanceId);
if(!Create(guid,fields[1].GetUInt32(),fields[2].GetFloat(),fields[3].GetFloat(),
fields[4].GetFloat(),fields[5].GetFloat(),fields[0].GetUInt32()))
{
if (!external) delete result;
return false;
}
m_DBTableGuid = stored_guid;
if(GetCreatureInfo()->rank > 0)
this->m_corpseDelay *= 3; //if creature is elite, then remove corpse later
SetHealth(fields[11].GetUInt32());
SetPower(POWER_MANA,fields[12].GetUInt32());
m_respawnradius = fields[7].GetFloat();
respawn_cord[0] = fields[8].GetFloat();
respawn_cord[1] = fields[9].GetFloat();
respawn_cord[2] = fields[10].GetFloat();
m_respawnDelay = fields[6].GetUInt32();
m_deathState = (DeathState)fields[14].GetUInt32();
if(m_deathState == JUST_DIED) // Dont must be set to JUST_DEAD, see Creature::setDeathState JUST_DIED -> CORPSE promoting.
{
sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) in wrong state: JUST_DEAD (1). State set to ALIVE.",GetGUIDLow(),GetEntry());
m_deathState = ALIVE;
}
else
if(m_deathState < ALIVE || m_deathState > DEAD)
{
sLog.outErrorDb("Creature (GUIDLow: %u Entry: %u ) in wrong state: %d. State set to ALIVE.",GetGUIDLow(),GetEntry(),m_deathState);
m_deathState = ALIVE;
}
m_respawnTime = (time_t)fields[13].GetUInt64();
if(m_respawnTime > time(NULL)) // not ready to respawn
m_deathState = DEAD;
else // ready to respawn
{
m_respawnTime = 0;
sDatabase.PExecute("DELETE FROM `creature_respawn` WHERE `guid` = '%u' AND `instance` = '%u'", m_DBTableGuid, GetInstanceId());
}
{
uint32 mtg = fields[15].GetUInt32();
if(mtg < MAX_DB_MOTION_TYPE)
m_defaultMovementType = MovementGeneratorType(mtg);
else
{
m_defaultMovementType = IDLE_MOTION_TYPE;
sLog.outErrorDb("Creature (GUID: %u ID: %u) have wrong movement generator type value %u, ignore and set to IDLE.",guid,GetEntry(),mtg);
}
}
if(!external) delete result;
LoadFlagRelatedData();
AIM_Initialize();
return true;
}
开发者ID:chrayn,项目名称:mangos-06,代码行数:81,代码来源:Creature.cpp
示例16: SetHomePosition
bool Vehicle::LoadFromDB(uint32 guid, Map *map)
{
CreatureData const* data = objmgr.GetCreatureData(guid);
if(!data)
{
sLog.outErrorDb("Creature (GUID: %u) not found in table `creature`, can't load. ",guid);
return false;
}
uint32 id = 0;
if(const CreatureInfo *cInfo = objmgr.GetCreatureTemplate(data->id))
id = cInfo->VehicleId;
if(!id || !sVehicleStore.LookupEntry(id))
return false;
m_DBTableGuid = guid;
if (map->GetInstanceId() != 0) guid = objmgr.GenerateLowGuid(HIGHGUID_VEHICLE);
uint16 team = 0;
if(!Create(guid,map,data->phaseMask,data->id,id,team,data->posX,data->posY,data->posZ,data->orientation,data))
return false;
//We should set first home position, because then AI calls home movement
SetHomePosition(data->posX,data->posY,data->posZ,data->orientation);
m_respawnradius = data->spawndist;
m_respawnDelay = data->spawntimesecs;
m_isDeadByDefault = data->is_dead;
m_deathState = m_isDeadByDefault ? DEAD : ALIVE;
m_respawnTime = objmgr.GetCreatureRespawnTime(m_DBTableGuid,GetInstanceId());
if(m_respawnTime > time(NULL)) // not ready to respawn
{
m_deathState = DEAD;
if(canFly())
{
float tz = GetMap()->GetHeight(data->posX,data->posY,data->posZ,false);
if(data->posZ - tz > 0.1)
Relocate(data->posX,data->posY,tz);
}
}
else if(m_respawnTime) // respawn time set but expired
{
m_respawnTime = 0;
objmgr.SaveCreatureRespawnTime(m_DBTableGuid,GetInstanceId(),0);
}
uint32 curhealth = data->curhealth;
if(curhealth)
{
curhealth = uint32(curhealth*_GetHealthMod(GetCreatureInfo()->rank));
if(curhealth < 1)
curhealth = 1;
}
SetHealth(m_deathState == ALIVE ? curhealth : 0);
SetPower(POWER_MANA,data->curmana);
// checked at creature_template loading
m_defaultMovementType = MovementGeneratorType(data->movementType);
m_creatureData = data;
return true;
}
开发者ID:MilchBuby,项目名称:riboncore,代码行数:67,代码来源:Vehicle.cpp
示例17: GetGUIDLow
bool Creature::isCanTrainingOf(Player* pPlayer, bool msg) const
{
if(!isTrainer())
return false;
if(m_tspells.empty())
{
sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_TRAINER but have empty trainer spell list.",
GetGUIDLow(),GetCreatureInfo()->Entry);
return false;
}
switch(GetCreatureInfo()->trainer_type)
{
case TRAINER_TYPE_CLASS:
if(pPlayer->getClass()!=GetCreatureInfo()->classNum)
{
if(msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
switch(GetCreatureInfo()->classNum)
{
case CLASS_DRUID: pPlayer->PlayerTalkClass->SendGossipMenu( 4913,GetGUID()); break;
case CLASS_HUNTER: pPlayer->PlayerTalkClass->SendGossipMenu(10090,GetGUID()); break;
case CLASS_MAGE: pPlayer->PlayerTalkClass->SendGossipMenu( 328,GetGUID()); break;
case CLASS_PALADIN:pPlayer->PlayerTalkClass->SendGossipMenu( 1635,GetGUID()); break;
case CLASS_PRIEST: pPlayer->PlayerTalkClass->SendGossipMenu( 4436,GetGUID()); break;
case CLASS_ROGUE: pPlayer->PlayerTalkClass->SendGossipMenu( 4797,GetGUID()); break;
case CLASS_SHAMAN: pPlayer->PlayerTalkClass->SendGossipMenu( 5003,GetGUID()); break;
case CLASS_WARLOCK:pPlayer->PlayerTalkClass->SendGossipMenu( 5836,GetGUID()); break;
case CLASS_WARRIOR:pPlayer->PlayerTalkClass->SendGossipMenu( 4985,GetGUID()); break;
}
}
return false;
}
break;
case TRAINER_TYPE_PETS:
if(pPlayer->getClass()!=CLASS_HUNTER)
{
pPlayer->PlayerTalkClass->ClearMenus();
pPlayer->PlayerTalkClass->SendGossipMenu(3620,GetGUID());
return false;
}
break;
case TRAINER_TYPE_MOUNTS:
if(GetCreatureInfo()->race && pPlayer->getRace() != GetCreatureInfo()->race)
{
if(msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
switch(GetCreatureInfo()->classNum)
{
case RACE_DWARF: pPlayer->PlayerTalkClass->SendGossipMenu(5865,GetGUID()); break;
case RACE_GNOME: pPlayer->PlayerTalkClass->SendGossipMenu(4881,GetGUID()); break;
case RACE_HUMAN: pPlayer->PlayerTalkClass->SendGossipMenu(5861,GetGUID()); break;
case RACE_NIGHTELF: pPlayer->PlayerTalkClass->SendGossipMenu(5862,GetGUID()); break;
case RACE_ORC: pPlayer->PlayerTalkClass->SendGossipMenu(5863,GetGUID()); break;
case RACE_TAUREN: pPlayer->PlayerTalkClass->SendGossipMenu(5864,GetGUID()); break;
case RACE_TROLL: pPlayer->PlayerTalkClass->SendGossipMenu(5816,GetGUID()); break;
case RACE_UNDEAD_PLAYER:pPlayer->PlayerTalkClass->SendGossipMenu( 624,GetGUID()); break;
}
}
return false;
}
break;
case TRAINER_TYPE_TRADESKILLS:
if(GetCreatureInfo()->trainer_spell && !pPlayer->HasSpell(GetCreatureInfo()->trainer_spell))
{
if(msg)
{
pPlayer->PlayerTalkClass->ClearMenus();
pPlayer->PlayerTalkClass->SendGossipMenu(11031,GetGUID());
}
return false;
}
break;
default:
sLog.outErrorDb("Creature %u (entry: %u) have trainer type %u",GetGUIDLow(),GetCreatureInfo()->Entry,GetCreatureInfo()->trainer_type);
return false;
}
return true;
}
开发者ID:chrayn,项目名称:mangos-06,代码行数:82,代码来源:Creature.cpp
示例18: LoadGossipOptions
void Creature::prepareGossipMenu( Player *pPlayer,uint32 gossipid )
{
PlayerMenu* pm=pPlayer->PlayerTalkClass;
pm->ClearMenus();
if(!m_goptions.size())
LoadGossipOptions();
GossipOption* gso;
GossipOption* ingso;
for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ )
{
gso=&*i;
if(gso->GossipId == gossipid)
{
bool cantalking=true;
if(gso->Id==1)
{
uint32 textid=GetNpcTextId();
GossipText * gossiptext=objmgr.GetGossipText(textid);
if(!gossiptext)
cantalking=false;
}
else
{
switch (gso->Action)
{
case GOSSIP_OPTION_QUESTGIVER:
pPlayer->PrepareQuestMenu(GetGUID());
//if (pm->GetQuestMenu()->MenuItemCount() == 0)
cantalking=false;
//pm->GetQuestMenu()->ClearMenu();
break;
case GOSSIP_OPTION_ARMORER:
cantalking=false; // added in special mode
break;
case GOSSIP_OPTION_SPIRITHEALER:
if( !pPlayer->isDead() )
cantalking=false;
break;
case GOSSIP_OPTION_VENDOR:
if(!GetItemCount())
{
sLog.outErrorDb("Creature %u (Entry: %u) have UNIT_NPC_FLAG_VENDOR but have empty trading item list.",
GetGUIDLow(),GetCreatureInfo()->Entry);
cantalking=false;
}
break;
case GOSSIP_OPTION_TRAINER:
if(!isCanTrainingOf(pPlayer,false))
cantalking=false;
break;
case GOSSIP_OPTION_UNLEARNTALENTS:
if(!isCanTrainingAndResetTalentsOf(pPlayer))
cantalking=false;
break;
case GOSSIP_OPTION_TAXIVENDOR:
if ( pPlayer->GetSession()->SendLearnNewTaxiNode(GetGUID()) )
return;
case GOSSIP_OPTION_GUARD:
case GOSSIP_OPTION_INNKEEPER:
case GOSSIP_OPTION_BANKER:
case GOSSIP_OPTION_PETITIONER:
case GOSSIP_OPTION_STABLEPET:
case GOSSIP_OPTION_TABARDVENDOR:
case GOSSIP_OPTION_BATTLEFIELD:
case GOSSIP_OPTION_AUCTIONEER:
break; // no checks
default:
sLog.outErrorDb("Creature %u (entry: %u) have unknown gossip option %u",GetGUIDLow(),GetCreatureInfo()->Entry,gso->Action);
break;
}
}
if(gso->Option!="" && cantalking )
{
pm->GetGossipMenu()->AddMenuItem((uint8)gso->Icon,gso->Option.c_str(), gossipid,gso->Action,false);
ingso=gso;
}
}
}
if(pm->GetGossipMenu()->MenuItemCount()==0 && HasFlag(UNIT_NPC_FLAGS,UNIT_NPC_FLAG_TRAINER) && !pm->GetQuestMenu()->MenuItemCount())
isCanTrainingOf(pPlayer,true);
/*
if(pm->GetGossipMenu()->MenuItemCount()==1 && ingso->Id==8 && GetGossipCount( ingso->GossipId )>0)
{
pm->ClearMenus();
for( GossipOptionList::iterator i = m_goptions.begin( ); i != m_goptions.end( ); i++ )
{
gso=&*i;
if(gso->GossipId==ingso->Id)
{
if(gso->Option!="")
pm->GetGossipMenu()->AddMenuItem((uint8)gso->Icon,gso->Option.c_str(),ingso->GossipId,gso->Action,false);
}
}
}
//.........这里部分代码省略.........
开发者ID:chrayn,项目名称:mangos-06,代码行数:101,代码来源:Creature.cpp
示例19: prepareItems
void MailDraft::SendMailTo(SQLTransaction& trans, MailReceiver const& receiver, MailSender const& sender, MailCheckMask checked, uint32 deliver_delay)
{
Player* pReceiver = receiver.GetPlayer(); // can be NULL
if (pReceiver)
prepareItems(pReceiver, trans); // generate mail template items
uint32 mailId = sObjectMgr->GenerateMailID();
time_t deliver_time = time(NULL) + deliver_delay;
//expire time if COD 3 days, if no COD 30 days, if auction sale pending 1 hour
uint32 expire_delay;
// auction mail without any items and money
if (sender.GetMailMessageType() == MAIL_AUCTION && m_items.empty() && !m_money)
expire_delay = sWorld->getIntConfig(CONFIG_MAIL_DELIVERY_DELAY);
// mail from battlemaster (rewardmarks) should last only one day
else if (sender.GetMailMessageType() == MAIL_CREATURE)
{
CreatureInfo const * creatureinfo = GetCreatureInfo(sender.GetSenderId());
if (creatureinfo && creatureinfo->unit_flags & UNIT_NPC_FLAG_BATTLEMASTER)
expire_delay = DAY;
else
expire_delay = (m_COD > 0) ? 3 * DAY : 30 * DAY;
}
else
expire_delay = (m_COD > 0) ? 3 * DAY : 30 * DAY;
time_t expire_time = deliver_time + expire_delay;
// Add to DB
uint8 index = 0;
PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_MAIL);
stmt->setUInt32( index, mailId);
stmt->setUInt8 (++index, uint8(sender.GetMailMessageType()));
stmt->setInt8 (++index, int8(sender.GetStationery()));
stmt->setUInt16(++index, GetMailTemplateId());
stmt->setUInt32(++index, sender.GetSenderId());
stmt->setUInt32(++index, receiver.GetPlayerGUIDLow());
stmt->setString(++index, GetSubject());
stmt->setString(++index, GetBody());
stmt->setBool (++index, !m_items.empty());
stmt->setUInt64(++index, uint64(expire_time));
stmt->setUInt64(++index, uint64(deliver_time));
stmt->setUInt32(++index, m_money);
stmt->setUInt32(++index, m_COD);
stmt->setUInt8 (++index, uint8(checked));
trans->Append(stmt);
for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* pItem = mailItemIter->second;
stmt = CharacterDatabase.GetPreparedStatement(CHAR_ADD_MAIL_ITEM);
stmt->setUInt32(0, mailId);
stmt->setUInt32(1, pItem->GetGUIDLow());
stmt->setUInt32(2, receiver.GetPlayerGUIDLow());
trans->Append(stmt);
}
// For online receiver update in game mail status and data
if (pReceiver)
{
pReceiver->AddNewMailDeliverTime(deliver_time);
if (pReceiver->IsMailsLoaded())
{
Mail * m = new Mail;
m->messageID = mailId;
m->mailTemplateId = GetMailTemplateId();
m->subject = GetSubject();
m->body = GetBody();
m->money = GetMoney();
m->COD = GetCOD();
for (MailItemMap::const_iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
{
Item* item = mailItemIter->second;
m->AddItem(item->GetGUIDLow(), item->GetEntry());
}
m->messageType = sender.GetMailMessageType();
m->stationery = sender.GetStationery();
m->sender = sender.GetSenderId();
m->receiver = receiver.GetPlayerGUIDLow();
m->expire_time = expire_time;
m->deliver_time = deliver_time;
m->checked = checked;
m->state = MAIL_STATE_UNCHANGED;
pReceiver->AddMail(m); // to insert new mail to beginning of maillist
if (!m_items.empty())
{
for (MailItemMap::iterator mailItemIter = m_items.begin(); mailItemIter != m_items.end(); ++mailItemIter)
pReceiver->AddMItem(mailItemIter->second);
}
}
else if (!m_items.empty())
{
//.........这里部分代码省略.........
开发者ID:kmishima,项目名称:DarkCore,代码行数:101,代码来源:Mail.cpp
示例20: SetUInt32Value
bool Creature::CreateFromProto(uint32 guidlow,uint32 Entry)
{
Object::_Create(guidlow, HIGHGUID_UNIT);
m_DBTableGuid = guidlow;
SetUInt32Value(OBJECT_FIELD_ENTRY,Entry);
CreatureInfo const *cinfo = objmgr.GetCreatureTemplate(Entry);
if(!cinfo)
{
sLog.outError("Error: creature entry %u does not exist.",Entry);
r
|
请发表评论