public NullMovement(CreatureObject parent) : base(parent) { _position = _creature.SpawnPosition; _rotation = _creature.SpawnRotation; parent.OnSpawn += NullMovement_OnSpawn; }
public InventoryItem(Rectangle _Bounds, Container _Parent, CreatureObject _InventoryOwner) : base(_Bounds) { this.itemObject = null; this.parent = _Parent; this.inventoryOwner = _InventoryOwner; }
public void AddPartyEnemy(CreatureObject PartyEnemy) { if (PartyEnemy == null) { throw new ApplicationException("Trying to add party enemy, but that creature does not exist."); } if (!Enemies.Contains(PartyEnemy)) { Enemies.Add(PartyEnemy); } if (CanPartySee(PartyEnemy)) { int EnemyArmorRank = PartyEnemy.Script.GetArmorRank(PartyEnemy.Script.GetItemInSlot(CLRScriptBase.INVENTORY_SLOT_CARMOUR, PartyEnemy.ObjectId)); if ((EnemyArmorRank == CLRScriptBase.ARMOR_RANK_HEAVY || EnemyArmorRank == CLRScriptBase.ARMOR_RANK_MEDIUM) && !EnemyHardTargets.Contains(PartyEnemy)) { EnemyHardTargets.Add(PartyEnemy); } if (EnemyArmorRank == CLRScriptBase.ARMOR_RANK_LIGHT || EnemyArmorRank == CLRScriptBase.ARMOR_RANK_NONE) { EnemySoftTargets.Add(PartyEnemy); } if (_LooksLikeSpellcaster(PartyEnemy)) { EnemySpellcasters.Add(PartyEnemy); } } else { EnemiesLost.Add(PartyEnemy); } }
public CreatureObject GetNearest(CreatureObject Source, List <CreatureObject> Creatures) { AreaObject SourceArea = Source.Area; Vector3 SourcePos = Source.Position; CreatureObject RetValue = null; if (Creatures.Count == 0) { return(RetValue); } float ShortestDistance = -1.0f; foreach (CreatureObject Target in Creatures) { // Only interested in objects in the same area. if (SourceArea != Target.Area) { continue; } Vector3 TargetPos = Target.Position; float Distance = MathOps.DistanceSq(SourcePos, TargetPos); if ((ShortestDistance < 0) || (Distance < ShortestDistance)) { ShortestDistance = Distance; RetValue = Target; } } return(RetValue); }
public void RemovePartyEnemy(CreatureObject PartyEnemy) { if (Enemies.Contains(PartyEnemy)) { Enemies.Remove(PartyEnemy); } if (EnemyHardTargets.Contains(PartyEnemy)) { EnemyHardTargets.Remove(PartyEnemy); } if (EnemySoftTargets.Contains(PartyEnemy)) { EnemySoftTargets.Remove(PartyEnemy); } if (EnemySpellcasters.Contains(PartyEnemy)) { EnemySpellcasters.Remove(PartyEnemy); } if (EnemyHealers.Contains(PartyEnemy)) { EnemyHealers.Remove(PartyEnemy); } }
public CreatureObject GetFarthest(CreatureObject Source, List <CreatureObject> Creatures) { AreaObject SourceArea = Source.Area; Vector3 SourcePos = Source.Position; CreatureObject RetValue = null; if (Creatures.Count == 0) { return(RetValue); } float LongestDistance = -1.0f; foreach (CreatureObject Target in Creatures) { // Only interested in objects in the same area. if (SourceArea != Target.Area) { continue; } Vector3 TargetPos = Target.Position; float Distance = MathOps.DistanceSq(SourcePos, TargetPos); if ((LongestDistance < 0) || ((Distance > LongestDistance) && (Distance < 100.0f * 100.0f))) // 100 meters is about as far as we'd expect combat to reach. { LongestDistance = Distance; RetValue = Target; } } return(RetValue); }
//Dient nur zum wechseln! Ohne Senden! EHER für host public void changeItemPosition(CreatureObject _InventoryOwner, int _OldPosition, int _NewPosition) { ItemObject var_ItemToChange = null; foreach (ItemObject var_ItemObject in this.items) { if (var_ItemObject.PositionInInventory == _OldPosition) { var_ItemToChange = var_ItemObject; break; } } if (var_ItemToChange != null) { if (_NewPosition == -1) { this.items.Remove(var_ItemToChange); var_ItemToChange.PositionInInventory = _NewPosition; var_ItemToChange.Position = new Microsoft.Xna.Framework.Vector3(40, 40, 0) + _InventoryOwner.Position; World.world.addObject(var_ItemToChange); } else { //TODO: Gucke ob an __NewPosition kein objekt! var_ItemToChange.PositionInInventory = _NewPosition; } } }
/// <summary> /// This function seeks signs of a spellcaster, looking for visible paraphenalia. Visibility is assumed, and should be checked separately. /// </summary> /// <param name="Creature">The creature to be assessed</param> /// <returns>True if there is some visible paraphenalia that suggests spellcasting.</returns> private bool _LooksLikeSpellcaster(CreatureObject Creature) { int VisibleSpellbooks = 0; foreach (uint Item in Creature.Script.GetItemsInInventory(Creature.ObjectId)) { if (Creature.Script.GetTag(Item) == "ACR_MOD_SPELLBOOK" || Creature.Script.GetTag(Item) == "ACR_MOD_HOLYSYMBOL") { VisibleSpellbooks++; } if (Creature.Script.GetHasInventory(Item) == CLRScriptBase.TRUE) { foreach (uint ContainerContents in Creature.Script.GetItemsInInventory(Item)) { if (Creature.Script.GetTag(ContainerContents) == "ACR_MOD_SPELLBOOK" || Creature.Script.GetTag(ContainerContents) == "ACR_MOD_HOLYSYMBOL") { VisibleSpellbooks--; } } } } if (VisibleSpellbooks > 0) { return(true); } return(false); }
private void WO_MOB_OnKilled(CreatureObject obj) { var awards = _threat.ToAward; if (awards.Length > 0) { var bonus = (uint)(_stats.Level * (awards.Length - 1)); if (_creature.LootID > 0) { if (DataMgr.Select(_creature.LootID, out DB_Loot loot)) { new WO_Loot(loot, this, awards[0].Player, _manager); } } awards[0].Player.Stats.AddExp(TalentMarkId.Combat, (uint)_stats.Level * Constants.LevelExpMultipler, bonus); for (uint i = 1; i < awards.Length; i++) { awards[i].Player.Stats.AddExp(TalentMarkId.Combat, (uint)(_stats.Level * Constants.LevelExpMultipler / i), bonus / i); } } if ((_data.Flags & 1) == 1) { Despawn(); } else { Destroy(); } }
public override bool SelectTarget(out CreatureObject target) { target = null; if (_threat.Count > 0) { foreach (var item in _threat.ToArray()) { if (!item.Key.IsSpawned || item.Key.IsDead || Vector3.DistanceSquared(item.Key.Position, _creature.Position) > Constants.MaxSpellsDistanceSquared) { if (item.Key.IsSpawned) { _creature.View.SetCombat(item.Key.Owner, false); } _threat.Remove(item.Key); } } } foreach (var item in _creature.Manager.GetPlayersInRadius(_creature, Constants.MaxInteractionDistance)) { if (!_threat.ContainsKey(item)) { _creature.View.SetCombat(item.Owner, true); _threat[item] = item.Player.Char.Level; } } return((target = _threat.OrderByDescending(x => x.Value).FirstOrDefault().Key) != null); }
void GenerateSplicedCreature() { Debug.Log("Generating new Spliced Creature"); List <int> bodyPartIndecies = new List <int> { 0, 1, 2, 3, 4 }; int varieties = bodyPartIndecies.Count / splicedDNA.Count; int remainder = bodyPartIndecies.Count - (varieties * splicedDNA.Count); Debug.Log("Varieties: " + varieties); List <int> varietyCounter = new List <int> (); for (int i = 0; i < splicedDNA.Count; i++) { varietyCounter.Add(varieties); } while (remainder > 0) { varietyCounter[Random.Range(0, varietyCounter.Count)]++; remainder--; } Debug.Log("Variety Counter: " + varietyCounter[0] + ", " + varietyCounter[1]); for (int i = 0; i < varietyCounter.Count; i++) { while (varietyCounter[i] > 0) { int newIndex = Random.Range(0, bodyPartIndecies.Count); switch (bodyPartIndecies[newIndex]) { case 0: head = splicedDNA[i].creatureType; jaw = splicedDNA[i].creatureType; break; case 1: body = splicedDNA[i].creatureType; break; case 2: tail = splicedDNA[i].creatureType; break; case 3: frontLegs = splicedDNA[i].creatureType; break; case 4: backLegs = splicedDNA[i].creatureType; break; } varietyCounter[i]--; bodyPartIndecies.RemoveAt(newIndex); } } }
public bool TryGetCreature(ushort guid, out CreatureObject obj) { obj = null; if (_nvObjects.TryGetValue(guid, out var ret) || _plObjects.TryGetValue(guid, out ret)) { obj = ret as CreatureObject; } return(obj != null); }
public override void OnEnter(AIState previousState) { base.OnEnter(previousState); this.Priority = 0; characterHealth = CreatureObject.GetComponent <CharacterHealth>(); characterHealth.DealtDamage += OnDealtDamage; }
public PetMovement(CreatureObject parent) : base(parent) { _entry = new SyncEntry(); _position = _creature.SpawnPosition; _rotation = _creature.SpawnRotation; parent.OnSpawn += PetMovement_OnSpawn; parent.OnDestroy += PetMovement_OnDestroy; }
/// <summary> /// Loads the creature from file. /// </summary> /// <returns>The status from file.</returns> /// <param name="status">Status.</param> public static CreatureObject LoadCreatureFromFile(CreatureObject _object) { m_Path = Load("cc_preset"); if (m_Path.Length == 0) { return(_object); } return(LoadObjectFromFile <CreatureObject>(_object)); }
/// <summary> /// Saves the creature to file. /// </summary> /// <param name="status">Status.</param> public static void SaveCreatureToFile(CreatureObject _object, string owner) { m_Path = Save(owner, "cc_preset"); if (m_Path.Length == 0) { return; } SaveObjectToFile <CreatureObject>(_object); }
public static bool CanCast(CreatureObject creature, TargetEntry target) { DB_Spell spell; DB_SpellEffect main; CreatureObject targetCO; if (DataMgr.Select(target.SpellID, out spell) && spell.Effects.TryGetValue(0, out main) && creature.Stats.Energy >= main.Data01) { if (target.HasGuid) { if (creature.Server.Objects.TryGetCreature((ushort)target.Guid, out targetCO) && !targetCO.IsDead) { if (Vector3.DistanceSquared(targetCO.Position, creature.Position) <= main.Data02 * main.Data02) { var isSelf = targetCO == creature; if ((main.Target & SpellTarget.Creature) != 0) { if (targetCO.IsPlayer) { if ((main.Target & SpellTarget.Self) != 0 && isSelf) { return(true); } else if ((main.Target & SpellTarget.Player) != 0) { return(targetCO.IsPlayer && !isSelf); } } else { return(targetCO.HasStats); } } else if ((main.Target & SpellTarget.Player) != 0) { if (isSelf) { return((main.Target & SpellTarget.Self) != 0); } return(targetCO.IsPlayer); } else if ((main.Target & SpellTarget.Self) != 0) { return(isSelf); } } } } else if ((main.Target & SpellTarget.Position) != 0) { return(Vector3.DistanceSquared(target.Position, creature.Position) <= main.Data02 * main.Data02); } } return(false); }
/// <summary> /// Promote a creature in the party to party leader. /// </summary> /// <param name="PartyLeader">Supplies the new party leader.</param> public void PromotePartyLeader(CreatureObject PartyLeader) { if (PartyLeader != null) { if (PartyLeader.Party != this) { throw new ApplicationException(String.Format( "Trying to promote creature {0} to party leader, but it is not in this party.", PartyLeader)); } } this.PartyLeader = PartyLeader; }
public InventoryField(CreatureObject _InventoryOwner, int _FieldId, Rectangle _Bounds) : base(_Bounds) { this.inventoryOwner = _InventoryOwner; this.fieldId = _FieldId; /*this.itemSpace = new Component(new Rectangle(this.Bounds.X, this.Bounds.Y, this.Bounds.Width, this.Bounds.Height)); * this.itemSpace.BackgroundGraphicPath = "Gui/Menu/Inventory/InventoryItemSpace"; * this.add(this.itemSpace);*/ //this.BackgroundGraphicPath = "Gui/Menu/Inventory/InventoryItemSpace"; this.item = null; }
public ScriptedMovement(ushort id, CreatureObject parent) : base(parent) { _state = 0; _entry = new SyncEntry(); _direction = Vector3.UnitZ; _position = _creature.SpawnPosition; _rotation = _creature.SpawnRotation.ToRadians(); if (DataMgr.Select(id, out _entries)) { Execute(); } parent.OnSpawn += ScriptedMovement_OnSpawn; parent.OnDestroy += ScriptedMovement_OnDestroy; }
public ScriptedMovement(ScriptedMovement original, CreatureObject clone) : base(clone) { _speed = original._speed; _state = original._state; _entry = new SyncEntry(); _entries = original._entries; _current = original._current; _waiting = original._waiting; _position = original.Position; _rotation = original.Rotation; _direction = original._direction; clone.OnSpawn += ScriptedMovement_OnSpawn; clone.OnDestroy += ScriptedMovement_OnDestroy; }
public void AddToSelection() { if (tubeSelection) { CreatureObject creature = SpliceManager.instance.allCreatureTypes[buttonSelectedIndex]; if (selectedCreatures.Contains(creature)) { selectedCreatures.Remove(creature); } else { selectedCreatures.Add(creature); } tubeButtons[buttonSelectedIndex].GetComponent <UIButtonSelected> ().Selected(); buttonGenerate.interactable = selectedCreatures.Count >= 2; } }
/// <summary> /// Get the C# creature object for the given object id. /// </summary> /// <param name="ObjectId">Supplies the object id to look up.</param> /// <param name="CreateIfNeeded">If true, the C# Creature object for /// the creature is created if the object didn't already exist.</param> /// <returns>The corresponding C# Creature object, else null.</returns> public CreatureObject GetCreatureObject(uint ObjectId, bool CreateIfNeeded = false) { CreatureObject Creature = (CreatureObject)GetGameObject(ObjectId, GameObjectType.Creature); if (Creature != null) { return(Creature); } else if (CreateIfNeeded && Script.GetObjectType(ObjectId) == CLRScriptBase.OBJECT_TYPE_CREATURE) { return(new CreatureObject(ObjectId, this)); } else { return(null); } }
public WO_VoidZone(CreatureObject onwer, DB_Spell spell, DB_SpellEffect main) : base(onwer.Manager.GetNewGuid() | Constants.DRObject, onwer.Manager) { _main = main; _spell = spell; _onwer = onwer; _position = onwer.Position; _ticks = (int)main.AttackModifer; OnUpdate += WO_VoidZone_OnUpdate; OnDestroy += WO_VoidZone_OnDestroy; _targets = new List <CreatureObject>(); _addedTargets = new List <CreatureObject>(); _removedTargets = new List <CreatureObject>(); _update = _period = (int)(main.LevelModifer * 1000) / _ticks; _hasAura = spell.Effects.Values.Any(x => x.Type == SpellEffectType.AuraModifier); Spawn(); }
public EquipmentField(CreatureObject _InventoryOwner, int _FieldId, List <ItemEnum> _AcceptedItemTypes, Rectangle _Bounds) : base(_Bounds) { this.inventoryOwner = _InventoryOwner; this.fieldId = _FieldId; this.acceptedItemTypes = _AcceptedItemTypes; this.AllowsDropIn = true; /*this.itemSpace = new Component(new Rectangle(this.Bounds.X, this.Bounds.Y, this.Bounds.Width, this.Bounds.Height)); * this.itemSpace.BackgroundGraphicPath = "Gui/Menu/Inventory/InventoryItemSpace"; * this.add(this.itemSpace);*/ //this.BackgroundGraphicPath = "Gui/Menu/Inventory/InventoryItemSpace"; this.item = null; }
//Sendet Änderung zum clienten bzw. server. public void changeItemPosition(CreatureObject _InventoryOwner, ItemObject _ItemObject, int _NewPosition) { int var_OldPosition = _ItemObject.PositionInInventory; _ItemObject.PositionInInventory = _NewPosition; if (var_OldPosition == _NewPosition) { } else { //Sende jeweilige Änderung if (Configuration.Configuration.isHost) { } else { Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.CreatureInventoryItemPositionChangeMessage(_InventoryOwner.Id, var_OldPosition, _NewPosition), GameMessageImportance.VeryImportant); } } }
public void dropItem(CreatureObject _InventoryOwner, ItemObject _ItemObject) { if (Configuration.Configuration.isHost) { } else { if (Configuration.Configuration.isSinglePlayer) { changeItemPosition(_InventoryOwner, _ItemObject.PositionInInventory, -1); } else { Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.CreatureInventoryItemPositionChangeMessage(_InventoryOwner.Id, _ItemObject.PositionInInventory, -1), GameMessageImportance.VeryImportant); } } this.items.Remove(_ItemObject); this.InventoryChanged = true; inventoryChangedEvent.Invoke(this, new ItemChangedArg(_ItemObject)); }
private void WO_VoidZone_OnDestroy() { if (_hasAura) { foreach (var item in _targets) { if (item.IsSpawned) { item.Stats.RemoveAuraEffects(_guid); } } } _onwer = null; _targets.Clear(); _addedTargets.Clear(); _removedTargets.Clear(); _targets = null; _addedTargets = null; _removedTargets = null; }
public void SetCreature(SplicedCreature splicedCreature) { oldCreature = splicedCreature; head.sprite = splicedCreature.head.head; jaw.sprite = splicedCreature.jaw.jaw; body.sprite = splicedCreature.body.body; tail.sprite = splicedCreature.tail.tail; frontLegsR.sprite = splicedCreature.frontLegs.frontLegsR; frontLegsL.sprite = splicedCreature.frontLegs.frontLegsL; backLegsR.sprite = splicedCreature.backLegs.backLegsR; backLegsL.sprite = splicedCreature.backLegs.backLegsL; creatureObjectSetup = splicedCreature.body; LoadCreatureObjectPivots(); LoadCreatureObjectColliders(splicedCreature); jaw.transform.localPosition = splicedCreature.head.jawPivot; body.transform.localScale = new Vector3(splicedCreature.body.uniformScale, splicedCreature.body.uniformScale, splicedCreature.body.uniformScale); creatureDamage = splicedCreature.head.damage + splicedCreature.jaw.damage + splicedCreature.body.damage + splicedCreature.tail.damage + splicedCreature.frontLegs.damage + splicedCreature.frontLegs.damage + splicedCreature.backLegs.damage + splicedCreature.backLegs.damage + splicedCreature.body.damage; creatureHealth = splicedCreature.head.health + splicedCreature.jaw.health + splicedCreature.body.health + splicedCreature.tail.health + splicedCreature.frontLegs.health + splicedCreature.frontLegs.health + splicedCreature.backLegs.health + splicedCreature.backLegs.health + splicedCreature.body.health; maxCreatureHealth = creatureHealth; healthBar.fillAmount = creatureHealth / maxCreatureHealth; }
public void itemDropedInInventory(CreatureObject _InventoryOwner, ItemObject _ItemObject, int _NewPosition) { if (this.items.Contains(_ItemObject)) { this.changeItemPosition(_InventoryOwner, _ItemObject, _NewPosition); } else { //TODO: Kommt wohl von wo anders... anderes Inventar usw.. //this.addItemObjectToInventory(_ItemObject); /*if (_InventoryOwner.Equipment.Contains(_ItemObject)) * { * //Sende jeweilige Änderung * if (Configuration.Configuration.isHost) * { * * } * else * { * Event.EventList.Add(new Event(new GameLibrary.Connection.Message.CreatureEquipmentToInventoryMessage(_InventoryOwner.Id, _ItemObject.PositionInInventory, _NewPosition), GameMessageImportance.VeryImportant)); * } * //_InventoryOwner.Equipment.Remove((EquipmentObject)_ItemObject); * //this.addItemObjectToInventory(_ItemObject); * }*/ if (_ItemObject is EquipmentObject) { if (_InventoryOwner.Body.containsEquipmentObject((EquipmentObject)_ItemObject)) { Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.CreatureEquipmentToInventoryMessage(_InventoryOwner.Id, _ItemObject.PositionInInventory, _NewPosition), GameMessageImportance.VeryImportant); } else { //_InventoryOwner enthält das Equip nicht im Body. Kommt woanders her! } } } }
//Dient nur zum wechseln! Ohne Senden! EHER für host public void changeItemPosition(CreatureObject _InventoryOwner, int _OldPosition, int _NewPosition) { ItemObject var_ItemToChange = null; foreach (ItemObject var_ItemObject in this.items) { if (var_ItemObject.PositionInInventory == _OldPosition) { var_ItemToChange = var_ItemObject; break; } } if (var_ItemToChange != null) { if (_NewPosition == -1) { this.items.Remove(var_ItemToChange); var_ItemToChange.PositionInInventory = _NewPosition; var_ItemToChange.Position = new Microsoft.Xna.Framework.Vector3(40, 40, 0) + _InventoryOwner.Position; GameLibrary.Model.Map.World.World.world.addObject(var_ItemToChange); } else { //TODO: Gucke ob an __NewPosition kein objekt! var_ItemToChange.PositionInInventory = _NewPosition; } } }
public void dropItem(CreatureObject _InventoryOwner, ItemObject _ItemObject) { this.items.Remove(_ItemObject); this.InventoryChanged = true; if (Configuration.Configuration.isHost) { } else { Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.CreatureInventoryItemPositionChangeMessage(_InventoryOwner.Id, _ItemObject.PositionInInventory, -1), GameMessageImportance.VeryImportant); } }
public void itemDropedInInventory(CreatureObject _InventoryOwner, ItemObject _ItemObject, int _NewPosition) { if (this.items.Contains(_ItemObject)) { this.changeItemPosition(_InventoryOwner, _ItemObject, _NewPosition); } else { //TODO: Kommt wohl von wo anders... anderes Inventar usw.. //this.addItemObjectToInventory(_ItemObject); /*if (_InventoryOwner.Equipment.Contains(_ItemObject)) { //Sende jeweilige Änderung if (Configuration.Configuration.isHost) { } else { Event.EventList.Add(new Event(new GameLibrary.Connection.Message.CreatureEquipmentToInventoryMessage(_InventoryOwner.Id, _ItemObject.PositionInInventory, _NewPosition), GameMessageImportance.VeryImportant)); } //_InventoryOwner.Equipment.Remove((EquipmentObject)_ItemObject); //this.addItemObjectToInventory(_ItemObject); }*/ if (_ItemObject is EquipmentObject) { if (_InventoryOwner.Body.containsEquipmentObject((EquipmentObject)_ItemObject)) { Configuration.Configuration.networkManager.addEvent(new GameLibrary.Connection.Message.CreatureEquipmentToInventoryMessage(_InventoryOwner.Id, _ItemObject.PositionInInventory, _NewPosition), GameMessageImportance.VeryImportant); } else { //_InventoryOwner enthält das Equip nicht im Body. Kommt woanders her! } } } }