本文整理汇总了C++中CreatureEventList类的典型用法代码示例。如果您正苦于以下问题:C++ CreatureEventList类的具体用法?C++ CreatureEventList怎么用?C++ CreatureEventList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CreatureEventList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: canDoCombat
ReturnValue Combat::canDoCombat(const CreatureP& caster, Tile* tile, bool isAggressive)
{
if(tile->hasProperty(BLOCKPROJECTILE) || tile->floorChange() || tile->getTeleporter())
return RET_NOTENOUGHROOM;
if(caster)
{
bool success = true;
CreatureEventList combatAreaEvents = caster->getCreatureEvents(CREATURE_EVENT_COMBAT_AREA);
for(CreatureEventList::iterator it = combatAreaEvents.begin(); it != combatAreaEvents.end(); ++it)
{
if(!(*it)->executeCombatArea(caster, tile, isAggressive) && success)
success = false;
}
if(!success)
return RET_NOTPOSSIBLE;
if(caster->getPosition().z < tile->getPosition().z)
return RET_FIRSTGODOWNSTAIRS;
if(caster->getPosition().z > tile->getPosition().z)
return RET_FIRSTGOUPSTAIRS;
if(!isAggressive)
return RET_NOERROR;
const Player* player = caster->getPlayer();
if(player && player->hasFlag(PlayerFlag_IgnoreProtectionZone))
return RET_NOERROR;
}
return isAggressive && tile->hasFlag(TILESTATE_PROTECTIONZONE) ?
RET_ACTIONNOTPERMITTEDINPROTECTIONZONE : RET_NOERROR;
}
示例2: addUser
bool ChatChannel::addUser(Player* player)
{
if(m_users.find(player->getID()) != m_users.end())
return false;
ChatChannel* channel = g_chat.getChannel(player, m_id);
if(!channel)
{
#ifdef __DEBUG_CHAT__
std::clog << "ChatChannel::addUser - failed retrieving channel." << std::endl;
#endif
return false;
}
if(m_id == CHANNEL_PARTY || m_id == CHANNEL_GUILD || m_id == CHANNEL_PRIVATE)
{
Player* tmpPlayer = NULL;
for(UsersMap::iterator cit = m_users.begin(); cit != m_users.end(); ++cit)
{
if((tmpPlayer = cit->second->getPlayer()))
tmpPlayer->sendChannelEvent(m_id, player->getName(), CHANNELEVENT_JOIN);
}
}
m_users[player->getID()] = player;
CreatureEventList joinEvents = player->getCreatureEvents(CREATURE_EVENT_CHANNEL_JOIN);
for(CreatureEventList::iterator it = joinEvents.begin(); it != joinEvents.end(); ++it)
(*it)->executeChannelJoin(player, m_id, m_users);
Manager::getInstance()->addUser(player->getID(), m_id);
return true;
}
示例3: removeUser
bool ChatChannel::removeUser(Player* player)
{
if(!player || player->isRemoved())
return false;
UsersMap::iterator it = m_users.find(player->getID());
if(it == m_users.end())
return false;
m_users.erase(it);
CreatureEventList leaveEvents = player->getCreatureEvents(CREATURE_EVENT_CHANNEL_LEAVE);
for(CreatureEventList::iterator it = leaveEvents.begin(); it != leaveEvents.end(); ++it)
(*it)->executeChannelLeave(player, m_id, m_users);
if(m_id == CHANNEL_PARTY || m_id == CHANNEL_GUILD || m_id == CHANNEL_PRIVATE)
{
Player* tmpPlayer = NULL;
for(UsersMap::iterator cit = m_users.begin(); cit != m_users.end(); ++cit)
{
if((tmpPlayer = cit->second->getPlayer()))
tmpPlayer->sendChannelEvent(m_id, player->getName(), CHANNELEVENT_LEAVE);
}
}
Manager::getInstance()->removeUser(player->getID(), m_id);
return true;
}
示例4: createCorpse
void Creature::dropCorpse(DeathList deathList)
{
if(master && !g_config.getBool(ConfigManager::SUMMONS_DROP_CORPSE))
{
g_game.addMagicEffect(getPosition(), MAGIC_EFFECT_POFF);
return;
}
Item* corpse = createCorpse(deathList);
if(corpse)
corpse->setParent(VirtualCylinder::virtualCylinder);
bool deny = false;
CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);
for(CreatureEventList::iterator it = deathEvents.begin(); it != deathEvents.end(); ++it)
{
if(!(*it)->executeDeath(this, corpse, deathList) && !deny)
deny = true;
}
if(!corpse)
return;
corpse->setParent(NULL);
if(deny)
return;
Tile* tile = getTile();
if(!tile)
return;
Item* splash = NULL;
switch(getRace())
{
case RACE_VENOM:
splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_GREEN);
break;
case RACE_BLOOD:
splash = Item::CreateItem(ITEM_FULLSPLASH, FLUID_BLOOD);
break;
default:
break;
}
if(splash)
{
g_game.internalAddItem(NULL, tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT);
g_game.startDecay(splash);
}
g_game.internalAddItem(NULL, tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
dropLoot(corpse->getContainer());
g_game.startDecay(corpse);
}
示例5: getCreatureEvents
CreatureEventList Creature::getCreatureEvents(CreatureEventType_t type)
{
CreatureEventList list;
for(CreatureEventList::iterator it = eventsList.begin(); it != eventsList.end(); ++it)
{
if((*it)->getEventType() == type && (*it)->isLoaded())
list.push_back(*it);
}
return list;
}
示例6: internalCreatureDisappear
void Creature::onCreatureDisappear(const Creature* creature, bool isLogout)
{
internalCreatureDisappear(creature, true);
if(creature != this && isMapLoaded && creature->getPosition().z == getPosition().z)
{
updateTileCache(creature->getTile(), creature->getPosition());
CreatureEventList disappearEvents = getCreatureEvents(CREATURE_EVENT_DISAPPEAR);
for(CreatureEventList::iterator it = disappearEvents.begin(); it != disappearEvents.end(); ++it)
(*it)->executeDisappear(this, creature);
}
}
示例7: canTargetCreature
ReturnValue Combat::canTargetCreature(const Player* player, const Creature* target)
{
if(player == target)
return RET_YOUMAYNOTATTACKTHISPLAYER;
Player* tmpPlayer = const_cast<Player*>(player);
bool deny = false;
CreatureEventList targetEvents = tmpPlayer->getCreatureEvents(CREATURE_EVENT_TARGET);
for(CreatureEventList::iterator it = targetEvents.begin(); it != targetEvents.end(); ++it)
{
if(!(*it)->executeAction(tmpPlayer, const_cast<Creature*>(target)) && !deny)
deny = true;
}
if(deny)
return RET_NEEDEXCHANGE;
if(!player->hasFlag(PlayerFlag_IgnoreProtectionZone))
{
if(player->getZone() == ZONE_PROTECTION)
return RET_YOUMAYNOTATTACKAPERSONWHILEINPROTECTIONZONE;
if(target->getZone() == ZONE_PROTECTION)
return RET_YOUMAYNOTATTACKAPERSONINPROTECTIONZONE;
if(target->getPlayer() || target->isPlayerSummon())
{
if(player->getZone() == ZONE_OPTIONAL)
return RET_ACTIONNOTPERMITTEDINANOPVPZONE;
if(target->getZone() == ZONE_OPTIONAL)
return RET_YOUMAYNOTATTACKAPERSONINPROTECTIONZONE;
}
}
if(player->hasFlag(PlayerFlag_CannotUseCombat))
return target->getPlayer() ? RET_YOUMAYNOTATTACKTHISPLAYER : RET_YOUMAYNOTATTACKTHISCREATURE;
if(target->getPlayer() && !Combat::isInPvpZone(player, target) && player->getSkullType(target->getPlayer()) == SKULL_NONE)
{
if(player->getSecureMode() == SECUREMODE_ON)
return RET_TURNSECUREMODETOATTACKUNMARKEDPLAYERS;
}
if(player->checkLoginDelay())
return RET_YOUMAYNOTATTACKIMMEDIATELYAFTERLOGGINGIN;
return Combat::canDoCombat(player, target, true);
}
示例8: getCreatureEvents
CreatureEventList Creature::getCreatureEvents(CreatureEventType_t type)
{
CreatureEventList retList;
if(!hasEventRegistered(type))
return retList;
for(CreatureEventList::iterator it = eventsList.begin(); it != eventsList.end(); ++it)
{
if((*it)->getEventType() == type)
retList.push_back(*it);
}
return retList;
}
示例9: canTargetCreature
ReturnValue Combat::canTargetCreature(const PlayerP& player, const CreatureP& target)
{
if(player == target)
return RET_YOUMAYNOTATTACKTHISPLAYER;
CreatureEventList targetEvents = player->getCreatureEvents(CREATURE_EVENT_TARGET);
bool deny = false;
for(CreatureEventList::iterator it = targetEvents.begin(); it != targetEvents.end(); ++it)
{
if(!(*it)->executeTarget(player, target))
deny = true;
}
if(deny)
return RET_DONTSHOWMESSAGE;
if(!player->hasFlag(PlayerFlag_IgnoreProtectionZone))
{
if(player->getZone() == ZONE_PROTECTION)
return RET_YOUMAYNOTATTACKAPERSONWHILEINPROTECTIONZONE;
if(target->getZone() == ZONE_PROTECTION)
return RET_YOUMAYNOTATTACKAPERSONINPROTECTIONZONE;
const Monster* targetMonster = target->getMonster();
if(target->getPlayer() || (targetMonster != nullptr && targetMonster->getMaster() && targetMonster->getMaster()->getPlayer()))
{
if(player->getZone() == ZONE_NOPVP)
return RET_ACTIONNOTPERMITTEDINANOPVPZONE;
if(target->getZone() == ZONE_NOPVP)
return RET_YOUMAYNOTATTACKAPERSONINPROTECTIONZONE;
}
}
if(player->hasFlag(PlayerFlag_CannotUseCombat) || !target->isAttackable())
return target->getPlayer() ? RET_YOUMAYNOTATTACKTHISPLAYER : RET_YOUMAYNOTATTACKTHISCREATURE;
if(target->getPlayer() && !Combat::isInPvpZone(*player, *target) && player->getSkullClient(target->getPlayer()) == SKULL_NONE)
{
if(player->getSecureMode() == SECUREMODE_ON)
return RET_TURNSECUREMODETOATTACKUNMARKEDPLAYERS;
if(player->getSkull() == SKULL_BLACK)
return RET_YOUMAYNOTATTACKTHISPLAYER;
}
return canDoCombat(player, target);
}
示例10: updateMapCache
void Creature::onThink(uint32_t interval)
{
if(!isMapLoaded && useCacheMap())
{
isMapLoaded = true;
updateMapCache();
}
if(followCreature && master != followCreature && !canSeeCreature(followCreature))
internalCreatureDisappear(followCreature, false);
if(attackedCreature && master != attackedCreature && !canSeeCreature(attackedCreature))
internalCreatureDisappear(attackedCreature, false);
blockTicks += interval;
if(blockTicks >= 1000)
{
blockCount = std::min((uint32_t)blockCount + 1, (uint32_t)2);
blockTicks = 0;
}
if(followCreature)
{
walkUpdateTicks += interval;
if(forceUpdateFollowPath || walkUpdateTicks >= 2000)
{
walkUpdateTicks = 0;
forceUpdateFollowPath = false;
isUpdatingPath = true;
}
}
if(isUpdatingPath)
{
isUpdatingPath = false;
goToFollowCreature();
}
#ifndef __GROUPED_ATTACKS__
onAttacking(interval / EVENT_CREATURECOUNT);
#else
onAttacking(interval);
#endif
executeConditions(interval);
CreatureEventList thinkEvents = getCreatureEvents(CREATURE_EVENT_THINK);
for(CreatureEventList::iterator it = thinkEvents.begin(); it != thinkEvents.end(); ++it)
(*it)->executeThink(this, interval);
}
示例11: getMaster
bool Creature::onKilledCreature(Creature* target, bool lastHit/* = true*/)
{
if (getMaster()) {
getMaster()->onKilledCreature(target);
}
//scripting event - onKill
CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_KILL);
for (CreatureEventList::const_iterator it = killEvents.begin(), end = killEvents.end(); it != end; ++it) {
(*it)->executeOnKill(this, target);
}
return false;
}
示例12: getCreatureEvents
CreatureEventList Creature::getCreatureEvents(CreatureEventType_t type)
{
CreatureEventList tmpEventList;
if (!hasEventRegistered(type)) {
return tmpEventList;
}
for (CreatureEventList::const_iterator it = eventsList.begin(), end = eventsList.end(); it != end; ++it) {
if ((*it)->getEventType() == type) {
tmpEventList.push_back(*it);
}
}
return tmpEventList;
}
示例13: getCreatureEvents
CreatureEventList Creature::getCreatureEvents(CreatureEventType_t type)
{
CreatureEventList tmpEventList;
if (!hasEventRegistered(type)) {
return tmpEventList;
}
for (CreatureEvent* creatureEvent : eventsList) {
if (creatureEvent->getEventType() == type) {
tmpEventList.push_back(creatureEvent);
}
}
return tmpEventList;
}
示例14: updateMapCache
void Creature::onCreatureAppear(const Creature* creature)
{
if(creature == this)
{
if(useCacheMap())
{
isMapLoaded = true;
updateMapCache();
}
}
else if(isMapLoaded && creature->getPosition().z == getPosition().z)
{
updateTileCache(creature->getTile(), creature->getPosition());
CreatureEventList disappearEvents = getCreatureEvents(CREATURE_EVENT_APPEAR);
for(CreatureEventList::iterator it = disappearEvents.begin(); it != disappearEvents.end(); ++it)
(*it)->executeDisappear(this, creature);
}
}
示例15: updateMapCache
void Creature::onThink(uint32_t interval)
{
if (!isMapLoaded && useCacheMap()) {
isMapLoaded = true;
updateMapCache();
}
if (followCreature && getMaster() != followCreature && !canSeeCreature(followCreature)) {
onCreatureDisappear(followCreature, false);
}
if (attackedCreature && getMaster() != attackedCreature && !canSeeCreature(attackedCreature)) {
onCreatureDisappear(attackedCreature, false);
}
blockTicks += interval;
if (blockTicks >= 1000) {
blockCount = std::min<uint32_t>(blockCount + 1, 2);
blockTicks = 0;
}
if (followCreature) {
walkUpdateTicks += interval;
if (forceUpdateFollowPath || walkUpdateTicks >= 2000) {
walkUpdateTicks = 0;
forceUpdateFollowPath = false;
isUpdatingPath = true;
}
}
if (isUpdatingPath) {
isUpdatingPath = false;
goToFollowCreature();
}
//scripting event - onThink
CreatureEventList thinkEvents = getCreatureEvents(CREATURE_EVENT_THINK);
for (CreatureEventList::const_iterator it = thinkEvents.begin(), end = thinkEvents.end(); it != end; ++it) {
(*it)->executeOnThink(this, interval);
}
}