private bool GetIsOpen() { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(false); } Identity identity = Identity; IntPtr pItems = N3EngineClientAnarchy_t.GetInventoryVec(pEngine, ref identity); return(pItems != IntPtr.Zero); }
private unsafe float GetCurrentTime() { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(0); fixed(Identity *pIdentity = &Identity) fixed(Identity * pOwner = &Owner) { return(N3EngineClientAnarchy_t.GetBuffCurrentTime(pEngine, pIdentity, pOwner) / 100); } }
public static unsafe List <Item> GetContainerItems(Identity identity) { List <Item> items = new List <Item>(); IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(items); } IntPtr pInvList = N3EngineClientAnarchy_t.GetContainerInventoryList(pEngine, &identity); if (pInvList == IntPtr.Zero) { return(items); } IntPtr pItems = N3EngineClientAnarchy_t.GetInventoryVec(pEngine, ref identity); if (pItems == IntPtr.Zero) { return(items); } List <IntPtr> containerInvList = (*(StdObjList *)pInvList).ToList(); int i = 0; foreach (IntPtr pItem in (*(StdStructVector *)pItems).ToList(sizeof(IntPtr))) { IntPtr pActualItem = *(IntPtr *)pItem; if (pActualItem != IntPtr.Zero) { try { int lowId = (*(ItemMemStruct *)pActualItem).LowId; int highId = (*(ItemMemStruct *)pActualItem).HighId; int ql = (*(ItemMemStruct *)pActualItem).QualityLevel; Identity unqiueIdentity = (*(ItemMemStruct *)pActualItem).UniqueIdentity; Identity slot = *((Identity *)(containerInvList[i] + 0x8)); items.Add(new Item(lowId, highId, ql, unqiueIdentity, slot)); } catch {} i++; } } return(items); }
private unsafe void TeamViewModule_SlotJoinTeamRequestFailed_Hook(IntPtr pThis, ref Identity identity) { try { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return; } N3EngineClientAnarchy_t.TeamJoinRequest(pEngine, ref identity, true); } catch (Exception) { } }
internal unsafe DummyItem(Identity identity) { Identity none = Identity.None; IntPtr pEngine = N3Engine_t.GetInstance(); IntPtr pItem = N3EngineClientAnarchy_t.GetItemByTemplate(pEngine, identity, &none); if (pItem == IntPtr.Zero) { throw new Exception($"DummyItem::DummyItem - Unable to locate item {identity}"); } Pointer = pItem; Identity = (*(MemStruct *)pItem).Identity; Name = Utils.UnsafePointerToString((*(MemStruct *)pItem).Name); }
public static unsafe bool CreateDummyItemID(int lowId, int highId, int ql, out Identity dummyItemId) { ACGItem itemInfo = new ACGItem { LowId = lowId, HighId = highId, QL = ql }; IntPtr pEngine = N3Engine_t.GetInstance(); fixed(Identity *pDummyItemId = &dummyItemId) { return(N3EngineClientAnarchy_t.CreateDummyItemID(pEngine, pDummyItemId, &itemInfo)); } }
public void StopAttack() { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return; } N3EngineClientAnarchy_t.StopAttack(pEngine); if (Pets.Length > 0) { Pets.Follow(); } }
public bool IsAvailable() { if (Time.NormalTime < _nextAttack) { return(false); } IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(false); } //Why is this inverted lol? return(!N3EngineClientAnarchy_t.IsSecondarySpecialAttackAvailable(pEngine, _stat)); }
public unsafe bool UseOn(Identity target) { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(false); } bool successful = N3EngineClientAnarchy_t.SecondarySpecialAttack(pEngine, &target, _stat); if (successful) { _nextAttack = Time.NormalTime + ATTACK_DELAY_BUFFER; } return(successful); }
private static unsafe List <Perk> GetFullPerkMap() { List <Perk> perks = new List <Perk>(); IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(perks); } foreach (PerkMemStruct perkMemStruct in N3EngineClientAnarchy_t.GetFullPerkMap(pEngine)->ToList <PerkMemStruct>()) { Perk perk = new Perk(perkMemStruct.Instance, perkMemStruct.TemplateInstance, perkMemStruct.PrerequisitePerkInstance, perkMemStruct.PerkType, perkMemStruct.AllowedProfessions, perkMemStruct.ActionInstance, perkMemStruct.RequiredExperience); perks.Add(perk); } // I'm not doing the following in the Perk constructor because we need the full perk // map to do it and querying the entire perk map again in the constructor is too expensive string currentName = "NoName"; int currentLevel = 1; foreach (Perk perk in perks.OrderBy(perk => perk.Instance)) { if (perk.Name != currentName) { currentName = perk.Name; currentLevel = 1; } perk.Level = currentLevel; currentLevel++; } return(perks); }
internal unsafe DummyItem(int lowId, int highId, int ql) { Identity none = Identity.None; IntPtr pEngine = N3Engine_t.GetInstance(); if (!CreateDummyItemID(lowId, highId, ql, out Identity dummyItemId)) { throw new Exception($"Failed to create dummy item. LowId: {lowId}\tLowId: {highId}\tLowId: {ql}"); } IntPtr pItem = N3EngineClientAnarchy_t.GetItemByTemplate(pEngine, dummyItemId, &none); if (pItem == IntPtr.Zero) { throw new Exception($"DummyItem::DummyItem - Unable to locate item. LowId: {lowId}\tLowId: {highId}\tLowId: {ql}"); } Pointer = pItem; Identity = (*(MemStruct *)pItem).Identity; Name = Utils.UnsafePointerToString((*(MemStruct *)pItem).Name); }
//Must be called from game loop! private static void ChangeMovement(MovementAction action) { if (action == MovementAction.LeaveSit) { Network.Send(new CharacterActionMessage() { Action = CharacterActionType.StandUp }); } else { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return; } N3EngineClientAnarchy_t.MovementChanged(pEngine, action, 0, 0, true); } }
public unsafe bool Use(SimpleChar target, bool setTarget = false, bool packetOnly = false) { if (target == null) { target = DynelManager.LocalPlayer; } if (setTarget) { target.Target(); } if (packetOnly) { Network.Send(new CharacterActionMessage() { Action = CharacterActionType.UsePerk, Target = target.Identity, Parameter1 = Identity.Instance, Parameter2 = (int)Hash }); EnqueuePendingPerk(this); return(true); } else { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(false); } Identity identity = Identity; return(N3EngineClientAnarchy_t.PerformSpecialAction(pEngine, ref identity)); } }
public static unsafe void SetTarget(Identity target, bool packetOnly = false) { if (!packetOnly) { TargetingModule_t.SetTarget(ref target, false); IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return; } N3EngineClientAnarchy_t.SelectedTarget(pEngine, ref target); } else { Network.Send(new LookAtMessage() { Target = target }); } }
private static unsafe List <PerkAction> GetPerkActions() { List <PerkAction> perks = new List <PerkAction>(); IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(perks); } foreach (IntPtr pAction in N3EngineClientAnarchy_t.GetSpecialActionList(pEngine)->ToList()) { SpecialActionMemStruct specialAction = *(SpecialActionMemStruct *)pAction; if (specialAction.Identity.Type != IdentityType.PerkHash) { continue; } perks.Add(new PerkAction(specialAction.TemplateIdentity, specialAction.Identity.Instance)); } return(perks.OrderBy(perk => perk.Identity.Instance).ToList()); }
public bool Remove() { IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) return(false); }
public unsafe bool MeetsUseReqs(SimpleChar target = null) { IntPtr pEngine; if ((pEngine = N3Engine_t.GetInstance()) == IntPtr.Zero) { return(false); } IntPtr pCriteria = N3EngineClientAnarchy_t.GetItemActionInfo(Pointer, ItemActionInfo.UseCriteria); //Should I return true or false here? hmm. if (pCriteria == IntPtr.Zero) { return(true); } bool[] unk = new bool[12]; byte prevReqsMet = 0; SimpleChar skillCheckChar = DynelManager.LocalPlayer; CriteriaSource criteriaSource = CriteriaSource.Self; //Default the end result to true unk[0] = true; foreach (IntPtr pReq in ((StdStructVector *)(pCriteria + 0x4))->ToList(0xC)) { int param1 = *(int *)(pReq); int param2 = *(int *)(pReq + 0x4); UseCriteriaOperator op = *(UseCriteriaOperator *)(pReq + 0x8); bool metReq = false; if (op == UseCriteriaOperator.OnUser) { criteriaSource = CriteriaSource.User; skillCheckChar = DynelManager.LocalPlayer; continue; } else if (op == UseCriteriaOperator.OnTarget) { criteriaSource = CriteriaSource.Target; skillCheckChar = target; continue; } if (target != null || criteriaSource != CriteriaSource.Target) { bool result; bool lastResult; switch (op) { case UseCriteriaOperator.EqualTo: case UseCriteriaOperator.LessThan: case UseCriteriaOperator.GreaterThan: case UseCriteriaOperator.BitAnd: case UseCriteriaOperator.NotBitAnd: if ((Stat)param1 == Stat.TargetFacing) { SimpleChar fightingTarget; if ((fightingTarget = DynelManager.LocalPlayer.FightingTarget) != null) { bool isFacing = fightingTarget.IsFacing(DynelManager.LocalPlayer); metReq = (param2 == 1) ? !isFacing : isFacing; } } else if ((Stat)param1 == Stat.MonsterData) // Ignore this check because something funky is going on with it. { metReq = true; } else { int stat = skillCheckChar.GetStat((Stat)param1); switch (op) { case UseCriteriaOperator.EqualTo: metReq = (stat == param2); break; case UseCriteriaOperator.LessThan: metReq = (stat < param2); break; case UseCriteriaOperator.GreaterThan: metReq = (stat > param2); break; case UseCriteriaOperator.BitAnd: metReq = (stat & param2) == param2; break; case UseCriteriaOperator.NotBitAnd: metReq = (stat & param2) != param2; break; default: //Chat.WriteLine($"Unknown Criteria -- Param1: {param1} - Param2: {param2} - Op: {op}"); break; } } break; case UseCriteriaOperator.And: if (prevReqsMet < 2) { return(false); } lastResult = unk[--prevReqsMet]; result = unk[--prevReqsMet]; //We can early exit on AND if (!result || !lastResult) { return(false); } metReq = true; break; case UseCriteriaOperator.Or: if (prevReqsMet < 2) { return(false); } lastResult = unk[--prevReqsMet]; result = unk[--prevReqsMet]; metReq = result || lastResult; break; case UseCriteriaOperator.Not: if (prevReqsMet < 1) { return(false); } metReq = !unk[--prevReqsMet]; break; case UseCriteriaOperator.HasWornItem: metReq = Inventory.Inventory.Find(param2, out Item item) && (item.Slot.Type == IdentityType.ArmorPage || item.Slot.Type == IdentityType.ImplantPage || item.Slot.Type == IdentityType.WeaponPage); break; case UseCriteriaOperator.IsNpc: if (param2 == 3) { metReq = target.IsNpc; } break; case UseCriteriaOperator.HasRunningNano: metReq = skillCheckChar.Buffs.Any(x => x.Identity.Instance == param2); break; case UseCriteriaOperator.HasNotRunningNano: metReq = skillCheckChar.Buffs.All(x => x.Identity.Instance != param2); break; case UseCriteriaOperator.HasPerk: metReq = N3EngineClientAnarchy_t.HasPerk(pEngine, param2); break; case UseCriteriaOperator.IsPerkUnlocked: metReq = true; break; case UseCriteriaOperator.HasRunningNanoLine: metReq = skillCheckChar.Buffs.Contains((NanoLine)param2); break; case UseCriteriaOperator.HasNotRunningNanoLine: metReq = !skillCheckChar.Buffs.Contains((NanoLine)param2); break; case UseCriteriaOperator.HasNcuFor: //TODO: check against actual nano program NCU cost metReq = skillCheckChar.GetStat(Stat.MaxNCU) - skillCheckChar.GetStat(Stat.CurrentNCU) > 0; break; case UseCriteriaOperator.TestNumPets: Pet[] pets = DynelManager.LocalPlayer.Pets; if (pets.Any(x => x.Type == PetType.Unknown)) { metReq = false; break; } PetType type = PetType.Unknown; if (param2 == 1) { type = PetType.Attack; } else if (param2 == 1001) { type = PetType.Heal; } else if (param2 == 2001) { type = PetType.Support; } else if (param2 == 4001) { type = PetType.Social; } metReq = !pets.Any(x => x.Type == type); break; case UseCriteriaOperator.HasWieldedItem: if (criteriaSource == CriteriaSource.Target) { metReq = true; } else { metReq = Inventory.Inventory.Items.Any(i => (i.LowId == param2 || i.HighId == param2) && (i.Slot.Instance >= (int)EquipSlot.Weap_Hud1 && i.Slot.Instance <= (int)EquipSlot.Imp_Feet)); } break; case UseCriteriaOperator.IsSameAs: //Not sure what these parmas correlate to but I don't know any other item that uses this operator either. if (param1 == 1 && param2 == 3) { if (target == null) { metReq = false; } else { metReq = target.Identity == DynelManager.LocalPlayer.Identity; } } break; case UseCriteriaOperator.AlliesNotInCombat: if (Team.Members.Contains(skillCheckChar.Identity)) { Identity[] teamMembers = Team.Members.Select(x => x.Identity).ToArray(); metReq = !DynelManager.Characters.Any(x => x.FightingTarget != null && teamMembers.Contains(x.FightingTarget.Identity)); } else { metReq = !DynelManager.Characters.Any(x => x.FightingTarget != null && (x.FightingTarget.Identity == skillCheckChar.Identity || x.FightingTarget.Identity == DynelManager.LocalPlayer.Identity)); } break; case UseCriteriaOperator.IsOwnPet: metReq = DynelManager.LocalPlayer.Pets.Contains(skillCheckChar.Identity); break; default: //Chat.WriteLine($"Unknown Criteria -- Param1: {param1} - Param2: {param2} - Op: {op}"); return(false); } } else { metReq = true; } unk[prevReqsMet++] = metReq; //Chat.WriteLine($"Name: {Name} -- Unk -- Param1: {param1} - Param2: {param2} - Op: {op} MetReq: {metReq} ------ {prevReqsMet} -- {unk[0]} {unk[1]} {unk[2]} {unk[3]}"); } return(unk[0]); }
//This will likely be made internal once I provide a way of accessing the inventory of all types of containers. //For now just utilize this if you REALLY need the contents of something random like contracts (and i guess bank too) public static unsafe List <Item> GetItems(Identity container) { List <Item> items = new List <Item>(); IntPtr pEngine = N3Engine_t.GetInstance(); if (pEngine == IntPtr.Zero) { return(items); } IntPtr pItems = N3EngineClientAnarchy_t.GetInventoryVec(pEngine, ref container); if (pItems == IntPtr.Zero) { return(items); } int i = 0; foreach (IntPtr pItem in (*(StdStructVector *)pItems).ToList(sizeof(IntPtr))) { //Resolve proper type for item slot IdentityType slotType = IdentityType.None; switch (container.Type) { case IdentityType.SimpleChar: slotType = IdentityType.Inventory; //Correct the slot type to match the equipment pages if (i <= (int)EquipSlot.Weap_Deck6) { slotType = IdentityType.WeaponPage; } else if (i <= (int)EquipSlot.Cloth_LeftFinger) { slotType = IdentityType.ArmorPage; } else if (i <= (int)EquipSlot.Imp_Feet) { slotType = IdentityType.ImplantPage; } else if (i <= (int)EquipSlot.Social_LeftWeap) { slotType = IdentityType.SocialPage; } break; case IdentityType.Bank: slotType = IdentityType.BankByRef; break; } IntPtr pActualItem = *(IntPtr *)pItem; if (pActualItem != IntPtr.Zero) { try { int lowId = (*(ItemMemStruct *)pActualItem).LowId; int highId = (*(ItemMemStruct *)pActualItem).HighId; int ql = (*(ItemMemStruct *)pActualItem).QualityLevel; Identity unqiueIdentity = (*(ItemMemStruct *)pActualItem).UniqueIdentity; items.Add(new Item(lowId, highId, ql, unqiueIdentity, new Identity(slotType, i))); } catch { } } i++; } return(items); }