本文整理汇总了C++中CMobEntity::Spawn方法的典型用法代码示例。如果您正苦于以下问题:C++ CMobEntity::Spawn方法的具体用法?C++ CMobEntity::Spawn怎么用?C++ CMobEntity::Spawn使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CMobEntity
的用法示例。
在下文中一共展示了CMobEntity::Spawn方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WeatherChange
void CZoneEntities::WeatherChange(WEATHER weather)
{
auto element = zoneutils::GetWeatherElement(weather);
for (EntityList_t::const_iterator it = m_mobList.begin(); it != m_mobList.end(); ++it)
{
CMobEntity* PCurrentMob = (CMobEntity*)it->second;
PCurrentMob->PAI->EventHandler.triggerListener("WEATHER_CHANGE", PCurrentMob, static_cast<int>(weather), element);
// can't detect by scent in this weather
if (PCurrentMob->m_Aggro & AGGRO_SCENT)
{
PCurrentMob->m_disableScent = (weather == WEATHER_RAIN || weather == WEATHER_SQUALL || weather == WEATHER_BLIZZARDS);
}
if (PCurrentMob->m_EcoSystem == SYSTEM_ELEMENTAL && PCurrentMob->PMaster == nullptr && PCurrentMob->m_SpawnType == SPAWNTYPE_WEATHER)
{
if (PCurrentMob->m_Element == element)
{
PCurrentMob->SetDespawnTime(0s);
PCurrentMob->m_AllowRespawn = true;
PCurrentMob->Spawn();
}
else
{
PCurrentMob->SetDespawnTime(1s);
PCurrentMob->m_AllowRespawn = false;
}
}
else if (PCurrentMob->m_SpawnType == SPAWNTYPE_FOG)
{
if (weather == WEATHER_FOG)
{
PCurrentMob->SetDespawnTime(0s);
PCurrentMob->m_AllowRespawn = true;
PCurrentMob->Spawn();
}
else
{
PCurrentMob->SetDespawnTime(1s);
PCurrentMob->m_AllowRespawn = false;
}
}
}
for (EntityList_t::const_iterator it = m_charList.begin(); it != m_charList.end(); ++it)
{
CCharEntity* PChar = (CCharEntity*)it->second;
PChar->PLatentEffectContainer->CheckLatentsZone();
PChar->PAI->EventHandler.triggerListener("WEATHER_CHANGE", PChar, static_cast<int>(weather), element);
}
}
示例2: spawnMonstersForBcnm
/***************************************************************
Spawns monsters for the given BCNMID/Battlefield number by
looking at bcnm_battlefield table for mob ids then spawning
them and adding them to the monster list for the given
battlefield.
****************************************************************/
bool spawnMonstersForBcnm(CBattlefield* battlefield) {
DSP_DEBUG_BREAK_IF(battlefield == nullptr);
//get ids from DB
const char* fmtQuery = "SELECT monsterId, conditions \
FROM bcnm_battlefield \
WHERE bcnmId = %u AND battlefieldNumber = %u";
int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->getID(), battlefield->getBattlefieldNumber());
if (ret == SQL_ERROR ||
Sql_NumRows(SqlHandle) == 0)
{
ShowError("spawnMonstersForBcnm : SQL error - Cannot find any monster IDs for BCNMID %i Battlefield %i \n",
battlefield->getID(), battlefield->getBattlefieldNumber());
}
else {
while (Sql_NextRow(SqlHandle) == SQL_SUCCESS) {
uint32 mobid = Sql_GetUIntData(SqlHandle, 0);
uint8 condition = Sql_GetUIntData(SqlHandle, 1);
CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB);
if (PMob != nullptr)
{
PMob->m_battlefieldID = battlefield->getBattlefieldNumber();
PMob->m_bcnmID = battlefield->getID();
if (condition & CONDITION_SPAWNED_AT_START)
{
if (!PMob->PAI->IsSpawned())
{
PMob->Spawn();
//ShowDebug("Spawned %s (%u) id %i inst %i \n",PMob->GetName(),PMob->id,battlefield->getID(),battlefield->getBattlefieldNumber());
battlefield->addEnemy(PMob, condition);
}
else {
ShowDebug(CL_CYAN"SpawnMobForBcnm: <%s> (%u) is already spawned\n" CL_RESET, PMob->GetName(), PMob->id);
}
}
else {
battlefield->addEnemy(PMob, condition);
}
}
else {
ShowDebug("SpawnMobForBcnm: mob %u not found\n", mobid);
}
}
if (!(battlefield->m_RuleMask & RULES_ALLOW_SUBJOBS))
{
// disable players subjob
battlefield->disableSubJob();
}
return true;
}
return false;
}
示例3: spawnSecondPartDynamis
bool spawnSecondPartDynamis(CBattlefield* battlefield) {
DSP_DEBUG_BREAK_IF(battlefield == nullptr);
//get ids from DB
const int8* fmtQuery = "SELECT monsterId \
FROM bcnm_battlefield \
WHERE bcnmId = %u AND battlefieldNumber = 2";
int32 ret = Sql_Query(SqlHandle, fmtQuery, battlefield->getID());
if (ret == SQL_ERROR ||
Sql_NumRows(SqlHandle) == 0)
{
ShowError("spawnSecondPartDynamis : SQL error - Cannot find any monster IDs for Dynamis %i \n",
battlefield->getID(), battlefield->getBattlefieldNumber());
}
else {
while (Sql_NextRow(SqlHandle) == SQL_SUCCESS) {
uint32 mobid = Sql_GetUIntData(SqlHandle, 0);
CMobEntity* PMob = (CMobEntity*)zoneutils::GetEntity(mobid, TYPE_MOB);
if (PMob != nullptr)
{
if (!PMob->PAI->IsSpawned())
{
PMob->Spawn();
PMob->m_battlefieldID = battlefield->getBattlefieldNumber();
ShowDebug("Spawned %s (%u) id %i inst %i \n", PMob->GetName(), PMob->id, battlefield->getID(), battlefield->getBattlefieldNumber());
battlefield->addEnemy(PMob, CONDITION_SPAWNED_AT_START & CONDITION_WIN_REQUIREMENT);
}
else {
ShowDebug(CL_CYAN"spawnSecondPartDynamis: <%s> (%u) is already spawned\n" CL_RESET, PMob->GetName(), PMob->id);
}
}
else {
ShowDebug("spawnSecondPartDynamis: mob %u not found\n", mobid);
}
}
return true;
}
return false;
}
示例4: TOTDChange
void CZoneEntities::TOTDChange(TIMETYPE TOTD)
{
SCRIPTTYPE ScriptType = SCRIPT_NONE;
switch (TOTD)
{
case TIME_MIDNIGHT:
{
}
break;
case TIME_NEWDAY:
{
for (EntityList_t::const_iterator it = m_mobList.begin(); it != m_mobList.end(); ++it)
{
CMobEntity* PMob = (CMobEntity*)it->second;
if (PMob->m_SpawnType == SPAWNTYPE_ATNIGHT)
{
PMob->SetDespawnTime(1ms);
PMob->m_AllowRespawn = false;
}
}
}
break;
case TIME_DAWN:
{
ScriptType = SCRIPT_TIME_DAWN;
for (EntityList_t::const_iterator it = m_mobList.begin(); it != m_mobList.end(); ++it)
{
CMobEntity* PMob = (CMobEntity*)it->second;
if (PMob->m_SpawnType == SPAWNTYPE_ATEVENING)
{
PMob->SetDespawnTime(1ms);
PMob->m_AllowRespawn = false;
}
}
}
break;
case TIME_DAY:
{
ScriptType = SCRIPT_TIME_DAY;
}
break;
case TIME_DUSK:
{
ScriptType = SCRIPT_TIME_DUSK;
}
break;
case TIME_EVENING:
{
ScriptType = SCRIPT_TIME_EVENING;
for (EntityList_t::const_iterator it = m_mobList.begin(); it != m_mobList.end(); ++it)
{
CMobEntity* PMob = (CMobEntity*)it->second;
if (PMob->m_SpawnType == SPAWNTYPE_ATEVENING)
{
PMob->SetDespawnTime(0s);
PMob->m_AllowRespawn = true;
PMob->Spawn();
}
}
}
break;
case TIME_NIGHT:
{
for (EntityList_t::const_iterator it = m_mobList.begin(); it != m_mobList.end(); ++it)
{
CMobEntity* PMob = (CMobEntity*)it->second;
if (PMob->m_SpawnType == SPAWNTYPE_ATNIGHT)
{
PMob->SetDespawnTime(0s);
PMob->m_AllowRespawn = true;
PMob->Spawn();
}
}
}
break;
}
if (ScriptType != SCRIPT_NONE)
{
for (EntityList_t::const_iterator it = m_charList.begin(); it != m_charList.end(); ++it)
{
charutils::CheckEquipLogic((CCharEntity*)it->second, ScriptType, TOTD);
}
}
}