예제 #1
0
void CNinja::Tick()
{
	CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);

	if(!pOwner)
	{
		Reset();
		return;
	}

	if(!m_Visible)
		return;

	char aBuf[128];
	int Click = pOwner->MouseEvent(m_Pos);

	if(!Click)
	{
		m_LastClick = 0;
		return;
	}
	
	switch(m_Type)
	{
	case 1:
		pOwner->Buy("Ninja permanent", &pOwner->GetPlayer()->m_AccData.m_NinjaPermanent, g_Config.m_EuNinjaPermanent, Click, 1);
		break;
	case 2:
		pOwner->Buy("Ninja at start", &pOwner->GetPlayer()->m_AccData.m_NinjaStart, g_Config.m_EuNinjaStart, Click, 1);
		break;
	case 3:
		pOwner->Buy("Ninja switch", &pOwner->GetPlayer()->m_AccData.m_NinjaSwitch, g_Config.m_EuNinjaSwitch, Click, 1);
		break;
	}
}
예제 #2
0
bool CLaser::HitCharacter(vec2 From, vec2 To)
{
	vec2 At;
	CCharacter *pOwnerChar = GameServer()->GetPlayerChar(m_Owner);
	CCharacter *pHit = GameServer()->m_World.IntersectCharacter(m_Pos, To, 0.f, At, pOwnerChar);
	if(!pHit)
		return false;

	m_From = From;
	m_Pos = At;
	m_Energy = -1;
	if (pOwnerChar)
	{
		if (m_Owner < FIRST_BOT_ID && pHit->GetPlayer()->GetCID() >= FIRST_BOT_ID && pHit->GetPlayer()->m_pAI)
			pHit->GetPlayer()->m_pAI->Stun(10);
		
		pHit->TakeDamage(vec2(0.f, 0.f), m_Damage, m_Owner, WEAPON_RIFLE);
	}
	else
		pHit->TakeDamage(vec2(0.f, 0.f), m_Damage, m_Owner, WEAPON_RIFLE);
	
	/*
	if (m_ExtraInfo == DOOMROCKETS)
	{
		CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, m_Pos, m_Owner, WEAPON_RIFLE, 2);
		GameServer()->m_World.InsertEntity(S);
	}
	*/
	
	return true;
}
예제 #3
0
void CGameContext::ConJail(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
	int Time = pResult->GetInteger(0);
	int JailID = pResult->GetVictim();
	char aBuf[200];

	if(Time < 20 || Time > 2419200)
	{
		pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Jail", "Set a time between 20 and 2419200 (4 weeks)");
		return;
	}

	CCharacter* pChr = pSelf->GetPlayerChar(JailID);
	if(pChr)
	{
		if(pChr->IsAlive())
		{
			pChr->GetPlayer()->m_AccData.m_Arrested = Time;
	
			if(Time)
			{
				str_format(aBuf, sizeof aBuf, "'%s' is arrested for %i secounds.", pSelf->Server()->ClientName(JailID), Time);
				pSelf->SendChat(-1, CHAT_ALL, aBuf);
				pChr->Die(pChr->GetPlayer()->GetCID(), WEAPON_GAME);
			
			}
		}
	}
}
예제 #4
0
void CGameControllerOpenFNG::HandleFreeze(int Killer, int Victim)
{
	CCharacter *pVictim = CHAR(Victim);
	if (!pVictim) // for odd reasons, this can happen (confirmed by segfault). didn't yet track down why 
	{
		D("no pVictim in HandleFreeze(%d, %d)", Killer, Victim);
		return;
	}

	if (CFG(BleedOnFreeze))
	{
		pVictim->Bleed(1);
		GS->CreateSound(pVictim->m_Pos, SOUND_CTF_RETURN);
	}

	int FailTeam = pVictim->GetPlayer()->GetTeam() & 1;
	m_aTeamscore[1 - FailTeam] += CFG(FreezeTeamscore);

	if (CFG(FreezeTeamscore) && CFG(FreezeBroadcast)) //probably of no real use but for completeness...
	{
		char aBuf[64];
		str_format(aBuf, sizeof aBuf, "%s froze (%+d)", GetTeamName(1-FailTeam), CFG(FreezeTeamscore));
		m_Broadcast.Update(-1, aBuf, CFG(BroadcastTime) * TS);
	}

	CPlayer *pPlKiller = TPLAYER(Killer);
	CPlayer *pPlVictim = TPLAYER(Victim);

	if (!pPlKiller || !pVictim)
		return;

	//freezing counts as a hostile interaction
	m_aLastInteraction[pVictim->GetPlayer()->GetCID()] = pPlKiller->GetCID();

	pPlKiller->m_Score += CFG(FreezeScore);
	pPlVictim->m_Score += CFG(FreezeScoreVic);
	SendFreezeKill(Killer, Victim, WEAPON_RIFLE);

	if (pPlKiller->GetCharacter())
	{
		GS->CreateSound(pPlKiller->GetCharacter()->m_Pos, SOUND_HIT, (1<<pPlKiller->GetCID()));
		if (CFG(FreezeLoltext) && CFG(FreezeScore))
		{
			char aBuf[64];
			str_format(aBuf, sizeof aBuf, "%+d", CFG(FreezeScore));
			GS->CreateLolText(pPlKiller->GetCharacter(), false, vec2(0.f, -50.f), vec2(0.f, 0.f), 50, aBuf);
		}
	}
}
예제 #5
0
void CGameContext::ConFreeze(IConsole::IResult *pResult, void *pUserData)
{
	if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
	CGameContext *pSelf = (CGameContext *)pUserData;
	int Seconds = -1;
	int Victim = pResult->GetVictim();

	char aBuf[128];

	if(pResult->NumArguments() == 1)
		Seconds = clamp(pResult->GetInteger(0), -2, 9999);

	CCharacter* pChr = pSelf->GetPlayerChar(Victim);
	if(!pChr)
		return;

	if(pSelf->m_apPlayers[Victim])
	{
		pChr->Freeze(Seconds);
		pChr->GetPlayer()->m_RconFreeze = Seconds != -2;
		CServer* pServ = (CServer*)pSelf->Server();
		if(Seconds >= 0)
			str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been Frozen for %d.", pServ->ClientName(Victim), Victim, Seconds);
		else if(Seconds == -2)
		{
			pChr->m_DeepFreeze = true;
			str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been Deep Frozen.", pServ->ClientName(Victim), Victim);
		}
		else
			str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d is Frozen until you unfreeze him.", pServ->ClientName(Victim), Victim);
		pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
	}

}
예제 #6
0
void CGameControllerOpenFNG::HandleMelt(int Melter, int Meltee)
{
	CCharacter *pMeltee = CHAR(Meltee);
	if (!pMeltee) //due to HandleFreeze, i suspect this COULD also possibly happen. 
	{
		D("no pMeltee in HandleMelt(%d, %d)", Melter, Meltee);
		return;
	}

	int MeltTeam = pMeltee->GetPlayer()->GetTeam()&1;
	m_aTeamscore[MeltTeam] += CFG(MeltTeamscore);

	if (CFG(MeltTeamscore) && CFG(MeltBroadcast))
	{
		char aBuf[64];
		str_format(aBuf, sizeof aBuf, "%s melted (%+d)", GetTeamName(MeltTeam), CFG(MeltTeamscore));
		m_Broadcast.Update(-1, aBuf, CFG(BroadcastTime) * TS);
	}

	CPlayer *pPlMelter = TPLAYER(Melter);

	if (!pPlMelter)
		return;

	pPlMelter->m_Score += CFG(MeltScore);
	SendFreezeKill(Melter, Meltee, WEAPON_HAMMER);

	if (pPlMelter->GetCharacter() && CFG(MeltLoltext) && CFG(MeltScore))
	{
		char aBuf[64];
		str_format(aBuf, sizeof aBuf, "%+d", CFG(MeltScore));
		GS->CreateLolText(pPlMelter->GetCharacter(), false, vec2(0.f, -50.f), vec2(0.f, 0.f), 50, aBuf);
	}
}
예제 #7
0
void CGameContext::ConGiveMoney(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
	int Time = pResult->GetInteger(0);
	int JailID = pResult->GetVictim();
	char aBuf[200];

	if(Time > 5000000 || Time < 1)
	{
		pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Debug", "Set a value between 1 and 5Mio");
		return;
	}

	CCharacter* pChr = pSelf->GetPlayerChar(JailID);
	if(pChr)
	{
		if(pChr->IsAlive())
		{
			pChr->GetPlayer()->m_AccData.m_Money += Time;
	
			if(Time)
			{
				str_format(aBuf, sizeof aBuf, "'%s' got %d TC", pSelf->Server()->ClientName(JailID), Time);
				pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "Money", aBuf);
			
			}
		}
	}
}
예제 #8
0
void CGameContext::ConUnFreeze(IConsole::IResult *pResult, void *pUserData)
{
	if(!CheckRights(pResult->m_ClientID, pResult->GetVictim(), (CGameContext *)pUserData)) return;
	CGameContext *pSelf = (CGameContext *)pUserData;
	int Victim = pResult->GetVictim();
	static bool Warning = false;
	char aBuf[128];
	CCharacter* pChr = pSelf->GetPlayerChar(Victim);
	if(!pChr)
		return;
	if(pChr->m_DeepFreeze && !Warning)
	{
		pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "warning", "This client is deeply frozen, repeat the command to defrost him.");
		Warning = true;
		return;
	}
	if(pChr->m_DeepFreeze && Warning)
	{
		pChr->m_DeepFreeze = false;
		Warning = false;
	}
	pChr->m_FreezeTime = 2;
	pChr->GetPlayer()->m_RconFreeze = false;
	CServer* pServ = (CServer*)pSelf->Server();
	str_format(aBuf, sizeof(aBuf), "'%s' ClientID=%d has been defrosted.", pServ->ClientName(Victim), Victim);
	pSelf->Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "info", aBuf);
}
예제 #9
0
void CNoSelfDMG::Tick()
{
	CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);

	if(!pOwner)
	{
		Reset();
		return;
	}

	if(!m_Visible)
		return;

	char aBuf[128];
	int Click = pOwner->MouseEvent(m_Pos);

	if(!Click)
	{
		m_LastClick = 0;
		return;
	}
	
	pOwner->Buy("No self damage", &pOwner->GetPlayer()->m_AccData.m_NoSelfDMG, g_Config.m_EuNoSelfDMG, Click, 1);
		
}
예제 #10
0
void CBarrier::Tick()
{
	m_LifeSpan--;
	
	if(m_LifeSpan < 0)
	{
		GameServer()->m_World.DestroyEntity(this);
	}
	else
	{
		// Find other players
		for(CCharacter *p = (CCharacter*) GameWorld()->FindFirst(CGameWorld::ENTTYPE_CHARACTER); p; p = (CCharacter *)p->TypeNext())
		{
			if(!p->IsInfected()) continue;

			vec2 IntersectPos = closest_point_on_line(m_Pos, m_Pos2, p->m_Pos);
			float Len = distance(p->m_Pos, IntersectPos);
			if(Len < p->m_ProximityRadius+g_BarrierRadius)
			{
				//Check for portal traps
				if(p->GetClass() != PLAYERCLASS_UNDEAD && (Server()->Tick() - p->m_PortalTick) < Server()->TickSpeed()/2)
				{
					CPlayer* pPortalPlayer = GameServer()->m_apPlayers[p->m_LastPortalOwner];
					if(pPortalPlayer)
					{
						pPortalPlayer->IncreaseScore(1);
					}
				}
				
				//Check for hook traps. The case when the player is frozen is in the function Die()
				if(!p->IsFrozen())
				{
					for(CCharacter *pHook = (CCharacter*) GameWorld()->FindFirst(CGameWorld::ENTTYPE_CHARACTER); pHook; pHook = (CCharacter *)pHook->TypeNext())
					{
						if(p->GetPlayer() && pHook->GetPlayer() && pHook->m_Core.m_HookedPlayer == p->GetPlayer()->GetCID() && pHook->GetPlayer()->GetCID() != m_Owner)
						{
							pHook->GetPlayer()->IncreaseScore(1);
						}
					}
				}
				
				p->Die(m_Owner, WEAPON_HAMMER);
			}
		}
	}
}
예제 #11
0
void CGameControllerOpenFNG::HandleSacr(int Killer, int Victim, int ShrineTeam)
{//assertion: Killer >= 0, victim anyways
	CCharacter *pVictim = CHAR(Victim);

	if (!pVictim) //due to HandleFreeze, i suspect this COULD also possibly happen. 
	{
		D("no pVictim in HandleSacr(%d, %d, %d)", Killer, Victim, ShrineTeam);
		return;
	}

	int FailTeam = pVictim->GetPlayer()->GetTeam();
	bool Wrong = ShrineTeam != -1 && FailTeam == ShrineTeam;

	m_aTeamscore[1-FailTeam] += Wrong?CFG(WrongSacrTeamscore):(ShrineTeam == -1 ? CFG(SacrTeamscore) : CFG(RightSacrTeamscore));

	if (!Wrong)
	{
		if (CFG(SacrSound) == 1)
			GameServer()->CreateSoundGlobal(SOUND_CTF_CAPTURE);
		else if (CFG(SacrSound) == 2)
			GameServer()->CreateSound(pVictim->m_Pos, SOUND_CTF_CAPTURE);
	}

	if (((Wrong && CFG(WrongSacrTeamscore)) || (!Wrong && (ShrineTeam == -1 ? CFG(SacrTeamscore) : CFG(RightSacrTeamscore)))) && CFG(SacrBroadcast))
	{
		char aBuf[64];
		str_format(aBuf, sizeof aBuf, "%s sacrificed%s (%+d)", GetTeamName(1-FailTeam), Wrong?" in wrong shrine":(ShrineTeam == -1 ? "" : ", pleasing their gods"),
		                                                                           Wrong?CFG(WrongSacrTeamscore):(ShrineTeam == -1 ? CFG(SacrTeamscore):CFG(RightSacrTeamscore)));
		m_Broadcast.Update(-1, aBuf, CFG(BroadcastTime) * TS);
	}

	CPlayer *pPlKiller = TPLAYER(Killer);
	if (!pPlKiller)
		return;

	pPlKiller->m_Score += Wrong?CFG(WrongSacrScore):(ShrineTeam == -1 ? CFG(SacrScore) : CFG(RightSacrScore));
	SendKill(Killer, Victim, WEAPON_NINJA);

	if(!Wrong && pPlKiller->GetCharacter())
			GameServer()->GetPlayerChar(Killer)->AddSpree();
	
	if (Wrong && pPlKiller->GetCharacter() && CFG(PunishWrongSacr))
	{
		pPlKiller->GetCharacter()->Freeze(CFG(PunishWrongSacr) * TS);
		GS->CreateSound(pPlKiller->GetCharacter()->m_Pos, SOUND_PLAYER_PAIN_LONG);
		GS->SendChatTarget(pPlKiller->GetCID(), "The gods are not pleased with this sacrifice!");
	}

	if (!Wrong && pPlKiller->GetCharacter())
		pPlKiller->GetCharacter()->SetEmote(EMOTE_HAPPY, TICK + TS * 2);

	if (pPlKiller->GetCharacter() && CFG(SacrLoltext) && ((!Wrong && CFG(SacrScore)) || (Wrong && CFG(WrongSacrScore))))
	{
		char aBuf[64];
		str_format(aBuf, sizeof aBuf, "%+d", Wrong?CFG(WrongSacrScore):(ShrineTeam == -1 ? CFG(SacrScore) : CFG(RightSacrScore)));
		GS->CreateLolText(pPlKiller->GetCharacter(), false, vec2(0.f, -50.f), vec2(0.f, 0.f), 50, aBuf);
	}
}
예제 #12
0
void CProjectile::Tick()
{
	float Pt = (Server()->Tick()-m_StartTick-1)/(float)Server()->TickSpeed();
	float Ct = (Server()->Tick()-m_StartTick)/(float)Server()->TickSpeed();
	vec2 PrevPos = GetPos(Pt);
	vec2 CurPos = GetPos(Ct);
	int Collide = GameServer()->Collision()->IntersectLine(PrevPos, CurPos, &CurPos, 0);
	CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
	CCharacter *TargetChr = GameServer()->m_World.IntersectCharacter(PrevPos, CurPos, 6.0f, CurPos, OwnerChar);

	m_LifeSpan--;

	if(TargetChr || Collide || m_LifeSpan < 0 || GameLayerClipped(CurPos))
	{
		if(m_LifeSpan >= 0 || m_Weapon == WEAPON_GRENADE)
			GameServer()->CreateSound(CurPos, m_SoundImpact);

		if(m_Explosive)
		{
			if (m_ExtraInfo == MEGAROCKETS)
			{
				/*GameServer()->CreateExplosion(CurPos+vec2(-32, -32), m_Owner, m_Weapon, false);
				GameServer()->CreateExplosion(CurPos+vec2(+32, -32), m_Owner, m_Weapon, false);
				GameServer()->CreateExplosion(CurPos+vec2(+32, +32), m_Owner, m_Weapon, false);
				GameServer()->CreateExplosion(CurPos+vec2(-32, +32), m_Owner, m_Weapon, false);*/
				
				CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, CurPos, m_Owner, m_Weapon, 1);
				GameServer()->m_World.InsertEntity(S);
			}
			else if (m_ExtraInfo == DOOMROCKETS)
			{
				CSuperexplosion *S = new CSuperexplosion(&GameServer()->m_World, CurPos, m_Owner, m_Weapon, 2);
				GameServer()->m_World.InsertEntity(S);
			}
			else
				GameServer()->CreateExplosion(CurPos, m_Owner, m_Weapon, false);
		}

		else if(TargetChr)
		{
			// apply sleep effect
			if (TargetChr->GetPlayer()->m_pAI && OwnerChar)
			{
				//if (OwnerChar->GetPlayer()->HasWeaponUpgrade(m_Weapon, UPG_SLEEPEFFECT))
				//	TargetChr->GetPlayer()->m_pAI->Zzz(40);
			}
			
			TargetChr->TakeDamage(m_Direction * max(0.001f, m_Force), m_Damage, m_Owner, m_Weapon);
		}
			
		GameServer()->m_World.DestroyEntity(this);
	}
}
예제 #13
0
void CTurret::Tick()
{
	CCharacter *OwnerChar = GameServer()->GetPlayerChar(m_Owner);
	if(OwnerChar && !OwnerChar->IsAlive())

	{
		Reset();
		return;
	}
	if((Server()->Tick() - m_EvalTick) / Server()->TickSpeed() < 10) //let the turret live for 90 seconds
	{
		if((Server()->Tick() - m_LastFire) / Server()->TickSpeed() > 0)
		{
			CCharacter *pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 16.0f, 0);
			if(pChr && pChr->IsAlive() && pChr->GetPlayer()->GetCID() != m_Owner)
			{
				pChr->TakeDamage(vec2(0.f, 0.f), 15, m_Owner, WEAPON_RIFLE);
				GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
				Reset();
			}
			else
			{
				pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 182.0f, 0);
				if(pChr && pChr->IsAlive() && pChr != OwnerChar && ((Server()->Tick() - pChr->GetLastSpawn()) / Server()->TickSpeed() > 1))
				{
					vec2 targetDirection = normalize(pChr->m_Pos - m_Pos);
					new CLaser(GameWorld(), m_Pos, targetDirection, GameServer()->Tuning()->m_LaserReach, m_Owner);
					GameServer()->CreateSound(m_Pos, SOUND_RIFLE_FIRE);
					m_LastFire = Server()->Tick();
				}
			}
		}
	}
	else
	{
		Reset();
		if(OwnerChar && OwnerChar->IsAlive() && OwnerChar->GetPlayer()->m_TurretsCreated > 0)
			OwnerChar->GetPlayer()->m_TurretsCreated --;
	}
}
예제 #14
0
void CBuyHealth::Tick()
{
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
		CCharacter *pUser = GameServer()->GetPlayerChar(i);

		if(!pUser)
			continue;

		int Click = pUser->MouseEvent(m_Pos-vec2(50,50));
		int Click1 = pUser->MouseEvent(m_Pos-vec2(-50,50));

		if(!Click && !Click1)
		{
			//m_LastClick = 0;
			continue;
		}
	
		pUser->Buy("Health", &pUser->GetPlayer()->m_AccData.m_Health, g_Config.m_EuHealth, Click, 500);
		pUser->Buy("Armor", &pUser->GetPlayer()->m_AccData.m_Armor, g_Config.m_EuArmor, Click1, 500);
	}
}
예제 #15
0
void CGameContext::ConUnjail(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
	int UnJailID = pResult->GetVictim();
	char aBuf[200];


	CCharacter* pChr = pSelf->GetPlayerChar(UnJailID);
	if(pChr)
	{
	pChr->GetPlayer()->m_AccData.m_Arrested = 1;
	}
}
예제 #16
0
void CHealthRegen::Snap(int SnappingClient)
{
	if(SnappingClient != m_Owner || NetworkClipped(SnappingClient, m_Pos) || !m_Visible)
		return;

	CNetObj_Pickup *pP[2];

	for(int i = 0; i < 2; i++)
	{
		pP[i] = static_cast<CNetObj_Pickup *>(Server()->SnapNewItem(NETOBJTYPE_PICKUP, m_IDs[i], sizeof(CNetObj_Pickup)));

		if(!pP[i])
			return;

		pP[i]->m_X = (int)m_Pos.x - 32 + 5*i;
		pP[i]->m_Y = (int)m_Pos.y + 5*i;
		pP[i]->m_Type = i;
		pP[i]->m_Subtype = 0;
	
	}

	CNetObj_Laser *pObj[4];
	
	for(int i = 0; i < 4; i++)
	{
		pObj[i] = static_cast<CNetObj_Laser *>(Server()->SnapNewItem(NETOBJTYPE_LASER, m_IDs[i+2], sizeof(CNetObj_Laser)));

		if(!pObj[i])
			return;

		pObj[i]->m_X = (int)m_Pos.x + 16 *((i+1)%2?0:(i==3?1:-1));
		pObj[i]->m_Y = (int)m_Pos.y + 16 * (i%2?0:(!i?-1:1));
		pObj[i]->m_FromX = (int)m_Pos.x;
		pObj[i]->m_FromY = (int)m_Pos.y;
		pObj[i]->m_StartTick = Server()->Tick();

	}

	CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);

	if(pOwner)
	{
		if(pOwner->GetPlayer()->m_AccData.m_AllWeapons)
		{

		}
	}
	
	
}
예제 #17
0
void CTeslacoil::Fire()
{
	m_AttackTick = Server()->Tick();

	vec2 TurretPos = m_Pos+vec2(0, -67*m_FlipY);
	
	bool Sound = false;
	
	for (int i = 0; i < MAX_CLIENTS; i++)
	{
		CPlayer *pPlayer = GameServer()->m_apPlayers[i];
		if(!pPlayer)
			continue;

		if (pPlayer->GetTeam() == m_Team && GameServer()->m_pController->IsTeamplay())
			continue;

		CCharacter *pCharacter = pPlayer->GetCharacter();
		if (!pCharacter)
			continue;
		
		if ((!pCharacter->IsAlive() || pCharacter->GetPlayer()->GetCID() == m_OwnerPlayer) && !GameServer()->m_pController->IsTeamplay())
			continue;
		
		if (GameServer()->m_pController->IsCoop())
		{
			if (!pCharacter->m_IsBot && m_Team >= 0)
				continue;
			
			if (pCharacter->m_IsBot && m_Team < 0)
				continue;
		}
		
		if (pCharacter->Invisible())
			continue;
			
		int Distance = distance(pCharacter->m_Pos, TurretPos);
		if (Distance < 700 && !GameServer()->Collision()->FastIntersectLine(pCharacter->m_Pos, TurretPos))
		{
			new CLightning(GameWorld(), TurretPos, pCharacter->m_Pos);
			pCharacter->TakeDamage(m_OwnerPlayer, GetBuildingWeapon(BUILDING_TESLACOIL), 5, vec2(0, 0), vec2(0, 0));
			//pCharacter->TakeDamage(vec2(0, 0), 5, m_DamageOwner, DEATHTYPE_TESLACOIL, vec2(0, 0), DAMAGETYPE_ELECTRIC, false);
			Sound = true;
		}
	}
	
	if (Sound)
		GameServer()->CreateSound(m_Pos + vec2(0, -50*m_FlipY), SOUND_TESLACOIL_FIRE);
}
예제 #18
0
void CGameWorld::ReleaseHooked(int ClientID)
{
	CCharacter *pChr = (CCharacter *)CGameWorld::FindFirst(CGameWorld::ENTTYPE_CHARACTER);
		for(; pChr; pChr = (CCharacter *)pChr->TypeNext())
		{
			CCharacterCore* Core = pChr->Core();
			if(Core->m_HookedPlayer == ClientID && !pChr->GetPlayer()->Cheats.Super)
			{
				Core->m_HookedPlayer = -1;
				Core->m_HookState = HOOK_RETRACTED;
				Core->m_TriggeredEvents |= COREEVENT_HOOK_RETRACT;
				Core->m_HookState = HOOK_RETRACTED;
			}
		}
}
예제 #19
0
int CLuaFile::EntityGetCharacterId(lua_State *L)
{
    lua_getglobal(L, "pLUA");
    CLuaFile *pSelf = (CLuaFile *)lua_touserdata(L, -1);
    lua_Debug Frame;
    lua_getstack(L, 1, &Frame);
    lua_getinfo(L, "nlSf", &Frame);

    CCharacter *pChr = (CCharacter *)pSelf->m_pServer->m_World.GetEntityByID(lua_tointeger(L, 1));
    if (pChr)
    {
        lua_pushinteger(L, pChr->GetPlayer()->GetCID());
        return 1;
    }
    return 0;
}
예제 #20
0
float IGameController::EvaluateSpawnPos(CSpawnEval *pEval, vec2 Pos)
{
	float Score = 0.0f;
	CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER));
	for(; pC; pC = (CCharacter *)pC->TypeNext())
	{
		// team mates are not as dangerous as enemies
		float Scoremod = 1.0f;
		if(pEval->m_FriendlyTeam != -1 && pC->GetPlayer()->GetTeam() == pEval->m_FriendlyTeam)
			Scoremod = 0.5f;

		float d = distance(Pos, pC->m_Pos);
		Score += Scoremod * (d == 0 ? 1000000000.0f : 1.0f/d);
	}

	return Score;
}
예제 #21
0
void CFastReload::Snap(int SnappingClient)
{
	if(SnappingClient != m_Owner || NetworkClipped(SnappingClient, m_Pos) || !m_Visible)
		return;

	CNetObj_Pickup *pP = static_cast<CNetObj_Pickup *>(Server()->SnapNewItem(NETOBJTYPE_PICKUP, m_ID, sizeof(CNetObj_Pickup)));

	if(!pP)
		return;

	pP->m_X = (int)m_Pos.x - 20;
	pP->m_Y = (int)m_Pos.y;
	pP->m_Type = POWERUP_WEAPON;
	pP->m_Subtype = WEAPON_GUN;
	
	CNetObj_Projectile *pProj[3];

	for(int i = 0; i < 3; i++)
	{
		pProj[i] = static_cast<CNetObj_Projectile *>(Server()->SnapNewItem(NETOBJTYPE_PROJECTILE, m_IDs[i], sizeof(CNetObj_Projectile)));

		if(!pProj[i])
			return;

		pProj[i]->m_X = (int)m_Pos.x + i*15;
		pProj[i]->m_Y = (int)m_Pos.y;
		pProj[i]->m_VelX = (int)10;
		pProj[i]->m_VelY = (int)-2;
		pProj[i]->m_StartTick = Server()->Tick()-2;
		pProj[i]->m_Type = WEAPON_GUN;

	}

	CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);

	if(pOwner)
	{
		if(pOwner->GetPlayer()->m_AccData.m_AllWeapons)
		{

		}
	}
	
	
}
예제 #22
0
bool CLaser::HitCharacter(vec2 From, vec2 To)
{
	vec2 At;
	CCharacter *pOwnerChar = GameServer()->GetPlayerChar(m_Owner);
	CCharacter *pHit = GameServer()->m_World.IntersectCharacter(m_Pos, To, 0.f, At, pOwnerChar);
	if(!pHit)
	{
		//pOwnerChar->GetPlayer()->m_Multiplier=0;
		return false;
	}
	
	m_From = From;
	m_Pos = At;
	m_Energy = -1;

  if (GameServer()->m_pController->m_pGameType == "iLMS")
  {
    m_CanKill = true;
    TryKill(pHit);
  }
  else
  {
	  if(m_Bounces > 0)
	  {
		  pHit->GetPlayer()->m_Wallshot = true;
  		//pOwnerChar->GetPlayer()->RaiseMultiplier();
	  }
	  if (g_Config.m_SvzCatchPlusMode == 2)
		  m_CanKill = checkPosition(pOwnerChar,pHit) && pHit->m_FreezeTicks > 0;
  		
    // 	if(m_Bounces > 0)
  	if(g_Config.m_SvWallshot != 2)
  	{
  		TryKill(pHit);
	  }
	  else
	  {
		  if(m_Bounces > 0)
		  {
			  TryKill(pHit);
  		}
	  }
  }
	return true;
}
예제 #23
0
void CGameContext::ConDonor(IConsole::IResult *pResult, void *pUserData)
{
	CGameContext *pSelf = (CGameContext *) pUserData;
	int Switch = pResult->GetInteger(0);
	int DonorID = pResult->GetVictim();
	char aBuf[200];

	CCharacter* pChr = pSelf->GetPlayerChar(DonorID);
	if (pChr)
	{
		pChr->GetPlayer()->m_AccData.m_Donor = Switch;
		if(Switch)
				str_format(aBuf, sizeof aBuf, "'%s' is a Donor now.", pSelf->Server()->ClientName(DonorID));
		else
					str_format(aBuf, sizeof aBuf, "'%s' is no longer a Donor.", pSelf->Server()->ClientName(DonorID));
		pSelf->SendChat(-1, CHAT_ALL, aBuf);
	}
}
예제 #24
0
bool CLaser::HitBuilding(vec2 From, vec2 To)
{
	vec2 At;
	CCharacter *pOwnerChar = GameServer()->GetPlayerChar(m_Owner);
	if (!pOwnerChar)
		return false;
	
	CBuilding *pHit = GameServer()->m_World.IntersectBuilding(m_Pos, To, 8.0f, At, pOwnerChar->GetPlayer()->GetTeam());
	if(!pHit)
		return false;
	
	m_From = From;
	m_Pos = At;
	m_Energy = -1;

	pHit->TakeDamage(m_Damage, m_Owner, WEAPON_LASER);
	GameServer()->CreateBuildingHit(m_Pos);
	return true;
}
예제 #25
0
void CGameControllerOpenFNG::DoHookers()
{
	for(int i = 0; i < MAX_CLIENTS; i++)
	{
		CCharacter *pChr = CHAR(i);
		if (!pChr)
			continue;
		
		int Hooking = pChr->GetHookedPlayer();

		if (Hooking >= 0)
		{
			CCharacter *pVic = CHAR(Hooking);
			if (!pVic || (pVic->GetPlayer()->GetTeam() != pChr->GetPlayer()->GetTeam() && pChr->GetHookTick() < CFG(HookRegisterDelay)))
				Hooking = -1;
		}

		int HammeredBy = pChr->LastHammeredBy();
		pChr->ClearLastHammeredBy();

		if (Hooking >= 0)
		{
			CCharacter *pVic = CHAR(Hooking);
			if (pVic)
			{
				bool SameTeam = pChr->GetPlayer()->GetTeam() == pVic->GetPlayer()->GetTeam();
				m_aLastInteraction[Hooking] = SameTeam ? -1 : i;
			}
		}

		if (HammeredBy >= 0)
		{	
			CCharacter *pHam = CHAR(HammeredBy);
			if (pHam)
			{
				bool SameTeam = pChr->GetPlayer()->GetTeam() == pHam->GetPlayer()->GetTeam();
				m_aLastInteraction[i] = SameTeam ? -1 : HammeredBy;
				if (!SameTeam && CFG(HammerFreeze) && pChr->GetFreezeTicks() <= 0)
				{
					pChr->Freeze(CFG(HammerFreeze) * TS, HammeredBy);
					m_aFrozenBy[i] = HammeredBy; //suppress kill event being generated
				}
			}
			else
				m_aLastInteraction[i] = -1;
		}
	}
}
예제 #26
0
void CSingularity::Suck()
{
	float Len;
	
	CCharacter *p = (CCharacter *)GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER);
	for(; p; p = (CCharacter *)p->TypeNext())
	{
		if(!p || !p->IsAlive())
			continue;	
		
		Len = distance(m_Pos, p->m_Pos);
		if(Len < m_KillRange)
		{
			if(m_Owner > -1)
				p->Die(m_Owner,WEAPON_RIFLE);
			else
				p->Die(p->GetPlayer()->GetCID(),WEAPON_WORLD);
		}
		else if(Len < m_Range)
			p->SetVel(p->GetVel() + (normalize(m_Pos - p->m_Pos) * exp((m_Range - Len)/(m_Range/2.5f))));
	}

	// save CPU for projectiles
	if(m_SkipTick)
		return;
	
	CProjectile *s = (CProjectile *)GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_PROJECTILE);
	for(; s; s = (CProjectile *)s->TypeNext())
	{
		if(!s)
			continue;
		
		Len = distance(m_Pos, s->m_Pos);
		if(Len < m_Range*1.5)
			s->SetVel(s->GetVel() + ((normalize(m_Pos - s->m_Pos) * exp((m_Range*1.5 - Len)/(m_Range*0.6f)))*0.04f));
	}
}
예제 #27
0
void CWall::Tick()
{
	CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);

	m_Lifespan--;

	if(!pOwner || m_Lifespan<=0)
	{
		Reset();
		return;
	}	

	if(m_Counter >= pOwner->GetPlayer()->m_AccData.m_HammerWalls)
	{
		Reset();
		return;
	}	

	vec2 Intersection;
	CCharacter *pTargetChr = GameServer()->m_World.IntersectCharacter(m_Pos, m_Pos2, 1.0f, Intersection, 0x0);

	if(pTargetChr)
	{
		if(pTargetChr->Protected() || (pTargetChr == pOwner && pTargetChr->ActiveWeapon() == WEAPON_GUN))
		{
			Reset();
			return;
		}

		if(pTargetChr != pOwner && !pTargetChr->Protected() && !pTargetChr->m_God)
		{
			pTargetChr->Die(m_Owner, WEAPON_HAMMER);
			m_Counter++;
		}
	}

}
예제 #28
0
void CHealthRegen::Tick()
{
	CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);

	if(!pOwner)
	{
		Reset();
		return;
	}

	if(!m_Visible)
		return;

	char aBuf[128];
	int Click = pOwner->MouseEvent(m_Pos);

	if(!Click)
	{
		m_LastClick = 0;
		return;
	}
	
	pOwner->Buy("Health regeneration", &pOwner->GetPlayer()->m_AccData.m_HealthRegen, g_Config.m_EuHealthRegen, Click, 25);
}
예제 #29
0
void CFastReload::Tick()
{
	CCharacter *pOwner = GameServer()->GetPlayerChar(m_Owner);

	if(!pOwner)
	{
		Reset();
		return;
	}

	if(!m_Visible)
		return;

	char aBuf[128];
	int Click = pOwner->MouseEvent(m_Pos);

	if(!Click)
	{
		m_LastClick = 0;
		return;
	}
	
	pOwner->Buy("Fast reload", &pOwner->GetPlayer()->m_AccData.m_FastReload, g_Config.m_EuFastReload, Click, 10);
}
예제 #30
0
파일: pickup.cpp 프로젝트: H-M-H/MineTee
void CPickup::Tick()
{
	// MineTee: wait for destroy
	if (m_DestroyTick > 0)
	{
        if (Server()->Tick() > m_DestroyTick)
        {
            GameWorld()->DestroyEntity(this);
            return;
        }
	}

	// wait for respawn
	if(m_SpawnTick > 0)
	{
		if(Server()->Tick() > m_SpawnTick)
		{
			// respawn
			m_SpawnTick = -1;

			if(m_Type == POWERUP_WEAPON)
				GameServer()->CreateSound(m_Pos, SOUND_WEAPON_SPAWN);
		}
		else
			return;
	}

	// MineTee
	CCharacter *pChr = 0x0;
	if (m_Type == POWERUP_DROPITEM)
	{
        CCharacter *pChrAttraction = GameServer()->m_World.ClosestCharacter(m_Pos, 60.0f, 0);
        if (pChrAttraction && Server()->Tick()-m_TimerOwnerTake > Server()->TickSpeed()*2.5f)
        {
        	float d = distance(m_Pos, pChrAttraction->m_Pos);
        	float v = abs((100.0f-d)*5.5f/100.0f);
        	m_Vel += normalize(pChrAttraction->m_Pos - m_Pos) * v;
        }

        GameServer()->Collision()->MoveBox(&m_Pos, &m_Vel, vec2(32.0f, 32.0f), 0.5f);
        m_Vel.y += GameServer()->m_World.m_Core.m_Tuning.m_Gravity;
        m_Vel.x += (m_Vel.x < 0.0f)?0.05f:-0.05f;

        if (Server()->Tick()-m_TimerOwnerTake > Server()->TickSpeed()*2.5f)
            pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
        else if (GameServer()->m_apPlayers[m_Owner] && GameServer()->m_apPlayers[m_Owner]->GetCharacter() && GameServer()->m_apPlayers[m_Owner]->GetCharacter()->IsAlive())
            pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, GameServer()->m_apPlayers[m_Owner]->GetCharacter());
	}
    else if (m_Type == POWERUP_BLOCK)
    {
        CCharacter *pChrAttraction = GameServer()->m_World.ClosestCharacter(m_Pos, 96.0f, 0);
        if (pChrAttraction)
        {
        	float d = distance(m_Pos, pChrAttraction->m_Pos);
        	float v = abs((100.0f-d)*5.5f/100.0f);
        	m_Pos += normalize(pChrAttraction->m_Pos - m_Pos) * v;
        }
        pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
    }
    else
        pChr = GameServer()->m_World.ClosestCharacter(m_Pos, 20.0f, 0);
	//

	// Check if a player intersected us
	if(pChr && pChr->IsAlive())
	{
		// player picked us up, is someone was hooking us, let them go
		int RespawnTime = -1;
		switch (m_Type)
		{
			// MineTee
			case POWERUP_DROPITEM:
				if (m_Subtype >= NUM_WEAPONS-CBlockManager::MAX_BLOCKS)
				{
					if (pChr->GiveBlock(m_Subtype, m_Amount))
					{
						GameServer()->CreateSound(m_Pos, SOUND_PICKUP_BLOCK);
						GameWorld()->DestroyEntity(this);
						return;
					}
				}
				else
				{
					if(pChr->GiveWeapon(m_Subtype, m_Amount))
					{
						RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

						if(m_Subtype == WEAPON_GRENADE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
						else if(m_Subtype == WEAPON_SHOTGUN)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
						else if(m_Subtype == WEAPON_RIFLE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);

						if(pChr->GetPlayer())
							GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
					}
				}
				break;
			case POWERUP_BLOCK:
				if (pChr->GiveBlock(m_Subtype, 1))
				{
					GameServer()->CreateSound(m_Pos, SOUND_PICKUP_BLOCK);
					GameWorld()->DestroyEntity(this);
					return;
				}
				break;
			case POWERUP_FOOD:
				if (m_Subtype == FOOD_COW)
				{
					if (pChr->IncreaseHealth(2) || pChr->IncreaseArmor(1))
					{
						GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
						GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
						GameWorld()->DestroyEntity(this);
						return;
					}
				}
				else if (m_Subtype == FOOD_PIG)
				{
					if (pChr->IncreaseHealth(1))
					{
						GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
						GameWorld()->DestroyEntity(this);
						return;
					}
				}
				break;
			//
			case POWERUP_HEALTH:
				if(pChr->IncreaseHealth(1))
				{
					GameServer()->CreateSound(m_Pos, SOUND_PICKUP_HEALTH);
					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
				}
				break;

			case POWERUP_ARMOR:
				if(pChr->IncreaseArmor(1))
				{
					GameServer()->CreateSound(m_Pos, SOUND_PICKUP_ARMOR);
					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;
				}
				break;

			case POWERUP_WEAPON:
				if(m_Subtype >= 0 && m_Subtype < NUM_WEAPONS)
				{
					if(pChr->GiveWeapon(m_Subtype, 10))
					{
						RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

						if(m_Subtype == WEAPON_GRENADE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_GRENADE);
						else if(m_Subtype == WEAPON_SHOTGUN)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);
						else if(m_Subtype == WEAPON_RIFLE)
							GameServer()->CreateSound(m_Pos, SOUND_PICKUP_SHOTGUN);

						if(pChr->GetPlayer())
							GameServer()->SendWeaponPickup(pChr->GetPlayer()->GetCID(), m_Subtype);
					}
				}
				break;

			case POWERUP_NINJA:
				{
					// activate ninja on target player
					pChr->GiveNinja();
					RespawnTime = g_pData->m_aPickups[m_Type].m_Respawntime;

					// loop through all players, setting their emotes
					CCharacter *pC = static_cast<CCharacter *>(GameServer()->m_World.FindFirst(CGameWorld::ENTTYPE_CHARACTER));
					for(; pC; pC = (CCharacter *)pC->TypeNext())
					{
						if (pC != pChr)
							pC->SetEmote(EMOTE_SURPRISE, Server()->Tick() + Server()->TickSpeed());
					}

					pChr->SetEmote(EMOTE_ANGRY, Server()->Tick() + 1200 * Server()->TickSpeed() / 1000);
					break;
				}

			default:
				break;
		};

		if(RespawnTime >= 0)
		{
			char aBuf[256];
			str_format(aBuf, sizeof(aBuf), "pickup player='%d:%s' item=%d/%d",
				pChr->GetPlayer()->GetCID(), Server()->ClientName(pChr->GetPlayer()->GetCID()), m_Type, m_Subtype);
			GameServer()->Console()->Print(IConsole::OUTPUT_LEVEL_DEBUG, "game", aBuf);
			m_SpawnTick = Server()->Tick() + Server()->TickSpeed() * RespawnTime;
		}
	}
}