using static RebirthManager; //using static RebirthManager; public class BlockSpawnCompanionRebirth : BlockMotionSensor { private int OwnerID = -1; private float _tickRate = 10UL; private int _maxSpawned = 1; private int _numberToSpawn = 1; private int _spawnRadius = 0; private int _spawnArea = 15; private float _spawnScale = 1f; private string _entityGroup = ""; private string _signText = ""; public override void Init() { base.Init(); if (Properties.Values.ContainsKey("TickRate")) Properties.ParseFloat("TickRate", ref _tickRate); if (Properties.Values.ContainsKey("MaxSpawned")) Properties.ParseInt("MaxSpawned", ref _maxSpawned); if (Properties.Values.ContainsKey("NumberToSpawn")) Properties.ParseInt("NumberToSpawn", ref _numberToSpawn); if (Properties.Values.ContainsKey("SpawnRadius")) Properties.ParseInt("SpawnRadius", ref _spawnRadius); if (Properties.Values.ContainsKey("SpawnArea")) Properties.ParseInt("SpawnArea", ref _spawnArea); if (Properties.Values.ContainsKey("EntityGroup")) _entityGroup = Properties.Values["EntityGroup"]; if (Properties.Values.ContainsKey("SpawnScale")) Properties.ParseFloat("SpawnScale", ref _spawnScale); if (Properties.Values.ContainsKey("Config")) _signText = Properties.Values["Config"]; } public override string GetActivationText(WorldBase _world, BlockValue _blockValue, int _clrIdx, Vector3i _blockPos, EntityAlive _entityFocusing) { return ""; } public override bool CanPlaceBlockAt(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue, bool _bOmitCollideCheck = false) { string restrictiveHire = RebirthVariables.customRestrictHires; /*if (restrictiveHire == "nofollowers") { return false; }*/ //Log.Out("========================================================================================"); EntityPlayerLocal primaryPlayer = GameManager.Instance.World.GetPrimaryPlayer(); if (primaryPlayer.Buffs.HasBuff("FuriousRamsayCompanionCooldown")) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 1"); return false; } float flWitchDoctorLevel = RebirthUtilities.GetPerkLevel(primaryPlayer, "furiousramsayattwitchdoctor"); float flBerserkerLevel = RebirthUtilities.GetPerkLevel(primaryPlayer, "furiousramsayattberserker"); float charismaticNature = RebirthUtilities.GetPerkLevel(primaryPlayer, "perkCharismaticNature"); bool isActiveClass9 = RebirthUtilities.IsClassActive(9); bool isActiveClass10 = RebirthUtilities.IsClassActive(10); if (!isActiveClass9 && _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeHorrorPanther_FR") { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 2"); return false; } if (!isActiveClass9 && _blockValue.Block.GetBlockName().Contains("FuriousRamsaySpawnCubeSkeleton")) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3"); return false; } if (!isActiveClass10 && _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeRagePanther_FR") { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 4"); return false; } bool isDog = false; bool isPanther = false; bool isSkeleton = false; bool isZombie = false; //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt GetBlockName(): " + _blockValue.Block.GetBlockName()); if (_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeHorrorPanther_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeRagePanther_FR") { isPanther = true; } if (_blockValue.Block.GetBlockName().Contains("FuriousRamsaySpawnCubeSkeleton")) { isSkeleton = true; } if (_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeZombie007_FR") { isZombie = true; } if (_blockValue.Block.GetBlockName() == "FuriousRamsaySpawnPantherCube001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeShepherdDog001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubePitbullDog001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeLabradorDog001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeHuskyDog001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeGoldenRetrieverDog001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeDobermanDog001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeDalmatianDog001_FR" || _blockValue.Block.GetBlockName() == "FuriousRamsaySpawnCubeBullTerrierDog001_FR" ) { isDog = true; } if (primaryPlayer != null) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 5"); int numDogCompanions = 0; int numWitchDoctorSkeletonCompanions = 0; int numWitchDoctorZombieCompanions = 0; int numWitchDoctorCompanions = 0; int numBerserkerCompanions = 0; foreach (hireInfo hire in playerHires) { if (hire.playerID == primaryPlayer.entityId) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt hire.className: " + hire.className); /*var companion = GameManager.Instance.World.GetEntity(hire.hireID) as EntityAlive; if (companion != null) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt companion.EntityClass.entityClassName: " + companion.EntityClass.entityClassName); if (companion.EntityClass.entityClassName == "FuriousRamsayNPCHorrorPanther") { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD WD COMPANION"); numWitchDoctorCompanions++; } if (companion.EntityClass.entityClassName == "FuriousRamsayNPCRagePanther") { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD BK COMPANION"); numBerserkerCompanions++; } if (companion.EntityClass.entityClassName == "FuriousRamsaySkeleton1NoHireCore" || companion.EntityClass.entityClassName == "FuriousRamsaySkeleton2NoHireCore" || companion.EntityClass.entityClassName == "FuriousRamsaySkeleton3NoHireCore" || companion.EntityClass.entityClassName == "FuriousRamsaySkeleton4NoHireCore" || companion.EntityClass.entityClassName == "FuriousRamsaySkeleton5NoHireCore" ) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD SK COMPANION"); numWitchDoctorSkeletonCompanions++; } if (companion.EntityClass.entityClassName == "FuriousRamsayZombie007a" ) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ZB COMPANION"); numWitchDoctorZombieCompanions++; } if (companion.EntityClass.entityClassName == "FuriousRamsayNPCPanther001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCShepherd001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCPitbull001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCLabrador001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCHusky001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCGoldenRetriever001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCDoberman001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCDalmatian001_FR" || companion.EntityClass.entityClassName == "FuriousRamsayNPCBullTerrier001_FR" ) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ANIMAL COMPANION"); numDogCompanions++; } }*/ if (hire.className == "FuriousRamsayNPCHorrorPanther") { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD WD COMPANION"); numWitchDoctorCompanions++; } if (hire.className == "FuriousRamsayNPCRagePanther") { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD BK COMPANION"); numBerserkerCompanions++; } if (hire.className == "FuriousRamsaySkeleton1NoHireCore" || hire.className == "FuriousRamsaySkeleton2NoHireCore" || hire.className == "FuriousRamsaySkeleton3NoHireCore" || hire.className == "FuriousRamsaySkeleton4NoHireCore" || hire.className == "FuriousRamsaySkeleton5NoHireCore" ) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD SK COMPANION"); numWitchDoctorSkeletonCompanions++; } if (hire.className == "FuriousRamsayZombie007minion" ) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ZB COMPANION"); numWitchDoctorZombieCompanions++; } if (hire.className == "FuriousRamsayNPCPanther001_FR" || hire.className == "FuriousRamsayNPCShepherd001_FR" || hire.className == "FuriousRamsayNPCPitbull001_FR" || hire.className == "FuriousRamsayNPCLabrador001_FR" || hire.className == "FuriousRamsayNPCHusky001_FR" || hire.className == "FuriousRamsayNPCGoldenRetriever001_FR" || hire.className == "FuriousRamsayNPCDoberman001_FR" || hire.className == "FuriousRamsayNPCDalmatian001_FR" || hire.className == "FuriousRamsayNPCBullTerrier001_FR" ) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt ADD ANIMAL COMPANION"); numDogCompanions++; } } } //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numWitchDoctorCompanions: " + numWitchDoctorCompanions); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numBerserkerCompanions: " + numBerserkerCompanions); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numWitchDoctorSkeletonCompanions: " + numWitchDoctorSkeletonCompanions); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numWitchDoctorZombieCompanions: " + numWitchDoctorZombieCompanions); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt numDogCompanions: " + numDogCompanions); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isDog: " + isDog); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isPanther: " + isPanther); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isSkeleton: " + isSkeleton); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt isZombie: " + isZombie); int numTotalCompanions = numDogCompanions + numWitchDoctorZombieCompanions + numWitchDoctorSkeletonCompanions + numBerserkerCompanions + numWitchDoctorCompanions; if (numTotalCompanions >= charismaticNature + 1) { //if (restrictiveHire != "none" || (RebirthVariables.customScenario == "purge" && RebirthVariables.customRestrictCompanionHires != "none")) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt Already at max number of companions, restrictiveHire: " + restrictiveHire); return false; } } if (!isActiveClass9 && !isActiveClass10 && isPanther) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt Panther with no WitchDoctor or Berserker"); return false; } if (!isActiveClass9 && (isSkeleton || isZombie)) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt Skeleton or Zombie with no WitchDoctor"); return false; } if (numDogCompanions >= 3) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 1"); //if (restrictiveHire != "none" || (RebirthVariables.customScenario == "purge" && RebirthVariables.customRestrictCompanionHires != "none")) { return false; } } if (isActiveClass9) { if (flWitchDoctorLevel < 5 && (numDogCompanions > 1) && (numWitchDoctorSkeletonCompanions + numWitchDoctorZombieCompanions + numWitchDoctorCompanions) == 1 && isPanther) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 2"); return false; } if (flWitchDoctorLevel < 6 && (numDogCompanions > 1) && (numWitchDoctorSkeletonCompanions + numWitchDoctorZombieCompanions + numWitchDoctorCompanions) == 1 && isSkeleton) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3a"); return false; } if (flWitchDoctorLevel < 4 && isZombie) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3b"); return false; } if (flWitchDoctorLevel < 5 && numWitchDoctorCompanions == 1 && isPanther) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3c"); return false; } if (flWitchDoctorLevel < 6 && numWitchDoctorSkeletonCompanions == 1 && isSkeleton) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3d"); return false; } if (flWitchDoctorLevel < 7 && numWitchDoctorZombieCompanions == 1 && isZombie) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3e"); return false; } if (flWitchDoctorLevel < 7 && (numDogCompanions > 1) && (numWitchDoctorSkeletonCompanions + numWitchDoctorZombieCompanions + numWitchDoctorCompanions) == 1 && isZombie) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 3f"); return false; } if (flWitchDoctorLevel < 5 && ((numWitchDoctorCompanions + numWitchDoctorZombieCompanions + numWitchDoctorSkeletonCompanions) >= 1) && !isDog) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 4"); return false; } if (numDogCompanions + numWitchDoctorCompanions > 2) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 5"); return false; } if (numWitchDoctorCompanions + numWitchDoctorSkeletonCompanions >= 2) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 6a"); return false; } if (numWitchDoctorCompanions + numWitchDoctorZombieCompanions >= 2) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 6b"); return false; } if (numWitchDoctorCompanions >= 2) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7"); return false; } if ((numWitchDoctorZombieCompanions + numWitchDoctorSkeletonCompanions + numWitchDoctorCompanions + numDogCompanions) == 2 && (numDogCompanions < 2)) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7a"); return false; } if (numDogCompanions >= 2 && (isZombie || isSkeleton || isPanther)) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7n"); return false; } } if (isActiveClass10) { if (flBerserkerLevel < 5 && numBerserkerCompanions == 1 && isPanther) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 8"); return false; } if (numDogCompanions + numBerserkerCompanions > 2) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 9"); return false; } if (numBerserkerCompanions >= 2) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 10"); return false; } if (numDogCompanions >= 2 && isPanther) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 7n"); return false; } } } if (_blockPos.y > 253) { //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt 6"); return false; } Block block = _blockValue.Block; //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt !block.isMultiBlock: " + !block.isMultiBlock); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt _blockPos.y + block.multiBlockPos.dim.y < 254: " + (_blockPos.y + block.multiBlockPos.dim.y < 254)); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt _bOmitCollideCheck: " + _bOmitCollideCheck); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt !overlapsWithOtherBlock: " + !this.overlapsWithOtherBlock(_world, _clrIdx, _blockPos, _blockValue)); bool result = (!block.isMultiBlock || _blockPos.y + block.multiBlockPos.dim.y < 254) && (GameManager.Instance.IsEditMode() || _bOmitCollideCheck || !this.overlapsWithOtherBlock(_world, _clrIdx, _blockPos, _blockValue)); //Log.Out("BlockSpawnCompanionRebirth-CanPlaceBlockAt result: " + result); return result; } private bool overlapsWithOtherBlock(WorldBase _world, int _clrIdx, Vector3i _blockPos, BlockValue _blockValue) { if (!this.isMultiBlock) { int type = _world.GetBlock(_clrIdx, _blockPos).type; return type != 0 && !Block.list[type].blockMaterial.IsGroundCover && !_world.IsWater(_blockPos); } byte rotation = _blockValue.rotation; for (int i = this.multiBlockPos.Length - 1; i >= 0; i--) { Vector3i pos = _blockPos + this.multiBlockPos.Get(i, _blockValue.type, (int)rotation); int type2 = _world.GetBlock(_clrIdx, pos).type; if (type2 != 0 && !Block.list[type2].blockMaterial.IsGroundCover && !_world.IsWater(pos)) { return true; } } return false; } public override void PlaceBlock(WorldBase _world, BlockPlacement.Result _result, EntityAlive _ea) { //Log.Out("BlockSpawnCompanionRebirth-PlaceBlock START"); base.PlaceBlock(_world, _result, _ea); int entityID = _ea.entityId; string strEntity = RebirthUtilities.GetValueFromKey(_signText, "ec"); ; int numEntities = 1; string strDistance = ""; string entityPos = (_result.blockPos.ToVector3() + new Vector3(0.5f, 0.25f, 0.5f)).ToString(); string entityRot = ""; string strSpawner = "static"; string strHeight = ""; string strDirection = ""; float numStartScale = _spawnScale; int numRotation = -1; bool randomRotation = true; bool atPlayerLevel = false; bool attackPlayer = false; int entityPlayerID = _ea.entityId; int minion = 1; string strSound = ""; int maxEntities = 20; int checkMaxEntities = 0; int minMax = 40; int repeat = 1; int allNames = 1; int isBoss = -1; int handParticle = -1; string lootListName = ""; string lootDropClass = ""; int lootDropChance = 1; string navIcon = ""; string buffList = ""; bool forceRespawn = false; //Log.Out("BlockSpawnCompanionRebirth-PlaceBlock numStartScale: " + numStartScale); var rotation = new Vector3(0f, (float)(90f * (_result.blockValue.rotation & 3)), 0f); entityRot = rotation.ToString(); EntityNPCRebirth entity = (EntityNPCRebirth)RebirthUtilities.SpawnEntity(entityID, strEntity, numEntities, entityPos, entityRot, strDistance, strSpawner, strHeight, strDirection, numStartScale, numRotation, randomRotation, atPlayerLevel, attackPlayer, entityPlayerID, minion, strSound, maxEntities, checkMaxEntities, minMax, repeat, allNames, isBoss, handParticle, lootListName, lootDropClass, lootDropChance, navIcon, buffList, false, forceRespawn); DamageBlock(GameManager.Instance.World, 0, _result.blockPos, _result.blockValue, Block.list[_result.blockValue.type].MaxDamage, -1, null, false, false); } }