378 lines
12 KiB
C#
378 lines
12 KiB
C#
using System.Collections.Generic;
|
|
using System.Xml.Linq;
|
|
//using static RebirthManager;
|
|
|
|
public class MinEventActionRandomEntitySpawn : MinEventActionTargetedBase
|
|
{
|
|
public override void Execute(MinEventParams _params)
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute START");
|
|
EntityAlive entity = _params.Self as EntityAlive;
|
|
if (entity == null)
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute 1");
|
|
return;
|
|
}
|
|
|
|
if (RebirthUtilities.IsHordeNight())
|
|
{
|
|
return;
|
|
}
|
|
|
|
int targetEntityID = -1;
|
|
EntityAlive targetEntity = entity.GetAttackTarget();
|
|
EntityPlayer closestPlayer = null;
|
|
|
|
if (targetEntity != null)
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute targetEntity: " + targetEntity.EntityName);
|
|
|
|
float distance = Vector3.Distance(entity.position, targetEntity.position);
|
|
|
|
if (distance > playerDistance)
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute TOO FAR FROM THE PLAYER");
|
|
return;
|
|
}
|
|
|
|
targetEntityID = targetEntity.entityId;
|
|
|
|
if (targetEntity is EntityPlayer)
|
|
{
|
|
closestPlayer = targetEntity as EntityPlayer;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
closestPlayer = entity.world.GetClosestPlayer(entity.position, 120f, false);
|
|
|
|
if (closestPlayer != null)
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute closestPlayer: " + closestPlayer.EntityName);
|
|
targetEntityID = closestPlayer.entityId;
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
string newEntityName = entityName;
|
|
|
|
if (newEntityName == "")
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute RANDOM ENTITY");
|
|
if (closestPlayer != null)
|
|
{
|
|
List<int> entities = RebirthUtilities.BuildEntityGroup(closestPlayer.gameStage);
|
|
|
|
int randomValue = GameManager.Instance.World.GetGameRandom().RandomRange(0, entities.Count - 1);
|
|
|
|
newEntityName = EntityClass.GetEntityClassName(entities[randomValue]);
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute RANDOM newEntityName: " + newEntityName);
|
|
}
|
|
else
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute BEFORE newEntityName: " + newEntityName);
|
|
if (hasFeralRadiated == 1)
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute hasFeralRadiated: " + hasFeralRadiated);
|
|
if (closestPlayer != null)
|
|
{
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute closestPlayer.gameStage: " + closestPlayer.gameStage);
|
|
if (closestPlayer.gameStage >= 380)
|
|
{
|
|
newEntityName = newEntityName + "Tainted";
|
|
}
|
|
else if (closestPlayer.gameStage >= 260)
|
|
{
|
|
newEntityName = newEntityName + "Radiated";
|
|
}
|
|
else if (closestPlayer.gameStage >= 140)
|
|
{
|
|
newEntityName = newEntityName + "Feral";
|
|
}
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute AFTER entityName: " + entityName);
|
|
}
|
|
}
|
|
}
|
|
|
|
if (maxTotalEntities > 0 || maxEntities > 0)
|
|
{
|
|
List<Entity> entitiesInBounds = GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityZombieSDX), BoundsUtils.BoundsForMinMax(entity.position.x - this.minMax, entity.position.y - this.minMaxY, entity.position.z - this.minMax, entity.position.x + this.minMax, entity.position.y + this.minMaxY, entity.position.z + this.minMax), new List<Entity>());
|
|
List<Entity> entitiesInBounds2 = GameManager.Instance.World.GetEntitiesInBounds(typeof(EntityZombieCopRebirth), BoundsUtils.BoundsForMinMax(entity.position.x - this.minMax, entity.position.y - this.minMaxY, entity.position.z - this.minMax, entity.position.x + this.minMax, entity.position.y + this.minMaxY, entity.position.z + this.minMax), new List<Entity>());
|
|
|
|
int numTotalEntities = 0;
|
|
int numEntities = 0;
|
|
|
|
List<Entity> entities = new List<Entity>();
|
|
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute entitiesInBounds.Count: " + entitiesInBounds.Count);
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute entitiesInBounds2.Count: " + entitiesInBounds2.Count);
|
|
|
|
foreach (Entity validateEntity in entitiesInBounds)
|
|
{
|
|
if (validateEntity != null && !validateEntity.IsDead())
|
|
{
|
|
entities.Add(validateEntity);
|
|
}
|
|
}
|
|
foreach (Entity validateEntity in entitiesInBounds2)
|
|
{
|
|
if (validateEntity != null && !validateEntity.IsDead() && !entities.Contains(validateEntity))
|
|
{
|
|
entities.Add(validateEntity);
|
|
}
|
|
}
|
|
foreach (Entity validateEntity in entities)
|
|
{
|
|
if (validateEntity.EntityClass.entityClassName.ToLower().Contains(entityName.ToLower()))
|
|
{
|
|
numEntities++;
|
|
}
|
|
numTotalEntities++;
|
|
}
|
|
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute maxEntities: " + maxEntities);
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute numEntities: " + numEntities);
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute maxTotalEntities: " + maxTotalEntities);
|
|
//Log.Out("MinEventActionRandomEntitySpawn-Execute numTotalEntities: " + numTotalEntities);
|
|
|
|
if (numEntities >= this.maxEntities ||
|
|
numTotalEntities >= this.maxTotalEntities)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
|
|
bool shouldAttackPlayer = false;
|
|
|
|
if (attackPlayer == 1)
|
|
{
|
|
shouldAttackPlayer = true;
|
|
}
|
|
|
|
bool spawnAtPlayerLevel = false;
|
|
|
|
if (atPlayerLevel == 1)
|
|
{
|
|
spawnAtPlayerLevel = true;
|
|
}
|
|
|
|
bool spawnAtRandomRotation = true;
|
|
|
|
if (randomRotation == 0)
|
|
{
|
|
spawnAtRandomRotation = false;
|
|
}
|
|
|
|
RebirthUtilities.SpawnEntity(entity.entityId, newEntityName, numEntities, entityPos, entityRot, strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, spawnAtRandomRotation, spawnAtPlayerLevel, shouldAttackPlayer, targetEntityID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList, false, forceSpawn);
|
|
}
|
|
public override bool ParseXmlAttribute(XAttribute _attribute)
|
|
{
|
|
var flag = base.ParseXmlAttribute(_attribute);
|
|
if (flag) return true;
|
|
var name = _attribute.Name;
|
|
|
|
if (name == null)
|
|
{
|
|
return flag;
|
|
}
|
|
else if (name == "maxEntities")
|
|
{
|
|
maxEntities = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "maxTotalEntities")
|
|
{
|
|
maxTotalEntities = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "entityName")
|
|
{
|
|
entityName = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "hasFeralRadiated")
|
|
{
|
|
hasFeralRadiated = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "playerDistance")
|
|
{
|
|
playerDistance = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "numEntities")
|
|
{
|
|
numEntities = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "StartScale")
|
|
{
|
|
float.TryParse(_attribute.Value, out numStartScale);
|
|
return true;
|
|
}
|
|
else if (name == "distance")
|
|
{
|
|
strDistance = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "height")
|
|
{
|
|
strHeight = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "spawner")
|
|
{
|
|
strSpawner = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "direction")
|
|
{
|
|
strDirection = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "sound")
|
|
{
|
|
strSound = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "minion")
|
|
{
|
|
minion = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "checkMaxEntities")
|
|
{
|
|
checkMaxEntities = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "minMax")
|
|
{
|
|
minMax = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "maxEntities")
|
|
{
|
|
maxEntities = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "attackPlayer")
|
|
{
|
|
attackPlayer = Int32.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "repeat")
|
|
{
|
|
repeat = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "allNames")
|
|
{
|
|
allNames = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "atplayerlevel")
|
|
{
|
|
atPlayerLevel = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "rotation")
|
|
{
|
|
numRotation = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "randomRotation")
|
|
{
|
|
randomRotation = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "isBoss")
|
|
{
|
|
isBoss = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "handParticle")
|
|
{
|
|
handParticle = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "lootListName")
|
|
{
|
|
lootListName = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "lootDropClass")
|
|
{
|
|
lootDropClass = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "lootDropChance")
|
|
{
|
|
lootDropChance = int.Parse(_attribute.Value);
|
|
return true;
|
|
}
|
|
else if (name == "navIcon")
|
|
{
|
|
navIcon = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "buffList")
|
|
{
|
|
buffList = _attribute.Value;
|
|
return true;
|
|
}
|
|
else if (name == "forceSpawn")
|
|
{
|
|
if (_attribute.Value == "true")
|
|
{
|
|
forceSpawn = true;
|
|
}
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
protected int playerDistance = 20;
|
|
protected int minMax = 80;
|
|
protected int minMaxY = 40;
|
|
protected int maxEntities = 6;
|
|
protected int maxTotalEntities = 20;
|
|
protected int hasFeralRadiated = 0;
|
|
protected string entityName = "";
|
|
private string strEntity = "";
|
|
private string entityPos = "";
|
|
private string entityRot = "";
|
|
private string strDistance = "";
|
|
private string strHeight = "";
|
|
private string strSpawner = "";
|
|
private string strDirection = "random";
|
|
private string strSound = "";
|
|
private float numStartScale = 0;
|
|
private int minion = 0;
|
|
private int numEntities = 1;
|
|
private int attackPlayer = 0;
|
|
private int checkMaxEntities = 0;
|
|
public int repeat = 1;
|
|
public int allNames = 1;
|
|
public int atPlayerLevel = 0;
|
|
public int randomRotation = 1;
|
|
public int numRotation = -1;
|
|
public int isBoss = -1;
|
|
public int handParticle = -1;
|
|
public string lootListName = "";
|
|
public string lootDropClass = "";
|
|
public int lootDropChance = 1;
|
|
public string navIcon = "";
|
|
public string buffList = "";
|
|
public bool forceSpawn = false;
|
|
} |