コード例 #1
0
ファイル: Bot.cpp プロジェクト: The4Bros/Starcraft_AI
void Bot::OnAttack(int damage, Bot* attacker)
{
	unit->Hit(damage, normal);

	if (unit->GetHP() <= 0)
	{
		OnKill();
	}
	else if (unit->team == App->AI->playerTeam)
	{
		if (unit->ArrivedToDestination())
		{
			Attack(attacker);
		}
	}
	else if (father)
	{
		App->AI->OnUnitDanger(father, this);
	}
	else if (flees)
	{
		if (unit->GetHP() < unit->GetMaxHP() / 10)
			SetState(flee);
		else
			SetState(attack);
	}
	else if (state != attack)
		Attack(attacker);
}
コード例 #2
0
ファイル: cmd_kill.cpp プロジェクト: mikebryant/inspircd
void cmd_kill::Handle (const char** parameters, int pcnt, userrec *user)
{
	userrec *u = ServerInstance->FindNick(parameters[0]);
	char killreason[MAXBUF];
	int MOD_RESULT = 0;

	ServerInstance->Log(DEBUG,"kill: %s %s", parameters[0], parameters[1]);

	if (u)
	{
		ServerInstance->Log(DEBUG, "into kill mechanism");
		FOREACH_RESULT(I_OnKill, OnKill(user, u, parameters[1]));

		if (MOD_RESULT)
		{
			ServerInstance->Log(DEBUG, "A module prevented the kill with result %d", MOD_RESULT);
			return;
		}

		if (!IS_LOCAL(u))
		{
			// remote kill
			ServerInstance->WriteOpers("*** Remote kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
			snprintf(killreason, MAXQUIT,"[%s] Killed (%s (%s))", ServerInstance->Config->ServerName, user->nick, parameters[1]);
			u->WriteCommonExcept("QUIT :%s", killreason);
			FOREACH_MOD(I_OnRemoteKill, OnRemoteKill(user, u, killreason));
			
			user_hash::iterator iter = ServerInstance->clientlist.find(u->nick);

			if (iter != ServerInstance->clientlist.end())
			{
				ServerInstance->Log(DEBUG,"deleting user hash value %d", iter->second);
				ServerInstance->clientlist.erase(iter);
			}

			if (u->registered == REG_ALL)
			{
				u->PurgeEmptyChannels();
			}

			DELETE(u);
		}
		else
		{
			// local kill
			ServerInstance->Log(DEFAULT,"LOCAL KILL: %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
			user->WriteTo(u, "KILL %s :%s!%s!%s (%s)", u->nick, ServerInstance->Config->ServerName, user->dhost, user->nick, parameters[1]);
			ServerInstance->WriteOpers("*** Local Kill by %s: %s!%s@%s (%s)", user->nick, u->nick, u->ident, u->host, parameters[1]);
			snprintf(killreason,MAXQUIT,"Killed (%s (%s))", user->nick, parameters[1]);
			userrec::QuitUser(ServerInstance, u, killreason);
		}
	}
	else
	{
		user->WriteServ( "401 %s %s :No such nick/channel", user->nick, parameters[0]);
	}
}
コード例 #3
0
ファイル: GameStats.cpp プロジェクト: amrhead/eaascode
void CGameStats::OnGameplayEvent(IEntity *pEntity, const GameplayEvent &event)
{
/*	for(int i=0;i<gEventNamesNum;++i)
	{
		if(gEventNames[i].key == event.event)
		{
			CryLog("GameStats : Event %s",gEventNames[i].name);
		}
	}*/

	int e_id = pEntity ? (int) pEntity->GetId() : 0;
	switch(event.event)
	{
	case eGE_GameStarted:
		StartGame(event.value!=0);
		break;
	case eGE_GameEnd:
		EndGame(event.value!=0);
		break;
	case eGE_SuddenDeath:
		SuddenDeath(event.value!=0);
		break;
	case eGE_RoundEnd:
		EndRound(event.value!=0, atoi(event.description));
		break;
	case eGE_Renamed:
		SetName(e_id, event.description);
		break;
	case eGE_Scored:
		SetScore(e_id, event.description, (int)event.value);
		break;
	case eGE_Kill:
		OnKill(e_id, (EntityId*)event.extra);
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
		break;
	case eGE_Death:
		OnDeath(e_id, (int)(TRUNCATE_PTR)event.extra);
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
		break;
  case eGE_WeaponShot:
	case eGE_WeaponHit:
	case eGE_SuitModeChanged:
	case eGE_WeaponMelee:
	case eGE_LeftVehicle:
	case eGE_EnteredVehicle:
	case eGE_ItemSelected:
	case eGE_WeaponReload:
	case eGE_Damage:
	case eGE_Revive:
	case eGE_WeaponFireModeChanged:
	case eGE_ZoomedIn:
	case eGE_ZoomedOut:
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
		break;
	case eGE_Connected:
		{
			bool restored = event.value!=0.0f;

			struct SExtraData
			{
					int status[2];
			};

			SExtraData* pExtra = static_cast<SExtraData*>(event.extra);
			NewPlayer(e_id, pExtra->status[0], pExtra->status[1]!=0, restored);
		}
		break;
  case eGE_ChangedTeam:
    SetTeam(e_id,(int)event.value);
    break;
  case eGE_Spectator:
    SetSpectator(e_id,(int)event.value);
		if(pEntity)
			ProcessPlayerStat(pEntity,event);
    break;
	case eGE_Disconnected:
		RemovePlayer(e_id, event.value!=0);
		break;
	case eGE_ScoreReset:
		ResetScore(e_id);
		break;
  case eGE_Rank:
    SetRank(e_id,(int)event.value);
    break;
	case eGE_GameReset:
		GameReset();
		break;
	default:
		break;
	}
}