本文整理汇总了C++中CreatureEventList::end方法的典型用法代码示例。如果您正苦于以下问题:C++ CreatureEventList::end方法的具体用法?C++ CreatureEventList::end怎么用?C++ CreatureEventList::end使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CreatureEventList
的用法示例。
在下文中一共展示了CreatureEventList::end方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: dropCorpse
bool Creature::dropCorpse()
{
if (!lootDrop && getMonster() && !(master && master->getPlayer())) {
if (master) {
//scripting event - onDeath
CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);
for (CreatureEventList::const_iterator it = deathEvents.begin(); it != deathEvents.end(); ++it) {
(*it)->executeOnDeath(this, NULL, _lastHitCreature, _mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
}
}
g_game.addMagicEffect(getPosition(), NM_ME_POFF);
} else {
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;
}
Tile* tile = getTile();
if (splash) {
g_game.internalAddItem(tile, splash, INDEX_WHEREEVER, FLAG_NOLIMIT);
g_game.startDecay(splash);
}
Item* corpse = getCorpse();
if (corpse) {
g_game.internalAddItem(tile, corpse, INDEX_WHEREEVER, FLAG_NOLIMIT);
g_game.startDecay(corpse);
}
//scripting event - onDeath
CreatureEventList deathEvents = getCreatureEvents(CREATURE_EVENT_DEATH);
for (CreatureEventList::const_iterator it = deathEvents.begin(); it != deathEvents.end(); ++it) {
(*it)->executeOnDeath(this, corpse, _lastHitCreature, _mostDamageCreature, lastHitUnjustified, mostDamageUnjustified);
}
if (corpse) {
dropLoot(corpse->getContainer());
}
}
return true;
}
示例2: 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;
}
示例3: 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;
}
示例4: 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;
}
示例5: dropCorpse
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);
}
示例6: onCreatureDisappear
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: onKilledCreature
bool Creature::onKilledCreature(Creature* target, uint32_t& flags, DeathEntry& entry)
{
bool ret = true;
if(master)
ret = master->onKilledCreature(target, flags, entry);
CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_KILL);
if(!hasBitSet((uint32_t)KILLFLAG_LASTHIT, flags))
{
for(CreatureEventList::iterator it = killEvents.begin(); it != killEvents.end(); ++it)
(*it)->executeKill(this, target, false);
return true;
}
for(CreatureEventList::iterator it = killEvents.begin(); it != killEvents.end(); ++it)
{
if(!(*it)->executeKill(this, target, true) && ret)
ret = false;
}
return ret;
}
示例8: 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);
}
示例9: onKilledCreature
bool Creature::onKilledCreature(Creature* target, DeathEntry& entry)
{
bool ret = true;
if(master)
ret = master->onKilledCreature(target, entry);
CreatureEventList killEvents = getCreatureEvents(CREATURE_EVENT_KILL);
if(!entry.isLast())
{
for(CreatureEventList::iterator it = killEvents.begin(); it != killEvents.end(); ++it)
(*it)->executeKill(this, target, entry);
return true;
}
for(CreatureEventList::iterator it = killEvents.begin(); it != killEvents.end(); ++it)
{
if(!(*it)->executeKill(this, target, entry) && ret)
ret = false;
}
return ret;
}
示例10: 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);
}
示例11: onThink
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);
}
示例12: onKilledCreature
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;
}
示例13: onCreatureAppear
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);
}
}
示例14: onThink
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);
}
}
示例15: onCreatureAppear
void Monster::onCreatureAppear(const Creature* creature)
{
Creature::onCreatureAppear(creature);
if(creature == this)
{
//We just spawned lets look around to see who is there.
if(isSummon())
isMasterInRange = canSee(getMaster()->getPosition());
setStorage(510, mType->realName); // sistema de shiny nomes 2.0
CreatureEventList spawn = getCreatureEvents(CREATURE_EVENT_SPAWN);
for(CreatureEventList::iterator it = spawn.begin(); it != spawn.end(); ++it)
(*it)->executeOnSpawn(this);
updateTargetList();
updateIdleStatus();
}
else
onCreatureEnter(const_cast<Creature*>(creature));
}