public virtual void ApplySkillAfterDelay(SkillDef s, Vector3? start, List<Target> currentTs, float delay) { if(pendingSkillActivations == null) { pendingSkillActivations = new List<SkillActivation>(); } pendingSkillActivations.Add(new SkillActivation(s, start, currentTs, delay)); }
public override void OnEnable() { s = target as SkillDef; fdb = Formulae.DefaultFormulae; base.OnEnable(); name = "Skill Definition"; }
public SkillActivation(SkillDef s, Vector3? st, List<Target> targs, float d) { skill = s; start = st; targets = targs.Select(t => t.Clone()).ToList(); delay = d; delayRemaining = delay; }
public float GetParam( string pname, SkillDef scontext=null, float fallback=float.NaN ) { return item.GetParam(pname, scontext, fallback); }
public void Awake() { //make sure we don't mess with the real asset if(def != null && def.reallyDefined) { def = Instantiate(def) as SkillDef; def.Owner = this; } }
public virtual float GetParam( int team, string pname, float fallback=float.NaN, SkillDef parentCtx=null ) { return GetTeam(team).GetParam(pname, fallback, parentCtx); }
public void Show(SkillDef def) { // Title.text = def.name; // Description.text = def.description; Title.text = string.Format("{0}",Localization.instance.Get("Skill_Name_"+def.id)); Description.text = string.Format("{0}",Localization.instance.Get("Skill_Desc_"+def.id)); // Icon.spriteName = "???"; // Tween.Reset(); // Tween.Play(true); }
public Gnome(Character gnome, SkillDef[] skillDefinitions) { ID = gnome.ID; Name = gnome.Name(); Location = new Location(gnome.Position); Stats = new GnomeStats(gnome); Profession = new GnomeProfession(gnome.Mind.Profession); BodyParts = GnomeBodyPartStatus.GetBodyStatus(gnome); LaborSkills = GnomeSkill.GetGnomeSkills(GnomeSkill.GnomeSkillType.Labor, skillDefinitions, gnome); CombatSkills = GnomeSkill.GetGnomeSkills(GnomeSkill.GnomeSkillType.Combat, skillDefinitions, gnome); }
public float GetParam(string pname, SkillDef scontext=null, float fallback=float.NaN) { MakeParametersIfNecessary(); if(!HasParam(pname)) { if(float.IsNaN(fallback)) { Debug.LogError("No fallback for missing item param "+pname+" on "+this); } return fallback; } return runtimeParameters[pname].GetValue(fdb, scontext, null, null, null, this); }
public GnomeSummary(IEnumerable<Character> gnomes, SkillDef[] skillDefinitions) { List<Gnome> gnomeList = new List<Gnome>(); foreach (var gnome in gnomes) { gnomeList.Add(new Gnome(gnome, skillDefinitions)); } Gnomes = gnomeList.ToArray(); Population = gnomeList.Count; }
public float GetParam(string pname, SkillDef scontext=null, float fallback=float.NaN) { MakeParametersIfNecessary(); FindWielder(); if(!HasOwnParam(pname)) { if(baseItem != null) { return baseItem.GetParam(pname, scontext, fallback); } if(float.IsNaN(fallback)) { Debug.LogError("No fallback for missing equipment param "+pname); } return fallback; } return runtimeParameters[pname].GetValue(fdb, scontext, null, null, this); }
public void initBySkillDef(SkillDef sd) { skillDef = sd; test_id = sd.id; // icon.spriteName = string.Format("SkillIcon_{0}", sd.id); //icon.spriteName = getBgSpriteName(); // icon.MakePixelPerfect(); if (null != learnedData){ CancelInvoke("UpdateTrainingTime"); } icon.spriteName = "si_"+sd.id;//getIconSpriteName(); if(icon.GetAtlasSprite() == null){ icon.spriteName = "si_ROCKET5B"; } }
public virtual float GetParam( string pname, float fallback=float.NaN, SkillDef parentCtx=null ) { Parameter p = parameters.FirstOrDefault(pn => pn.Name == pname); if(p != null) { return p.Formula.GetValue(fdb, parentCtx); } else { if(float.IsNaN(fallback)) { Debug.LogError("No fallback for missing param "+pname); } return fallback; } }
public static GnomeSkill[] GetGnomeSkills(GnomeSkillType skillType, SkillDef[] skillDefinitions, Character gameGnome) { List<String> skillNames = new List<String>(); if (skillType.HasFlag(GnomeSkillType.Labor)) { skillNames.AddRange(GnomanEmpire.Instance.GameDefs.CharacterSettings.LaborSkills); } if (skillType.HasFlag(GnomeSkillType.Combat)) { skillNames.AddRange(GnomanEmpire.Instance.GameDefs.CharacterSettings.CombatSkills); } var skills = skillDefinitions.Where(obj => skillNames.Contains(obj.Name)).Select(skill => new GnomeSkill(gameGnome, skill)).ToArray(); return skills; }
// Use this for initialization void Start() { RectTransform rt; TextAsset textAsset = (TextAsset) Resources.Load("skill-list"); if (!textAsset) Debug.Log("failed to load xml resource"); var doc = new XmlDocument(); doc.LoadXml (textAsset.text); SkList = new Dictionary<string, SkillDef> (); XmlNodeList root = doc.SelectNodes ("skills/skill"); string id; //for parsing foreach (XmlNode node in root) { id = node.Attributes.GetNamedItem("id").Value; SkList[id] = new SkillDef(); SkList[id].name = node.Attributes.GetNamedItem("name").Value; SkList[id].desc = node.Attributes.GetNamedItem("description").Value; }//foreach node skills = new List<GameObject>(); int i = 0; foreach (KeyValuePair<string, SkillDef> pair in SkList) { var skill = Instantiate (elem); skill.GetComponentInChildren<Text> ().text = pair.Value.name; rt = skill.GetComponent<RectTransform> (); rt.SetParent (panel.transform); var evt = skill.GetComponent<EventTrigger>(); EventTrigger.Entry entry = new EventTrigger.Entry(); entry.eventID = EventTriggerType.PointerClick; entry.callback = new EventTrigger.TriggerEvent(); UnityEngine.Events.UnityAction<BaseEventData> callback = new UnityEngine.Events.UnityAction<BaseEventData>(elementClick); entry.callback.AddListener(callback); evt.triggers.Add(entry); skills.Add(skill); } /*skills [1] = Instantiate (elem); skills [1].GetComponentInChildren<Text> ().text = "Dodge"; rt = skills[1].GetComponent<RectTransform>(); rt.SetParent(panel.transform);*/ }
/// <summary> /// Clones an existing SkillDef into a new instance with the same values. /// </summary> /// <param name="oldDef">The SkillDef instance to clone.</param> /// <returns>A clone of oldDef, shallow changes to which will not affect the original.</returns> public static SkillDef CloneSkillDef(SkillDef oldDef) { var newDef = ScriptableObject.CreateInstance <SkillDef>(); newDef.skillName = oldDef.skillName; newDef.skillNameToken = oldDef.skillNameToken; newDef.skillDescriptionToken = oldDef.skillDescriptionToken; newDef.icon = oldDef.icon; newDef.activationStateMachineName = oldDef.activationStateMachineName; newDef.activationState = oldDef.activationState; newDef.interruptPriority = oldDef.interruptPriority; newDef.baseRechargeInterval = oldDef.baseRechargeInterval; newDef.baseMaxStock = oldDef.baseMaxStock; newDef.rechargeStock = oldDef.rechargeStock; newDef.requiredStock = oldDef.requiredStock; newDef.stockToConsume = oldDef.stockToConsume; newDef.beginSkillCooldownOnSkillEnd = oldDef.beginSkillCooldownOnSkillEnd; newDef.fullRestockOnAssign = oldDef.fullRestockOnAssign; newDef.dontAllowPastMaxStocks = oldDef.dontAllowPastMaxStocks; newDef.canceledFromSprinting = oldDef.canceledFromSprinting; newDef.isCombatSkill = oldDef.isCombatSkill; newDef.resetCooldownTimerOnUse = oldDef.resetCooldownTimerOnUse; newDef.cancelSprintingOnActivation = oldDef.cancelSprintingOnActivation; newDef.canceledFromSprinting = oldDef.canceledFromSprinting; newDef.forceSprintDuringState = oldDef.forceSprintDuringState; newDef.mustKeyPress = oldDef.mustKeyPress; newDef.keywordTokens = oldDef.keywordTokens; return(newDef); }
public override void Execute(int amount, string boughtBy) { IEnumerable <Pawn> colonists = Find.ColonistBar.GetColonistsInOrder(); IEnumerable <Pawn> orderedColonists; if (inspirationDef.associatedSkills == null) { orderedColonists = colonists.InRandomOrder(); } else { // Just grab the first skill, current inspirations only appear to have 0 or 1 in the list // Worst case it just won't take all skills into account SkillDef skillDef = inspirationDef.associatedSkills[0]; orderedColonists = colonists.OrderByDescending(colonist => colonist.skills.GetSkill(skillDef).Level); } foreach (Pawn colonist in orderedColonists) { bool colonistInspirationSet = colonist.mindState.inspirationHandler.TryStartInspiration_NewTemp(inspirationDef); if (colonistInspirationSet) { String notificationMessage; // I hope no viewer uses RC with the name "Poll" if (boughtBy == "Poll") { notificationMessage = $"<color=#9147ff>By popular opinion</color>, your channel has triggered {defLabel} for {colonist.Name}, hopefully it helps!"; } else { notificationMessage = $"<color=#9147ff>{boughtBy}</color> purchased {defLabel} for {colonist.Name}. Enjoy!!"; } AlertManager.NormalEventNotification(notificationMessage); return; } } AlertManager.NormalEventNotification($"<color=#9147ff>{boughtBy}</color> tried to buy {defLabel} but it failed. Currently there are no refunds :( "); }
public int GetExtendedSkillLevel(SkillDef skillDef, Type type) { int returnval = 0; switch (SkillUsage) { case enum_ModExtension_SkillsskillUsage.ThisOverrides: { returnval = GetSkillLevel(skillDef); break; } case enum_ModExtension_SkillsskillUsage.ReserchIsCapping: { returnval = Mathf.Clamp(GetSkillLevel(skillDef), 0, ReserchSkillModifier.GetResechSkillLevel(type)); break; } case enum_ModExtension_SkillsskillUsage.ThisIsCapping: { returnval = Mathf.Clamp(ReserchSkillModifier.GetResechSkillLevel(type), 0, GetSkillLevel(skillDef)); break; } case ModExtension_Skills.enum_ModExtension_SkillsskillUsage.ReserchOverrides: { returnval = ReserchSkillModifier.GetResechSkillLevel(type); break; } default: { returnval = GetSkillLevel(skillDef); break; } } return(returnval); }
private void CharacterSelectController_OnNetworkUserLoadoutChanged(ILContext il) { void emittedAction(CharacterModel model, Loadout loadout, Int32 body) { GenericSkill[] skills = BodyCatalog.GetBodyPrefabSkillSlots(body); for (Int32 i = 0; i < skills.Length; i++) { UInt32 selectedSkillIndex = loadout.bodyLoadoutManager.GetSkillVariant(body, i); GenericSkill slot = skills[i]; for (Int32 j = 0; j < slot.skillFamily.variants.Length; j++) { SkillDef skillDef = slot.skillFamily.variants[j].skillDef; if (skillDef != null && skillDef is PassiveSkillDef) { var passiveSkillDef = skillDef as PassiveSkillDef; if (j == selectedSkillIndex) { passiveSkillDef.OnAssignDisplay(model); } else { passiveSkillDef.OnUnassignDisplay(model); } } } } } var c = new ILCursor(il); _ = c.GotoNext(MoveType.After, x => x.MatchCallOrCallvirt <RoR2.SkinDef>("Apply")); _ = c.Emit(OpCodes.Ldloc, 6); _ = c.Emit(OpCodes.Ldloc, 2); _ = c.Emit(OpCodes.Ldloc, 3); _ = c.EmitDelegate <Action <CharacterModel, Loadout, Int32> >(emittedAction); }
public static int FinalLevelOfSkill(Pawn pawn, SkillDef sk) { float num; if (sk.usuallyDefinedInBackstories) { num = (float)Rand.RangeInclusive(0, 4); } else { num = Rand.ByCurve(LevelRandomCurve); } foreach (Backstory backstory in from bs in pawn.story.AllBackstories where bs != null select bs) { foreach (KeyValuePair <SkillDef, int> keyValuePair in backstory.skillGainsResolved) { if (keyValuePair.Key == sk) { num += (float)keyValuePair.Value * Rand.Range(1f, 1.4f); } } } for (int i = 0; i < pawn.story.traits.allTraits.Count; i++) { int num2 = 0; if (pawn.story.traits.allTraits[i].CurrentData.skillGains.TryGetValue(sk, out num2)) { num += (float)num2; } } float num3 = Rand.Range(1f, AgeSkillMaxFactorCurve.Evaluate((float)pawn.ageTracker.AgeBiologicalYears)); num *= num3; num = LevelFinalAdjustmentCurve.Evaluate(num); return(Mathf.Clamp(Mathf.RoundToInt(num), 0, 20)); }
private void CreateEngiSkill() { SkillDef def = ScriptableObject.CreateInstance <SkillDef>(); var family = engi.GetComponent <SkillLocator>().special.skillFamily; def.activationState = new EntityStates.SerializableEntityStateType(typeof(Skills.Engi.Special.PlaceOmegaTurret)); def.activationStateMachineName = "Weapon"; def.interruptPriority = EntityStates.InterruptPriority.Skill; def.icon = family.variants[1].skillDef.icon; def.baseRechargeInterval = (_DEBUGGING ? 1f : 60f); def.shootDelay = 0.0f; def.baseMaxStock = 1; def.rechargeStock = 1; def.requiredStock = 1; def.stockToConsume = 0; def.isBullets = false; def.beginSkillCooldownOnSkillEnd = true; def.isCombatSkill = false; def.noSprint = true; def.canceledFromSprinting = false; def.mustKeyPress = false; def.fullRestockOnAssign = true; var variant = new SkillFamily.Variant { viewableNode = new RoR2.ViewablesCatalog.Node("OmegaNodeThing", false), skillDef = def, unlockableName = "" }; RoR2Plugin.SkillsAPI.AddSkillDef(def); Array.Resize <SkillFamily.Variant>(ref family.variants, family.variants.Length + 1); family.variants[family.variants.Length - 1] = variant; }
public virtual float GetParam( string pname, float fallback = float.NaN, SkillDef parentCtx = null ) { if (parentCtx == null) { parentCtx = this; } MakeParametersIfNecessary(); //TODO: let all other equipment and skills modulate this param? if (!HasParam(pname)) { if (float.IsNaN(fallback)) { Debug.LogError("No fallback for missing param " + pname); } /* Debug.Log("using fallback "+fallback+" for "+pname);*/ return(fallback); } return(runtimeParameters[pname].GetValue(fdb, parentCtx)); }
public SkillDef GetSkillDefinition(string activationStateMachineName) { SkillDef primaryDef = SkillDef.CreateInstance <SkillDef>(); primaryDef.activationState = new EntityStates.SerializableEntityStateType(typeof(Primary)); primaryDef.baseRechargeInterval = 1f; primaryDef.baseMaxStock = 5; primaryDef.rechargeStock = 1; primaryDef.skillName = "MySkillName"; primaryDef.skillNameToken = "My Name Token"; primaryDef.skillDescriptionToken = "This is the description of the primary skill."; primaryDef.activationStateMachineName = activationStateMachineName; primaryDef.isBullets = false; primaryDef.beginSkillCooldownOnSkillEnd = true; primaryDef.interruptPriority = EntityStates.InterruptPriority.Skill; primaryDef.isCombatSkill = true; primaryDef.noSprint = false; primaryDef.canceledFromSprinting = false; primaryDef.mustKeyPress = true; primaryDef.requiredStock = 1; primaryDef.stockToConsume = 1; return(primaryDef); }
public override void ExportGraph(List <InternalBaseGraphAsset> assets) { for (int i = 0; i < assets.Count; i++) { if (assets[i] is AoeGraphAsset) { AoeGraphAsset asset = assets[i] as AoeGraphAsset; BaseGraph graphData = asset.DeserializeGraph(); //运行时数据结构 AoeModel model = SerializeToAoeModel(graphData, asset); string filePath = SkillDef.GetAoeCnfPath(asset.aoeId); IOHelper.WriteText(JsonMapper.ToJson(model), filePath); Debug.Log($"Aoe配置生成成功>>>>{filePath}"); } } AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }
public bool HasIncapableSkills(Pawn pawn) { HarmonyPatches.DebugMessage($"HasIncapableSkills called"); Map map = pawn.Map; //Check if we have level 0 skills List <SkillDef> allDefsListForReading = DefDatabase <SkillDef> .AllDefsListForReading; HarmonyPatches.DebugMessage($"AllDefsForReading"); for (int i = 0; i < allDefsListForReading.Count; i++) { SkillDef skillDef = allDefsListForReading[i]; SkillRecord skill = TempExecutioner(map).skills.GetSkill(skillDef); if (skill.Level == 0) { return(true); } if (skill.TotallyDisabled) { return(true); } } return(false); }
public Gnome(Character gnome, int level, int row, int column, int mapCellPosition, int realIndex) { this.name = gnome.Name(); this.id = realIndex; this.level = level; this.row = row; this.column = column; this.position = mapCellPosition; this.profession = gnome.Mind.Profession; this.mining = gnome.SkillLevel(CharacterSkillType.Mining); foreach (var skill in SkillDef.AllLaborSkills()) { this.laborSkills.Add(new SkillEntry(skill, gnome.SkillLevel(skill), gnome.Mind.IsSkillAllowed(skill))); } foreach (var skill in SkillDef.AllCombatSkills()) { this.combatSkills.Add(new SkillEntry(skill, gnome.SkillLevel(skill), gnome.Mind.IsSkillAllowed(skill))); } foreach (var attribute in Enum.GetValues(typeof(CharacterAttributeType))) { this.attributes.Add(new AttributeEntry((CharacterAttributeType)attribute, gnome.AttributeLevel((CharacterAttributeType)attribute))); } }
override public void SkillApplied(SkillDef s) { base.SkillApplied(s); if (s.character != null && s.character == activeCharacter) { if (!(s is MoveSkillDef)) { activeCharacterHasActed = true; float cost = perActionCTCostStat != null? s.character.GetStat(perActionCTCostStat, defaultPerActionCTCost) : defaultPerActionCTCost; if (coalesceCTDecrements) { pendingCTDecrement += cost; } else { s.character.AdjustBaseStat(ctStat, -cost); } } } }
public static void AddSkillDef(SkillDef skillDef) { //Log.Counter(); if (!loaded) { throw new CoreNotLoadedException(nameof(SkillsCore)); } if (addedSkillDefs.Contains(skillDef)) { return; } if (skillDef == null) { throw new ArgumentNullException("skillDef"); } //SkillCatalog.getAdditionalSkillDefs += ( list ) => list.Add( skillDef ); _ = addedSkillDefs.Add(skillDef); addedSkills.Add(skillDef); //Log.Counter(); }
// Token: 0x06000034 RID: 52 RVA: 0x00003B50 File Offset: 0x00001D50 protected virtual int FinalLevelOfSkill(Pawn pawn, SkillDef sk) { float num; if (sk.usuallyDefinedInBackstories) { num = Rand.RangeInclusive(0, 4); } else { num = Rand.ByCurve(LevelRandomCurve); } foreach (var backstory in from bs in pawn.story.AllBackstories where bs != null select bs) { foreach (var keyValuePair in backstory.skillGainsResolved) { if (keyValuePair.Key == sk) { num += keyValuePair.Value * Rand.Range(1f, 1.4f); } } } foreach (var trait in pawn.story.traits.allTraits) { if (trait.CurrentData.skillGains.TryGetValue(sk, out var num2)) { num += num2; } } num = LevelFinalAdjustmentCurve.Evaluate(num); return(Mathf.Clamp(Mathf.RoundToInt(num), 0, 20)); }
public override void SetupAttributes() { base.SetupAttributes(); //load custom assets var muzzleEffectPrefab = TinkersSatchelPlugin.resources.LoadAsset <GameObject>("Assets/TinkersSatchel/Prefabs/Misc/EngiChaffFlareEffect.prefab"); skillDef = TinkersSatchelPlugin.resources.LoadAsset <SkillDef>("Assets/TinkersSatchel/SkillDefs/EngiSecondaryChaff.asset"); //load vanilla assets targetSkillFamily = Addressables.LoadAssetAsync <SkillFamily>("RoR2/Base/Engi/EngiBodySecondaryFamily.asset") .WaitForCompletion(); var tracerMtl = Addressables.LoadAssetAsync <Material>("RoR2/Base/Firework/matFireworkSparkle.mat") .WaitForCompletion(); //modify muzzleEffectPrefab.GetComponent <ParticleSystemRenderer>().material = tracerMtl; Fire.effectPrefab = muzzleEffectPrefab; //R2API catalog reg ContentAddition.AddEffect(muzzleEffectPrefab); skillDef.activationState = ContentAddition.AddEntityState <Fire>(out bool entStateDidSucceed); if (!entStateDidSucceed) { TinkersSatchelPlugin._logger.LogError("EntityState setup failed on EngiSecondaryChaff! Skill will not appear nor function."); } else if (!ContentAddition.AddSkillDef(skillDef)) { TinkersSatchelPlugin._logger.LogError("SkillDef setup failed on EngiSecondaryChaff! Skill will not appear nor function."); } else { setupSucceeded = true; } }
internal static SkillDef CreatePrimarySkillDef(SerializableEntityStateType state, string stateMachine, string skillNameToken, string skillDescriptionToken, Sprite skillIcon, bool agile) { SkillDef skillDef = ScriptableObject.CreateInstance <SkillDef>(); skillDef.skillName = skillNameToken; skillDef.skillNameToken = skillNameToken; skillDef.skillDescriptionToken = skillDescriptionToken; skillDef.icon = skillIcon; skillDef.activationState = state; skillDef.activationStateMachineName = stateMachine; skillDef.baseMaxStock = 1; skillDef.baseRechargeInterval = 0; skillDef.beginSkillCooldownOnSkillEnd = false; skillDef.canceledFromSprinting = false; skillDef.forceSprintDuringState = false; skillDef.fullRestockOnAssign = true; skillDef.interruptPriority = InterruptPriority.Any; skillDef.isBullets = false; skillDef.isCombatSkill = true; skillDef.mustKeyPress = false; skillDef.noSprint = !agile; skillDef.rechargeStock = 1; skillDef.requiredStock = 0; skillDef.shootDelay = 0f; skillDef.stockToConsume = 0; if (agile) { skillDef.keywordTokens = new string[] { "KEYWORD_AGILE" } } ; LoadoutAPI.AddSkillDef(skillDef); return(skillDef); }
public static int GetResechSkillLevel(Type callertype, SkillDef skillDef = null) { //Type.GetType("ProjectRimFactory.Drones.Pawn_Drone, ProjectRimFactory", false) if (callertype == typeof(Pawn_Drone) || callertype == typeof(Building_DroneStation)) { //Order Matters if (PRFDefOf.PRF_AdvancedDrones.IsFinished) { return(20); //Advanced Version } else if (PRFDefOf.PRF_ImprovedDrones.IsFinished) { return(15); //Improved Version } else if (PRFDefOf.PRF_BasicDrones.IsFinished) { return(10); //Basic } } return(reserchSkillLevelDefault); }
private static void CreateSpecial() { LoadoutAPI.AddSkill(typeof(Weapon.GrandParentBoss.PortalJump)); SkillDef specialSkillDef = ScriptableObject.CreateInstance <SkillDef>(); specialSkillDef.activationState = new SerializableEntityStateType(typeof(Weapon.GrandParentBoss.PortalJump)); specialSkillDef.activationStateMachineName = "Weapon"; specialSkillDef.baseMaxStock = 1; specialSkillDef.baseRechargeInterval = 12f; specialSkillDef.beginSkillCooldownOnSkillEnd = false; specialSkillDef.canceledFromSprinting = false; specialSkillDef.fullRestockOnAssign = false; specialSkillDef.interruptPriority = InterruptPriority.Any; specialSkillDef.isBullets = false; specialSkillDef.isCombatSkill = true; specialSkillDef.mustKeyPress = false; specialSkillDef.noSprint = false; specialSkillDef.rechargeStock = 1; specialSkillDef.requiredStock = 1; specialSkillDef.shootDelay = 1f; specialSkillDef.stockToConsume = 1; specialSkillDef.skillDescriptionToken = "AAAAAAAAAAAAAAAAAAAA"; specialSkillDef.skillName = "AAAAAAAAAAAAA"; specialSkillDef.skillNameToken = "AAAAAAAAAAAAAA"; LoadoutAPI.AddSkillDef(specialSkillDef); SkillFamily specialSkillFamily = skillLocator.special.skillFamily; specialSkillFamily.variants[0] = new SkillFamily.Variant { skillDef = specialSkillDef, unlockableName = "", viewableNode = new ViewablesCatalog.Node(specialSkillDef.skillNameToken, false, null) }; }
private static void Postfix(Object model, SkillDef def, object __instance) { var r = AccessTools.PropertyGetter(Patch_RimHUDBase.hudPawnModel, "Base"); Pawn b = (Pawn)r.Invoke(model, null); Pawn_SkillTracker st = b.skills; SkillRecord skillRecord = (st != null) ? st.GetSkill(def) : null; if (skillRecord == null) { return; } var label = AccessTools.Field(Patch_RimHUDBase.hudSkillModel, "<Label>k__BackingField"); if (label == null) { return; } InterestDef i = InterestBase.interestList[(int)skillRecord.passion]; string end = ""; float val = i.GetValue(); if (val < 0) { end = new string('-', -(int)Math.Floor(val / 75.0f)); } else if (val > 0) { end = new string('+', (int)Math.Floor(val / 75.0f)); } string l = def.LabelCap + end; label.SetValue(__instance, l); }
public override void DoWindowContents(Rect inRect) { Widgets.Label(new Rect(0, 15, 70, 20), Translator.Translate("BackstorySlotInfo")); if (Widgets.ButtonText(new Rect(80, 15, 175, 20), skill.LabelCap)) { List <FloatMenuOption> list = new List <FloatMenuOption>(); foreach (var skill in DefDatabase <SkillDef> .AllDefsListForReading) { list.Add(new FloatMenuOption(skill.LabelCap, delegate { this.skill = skill; })); } Find.WindowStack.Add(new FloatMenu(list)); } Widgets.Label(new Rect(0, 50, 70, 20), Translator.Translate("CountInfo")); Widgets.TextFieldNumeric(new Rect(80, 50, 175, 20), ref count, ref buff, -20, 20); if (Widgets.ButtonText(new Rect(0, 90, 260, 20), Translator.Translate("AddNewSkillGain"))) { AddNewSkill(); } }
private static void AdditionalSetup() { NoAttackSkillDef = ScriptableObject.CreateInstance <SkillDef>(); NoAttackSkillDef.activationState = new SerializableEntityStateType(typeof(ROR2_SaxtonHale.States.NoAttackState)); NoAttackSkillDef.activationStateMachineName = "Weapon"; NoAttackSkillDef.baseMaxStock = 0; NoAttackSkillDef.baseRechargeInterval = 0f; NoAttackSkillDef.beginSkillCooldownOnSkillEnd = true; NoAttackSkillDef.canceledFromSprinting = false; NoAttackSkillDef.fullRestockOnAssign = false; NoAttackSkillDef.interruptPriority = InterruptPriority.Frozen; NoAttackSkillDef.isBullets = false; NoAttackSkillDef.isCombatSkill = false; NoAttackSkillDef.mustKeyPress = false; NoAttackSkillDef.noSprint = true; NoAttackSkillDef.rechargeStock = 0; NoAttackSkillDef.requiredStock = 1; NoAttackSkillDef.shootDelay = 0f; NoAttackSkillDef.stockToConsume = 0; NoAttackSkillDef.icon = Resources.Load <SkillDef>("skilldefs/captainbody/CaptainSkillUsedUp").icon; NoAttackSkillDef.skillDescriptionToken = "SAXTONHALE_SCARED_DESCRIPTION"; NoAttackSkillDef.skillName = "SAXTONHALE_SCARED_NAME"; NoAttackSkillDef.skillNameToken = "SAXTONHALE_SCARED_NAME"; }
public override bool CanBeUsedBy(Pawn p, out string failReason) { foreach (SkillRequirement requirement in Props.skillRequirements) { SkillDef skillDef = requirement.skill; int minLevel = requirement.minLevel; if (p.skills.GetSkill(skillDef).TotallyDisabled) { failReason = "SkillDisabled".Translate(); return(false); } if (p.skills.GetSkill(skillDef).Level >= minLevel) { continue; } failReason = "UnderRequiredSkill".Translate(requirement.Summary); return(false); } return(base.CanBeUsedBy(p, out failReason)); }
private static void CreateUtility() { LoadoutAPI.AddSkill(typeof(Weapon.GrandParentBoss.PortalJump)); SkillDef utilitySkillDef = ScriptableObject.CreateInstance <SkillDef>(); utilitySkillDef.activationState = new SerializableEntityStateType(typeof(EntityStates.GrandParentBoss.Offspring)); utilitySkillDef.activationStateMachineName = "Weapon"; utilitySkillDef.baseMaxStock = 1; utilitySkillDef.baseRechargeInterval = 3f; utilitySkillDef.beginSkillCooldownOnSkillEnd = true; utilitySkillDef.canceledFromSprinting = false; utilitySkillDef.fullRestockOnAssign = true; utilitySkillDef.interruptPriority = InterruptPriority.PrioritySkill; utilitySkillDef.isBullets = false; utilitySkillDef.isCombatSkill = false; utilitySkillDef.mustKeyPress = false; utilitySkillDef.noSprint = false; utilitySkillDef.rechargeStock = 1; utilitySkillDef.requiredStock = 1; utilitySkillDef.shootDelay = 0.5f; utilitySkillDef.stockToConsume = 1; utilitySkillDef.skillDescriptionToken = "AAAAAAAAAAAAAAAAAAAAAAAAAAAAA"; utilitySkillDef.skillName = "AAAAAAAAAAAAAA"; utilitySkillDef.skillNameToken = "AAAAAAAAAAAA"; //utilitySkillDef.icon = Sprite.Create(this.OVERCLOCK, new Rect(0, 0, this.OVERCLOCK.width, this.OVERCLOCK.height), new Vector2(.5f, .5f)); LoadoutAPI.AddSkillDef(utilitySkillDef); SkillFamily utilitySkillFamily = skillLocator.utility.skillFamily; utilitySkillFamily.variants[0] = new SkillFamily.Variant { skillDef = utilitySkillDef, unlockableName = "", viewableNode = new ViewablesCatalog.Node(utilitySkillDef.skillNameToken, false, null) }; }
internal static void SetupAttributes() { var oldDef = Resources.Load <SkillDef>("skilldefs/crocobody/CrocoDisease"); myDef = CloneSkillDef(oldDef); var nametoken = "CLASSICITEMS_SCEPCROCO_DISEASENAME"; var desctoken = "CLASSICITEMS_SCEPCROCO_DISEASEDESC"; var namestr = "Plague"; LanguageAPI.Add(nametoken, namestr); LanguageAPI.Add(desctoken, Language.GetString(oldDef.skillDescriptionToken) + "\n<color=#d299ff>SCEPTER: Victims become walking sources of Plague.</color>"); myDef.skillName = namestr; myDef.skillNameToken = nametoken; myDef.skillDescriptionToken = desctoken; myDef.icon = Resources.Load <Sprite>("@ClassicItems:Assets/ClassicItems/icons/scepter/croco_firediseaseicon.png"); LoadoutAPI.AddSkillDef(myDef); var mshPrefab = Resources.Load <GameObject>("Prefabs/NetworkedObjects/MushroomWard"); var dwPrefabPrefab = new GameObject("CIDiseaseAuraPrefabPrefab"); dwPrefabPrefab.AddComponent <TeamFilter>(); dwPrefabPrefab.AddComponent <MeshFilter>().mesh = mshPrefab.GetComponentInChildren <MeshFilter>().mesh; dwPrefabPrefab.AddComponent <MeshRenderer>().material = UnityEngine.Object.Instantiate(mshPrefab.GetComponentInChildren <MeshRenderer>().material); dwPrefabPrefab.GetComponent <MeshRenderer>().material.SetVector("_TintColor", new Vector4(1.5f, 0.3f, 1f, 0.3f)); dwPrefabPrefab.AddComponent <NetworkedBodyAttachment>().forceHostAuthority = true; var dw = dwPrefabPrefab.AddComponent <DiseaseWard>(); dw.rangeIndicator = dwPrefabPrefab.GetComponent <MeshRenderer>().transform; dw.interval = 1f; diseaseWardPrefab = dwPrefabPrefab.InstantiateClone("CIDiseaseWardAuraPrefab"); UnityEngine.Object.Destroy(dwPrefabPrefab); }
/// <summary> /// Copies skilldef settings from beingCopiedFrom to copier. /// </summary> /// <param name="beingCopiedFrom"></param> /// <param name="copier"></param> public static void CopySkillDefSettings(SkillDef beingCopiedFrom, SkillDef copier) { copier.activationState = beingCopiedFrom.activationState; copier.activationStateMachineName = beingCopiedFrom.activationStateMachineName; copier.baseMaxStock = beingCopiedFrom.baseMaxStock; copier.baseRechargeInterval = beingCopiedFrom.baseRechargeInterval; copier.beginSkillCooldownOnSkillEnd = beingCopiedFrom.beginSkillCooldownOnSkillEnd; copier.canceledFromSprinting = beingCopiedFrom.canceledFromSprinting; copier.dontAllowPastMaxStocks = beingCopiedFrom.dontAllowPastMaxStocks; copier.forceSprintDuringState = beingCopiedFrom.forceSprintDuringState; copier.fullRestockOnAssign = beingCopiedFrom.fullRestockOnAssign; copier.icon = beingCopiedFrom.icon; copier.interruptPriority = beingCopiedFrom.interruptPriority; copier.isCombatSkill = beingCopiedFrom.isCombatSkill; copier.keywordTokens = beingCopiedFrom.keywordTokens; copier.mustKeyPress = beingCopiedFrom.mustKeyPress; copier.canceledFromSprinting = beingCopiedFrom.canceledFromSprinting; copier.rechargeStock = beingCopiedFrom.rechargeStock; copier.cancelSprintingOnActivation = beingCopiedFrom.cancelSprintingOnActivation; copier.skillDescriptionToken = beingCopiedFrom.skillDescriptionToken; copier.skillName = beingCopiedFrom.skillName; copier.skillNameToken = beingCopiedFrom.skillNameToken; copier.stockToConsume = beingCopiedFrom.stockToConsume; }
public override void DefsLoaded() { //1. Preparing settings UpdateSettings(); //2. Adding Tech Tab to Pawns //ThingDef injection stolen from the work of notfood for Psychology var zombieThinkTree = DefDatabase <ThinkTreeDef> .GetNamedSilentFail("Zombie"); IEnumerable <ThingDef> things = (from def in DefDatabase <ThingDef> .AllDefs where def.race?.intelligence == Intelligence.Humanlike && (zombieThinkTree == null || def.race.thinkTreeMain != zombieThinkTree) select def); List <string> registered = new List <string>(); foreach (ThingDef t in things) { if (t.inspectorTabsResolved == null) { t.inspectorTabsResolved = new List <InspectTabBase>(1); } t.inspectorTabsResolved.Add(InspectTabManager.GetSharedInstance(typeof(ITab_PawnKnowledge))); if (t.comps == null) { t.comps = new List <CompProperties>(1); } t.comps.Add(new CompProperties_Knowledge()); registered.Add(t.defName); } InspectPaneUtility.Reset(); //3. Preparing knowledge support infrastructure //a. Things everyone knows UniversalWeapons.AddRange(DefDatabase <ThingDef> .AllDefs.Where(x => x.IsWeapon)); UniversalCrops.AddRange(DefDatabase <ThingDef> .AllDefs.Where(x => x.plant != null && x.plant.Sowable)); //b. Minus things unlocked on research ThingFilter lateFilter = new ThingFilter(); foreach (ResearchProjectDef tech in DefDatabase <ResearchProjectDef> .AllDefs) { tech.InferSkillBias(); tech.CreateStuff(lateFilter, unlocked); foreach (ThingDef weapon in tech.UnlockedWeapons()) { UniversalWeapons.Remove(weapon); } foreach (ThingDef plant in tech.UnlockedPlants()) { UniversalCrops.Remove(plant); } } ; //c. Also removing atipical weapons List <string> ForbiddenWeaponTags = TechDefOf.WeaponsNotBasic.weaponTags; UniversalWeapons.RemoveAll(x => SplitSimpleWeapons(x, ForbiddenWeaponTags)); List <ThingDef> garbage = new List <ThingDef>(); garbage.Add(TechDefOf.WeaponsNotBasic); //d. Classifying pawn backstories PawnBackgroundUtility.BuildCache(); //e. Telling humans what's going on ThingCategoryDef knowledgeCat = TechDefOf.Knowledge; IEnumerable <ThingDef> codifiedTech = DefDatabase <ThingDef> .AllDefs.Where(x => x.IsWithinCategory(knowledgeCat)); if (Prefs.LogVerbose || FullStartupReport) { Log.Message($"[HumanResources] Codified technologies: {codifiedTech.Select(x => x.label).ToStringSafeEnumerable()}"); Log.Message($"[HumanResources] Basic crops: {UniversalCrops.ToStringSafeEnumerable()}"); Log.Message($"[HumanResources] Basic weapons: {UniversalWeapons.ToStringSafeEnumerable()}"); Log.Message($"[HumanResources] Basic weapons that require training: {SimpleWeapons.ToStringSafeEnumerable()}"); Log.Warning($"[HumanResources] Basic weapons tags: {SimpleWeapons.Where(x => !x.weaponTags.NullOrEmpty()).SelectMany(x => x.weaponTags).Distinct().ToStringSafeEnumerable()}"); if (FullStartupReport) { Log.Warning("[HumanResources] Backstories classified by TechLevel:"); for (int i = 0; i < 8; i++) { TechLevel level = (TechLevel)i; IEnumerable <string> found = PawnBackgroundUtility.TechLevelByBackstory.Where(e => e.Value == level).Select(e => e.Key); if (!found.EnumerableNullOrEmpty()) { Log.Message($"- {level.ToString().CapitalizeFirst()} ({found.EnumerableCount()}): {found.ToStringSafeEnumerable()}"); } } Log.Warning("[HumanResources] Techs classified by associated skill:"); var skills = DefDatabase <SkillDef> .AllDefsListForReading.GetEnumerator(); while (skills.MoveNext()) { SkillDef skill = skills.Current; IEnumerable <string> found = TechTracker.FindTechs(skill).Select(x => x.Tech.label); Log.Message($"- {skill.LabelCap} ({found.EnumerableCount()}): {found.ToStringSafeEnumerable()}"); } } } else { Log.Message($"[HumanResources] This is what we know: {codifiedTech.EnumerableCount()} technologies processed, {UniversalCrops.Count()} basic crops, {UniversalWeapons.Count()} basic weapons + {SimpleWeapons.Count()} that require training."); } //4. Filling gaps on the database //a. TechBook dirty trick, but only now this is possible! TechDefOf.TechBook.stuffCategories = TechDefOf.UnfinishedTechBook.stuffCategories = TechDefOf.LowTechCategories.stuffCategories; TechDefOf.TechDrive.stuffCategories = TechDefOf.HiTechCategories.stuffCategories; garbage.Add(TechDefOf.LowTechCategories); garbage.Add(TechDefOf.HiTechCategories); //b. Filling main tech category with subcategories foreach (ThingDef t in lateFilter.AllowedThingDefs.Where(t => !t.thingCategories.NullOrEmpty())) { foreach (ThingCategoryDef c in t.thingCategories) { c.childThingDefs.Add(t); if (!knowledgeCat.childCategories.NullOrEmpty() && !knowledgeCat.childCategories.Contains(c)) { knowledgeCat.childCategories.Add(c); } } } //c. Populating knowledge recipes and book shelves foreach (RecipeDef r in DefDatabase <RecipeDef> .AllDefs.Where(x => x.ingredients.Count == 1 && x.fixedIngredientFilter.AnyAllowedDef == null)) { r.fixedIngredientFilter.ResolveReferences(); r.defaultIngredientFilter.ResolveReferences(); } foreach (ThingDef t in DefDatabase <ThingDef> .AllDefs.Where(x => x.thingClass == typeof(Building_BookStore))) { t.building.fixedStorageSettings.filter.ResolveReferences(); t.building.defaultStorageSettings.filter.ResolveReferences(); } //d. Removing temporary defs from database. foreach (ThingDef def in garbage) { AccessTools.Method(typeof(DefDatabase <ThingDef>), "Remove").Invoke(this, new object[] { def }); } }
void xmlToList(string skillList) { XmlDocument document = new XmlDocument (); document.LoadXml (skillList); XmlNodeList skList = document.DocumentElement.GetElementsByTagName ("heroSkills"); for (int i = 0; i<skList.Count; i++) { XmlNode node = skList [i]; XmlNodeList childs = node.ChildNodes; string type = node.Attributes ["type"].Value; for (int j = 0; j<childs.Count; j++) { XmlNode childNode = childs [j]; string id = childNode.Attributes["id"].Value; string name = childNode.Attributes ["name"].Value; int level = int.Parse (childNode.Attributes ["level"].Value); bool isPassive = "true".Equals (childNode.Attributes ["isPassive"].Value); int silver = int.Parse (childNode.Attributes ["buySilver"].Value); int gold = int.Parse (childNode.Attributes ["buyGold"].Value); int commandPoints = int.Parse (childNode.Attributes ["buyCp"].Value); long learnTime = int.Parse (childNode.Attributes ["learnTime"].Value); int coolDown = int.Parse (childNode.Attributes ["coolDown"].Value); string comboPartners = (null != childNode.Attributes["comboPartner"])? childNode.Attributes ["comboPartner"].Value: string.Empty; string comboPartnersSkillID = (null != childNode.Attributes["partnerSkillID"])? childNode.Attributes ["partnerSkillID"].Value: string.Empty; Hashtable number = new Hashtable (); string description = string.Empty; XmlNodeList nodes = childNode.ChildNodes; int buffDurationTime = 0; int skillDurationTime = 0; // List<Effect> passiveEffectList = new List<Effect>(); // // List<Effect> buffEffectList = new List<Effect>(); Hashtable passiveEffectTable = new Hashtable ();; Hashtable buffEffectTable = new Hashtable ();; for (int k = 0; k<nodes.Count; k++) { XmlNode nd = nodes [k]; if ("effect".Equals (nd.Name)) { passiveEffectTable = getEffectTable(nd); } if ("num".Equals (nd.Name)) { skillDurationTime = int.Parse(nd.Attributes["time"].Value); number = getEffectTable(nd); } if ("buff".Equals (nd.Name)) { buffDurationTime = int.Parse(nd.Attributes["time"].Value); buffEffectTable = getEffectTable(nd); }// end if }// end for k SkillDef sd = new SkillDef(); sd.id = id; sd.name = name; sd.unlockLv = level; sd.isPassive = isPassive; sd.silver = silver; sd.gold = gold; sd.commandPoints = commandPoints; sd.comboPartners = comboPartners; sd.comboPartnersSkillID = comboPartnersSkillID; sd.description = description; sd.learnTime = learnTime; sd.buffDurationTime = buffDurationTime; sd.skillDurationTime = skillDurationTime; if (isPassive) { sd.passiveEffectTable = passiveEffectTable; } else { sd.funcName = childNode.Attributes ["id"].Value; sd.coolDown = coolDown; sd.activeEffectTable = number; sd.target = (null != childNode.Attributes["target"])? childNode.Attributes ["target"].Value: string.Empty; sd.buffEffectTable = buffEffectTable; }// end if allHeroSkillHash [id] = sd; }// end for j }// end for i }
public void initByArtoo(ICollection activeSkills, ICollection passiveSkills) { foreach(Hashtable h in activeSkills){ SkillDef sd = new SkillDef(); sd.id = h["uid"] as string; sd.name = h["name"] as string; sd.unlockLv = int.Parse(h["level"] as string); sd.silver = int.Parse(h["buySilver"] as string); sd.gold = int.Parse(h["buyGold"] as string); sd.commandPoints = int.Parse(h["buyCp"] as string); sd.comboPartners = h["comboPartner"] as string; sd.comboPartnersSkillID = h["partnerSkillID"] as string; sd.description = h["description"] as string; sd.learnTime = int.Parse(h["learnTime"] as string); sd.buffDurationTime = 0; sd.skillDurationTime = 0; //-------active sd.isPassive = false; sd.coolDown = int.Parse(h["coolDown"] as string); sd.funcName = h["uid"] as string; sd.target = (null != h["target"])? h ["target"] as string: string.Empty; sd.activeEffectTable = getEffectTable(h,"sk_"); if(h["sk_time"] != null){ sd.skillDurationTime = int.Parse(h["sk_time"] as string); } sd.buffEffectTable = getEffectTable(h,"buff_"); if(h["buff_time"]!=null){ sd.buffDurationTime = int.Parse(h["buff_time"] as string); } allHeroSkillHash [sd.id] = sd; } foreach(Hashtable h in passiveSkills){ SkillDef sd = new SkillDef(); sd.id = h["uid"] as string; sd.name = h["name"] as string; sd.unlockLv = int.Parse(h["level"] as string); sd.silver = int.Parse(h["buySilver"] as string); sd.gold = int.Parse(h["buyGold"] as string); sd.commandPoints = int.Parse(h["buyCp"] as string); sd.comboPartners = h["comboPartner"] as string; sd.comboPartnersSkillID = h["partnerSkillID"] as string; sd.description = h["description"] as string; sd.learnTime = int.Parse(h["learnTime"] as string); sd.buffDurationTime = 0; sd.skillDurationTime = 0; sd.isPassive = true; sd.passiveEffectTable = getEffectTable(h,"effect_"); allHeroSkillHash [sd.id] = sd; } }
public override void ApplySkillAfterDelay(SkillDef s, Vector3? start, List<Target> ts, float delay) { base.ApplySkillAfterDelay(s, start, ts, activeInitiative - delay); }
public virtual void SkillApplied(SkillDef s) { }
public float ModifyStat( float stat, SkillDef scontext, Character ccontext, Character tcontext, Equipment econtext ) { float ignore=0; return ModifyStat( stat, scontext, ccontext, tcontext, econtext, ref ignore ); }
override public void SkillApplied(SkillDef s) { base.SkillApplied(s); }
public override void SkillApplied(SkillDef s) { base.SkillApplied(s); if(s.character != null && s.character == activeCharacter) { if(!(s is MoveSkillDef)) { activeCharacterHasActed = true; float cost = perActionCTCostStat != null ? s.character.GetStat(perActionCTCostStat, defaultPerActionCTCost) : defaultPerActionCTCost; if(coalesceCTDecrements) { pendingCTDecrement += cost; } else { s.character.AdjustBaseStat(ctStat, -cost); } } } }
protected bool TrySpecialMoveResponse(float direction, PathNode endNode, Character[] chars, Region lineMove, SkillDef cause) { bool success=false; PathNode pn = endNode; var shoveChars = new List<Character>(); shoveChars.AddRange(chars); int tries = 0; const int tryLimit = 20; do { pn = lineMove.GetNextLineMovePosition(this, pn, direction, 1, 1, 0); //hack: slide on through untargetable characters if(pn != null) { var hereChars = map.CharactersAt(pn.pos); var nextChars = hereChars.Where(c => !c.IsMounting && c.IsTargetable).ToArray(); //don't push people onto a tile with untargetable characters if(nextChars.Length == 0 && hereChars.Where(c => !c.IsTargetable).Count() == 0) { success = true; } else { shoveChars.AddRange(nextChars); } // Debug.Log("ncs "+nextChars.Length); } // Debug.Log("pn "+pn); tries++; } while(pn != null && !success && tries < tryLimit); if(tries >= tryLimit) { Debug.LogError("too many tries"); return false; } if(success) { Region responseMove = new Region(); responseMove.type = RegionType.LineMove; responseMove.interveningSpaceType = InterveningSpaceType.LineMove; responseMove.radiusMaxF = Formula.Constant(1); responseMove.xyDirectionF = Formula.Constant(direction); responseMove.canCrossWalls = false; responseMove.canCrossEnemies = false; responseMove.canHaltAtEnemies = false; responseMove.Owner = cause; responseMove.facingLock = FacingLock.Cardinal; for(int i = shoveChars.Count-1; i >= 0; i--) { Character sc = shoveChars[i]; sc.SpecialMove( sc.TilePosition, false, "collision_response", responseMove, 25, 25, cause ); } } return success; }
public override void SkillApplied(SkillDef s) { base.SkillApplied(s); // Deactivate(s.character); }
public virtual void Deactivate(Character c=null, object context=null) { if(c == null) { c = activeCharacter; } if(activeCharacter == c) { c.SendMessage("Deactivate", context, SendMessageOptions.RequireReceiver); map.BroadcastMessage( "DeactivatedCharacter", c, SendMessageOptions.DontRequireReceiver ); activeCharacter = null; pendingDeactivationSkill = null; pendingDeactivationCharacter = null; } }
public virtual void DeactivateAfterSkillApplication(Character c, SkillDef skill) { pendingDeactivationSkill = skill; pendingDeactivationCharacter = c; }
public void Awake() { Chat.AddMessage("A5 Skill Component Booted"); SurvivorAPI.SurvivorCatalogReady += delegate(object s, EventArgs e) { int bodyIndex = BodyCatalog.FindBodyIndex("BomberBody"); SkillLocator skillLocator = BodyCatalog.GetBodyPrefab(bodyIndex).GetComponent <SkillLocator>(); SkillFamily SkillFamily = BodyCatalog.GetBodyPrefab(bodyIndex).GetComponent <SkillFamily>(); SkillFamily skillFamily = skillLocator.primary.skillFamily; SkillFamily skillFamily2 = skillLocator.secondary.skillFamily; SkillFamily skillFamily3 = skillLocator.utility.skillFamily; SkillFamily skillFamily4 = skillLocator.special.skillFamily; SkillDef defaultSkill = skillFamily.variants[skillFamily.defaultVariantIndex].skillDef; SkillDef secondskill = skillFamily2.variants[skillFamily2.defaultVariantIndex].skillDef; SkillDef thirdskill = skillFamily3.variants[skillFamily3.defaultVariantIndex].skillDef; SkillDef fourthskill = skillFamily4.variants[skillFamily4.defaultVariantIndex].skillDef; //Alt skills //SkillFamily altskillFamily = skillLocator.primary.skillFamily; //SkillFamily altskillFamily2 = skillLocator.secondary.skillFamily; //SkillFamily altskillFamily3 = skillLocator.utility.skillFamily; //SkillFamily altskillFamily4 = skillLocator.special.skillFamily; //SkillDef altdefaultSkill = skillFamily.variants[skillFamily.defaultVariantIndex].skillDef; //SkillDef altsecondskill = skillFamily2.variants[skillFamily2.defaultVariantIndex].skillDef; //SkillDef altthirdskill = skillFamily3.variants[skillFamily3.defaultVariantIndex].skillDef; //SkillDef altfourthskill = skillFamily4.variants[skillFamily4.defaultVariantIndex].skillDef; //Primary defaultSkill.beginSkillCooldownOnSkillEnd = true; defaultSkill.baseRechargeInterval = 1f; defaultSkill.rechargeStock = 1; defaultSkill.baseMaxStock = 6; defaultSkill.stockToConsume = 1; defaultSkill.requiredStock = 1; defaultSkill.canceledFromSprinting = false; defaultSkill.noSprint = false; defaultSkill.skillNameToken = "Shotgun"; defaultSkill.skillDescriptionToken = "Fire a shotgun that does <style=cIsDamage>15 base damage per bullet</style>. Has six rounds."; defaultSkill.activationState = new EntityStates.SerializableEntityStateType(typeof(EntityStates.BomberRework.Shotgun.FireShotgun)); //alt primary //Secondary secondskill.beginSkillCooldownOnSkillEnd = true; secondskill.baseRechargeInterval = 3; secondskill.rechargeStock = 1; secondskill.baseMaxStock = 1; secondskill.stockToConsume = 1; secondskill.requiredStock = 1; secondskill.canceledFromSprinting = false; secondskill.noSprint = false; secondskill.skillNameToken = "Shotgun Slug"; secondskill.skillDescriptionToken = "Fire a shotgun slug that does <style=cIsDamage>50 base damage</style>."; //Fire a snare that pulls all enemies in and deals damage secondskill.activationState = new EntityStates.SerializableEntityStateType(typeof(EntityStates.BomberRework.Shotgun.FireSlug)); //Utility // thirdskill.activationState = (EntityStates.SerializableEntityStateType)BodyCatalog.FindBodyPrefab("BomberBody").GetComponent<SkillLocator>().utility.activationState; thirdskill.beginSkillCooldownOnSkillEnd = true; thirdskill.baseRechargeInterval = 12; thirdskill.rechargeStock = 1; thirdskill.baseMaxStock = 1; thirdskill.stockToConsume = 1; thirdskill.requiredStock = 1; thirdskill.canceledFromSprinting = true; thirdskill.noSprint = false; thirdskill.skillNameToken = "Repurposed MED-E"; //thumper thirdskill.skillDescriptionToken = "Summon a repurposed MED-E bot that does <style=cIsDamage>12 base damage</style> on first hit, but does <style=cIsDamage>15 base damage</style> on second hit and onward. Also called Thumpers."; //thumpa dump thumpa dump thirdskill.noSprint = false; thirdskill.activationState = new EntityStates.SerializableEntityStateType(typeof(EntityStates.Treebot.Weapon.CreatePounder)); //SkillFamily utility = skillFamily3; //utility.activationState = new EntityStates.SerializableEntityStateType(EntityState.Instantiate(74).GetType()); //Special //fourthskill.activationState = (EntityStates.SerializableEntityStateType)BodyCatalog.FindBodyPrefab("BomberBody").GetComponent<SkillLocator>().special.activationState; fourthskill.beginSkillCooldownOnSkillEnd = true; fourthskill.baseRechargeInterval = 5; fourthskill.rechargeStock = 1; fourthskill.stockToConsume = 1; fourthskill.requiredStock = 1; fourthskill.baseMaxStock = 1; fourthskill.canceledFromSprinting = false; fourthskill.noSprint = false; fourthskill.skillNameToken = "Disperse Pellets"; fourthskill.skillDescriptionToken = "Launch a <style=cIsDamage>stun</style> pellet canister that does <style=cIsDamage>37 base damage</style> on hit, then explodes into 5 pellets that do <style=cIsDamage>7 base damage</style>."; fourthskill.mustKeyPress = true; fourthskill.activationState = new EntityStates.SerializableEntityStateType(typeof(EntityStates.Toolbot.AimStunDrone)); //SkillFamily special = skillFamily4; EntityStates.Treebot.Weapon //Reflection.SetFieldValue(special, "activationState", new SerializableEntityStateType(EntityState.Instantiate(6).GetType())); }; }
public void SpecialMove( Vector3 start, bool animateMoveToStart, string moveType, Region lineMove, float specialMoveSpeedXY, float specialMoveSpeedZ, SkillDef cause ) { specialMoveType = moveType; specialMoveExecutor.XYSpeed = specialMoveSpeedXY; specialMoveExecutor.ZSpeedDown = specialMoveSpeedZ; List<Character> collidedCharacters = new List<Character>(); float direction=-1, amount=-1, remaining=-1, dropDistance=-1; PathNode movePath = lineMove.GetLineMove( out direction, out amount, out remaining, out dropDistance, collidedCharacters, this, start ); //move executor special move (path) specialMoveExecutor.Activate(); CharacterSpecialMoveReport rep = new CharacterSpecialMoveReport( this, moveType, lineMove, cause, start, movePath, direction, amount, remaining, dropDistance, collidedCharacters ); map.BroadcastMessage( "WillSpecialMoveCharacter", rep, SendMessageOptions.DontRequireReceiver ); MoveExecutor.MoveFinished movedToStart = (srcStart, srcEndNode, srcFinishedNicely) => { Debug.Log("src finished nicely? "+srcFinishedNicely); specialMoveExecutor.SpecialMoveTo( movePath, (src, endNode, finishedNicely) => { Debug.Log( "specially moved character "+this.name+ " by "+moveType+ " from "+start+ " in dir "+direction+ " node "+movePath+ " into "+( collidedCharacters.Count==0 ? "nobody": ""+collidedCharacters.Count+" folks" )+ " left over "+remaining+ " dropped "+dropDistance ); map.BroadcastMessage( "DidSpecialMoveCharacter", rep, SendMessageOptions.DontRequireReceiver ); specialMoveExecutor.Deactivate(); var allChars = map.CharactersAt(endNode.pos); var otherChars = allChars.Where(c => c != this && c != mountedCharacter).ToArray(); Character[] chars = null; if(otherChars.Length > 0) { //try to fix myself chars = new Character[]{IsMounting ? mountedCharacter : this}; } if(chars != null && chars.Length > 0) { //if any collisions left over between me and somebody else... Debug.Log("fix collisions"); bool success = false; if(!success) { Debug.Log("try straight"); success = TrySpecialMoveResponse(direction, endNode, chars, lineMove, cause); } if(!success) { Debug.Log("try left"); success = TrySpecialMoveResponse(SRPGUtil.WrapAngle(direction+90), endNode, chars, lineMove, cause); } if(!success) { Debug.Log("try right"); success = TrySpecialMoveResponse(SRPGUtil.WrapAngle(direction-90), endNode, chars, lineMove, cause); } if(!success) { Debug.Log("try back"); success = TrySpecialMoveResponse(SRPGUtil.WrapAngle(direction+180), endNode, chars, lineMove, cause); } if(!success) { Debug.LogError("Can't shove "+chars.Length+" chars out of the way!"); } } } ); }; if(start != TilePosition) { if(animateMoveToStart) { specialMoveExecutor.SpecialMoveTo( new PathNode(start, null, 0), movedToStart, 3.0f ); } else { specialMoveExecutor.ImmediatelyMoveTo( new PathNode(start, null, 0), movedToStart, 3.0f ); } } else { movedToStart(start, new PathNode(start, null, 0), true); } }
private IntInputWidget <Dictionary <SkillDef, int> > CreateSkillGainsInput(SkillDef sd) { return(new IntInputWidget <Dictionary <SkillDef, int> >(this.Backstory.skillGainsResolved, Util.GetLabel(sd), d => d[sd], (d, i) => d[sd] = i)); }
public static HackingResult ComputeHackResult(Pawn hacker, SkillDef mainSkill, SkillDef secondarySkill, float chanceToSucceedPerSkillLevel) { int mainSkillLevel = 0; if (hacker.skills.GetSkill(mainSkill).TotallyDisabled == false) { mainSkillLevel = hacker.skills.GetSkill(mainSkill).level; } int secondarySkillLevel = 0; if ((secondarySkill != null) && (hacker.skills.GetSkill(secondarySkill).TotallyDisabled == false)) { secondarySkillLevel = hacker.skills.GetSkill(secondarySkill).level; } int bestSkillLevel = Math.Max(mainSkillLevel, secondarySkillLevel); if (bestSkillLevel < 3) { return HackingResult.MajorFail; } else if (bestSkillLevel >= 17) { return HackingResult.MajorSuccess; } else { float luck = Rand.Value * 100; if (luck < bestSkillLevel * chanceToSucceedPerSkillLevel) { // Hacking successful. return HackingResult.MinorSuccess; } else { // Bad luck. return HackingResult.MinorFail; } } }
protected virtual void SkillApplied(SkillDef s) { //react against each effect currentReactedSkill = s; List <StatEffectRecord> fx = s.lastEffects; bool reacts = false; foreach (StatEffectRecord se in fx) { currentReactedEffect = se; if (ReactsAgainst(s, se)) { reacts = true; break; } } if (reacts) { ClearLastEffects(); currentTargetCharacter = s.character; Target target = (new Target()).Character(s.character); reactionTargetRegion.Owner = this; reactionEffectRegion.Owner = this; PathNode[] reactionTiles = PathNodesForTarget( target, reactionTargetRegion, reactionEffectRegion, character.TilePosition, Quaternion.Euler(0, character.Facing, 0) ); targetCharacters = new List <Character>() { s.character }; SetArgsFromTarget(target, null, ""); targetCharacters = reactionEffectRegion.CharactersForTargetedTiles(reactionTiles); if (targetCharacters.Contains(currentTargetCharacter)) { ApplyPerApplicationEffectsTo( reactionApplicationEffects.effects, new List <Character>() { currentTargetCharacter } ); if (reactionEffects.Length > 0) { ApplyEffectsTo( target, null, reactionEffects, targetCharacters, "reaction.hitType", character.TilePosition ); } map.BroadcastMessage( "SkillApplied", this, SendMessageOptions.DontRequireReceiver ); } } currentReactedSkill = null; currentReactedEffect = null; }
public override void SkillApplied(SkillDef s) { base.SkillApplied(s); if(s.character != activeCharacter) { return; } //FIXME: too eager, put something in the UI Deactivate(s.character); }
private int sortByLevel(SkillDef sd1, SkillDef sd2) { if(sd1.unlockLv > sd2.unlockLv) { return 1; } else if(sd1.unlockLv == sd2.unlockLv) { string s1 = sd1.id.Substring(sd1.id.Length - 1); string s2 = sd2.id.Substring(sd2.id.Length - 1); return string.Compare(s1, s2); } else if(sd1.unlockLv < sd2.unlockLv) { return -1; } return 0; }
public void SkillDeactivated(SkillDef s) { if(s == pendingDeactivationSkill) { if(pendingDeactivationCharacter == activeCharacter) { Deactivate(pendingDeactivationCharacter, s); } pendingDeactivationSkill = null; pendingDeactivationCharacter = null; } }