Example #1
0
void Creature::onDie()
{
	DeathList killers = getKillers(g_config.getNumber(ConfigManager::DEATH_ASSIST_COUNT));

	for(DeathList::const_iterator it = killers.begin(); it != killers.end(); ++it){
		if(it->isCreatureKill()){
			Creature* attacker = it->getKillerCreature();
			if(attacker){
				attacker->onKilledCreature(this);
			}
		}
	}

	for(CountMap::iterator it = damageMap.begin(); it != damageMap.end(); ++it){
		if(Creature* attacker = g_game.getCreatureByID((*it).first)){
			attacker->onAttackedCreatureKilled(this);
		}
	}

	Item* corpse = dropCorpse();
	die();

	g_game.onCreatureDeath(this, corpse, (killers.front().isCreatureKill()? killers.front().getKillerCreature() : NULL));

	if(corpse){
		Player* killer = g_game.getPlayerByID(corpse->getCorpseOwner());
		if(killer){
			killer->broadcastLoot(this, corpse->getContainer());
		}
	}

	if(getMaster()){
		getMaster()->removeSummon(this);
	}
}
Example #2
0
void IOGuild::frag(Player* player, uint64_t deathId, const DeathList& list)
{
	Database* db = Database::getInstance();
	War_t war;

	std::stringstream s;
	for(DeathList::const_iterator it = list.begin(); it != list.end(); )
	{
		if(it->isLast())
			war = it->getWar();

		Creature* creature = it->getKillerCreature();
		if(it != list.begin())
		{
			++it;
			if(it == list.end())
				s << " and ";
			else
				s << ", ";
		}
		else
			++it;

		s << creature->getName();
	}

	std::string killers = s.str();
	s.str("");

	ChatChannel* channel = NULL;
	if((channel = g_chat.getChannel(player, CHANNEL_GUILD)))
	{
		s << "Guild member " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[
			war.type == WAR_GUILD] << ":" << war.frags[war.type] << " frags (limit " << war.limit << ").";
		channel->talk("", SPEAK_CHANNEL_RA, s.str());
	}

	s.str("");
	if((channel = g_chat.getChannel(list[0].getKillerCreature()->getPlayer(), CHANNEL_GUILD)))
	{
		s << "Opponent " << player->getName() << " was killed by " << killers << ". The new score is " << war.frags[
			war.type] << ":" << war.frags[war.type == WAR_GUILD] << " frags (limit " << war.limit << ").";
		channel->talk("", SPEAK_CHANNEL_RA, s.str());
	}

	DBQuery query;
	query << "INSERT INTO `guild_kills` (`guild_id`, `war_id`, `death_id`) VALUES (" << war.ids[war.type] << ", " << war.war << ", " << deathId << ");";
	db->query(query.str());
}
Example #3
0
void IOGuild::frag(Player* player, uint64_t deathId, const DeathList& list, bool score)
{
	War_t war;
	std::stringstream s;
	for(DeathList::const_iterator it = list.begin(); it != list.end(); )
	{
		if(score)
		{
			if(it->isLast())
				war = it->getWar();
		}
		else if(!war.war)
			war = it->getWar();

		Creature* creature = it->getKillerCreature();
		if(it != list.begin())
		{
			++it;
			if(it == list.end())
				s << " and ";
			else
				s << ", ";
		}
		else
			++it;

		s << creature->getName();
	}

	if(!war.ids[war.type])
	{
		#ifdef __DEBUG__
		std::clog << "[Notice - IOGuild::frag] Unable to attach war frag to player " << player->getName() << "." << std::endl;
		#endif
		return;
	}

	std::string killers = s.str();
	s.str("");

	ChatChannel* channel = NULL;
	if((channel = g_chat.getChannel(player, CHANNEL_GUILD)))
	{
		s << "Guild member " << player->getName() << " was killed by " << killers << ".";
		if(score)
			s << " The new score is " << war.frags[war.type == WAR_GUILD] << ":"
				<< war.frags[war.type] << " frags (limit " << war.limit << ").";

		channel->talk("", MSG_GAMEMASTER_CHANNEL, s.str());
	}

	s.str("");
	if((channel = g_chat.getChannel(list[0].getKillerCreature()->getPlayer(), CHANNEL_GUILD)))
	{
		s << "Opponent " << player->getName() << " was killed by " << killers << ".";
		if(score)
			s << " The new score is " << war.frags[war.type] << ":"
				<< war.frags[war.type == WAR_GUILD] << " frags (limit " << war.limit << ").";

		channel->talk("", MSG_CHANNEL_HIGHLIGHT, s.str());
	}

	Database* db = Database::getInstance();
	DBQuery query;

	query << "INSERT INTO `guild_kills` (`guild_id`, `war_id`, `death_id`) VALUES ("
		<< war.ids[war.type] << ", " << war.war << ", " << deathId << ");";
	db->query(query.str());
}