internal static void SetStolenForever(this BSExtraDataList entry) { var ownerBad = TESForm.LookupFormById(StolenForeverOwnerFormId); if (ownerBad == null) { return; } var ownerPtr = ownerBad.Cast <TESForm>(); if (ownerPtr == IntPtr.Zero) { return; } var ptr = entry.Cast <BSExtraDataList>(); if (ptr != IntPtr.Zero) { Memory.InvokeCdecl(BetterStealingPlugin._SetListOwner_Func, ptr, ownerPtr); return; } throw new ArgumentNullException(); }
/// <summary> /// Checks if the given actor is a creature by checking if it /// has the creature keyword. /// </summary> /// <param name="actor">The Actor</param> /// <returns><c>true</c> if creature, <c>false</c> if not</returns> public static bool IsCreature([NotNull] this Actor actor) { if (_creatureKeyword != null) { return(actor.Race.HasKeyword(_creatureKeyword)); } var keywordForm = TESForm.LookupFormById(CreatureKeywordID); if (keywordForm is BGSKeyword keyword) { _creatureKeyword = keyword; } return(actor.Race.HasKeyword(_creatureKeyword)); }
private List <NiAVObject> GetHelmetNodes(NiNode root) { var ls = new List <NiAVObject>(); if (root != null) { bool hadHead = false; foreach (var ch in root.Children) { if (ch == null) { continue; } string nm = ch.Name.Text; if (string.IsNullOrEmpty(nm) || !nm.EndsWith("]")) { continue; } int ix = nm.LastIndexOf('('); if (ix < 0) { continue; } nm = nm.Substring(ix + 1); ix = nm.IndexOf(')'); if (ix < 0) { continue; } nm = nm.Substring(0, ix); uint formId = 0; if (!uint.TryParse(nm, System.Globalization.NumberStyles.HexNumber, null, out formId)) { continue; } var form = TESForm.LookupFormById(formId); if (form == null || form.FormType != FormTypes.Armor) { continue; } uint biped = NetScriptFramework.Memory.ReadUInt32(form.Address + 0x1B8); if ((biped & this.IsHelmetBipedMask) != 0 && (biped & this.NotHelmetBipedMask) == 0) { if ((biped & this.IsHeadBipedMask) != 0) { hadHead = true; } ls.Add(ch); } } this.HadHeadInHelmetNodes = hadHead; } return(ls); }