Example #1
0
 @Override
 public boolean equals(Object o) {
   if (this == o) {
     return true;
   }
   if (!(o instanceof MimeType)) {
     return false;
   }
   final MimeType type = (MimeType) o;
   return MiscUtil.equals(Name, type.Name) && MiscUtil.mapsEquals(myParameters, type.myParameters);
 }
Example #2
0
/**
 * Cause a general explosion in the world
 */
public static void explode(GameObject inflictor, GameObject attacker, NativeEntity ent, int damage, float radius)
	{
	int        effect;
	Point3f explodeOrigin = ent.getOrigin();	
	if ((Engine.getPointContents(explodeOrigin) & Engine.MASK_WATER) == 0)
		{
		if (ent.getGroundEntity() != null)
			effect = Engine.TE_GRENADE_EXPLOSION;
		else
			effect = Engine.TE_ROCKET_EXPLOSION;
		}
	else
		{
		if (ent.getGroundEntity() != null)
			effect = Engine.TE_GRENADE_EXPLOSION_WATER;
		else
			effect = Engine.TE_ROCKET_EXPLOSION_WATER;
		}

	MiscUtil.radiusDamage(inflictor, attacker, damage, ent, radius, "g_splash");

	Engine.writeByte(Engine.SVC_TEMP_ENTITY);
	Engine.writeByte(effect);
	Engine.writePosition(explodeOrigin);
	Engine.multicast(explodeOrigin, Engine.MULTICAST_PHS);
	}
Example #3
0
/**
 * Select the spawnpoint farthest from other players.
 * @return q2jgame.GameEntity
 */
public static GenericSpawnpoint getSpawnpointFarthest() 
	{
	GenericSpawnpoint result = null;
	float bestDistance = 0;
	
	Vector list = Game.getLevelRegistryList(q2java.baseq2.spawn.info_player_deathmatch.REGISTRY_KEY);
	Enumeration enum = list.elements();
	while (enum.hasMoreElements())
		{
		GenericSpawnpoint spawnPoint = (GenericSpawnpoint) enum.nextElement();
		float range = MiscUtil.nearestPlayerDistance(spawnPoint);

		if (range > bestDistance)
			{
			bestDistance = range;
			result = spawnPoint;
			}
		}

	return result;
	}
Example #4
0
/**
 * Select a random spawnpoint, but exclude the two points closest
 * to other players.
 * @return q2jgame.GameEntity
 */
public static GenericSpawnpoint getSpawnpointRandom() 
	{
	GenericSpawnpoint spawnPoint = null;
	GenericSpawnpoint spot1 = null;
	GenericSpawnpoint spot2 = null;
	float range1 = Float.MAX_VALUE;
	float range2 = Float.MAX_VALUE;
	int count = 0;
	
	// find the two deathmatch spawnpoints that are closest to any players
	Vector list = Game.getLevelRegistryList(q2java.baseq2.spawn.info_player_deathmatch.REGISTRY_KEY);

	// if no deathmatch spawnpoint, try single-player ones
	if (list.size() < 1)
		list = Game.getLevelRegistryList(q2java.baseq2.spawn.info_player_start.REGISTRY_KEY);
		
	Enumeration enum = list.elements();
	while (enum.hasMoreElements())
		{
		count++;
		spawnPoint = (GenericSpawnpoint) enum.nextElement();
		float range = MiscUtil.nearestPlayerDistance(spawnPoint);

		if (range < range1)
			{
			range1 = range;
			spot1 = spawnPoint;
			}		
		else
			{
			if (range < range2)
				{
				range2 = range;
				spot2 = spawnPoint;
				}
			}			
			
		}

	if (count == 0)
		return null;
		
	if (count <= 2)
		spot1 = spot2 = null;
	else
		count -= 2;			

	int selection = (GameUtil.randomInt() & 0x0fff) % count;
	spawnPoint = null;

	enum = list.elements();
	while (enum.hasMoreElements())
		{
		spawnPoint = (GenericSpawnpoint) enum.nextElement();
		
		// skip the undesirable spots
		if ((spawnPoint == spot1) || (spawnPoint == spot2))
			continue;
			
		if ((selection--) == 0)					
			break;
		}

	return spawnPoint;
	}
Example #5
0
 @Override
 public int hashCode() {
   return MiscUtil.hashCode(Name);
 }
Example #6
0
 public boolean weakEquals(MimeType type) {
   return MiscUtil.equals(Name, type.Name);
 }