Exemplo n.º 1
0
	public void addCapture( CTFPlayer capturer )
	{
		fCaptures++;

		// add bonusses to team-members and update hud
		CTFPlayer[] players = getPlayers();
		for ( int i=0; i<players.length; i++ )
		{
			players[i].setScore( players[i].getScore() + CTFPlayer.CTF_TEAM_BONUS );
		}

		// Add extra to carrier
		capturer.setScore( capturer.getScore() + CTFPlayer.CTF_CAPTURE_BONUS - CTFPlayer.CTF_TEAM_BONUS );

		//inform all players (also spectators) that our captures increased
		int index = ( this == Team.TEAM1 ? STAT_CTF_TEAM1_CAPS : STAT_CTF_TEAM2_CAPS );

		Enumeration enum = NativeEntity.enumeratePlayerEntities();
		while ( enum.hasMoreElements() )
		{
			NativeEntity p = (NativeEntity)enum.nextElement();
			//p.setPlayerStat( fStatCapsIndex, (short)fCaptures );
			p.setPlayerStat( index, (short)fCaptures );
		}

	}
Exemplo n.º 2
0
	/**
	 * Filter a team member's damage.
	 * @param DamageObject - damage to be filtered.
	 */
	public void damageOccured(DamageEvent damage)
	{
		// check for self-inflicted damage
		if (damage.getVictim() == damage.getAttacker())
			return; // they deserve what they get..no help from us
			
		// check if the attacker also belongs to this team
		if (isTeamMember(damage.getAttacker()))
		{
			damage.fAmount = 0;
			return;  // give the guy a break
		}
		
		if ((damage.getAttacker() instanceof Player) && ((Player)damage.getVictim()).isCarrying("flag"))
		{
			// A CTF Player other than ourselves attacked us and we have the flag			
			// mark the attacker that he was aggressive to the flag-carrier.
			CTFPlayer p = (CTFPlayer)(damage.getAttacker());
			p.fLastCarrierHurt = Game.getGameTime();
		}		
	}