Esempio n. 1
0
        //[ModifiesMember("CanActivate")]
        private bool CanActivateNew(GameObject victim)
        {
            bool disableFriendlyFire = IEModOptions.DisableFriendlyFire;

            if (!this.m_trap_initialized)
            {
                Debug.LogError("Cannot activate uninitialized trap!");
                return(false);
            }

            if (disableFriendlyFire)
            {
                Faction victimFaction = victim.GetComponent <Faction>();

                if (victimFaction.isPartyMember && this.IsPlayerOwnedTrap)
                {
                    return(false);
                }
            }

            if (this.Disarmed || this.m_triggerVictim != null)
            {
                return(false);
            }
            if (this.MaxHitCount > 0 && this.m_numHits >= this.MaxHitCount)
            {
                return(false);
            }
            if (GameUtilities.IsAnimalCompanion(victim))
            {
                return(false);
            }
            if (this.m_ocl != null)
            {
                return(true);
            }
            if (this.ActivatesForAnyone)
            {
                return(true);
            }
            Faction component = victim.GetComponent <Faction>();

            return(component != null && (component.IsHostile(base.gameObject) || this.m_trap_faction.IsHostile(victim)));
        }
Esempio n. 2
0
        public static void ChangeClass(string guid, string charclass)
        {
            GameObject npc      = null;
            string     charname = guid.Replace("_", " ");

            foreach (var partymember in PartyMemberAI.PartyMembers)
            {
                if (partymember != null && RemoveDiacritics(partymember.gameObject.GetComponent <CharacterStats>().Name()).Contains(charname))
                {
                    npc = partymember.gameObject;
                }
            }
            if (npc == null)
            {
                npc = UnityEngine.GameObject.Find(guid);
            }
            if (npc != null)
            {
                bool goOn = false;
                try
                {
                    if (Enum.Parse(typeof(CharacterStats.Class), charclass) != null)
                    {
                        goOn = true;
                    }
                }
                catch
                {
                    global::Console.AddMessage(charclass + " - not found as a class.");
                }
                if (goOn)
                {
                    object newclassobj = Enum.Parse(typeof(CharacterStats.Class), charclass);
                    int    newclassId  = Convert.ToInt32(newclassobj);

                    List <string> Innates = new List <string>();

                    //Put all innate non-racial talents and abilities here (case insensitive):
                    Innates.Add("crucible_of_the_soul");
                    Innates.Add("armed_to_the_teeth");
                    Innates.Add("speaker_to_the_restless");
                    Innates.Add("dominion_of_the_sleepers");
                    Innates.Add("steps_to_the_wheel");
                    Innates.Add("Beraths_Boon");
                    Innates.Add("Hyleas_Boon");
                    Innates.Add("Waels_Boon");
                    Innates.Add("Galawains_Boon");
                    Innates.Add("Rymrgands_Boon");
                    Innates.Add("Skaens_Boon");
                    Innates.Add("Second_Skin");
                    Innates.Add("The_Merciless_Hand");
                    Innates.Add("Mob_Justice");
                    Innates.Add("Mob Justice");                     //the ability has a space in place of an underscore...
                    Innates.Add("Blooded_Hunter");
                    Innates.Add("Song_of_the_Heavens");
                    Innates.Add("Wild_Running");
                    Innates.Add("Dungeon_Delver");
                    Innates.Add("Scale-Breaker");
                    Innates.Add("Gift_from_the_Machine");
                    Innates.Add("Effigys_Resentment");                     //should work for all types

                    if (npc.GetComponent <CharacterStats>().name.Contains("Sagani"))
                    {
                        Innates.Add("SummonCompanionArcticFox");
                    }

                    //==========================================================================
                    //REMOVE TALENTS
                    //==========================================================================
                    List <GenericTalent> talentRemoveList = new List <GenericTalent>();
                    foreach (GenericTalent activeTalent in npc.GetComponent <CharacterStats>().ActiveTalents)
                    {
                        bool saveMe = false;
                        foreach (string innate in Innates)
                        {
                            if (activeTalent.gameObject.name.IndexOf(innate, StringComparison.OrdinalIgnoreCase) >= 0)                             //look for substring
                            {
                                saveMe = true;
                                break;
                            }
                        }
                        if (!saveMe)
                        {
                            talentRemoveList.Add(activeTalent);
                        }
                    }
                    foreach (GenericTalent talentToRemove in talentRemoveList)
                    {
                        AbilityProgressionTable.RemoveAbilityFromCharacter(talentToRemove.gameObject, npc.GetComponent <CharacterStats>());
                    }

                    talentRemoveList.Clear();
                    foreach (GenericTalent talent in npc.GetComponent <CharacterStats>().Talents)
                    {
                        bool saveMe = false;
                        foreach (string innate in Innates)
                        {
                            if (talent.gameObject.name.IndexOf(innate, StringComparison.OrdinalIgnoreCase) >= 0)                             //look for substring
                            {
                                saveMe = true;
                                break;
                            }
                        }
                        if (!saveMe)
                        {
                            talentRemoveList.Add(talent);
                        }
                    }
                    foreach (GenericTalent talentToRemove in talentRemoveList)
                    {
                        AbilityProgressionTable.RemoveAbilityFromCharacter(talentToRemove.gameObject, npc.GetComponent <CharacterStats>());
                    }
                    //==========================================================================

                    //==========================================================================
                    //REMOVE ABILITIES
                    //==========================================================================
                    List <GenericAbility> abilRemoveList = new List <GenericAbility>();
                    foreach (GenericAbility activeAbility in npc.GetComponent <CharacterStats>().ActiveAbilities)
                    {
                        if (activeAbility.EffectType == GenericAbility.AbilityType.Racial)
                        {
                            continue;
                        }
                        bool saveMe = false;
                        foreach (string innate in Innates)
                        {
                            if (activeAbility.gameObject.name.IndexOf(innate, StringComparison.OrdinalIgnoreCase) >= 0)                             //look for substring
                            {
                                saveMe = true;
                                break;
                            }
                        }
                        if (!saveMe)
                        {
                            abilRemoveList.Add(activeAbility);
                        }
                    }
                    foreach (GenericAbility abilToRemove in abilRemoveList)
                    {
                        abilToRemove.ForceDeactivate(npc);
                        AbilityProgressionTable.RemoveAbilityFromCharacter(abilToRemove.gameObject, npc.GetComponent <CharacterStats>());
                    }
                    abilRemoveList.Clear();
                    foreach (GenericAbility ability in npc.GetComponent <CharacterStats>().Abilities)
                    {
                        if (ability.EffectType == GenericAbility.AbilityType.Racial)
                        {
                            continue;
                        }
                        bool saveMe = false;
                        foreach (string innate in Innates)
                        {
                            if (ability.gameObject.name.IndexOf(innate, StringComparison.OrdinalIgnoreCase) >= 0)                             //look for substring
                            {
                                saveMe = true;
                                break;
                            }
                        }
                        if (!saveMe)
                        {
                            abilRemoveList.Add(ability);
                        }
                    }
                    foreach (GenericAbility abilToRemove in abilRemoveList)
                    {
                        abilToRemove.ForceDeactivate(npc);
                        AbilityProgressionTable.RemoveAbilityFromCharacter(abilToRemove.gameObject, npc.GetComponent <CharacterStats>());
                    }
                    //==========================================================================

                    // remove ranger's pet
                    if (npc.GetComponent <CharacterStats>().CharacterClass == CharacterStats.Class.Ranger && !npc.GetComponent <CharacterStats>().name.Contains("Sagani"))
                    {
                        foreach (var cre in npc.GetComponent <AIController>().SummonedCreatureList)
                        {
                            if (GameUtilities.IsAnimalCompanion(cre.gameObject))
                            {
                                PartyMemberAI.RemoveFromActiveParty(cre.GetComponent <PartyMemberAI>(), true);
                                cre.GetComponent <Persistence>().UnloadsBetweenLevels = true;
                                cre.GetComponent <Health>().m_isAnimalCompanion       = false;
                                cre.GetComponent <Health>().ApplyDamageDirectly(1000);
                                cre.GetComponent <Health>().ApplyDamageDirectly(1000);
                                global::Console.AddMessage(cre.GetComponent <CharacterStats>().Name() + " is free from its bonds and returns to the wilds to be with its own kind.", Color.green);
                                cre.SetActive(false);
                            }
                        }
                        //npc.GetComponent<AIController> ().SummonedCreatureList.Clear ();
                    }

                    // remove or give grimoire
                    if (npc.GetComponent <CharacterStats>().CharacterClass != (CharacterStats.Class)newclassId)
                    {
                        if (npc.GetComponent <CharacterStats>().CharacterClass == CharacterStats.Class.Wizard)
                        {
                            npc.GetComponent <Equipment>().UnEquip(Equippable.EquipmentSlot.Grimoire);
                        }

                        npc.GetComponent <CharacterStats>().CharacterClass = (CharacterStats.Class)newclassId;

                        if (npc.GetComponent <CharacterStats>().CharacterClass == CharacterStats.Class.Wizard)
                        {
                            // equip an empty grimoire...?
                            Equippable grim = GameResources.LoadPrefab <Equippable>("empty_grimoire_01", true);
                            if (grim != null)
                            {
                                grim.GetComponent <Grimoire>().PrimaryOwnerName = npc.GetComponent <CharacterStats>().Name();
                                npc.GetComponent <Equipment>().Equip(grim);
                            }
                        }
                    }

                    //BaseDeflection,BaseFortitude,BaseReflexes,BaseWill,MeleeAccuracyBonus,RangedAccuracyBonus,MaxHealth,MaxStamina,HealthStaminaPerLevel,ClassHealthMultiplier
                    object comp = (object)npc.GetComponent <CharacterStats>();
                    DataManager.AdjustFromData(ref comp);

                    npc.GetComponent <CharacterStats>().Level = 0;

                    npc.GetComponent <CharacterStats>().StealthSkill   = 0;
                    npc.GetComponent <CharacterStats>().StealthBonus   = 0;
                    npc.GetComponent <CharacterStats>().AthleticsSkill = 0;
                    npc.GetComponent <CharacterStats>().AthleticsBonus = 0;
                    npc.GetComponent <CharacterStats>().LoreSkill      = 0;
                    npc.GetComponent <CharacterStats>().LoreBonus      = 0;
                    npc.GetComponent <CharacterStats>().MechanicsSkill = 0;
                    npc.GetComponent <CharacterStats>().MechanicsBonus = 0;
                    npc.GetComponent <CharacterStats>().SurvivalSkill  = 0;
                    npc.GetComponent <CharacterStats>().SurvivalBonus  = 0;

                    npc.GetComponent <CharacterStats>().RemainingSkillPoints = 0;

                    string HeOrShe = npc.GetComponent <CharacterStats>().Gender.ToString();
                    global::Console.AddMessage(npc.GetComponent <CharacterStats>().Name() + " has reformed into a " + charclass + ". " + (HeOrShe == "Male" ? "He" : "She") + " lost all " + (HeOrShe == "Male" ? "his" : "her") + " previous abilities and talents.", Color.green);
                }
            }
            else
            {
                global::Console.AddMessage("Couldn't find: " + guid, Color.yellow);
            }
        }