예제 #1
0
        public static bool Prefix(EntityAlive __instance, ref DamageSource _damageSource, ref int _strength, bool _criticalHit, float _impulseScale)
        {
            // Apply a damage boost if there is a head shot.
            if (__instance is EntityZombie)
            {
                // No head shots for snakes.
                if (__instance is EntityAnimalSnake)
                {
                    return(true);
                }

                if (_strength > 999)
                {
                    AdvLogging.DisplayLog(AdvFeatureClass, " Massive Damage Detected. Falling back to base");
                    return(true);
                }
                if (Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
                {
                    // If its not a player, deal with default
                    EntityPlayerLocal entityAlive = GameManager.Instance.World.GetEntity(_damageSource.getEntityId()) as EntityPlayerLocal;
                    if (entityAlive == null)
                    {
                        return(true);
                    }

                    EnumBodyPartHit bodyPart = _damageSource.GetEntityDamageBodyPart(__instance);
                    if (bodyPart == EnumBodyPartHit.Head)
                    {
                        AdvLogging.DisplayLog(AdvFeatureClass, " Headshot Mode Active: Headshot! ");
                        // Apply a damage multiplier for the head shot, and bump the dismember bonus for the head shot
                        // This will allow the heads to go explode off, which according to legend, if the only want to truly kill a zombie.
                        _damageSource.DamageMultiplier = 1f;
                        // _strength = 1;
                        _damageSource.DismemberChance = 0.8f;
                    }
                    // Reducing the damage to the torso will prevent the entity from being killed by torso shots, while also maintaining de-limbing.
                    else
                    {
                        AdvLogging.DisplayLog(AdvFeatureClass, " Headshot Mode Active: Non-Headshot");
                        _damageSource.DamageMultiplier = 0.1f;
                        _strength = 1;
                    }
                }
            }
            return(true);
        }
예제 #2
0
    public static int ChangeHandholdItem(int EntityID, Need myCurrentNeed, int Preferred = -1)
    {
        int         index    = 0;
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity == null)
        {
            return(index);
        }


        //  Debug.Log("My Current Need: " + myCurrentNeed.ToString() + " Preferred Item Slot: " + Preferred);
        if (Preferred == -1)
        {
            switch (myCurrentNeed)
            {
            // Ranged
            case Need.Ranged:
                index = FindItemWithAction(EntityID, typeof(ItemActionRanged));
                break;

            // Ranged
            case Need.Melee:
                index = FindItemWithAction(EntityID, typeof(ItemActionMelee));
                break;
            }
        }
        else
        {
            index = Preferred;
        }

        // If there's no change, don't do anything.
        if (myEntity.inventory.holdingItemIdx == index)
        {
            return(index);
        }

        myEntity.inventory.SetHoldingItemIdxNoHolsterTime(index);

        // Forcing the show items
        myEntity.inventory.ShowHeldItem(false, 0f);
        myEntity.inventory.ShowHeldItem(true);

        return(index);
    }
예제 #3
0
        public static EntityAlive GetPlayerAlive(string _playerId)
        {
            PersistentPlayerData _persistentPlayerData = GetPersistentPlayerDataFromSteamId(_playerId);

            if (_persistentPlayerData != null)
            {
                if (GameManager.Instance.World.Players.dict.ContainsKey(_persistentPlayerData.EntityId))
                {
                    EntityAlive _entityAlive = (EntityAlive)GetEntity(_persistentPlayerData.EntityId);
                    if (_entityAlive != null)
                    {
                        return(_entityAlive);
                    }
                }
            }
            return(null);
        }
    public static Entity GetAttackOrReventTarget(int EntityID)
    {
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity)
        {
            if (myEntity.GetAttackTarget() != null)
            {
                return(myEntity.GetAttackTarget());
            }
            if (myEntity.GetRevengeTarget() == null)
            {
                return(myEntity.GetRevengeTarget());
            }
        }
        return(null);
    }
    public override void Init(EntityAlive _theEntity)
    {
        base.Init(_theEntity);
        MutexBits    = 3;
        executeDelay = 10f;

        // There is too many values that we need to read in from the entity, so we'll read them directly from the entityclass
        EntityClass entityClass = EntityClass.list[_theEntity.entityClass];



        lstHomeBlocks = ConfigureEntityClass("HomeBlocks", entityClass);

        lstSanitation      = ConfigureEntityClass("ToiletBlocks", entityClass);
        lstSanitationBuffs = ConfigureEntityClass("SanitationBuffs", entityClass);

        if (entityClass.Properties.Values.ContainsKey("SanitationBlock"))
        {
            strSanitationBlock = entityClass.Properties.Values["SanitationBlock"];
        }

        lstBeds            = ConfigureEntityClass("Beds", entityClass);
        lstProductionBuffs = ConfigureEntityClass("ProductionFinishedBuff", entityClass);


        if (entityClass.Properties.Classes.ContainsKey("ProductionItems"))
        {
            DynamicProperties dynamicProperties3 = entityClass.Properties.Classes["ProductionItems"];
            foreach (KeyValuePair <string, object> keyValuePair in dynamicProperties3.Values.Dict.Dict)
            {
                ProductionItem item = new ProductionItem();
                item.item  = ItemClass.GetItem(keyValuePair.Key, false);
                item.Count = int.Parse(dynamicProperties3.Values[keyValuePair.Key]);


                String strCvar = "Nothing";
                if (dynamicProperties3.Params1.TryGetValue(keyValuePair.Key, out strCvar))
                {
                    item.cvar = strCvar;
                }

                lstProductionItem.Add(item);
                DisplayLog("Adding Production Item: " + keyValuePair.Key + " with a count of: " + item.Count + " and will reset: " + strCvar);
            }
        }
    }
예제 #6
0
        private IEnumerator EffectExisting(EntityPlayer player, List <Entity> existing)
        {
            Printer.Log(91, "GhostDyn EffectExisting", existing.Count);
            for (int k = 0; k < existing.Count; k++)
            {
                yield return(Repeater.Yield);

                _existingIndex = (_existingIndex + 1) % existing.Count;
                EntityAlive ghost = existing[_existingIndex] as EntityAlive;
                if (ghost == null)
                {
                    continue;
                }
                Printer.Log(91, "GhostDyn EffectExisting Rebuff", ghost);
                ghost.Buffs.AddBuff("buffZBRespiteKeep"); // keep alive - so igniting buff should be infinite
            }
        }
예제 #7
0
    public static bool HasTask(int EntityID, String strTask)
    {
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAlive;

        if (myEntity != null)
        {
            foreach (var task in myEntity.aiManager.GetTasks <EAIBase>())
            {
                if (task.GetTypeName().Contains(strTask))
                {
                    return(true);
                }
            }
        }

        return(false);
    }
예제 #8
0
        static bool Prefix(EAIManager __instance, EntityAlive ___entity)
        {
            IEnumerator DelayThenRun(EntityAlive entity)
            {
                yield return(entityWait); //saves allocation/gc

                if (entity != null && entity.IsSleeper && entity.IsAlive())
                {
                    //Log.Warning("Spawning scout...");
                    GameManager.Instance.World.aiDirector.GetComponent <AIDirectorChunkEventComponent>() //could cache this
                    .SpawnScouts(entity.position);
                }
            }

            GameManager.Instance.StartCoroutine(DelayThenRun(___entity));
            return(true);
        }
예제 #9
0
        static bool Prefix(EntityAlive __instance)
        {
            // Check if this feature is enabled.
            if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
            {
                return(true);
            }

            // If a door is found, try to open it. If it returns false, start attacking it.
            EntityAliveSDX myEntity = __instance as EntityAliveSDX;

            if (myEntity)
            {
                myEntity.RestoreSpeed();
            }
            return(true);
        }
예제 #10
0
        public static bool Prefix(EntityAlive __instance)
        {
            if (SphereII_InertEntity.IsInert(__instance))
            {
                if ((__instance.WorldTimeBorn + 15) > __instance.world.worldTime)
                {
                    __instance.emodel.avatarController.GetAnimator().enabled = true;
                    return(true);
                }

                __instance.emodel.avatarController.GetAnimator().enabled = false;
                return(false);
            }


            return(true);
        }
 public static void SetupStartingItems(EntityAlive __instance, List <ItemStack> ___itemsOnEnterGame)
 {
     for (int i = 0; i < ___itemsOnEnterGame.Count; i++)
     {
         ItemStack itemStack = ___itemsOnEnterGame[i];
         ItemClass forId     = ItemClass.GetForId(itemStack.itemValue.type);
         if (forId.HasQuality)
         {
             itemStack.itemValue = new ItemValue(itemStack.itemValue.type, 1, 6, false, null, 1f);
         }
         else
         {
             itemStack.count = forId.Stacknumber.Value;
         }
         __instance.inventory.SetItem(i, itemStack);
     }
 }
예제 #12
0
    public virtual bool ConfigureTargetEntity()
    {
        if (this.entityTarget != null)
        {
            return(true);
        }

        this.NearbyEntities.Clear();

        if (this.entityAliveSDX == null)
        {
            if (this.theEntity is EntityAliveSDX)
            {
                this.entityAliveSDX = (this.theEntity as EntityAliveSDX);
            }
            else
            {
                DisplayLog(" Not an EntityAliveSDX");
                return(false);
            }
        }

        DisplayLog(" ConfigureTargetEntity()");
        // Search in the bounds are to try to find the most appealing entity to follow.
        Bounds bb = new Bounds(this.theEntity.position, new Vector3(30f, 20f, 30f));

        this.theEntity.world.GetEntitiesInBounds(typeof(EntityAlive), bb, this.NearbyEntities);
        for (int i = this.NearbyEntities.Count - 1; i >= 0; i--)
        {
            EntityAlive x = (EntityAlive)this.NearbyEntities[i];
            if (x != this.theEntity)
            {
                // Check the entity against the incentives
                if (entityAliveSDX.CheckIncentive(this.lstIncentives, x))
                {
                    DisplayLog(" Found my Target: " + x.EntityName);
                    this.entityTarget = x;
                    return(true);
                }
            }
        }

        this.entityTarget = null;
        return(false);
    }
    public override void Execute(MinEventParams _params)
    {
        if (!SingletonMonoBehaviour <ConnectionManager> .Instance.IsServer)
        {
            return;
        }

        for (int j = 0; j < this.targets.Count; j++)
        {
            EntityAlive entity = this.targets[j] as EntityAlive;
            if (entity)
            {
                int EntityID = entity.entityClass;

                // If the group is set, then use it.
                if (!string.IsNullOrEmpty(this.strSpawnGroup))
                {
                    int ClassID = 0;
                    EntityID = EntityGroups.GetRandomFromGroup(this.strSpawnGroup, ref ClassID);
                }
                Vector3 transformPos;
                entity.world.GetRandomSpawnPositionMinMaxToPosition(entity.position, 2, 6, 2, true, out transformPos, false);

                Entity NewEntity = EntityFactory.CreateEntity(EntityID, transformPos, entity.rotation) as Entity;
                if (NewEntity)
                {
                    NewEntity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
                    GameManager.Instance.World.SpawnEntityInWorld(NewEntity);
                    if (NewEntity is EntityAlive)
                    {
                        Debug.Log("Setting " + this.strCvar + " ID to: " + entity.entityId + " for " + NewEntity.entityId);
                        (NewEntity as EntityAlive).Buffs.SetCustomVar(strCvar, entity.entityId, true);
                    }
                }
                else
                {
                    Debug.Log(" Could not Spawn baby for: " + entity.name + " : " + entity.entityId);
                }
            }
            else
            {
                Debug.Log("SpawnBabySDX(): Not an EntityAlive");
            }
        }
    }
예제 #14
0
 public static void Postfix(EntityAlive __instance, BinaryWriter _bw)
 {
     if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
     {
         return;
     }
     try
     {
         if (RandomSizeHelper.AllowedRandomSize(__instance))
         {
             float flScale = __instance.gameObject.transform.localScale.x;
             _bw.Write(flScale);
         }
     }
     catch (Exception)
     {
     }
 }
    public new static void SpawnQuestEntity(int spawnedEntityID, int entityIDQuestHolder, EntityPlayer player)
    {
        if (GameManager.Instance.World.Entities.dict.ContainsKey(entityIDQuestHolder))
        {
            EntityAlive questEntity = GameManager.Instance.World.Entities.dict[entityIDQuestHolder] as EntityAlive;
            if (questEntity == null)
            {
                return;
            }

            Vector3 transformPos = questEntity.position;
            Vector3 rotation     = new Vector3(0f, questEntity.transform.eulerAngles.y + 180f, 0f);
            Entity  entity       = EntityFactory.CreateEntity(spawnedEntityID, transformPos, rotation);
            entity.SetSpawnerSource(EnumSpawnerSource.StaticSpawner);
            GameManager.Instance.World.SpawnEntityInWorld(entity);
            questEntity.MarkToUnload();
        }
    }
예제 #16
0
        public static bool Prefix(EntityAlive __instance)
        {
            if (__instance.Buffs.HasCustomVar("RandomSize"))
            {
                AdvLogging.DisplayLog(AdvFeatureClass, " Update()");

                float scale = __instance.Buffs.GetCustomVar("RandomSize");
                AdvLogging.DisplayLog(AdvFeatureClass, " Scale: " + scale + " Transform: " + __instance.gameObject.transform.localScale.x);

                // if (__instance.gameObject.transform.localScale.x != scale)
                {
                    AdvLogging.DisplayLog(AdvFeatureClass, " Setting Scale:  " + scale);

                    __instance.gameObject.transform.localScale = new Vector3(scale, scale, scale);
                }
            }
            return(true);
        }
예제 #17
0
        public static bool AllowedRandomSize(EntityAlive entity)
        {
            bool bRandomSize = false;

            if (entity is EntityZombie)
            {
                bRandomSize = true;
            }

            EntityClass entityClass = EntityClass.list[entity.entityClass];

            if (entityClass.Properties.Values.ContainsKey("RandomSize"))
            {
                bRandomSize = StringParsers.ParseBool(entityClass.Properties.Values["RandomSize"], 0, -1, true);
            }

            return(bRandomSize);
        }
예제 #18
0
    public IEnumerator DestroyAround(EntityAlive ctrl)
    {
        running = true; // Actions are static, is this fine ? FIXME: There should be one per giant !
        Printer.Log(35, "MinEventActionGiantDestroy", ctrl, ctrl.GetPosition());

        Bounds  Bounds = ctrl.boundingBox; // check: not affected by rescale !
        Vector3 dir    = SdtdUtils.EffectsEntity.MoveDir(ctrl);
        Vector3 pos    = ctrl.GetPosition();

        int ymax = (int)Math.Floor(ctrl.boundingBox.size.y * ctrl.gameObject.transform.localScale.y);

        // how to enumerate x,z  wrt direction ?? h is ok
        foreach (int p in SdtdUtils.EffectsGround.LR(4))
        {
            foreach (int q in SdtdUtils.EffectsGround.LR(4))
            {
                Vector3 where = new Vector3(pos.x + p, pos.y, pos.z + q);
                if (!aigu(dir.x, dir.z, where.x - pos.x, where.z - pos.z))
                {
                    continue;                  // test not depending on y
                }
                for (int y = 0; y < ymax; y++) // TODO adjust by current giant ratio
                {
                    Printer.Log(30, "MinEventActionGiantDestroy at", p, q, y);
                    where.y = pos.y + y;
                    Vector3i   iwhere = Vectors.ToInt(where);
                    BlockValue block  = World.GetBlock(iwhere);
                    if (block.type != 0)
                    {
                        DamageBlock(ctrl, iwhere);
                    }
                    // todo: passer block et bv a DamageBlock
                }
                DamageEnts(ctrl);
                yield return(new WaitForSeconds(0.2f));

                if (ctrl == null || ctrl.IsDead())
                {
                    yield break;
                }
            }
        }
        running = false;
    }
예제 #19
0
    public override bool GetBindingValue(ref string value, BindingItem binding)
    {
        EntityPlayer player = base.xui.playerUI.entityPlayer;

        if (player == null)
        {
            return(false);
        }

        int entityID = 0;

        if (player.Buffs.HasCustomVar("CurrentNPC"))
        {
            entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
        }

        if (entityID == 0)
        {
            return(false);
        }

        string fieldName = binding.FieldName;

        if (fieldName != null)
        {
            if (fieldName == "respondentname")
            {
                EntityAlive myEntity = player.world.GetEntity(entityID) as EntityAlive;
                if (myEntity)
                {
                    if (EntityUtilities.GetHireCost(entityID) <= 0)
                    {
                        value = myEntity.EntityName;
                    }
                    //else
                    //    value = myEntity.EntityName;// + " ( Hire for " + myEntity.GetHireCost() + " " + myEntity.GetHireCurrency().ItemClass.Name + " )";
                    return(true);
                }
                value = ((!(base.xui.Dialog.Respondent != null)) ? string.Empty : Localization.Get(base.xui.Dialog.Respondent.EntityName));
                return(true);
            }
        }
        return(false);
    }
        public static bool Postfix(bool __result, EAISetNearestEntityAsTarget __instance)
        {
            // Check if we have any target in mind.
            EntityAlive targetEntity = __instance.targetEntity;

            if (targetEntity == null)
            {
                DisplayLog("No Target Entity", __instance.theEntity);
                return(__result);
            }

            DisplayLog("Postfix for CanExecute()", __instance.theEntity);
            // If we have a target, check if they are our leader, so we can forgive them.
            if (__result)
            {
                DisplayLog("Checking for Leader", __instance.theEntity);
                // If the Revenge Target is your leader, then forgive them?
                Entity myLeader = EntityUtilities.GetLeaderOrOwner(__instance.theEntity.entityId);
                if (myLeader)
                {
                    DisplayLog("Leader Found " + myLeader.entityId + ", checking ID", __instance.theEntity);
                    if (targetEntity.entityId == myLeader.entityId)
                    {
                        __result = false;
                    }
                }
            }

            // If we are still intent on attacking this target, check its faction, and see if we can forgive them.
            // If they don't really like them, it doesn't mean they want to kill them.
            if (__result)
            {
                DisplayLog("Checking Relationship with " + targetEntity.entityId, __instance.theEntity);
                FactionManager.Relationship myRelationship = FactionManager.Instance.GetRelationshipTier(__instance.theEntity, targetEntity);
                if (myRelationship != FactionManager.Relationship.Hate)
                {
                    __result = false;
                }
                DisplayLog("\tMRelationship with " + targetEntity.entityId + " is " + myRelationship.ToString(), __instance.theEntity);
            }

            DisplayLog("CanExecute(): " + __result, __instance.theEntity);
            return(__result);
        }
예제 #21
0
    public static bool CheckIncentive(int EntityID, List <String> lstIncentives, EntityAlive entity)
    {
        bool           result   = false;
        EntityAliveSDX myEntity = GameManager.Instance.World.GetEntity(EntityID) as EntityAliveSDX;

        if (myEntity == null)
        {
            return(result);
        }

        foreach (String strIncentive in lstIncentives)
        {
            // Check if the entity that is looking at us has the right buff for us to follow.
            if (myEntity.Buffs.HasBuff(strIncentive))
            {
                result = true;
            }

            // Check if there's a cvar for that incentive, such as $Mother or $Leader.
            if (myEntity.Buffs.HasCustomVar(strIncentive))
            {
                // DisplayLog(" Incentive: " + strIncentive + " Value: " + this.Buffs.GetCustomVar(strIncentive));
                if ((int)myEntity.Buffs.GetCustomVar(strIncentive) == entity.entityId)
                {
                    result = true;
                }
            }

            if (entity)
            {
                // Then we check if the control mechanism is an item being held.
                if (entity.inventory.holdingItem.Name == strIncentive)
                {
                    result = true;
                }
            }
            // if we are true here, it means we found a match to our entity.
            if (result)
            {
                break;
            }
        }
        return(result);
    }
예제 #22
0
    private MecanimSDX()
    {
        entityAlive = transform.gameObject.GetComponent <EntityAlive>();
        var entityClass = EntityClass.list[entityAlive.entityClass];


        AttackHash = GenerateLists(entityClass, "AttackAnimations");


        // The following will read our Index values from the XML to determine the maximum attack animations.
        // The range should be 1-based, meaning a value of 1 will specify the index value 0.
        // <property name="AttackIndexes" value="20", means there are 20 animations, running from 0 to 19
        int.TryParse(entityClass.Properties.Values["AttackIndexes"], out AttackIndexes);
        int.TryParse(entityClass.Properties.Values["SpecialAttackIndexes"], out SpecialAttackIndexes);

        int.TryParse(entityClass.Properties.Values["SpecialSecondIndexes"], out SpecialSecondIndexes);
        int.TryParse(entityClass.Properties.Values["RagingIndexes"], out RagingIndexes);

        int.TryParse(entityClass.Properties.Values["ElectrocutionIndexes"], out ElectrocutionIndexes);
        int.TryParse(entityClass.Properties.Values["CrouchIndexes"], out CrouchIndexes);

        int.TryParse(entityClass.Properties.Values["StunIndexes"], out StunIndexes);
        int.TryParse(entityClass.Properties.Values["SleeperIndexes"], out SleeperIndexes);

        int.TryParse(entityClass.Properties.Values["HarvestIndexes"], out HarvestIndexes);
        int.TryParse(entityClass.Properties.Values["PainIndexes"], out PainIndexes);

        int.TryParse(entityClass.Properties.Values["DeathIndexes"], out DeathIndexes);
        int.TryParse(entityClass.Properties.Values["RunIndexes"], out RunIndexes);

        int.TryParse(entityClass.Properties.Values["WalkIndexes"], out WalkIndexes);
        int.TryParse(entityClass.Properties.Values["IdleIndexes"], out IdleIndexes);

        int.TryParse(entityClass.Properties.Values["JumpIndexes"], out JumpIndexes);
        int.TryParse(entityClass.Properties.Values["EatingIndexes"], out EatingIndexes);

        int.TryParse(entityClass.Properties.Values["RandomIndexes"], out RandomIndexes);
        int.TryParse(entityClass.Properties.Values["AttackIdleIndexes"], out AttackIdleIndexes);

        if (entityClass.Properties.Values.ContainsKey("RightHandJointName"))
        {
            this.RightHand = entityClass.Properties.Values["RightHandJointName"];
        }
    }
예제 #23
0
    public override void SwapAmmoType(EntityAlive _entity, int _selectedIndex = -1)
    {
        Debug.Log("swap");
        ItemActionDataStaff actionDataRanged = (ItemActionDataStaff)_entity.inventory.holdingItemData.actionData[0];

        for (var index = 0; index < actionDataRanged.projectileInstance.Count; index++)
        {
            Transform transform = actionDataRanged.projectileInstance[index];
            if (transform != null)
            {
                Debug.Log("destroy");
                Object.Destroy(transform.gameObject);
            }
        }

        actionDataRanged.projectileInstance.Clear();

        base.SwapAmmoType(_entity, _selectedIndex);
    }
    // changes the self's faction.
    //  <triggered_effect trigger="onSelfBuffStart" action="ChangeFactionSDX, Mods" target="self" value="bandits" /> //  change faction to bandits
    //  <triggered_effect trigger="onSelfBuffStart" action="ChangeFactionSDX, Mods" target="self" value="undead" /> //change faction to undead
    //  <triggered_effect trigger="onSelfBuffStart" action="ChangeFactionSDX, Mods" target="self" value="original" /> //change faction to the original value

    public override void Execute(MinEventParams _params)
    {
        for (int i = 0; i < this.targets.Count; i++)
        {
            EntityAlive entity = this.targets[i] as EntityAlive;
            if (entity != null)
            {
                // If the faction name is original, try to find the original faction of the entity, stored via cvar.
                if (Faction == "original")
                {
                    // If there's already a factionoriginal cvar, retrive the faction name to be re-assigned.
                    if (entity.Buffs.HasCustomVar("FactionOriginal"))
                    {
                        var     FactionID = (byte)entity.Buffs.GetCustomVar("FactionOriginal");
                        Faction Temp      = FactionManager.Instance.GetFaction(FactionID);
                        if (Temp != null)
                        {
                            Faction = Temp.Name;
                        }
                    }
                }

                // Search for the faction
                Faction newFaction = FactionManager.Instance.GetFactionByName(Faction);
                if (newFaction != null)
                {
                    // If there's no original cvar, store it here. That's because it doesn't seem to persist over restarts, but cvars will
                    if (!entity.Buffs.HasCustomVar("FactionOriginal"))
                    {
                        entity.Buffs.SetCustomVar("FactionOriginal", entity.factionId);
                    }

                    // Set the new faction ID as a cvar for saving.
                    entity.Buffs.SetCustomVar("FactionNew", newFaction.ID);

                    Debug.Log("Changing " + entity.EntityName + " faction from " + entity.factionId + "  to " + newFaction.ID);

                    entity.factionId = newFaction.ID;
                    Debug.Log("\nNew Faction: " + entity.factionId);
                }
            }
        }
    }
    static bool Prefix(int playOnEntityId, string soundGoupName, float _occlusion)
    {
        AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): int, string, float: " + soundGoupName);
        EntityAlive myEntity = GameManager.Instance.World.GetEntity(playOnEntityId) as EntityAlive;

        if (myEntity == null)
        {
            return(true);
        }

        if (String.IsNullOrEmpty(soundGoupName))
        {
            return(true);
        }

        AdvLogging.DisplayLog(AdvFeatureClass, "Audio.Client.Play(): Vector3, string: " + soundGoupName.Split('/').Last());
        SphereII_GiveBuffOrQuestBySound.CheckForBuffOrQuest(soundGoupName.Split('/').Last(), myEntity.position);
        return(true);
    }
예제 #26
0
 private void FindNaturalEnemy()
 {
     if (naturalEnemies == null)
     {
         return;
     }
     if (naturalEnemies.Length == 0)
     {
         return;
     }
     using (
         List <Entity> .Enumerator enumerator =
             this.world.GetEntitiesInBounds(typeof(EntityAlive),
                                            BoundsUtils.BoundsForMinMax(this.position.x - 50f, this.position.y - 50f,
                                                                        this.position.z - 50f, this.position.x + 50f,
                                                                        this.position.y + 50f,
                                                                        this.position.z + 50f), new List <Entity>()).GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             EntityAlive _other = enumerator.Current as EntityAlive;
             if (Array.Exists(naturalEnemies, s => s.Equals(_other.EntityName)))
             {
                 if (_other.IsAlive())
                 {
                     //if (base.CanSee(_other))
                     {
                         if (_other.GetWaterLevel() < 0.5f)
                         {
                             if (debug)
                             {
                                 Debug.Log("Found natural enemy!");
                             }
                             base.SetRevengeTarget(_other);
                             isHunting = true;
                             return;
                         }
                     }
                 }
             }
         }
     }
 }
    private void DoBuffsAndRadiation(EntityAlive player)
    {
        if (RadiationDamage > 0)
        {
            player.DamageEntity(DamageSource.radiation, (int)RadiationDamage, false, 1f);
        }

        //  if (BuffActions == null || BuffActions.Count == 0 || GameTimer.Instance.ticks <= NextBuff) return;

        NextBuff = GameTimer.Instance.ticks + 200;

        //using (var enumerator = BuffActions.GetEnumerator())
        //{
        //  while (enumerator.MoveNext())
        //  {
        //    if (enumerator.Current != null) enumerator.Current.Execute(BlockValue.type, player, false, EnumBodyPartHit.None, null);
        //  }
        //}
    }
예제 #28
0
        public static bool AllowedRandomSize(EntityAlive entity)
        {
            bool bRandomSize = false;

            if (entity is EntityZombie)
            {
                AdvLogging.DisplayLog(AdvFeatureClass, " Random Size: Is A Zombie. Random size is true");
                bRandomSize = true;
            }
            EntityClass entityClass = EntityClass.list[entity.entityClass];

            if (entityClass.Properties.Values.ContainsKey("RandomSize"))
            {
                bRandomSize = StringParsers.ParseBool(entityClass.Properties.Values["RandomSize"], 0, -1, true);
            }

            AdvLogging.DisplayLog(AdvFeatureClass, "Entity: " + entity.DebugNameInfo + " Random Size:  " + bRandomSize);
            return(bRandomSize);
        }
예제 #29
0
    public override void OnOpen()
    {
        base.OnOpen();
        this.player = base.xui.playerUI.entityPlayer;
        int entityID = 0;

        if (player.Buffs.HasCustomVar("CurrentNPC"))
        {
            entityID = (int)player.Buffs.GetCustomVar("CurrentNPC");
        }

        UnityEngine.Debug.Log("Entity ID: " + entityID);
        this.entity = player.world.GetEntity(entityID) as EntityAliveSDX;
        if (!this.entity)
        {
            UnityEngine.Debug.Log(" Entity is null ");
            OnClose();
        }
    }
예제 #30
0
    // Returns true for the default PlaceBlock code to execute. If it returns false, it won't execute it at all.
    static bool Prefix(EntityAlive _ea)
    {
        // Check if this feature is enabled.
        if (!Configuration.CheckFeatureStatus(AdvFeatureClass, Feature))
        {
            return(true);
        }

        EntityPlayerLocal player = _ea as EntityPlayerLocal;

        if (player == null)
        {
            return(true);
        }

        if (player.IsGodMode == true)
        {
            return(true);
        }

        if (player.IsFlyMode == true)
        {
            return(true);
        }

        if (player.IsInElevator())
        {
            return(true);
        }

        if (player.IsInWater())
        {
            return(true);
        }

        // If you aren't on the ground, don't place the block.
        if (!player.onGround)
        {
            return(false);
        }

        return(true);
    }