public float resolveAction(Data.Action action) { Entity e; if (!entityList.TryGetValue(action.entityId, out e)) { Debug.LogError("resolveAction() - can't find entity with id " + action.entityId); } if (action is MovementAction) { if (!action.isActionSkiped()) { MovementAction movementAction = (MovementAction)action; solver.resolveMovement(e, movementAction.path); return(movementAction.path.Length * 0.2f); } // TODO else give MP } else if (action is SpellAction) { if (!action.isActionSkiped()) { SpellAction spellAction = (SpellAction)action; Cell target = grid.GetCell(spellAction.targetCellId); SpellData spell = DataManager.SPELL_DATA[spellAction.spellId]; solver.resolveSpell(spell, e, target, spellAction is QuickSpellAction); return(0.5f); } // TODO else give AP } return(0); }
void OnGUI() { Repaint(); EditorUtility.SetDirty(this); popupselction = EditorGUILayout.Popup(popupselction, currentSpellsAsArray); if (workingSpell == null) { if (popupselction != 0) { try { workingSpell = SpellAction.ParseAndCreateSpell("Spells/" + currentSpellsAsArray[popupselction]); } catch { workingSpell = null; } } } else { workingSpell.DrawEditor(); if (GUILayout.Button("Save")) { FileStream f = File.Open("Assets/Resources/Spells/" + currentSpellsAsArray[popupselction] + ".json", FileMode.OpenOrCreate); string contents = workingSpell.convertToJSONString(); f.Write(Encoding.ASCII.GetBytes(contents), 0, Encoding.ASCII.GetByteCount(contents)); f.Close(); } } }
void OnGUI() { Repaint(); EditorUtility.SetDirty(this); popupselction = EditorGUILayout.Popup(popupselction, currentSpellsAsArray); if (workingSpell == null) { if (popupselction != 0) { try { workingSpell = SpellAction.ParseAndCreateSpell("Spells/" + currentSpellsAsArray[popupselction]); } catch { workingSpell = null; } } } else { workingSpell.DrawEditor(); if (GUILayout.Button("Save")) { FileStream f = File.Open("Assets/Resources/Spells/" + currentSpellsAsArray[popupselction] + ".json", FileMode.OpenOrCreate); string contents = workingSpell.convertToJSONString(); f.Write(Encoding.ASCII.GetBytes(contents), 0, Encoding.ASCII.GetByteCount(contents)); f.Close(); } } }
private void OnCollisionEnter2D(Collision2D collision) { if (collision.gameObject.CompareTag("Spell")) { if (collision.gameObject.GetComponent <SpellActionBomb>() != null) { SpellActionBomb SpellProjectile = collision.gameObject.GetComponent <SpellActionBomb>(); if (SpellProjectile.SpellType == Weakness) { Life--; } if (SpellProjectile.SpellType == GreatWeakness) { Life = 0; } } else { SpellAction SpellProjectile = collision.gameObject.GetComponent <SpellAction>(); if (SpellProjectile.SpellType == Weakness) { Life--; } if (SpellProjectile.SpellType == GreatWeakness) { Life = 0; } } } }
public override void Execute(Action action) { SpellAction sp = SpellAction.ParseAndCreateSpell(actionID); sp.character = character; character.AddAction(sp); action(); }
public static void DeepCopySpellAction(SpellAction to, SpellAction from) { to.input = from.input; to.targetAnim = from.targetAnim; to.throwAnim = from.throwAnim; to.castTime = from.castTime; to.focusCost = from.focusCost; to.staminaCost = from.staminaCost; }
public override void StartAttack(GameObject attackTarget) { if (attackTarget == null) { return; } if (attackTarget is GameLiving && GameServer.ServerRules.IsAllowedToAttack(this, (GameLiving)attackTarget, true) == false) { return; } if (Brain is IControlledBrain) { if ((Brain as IControlledBrain).AggressionState == eAggressionState.Passive) { return; } GamePlayer playerowner; if ((playerowner = ((IControlledBrain)Brain).GetPlayerOwner()) != null) { playerowner.Stealth(false); } } TargetObject = attackTarget; if (TargetObject.Realm == 0 || Realm == 0) { m_lastAttackTickPvE = m_CurrentRegion.Time; } else { m_lastAttackTickPvP = m_CurrentRegion.Time; } if (m_attackers.Count == 0) { if (SpellTimer == null) { SpellTimer = new SpellAction(this); } if (!SpellTimer.IsAlive) { SpellTimer.Start(1); } } if (Brain is TurretMainPetTankBrain) { base.StartAttack(TargetObject); } }
void OnGUI() { for (int i = 0; i < SpellEditor.currentSpells.Count; i++) { if (GUILayout.Button(SpellEditor.currentSpells[i])) { SpellEditor.workingSpell = SpellAction.ParseAndCreateSpell(("Spells/" + SpellEditor.currentSpells[i]).Replace(".txt", "")); GUI.FocusWindow(0); Close(); } } }
public static SpellAction ParseAndCreateSpell(string fileName) { if (allAbilites == null) { allAbilites = new Dictionary <string, SpellAction>(); } LuaFile file = new LuaFile(); file.Setup("Spells/" + fileName); SpellAction newSpell = new SpellAction(); newSpell.name = file.GetValue("Name").ToString(); newSpell.targetType = (TargetType)Convert.ToInt32(file.GetValue("TargetType")); newSpell.targetFilter = (TargetFilter)Convert.ToInt32(file.GetValue("TargetFilter")); newSpell.targetRange = (TargetRange)Convert.ToInt32(file.GetValue("TargetRange")); newSpell.targetAOE = (TargetAOE)Convert.ToInt32(file.GetValue("TargetAOE")); if (newSpell.targetRange == TargetRange.Range) { newSpell.range = Convert.ToInt32(file.GetValue("Range")); } else { newSpell.range = 1; } Table table = (Table)file.GetValue("Events"); Table insideTable; foreach (DynValue dy in table.Values) { insideTable = dy.Table; switch (insideTable.Get("Type").String) { case "DamageEvent": newSpell.protoEvents.Add(DamageEventPrototype.Builder(insideTable)); break; case "SpawnEvent": newSpell.protoEvents.Add(SpawnEventPrototype.Builder(insideTable)); break; case "BuffCastEvent": newSpell.protoEvents.Add(BuffCastEventPrototype.Builder(insideTable)); break; default: break; } } return(newSpell); }
public void OnAbilityButtonPressed(string name) { if (allowedActions.ContainsKey(name)) { currentAction = allowedActions[name]; if (currentAction.GetType() == typeof(SpellAction)) { fallbackAction = (SpellAction)currentAction; } } else { currentAction = allowedActions["Move"]; } }
public static void DeepCopySpell(Spell from, Spell to) { to.item_id = from.item_id; to.spellType = from.spellType; to.spellClass = from.spellClass; to.projectile = from.projectile; to.spell_effect = from.spell_effect; to.particlePrefab = from.particlePrefab; to.spellActions = new List <SpellAction>(); for (int i = 0; i < from.spellActions.Count; i++) { SpellAction a = new SpellAction(); DeepCopySpellAction(a, from.spellActions[i]); to.spellActions.Add(a); } }
private static void ChatHandlers_OnSpellCast(Mobile mob, SpellAction value) { if (mob == World.Player) { _lastSpell = value; GameActions.Print($"Player casting {_lastSpell}"); } SpellHandle spell = default; if (!_mobiles.TryGetValue(mob.Serial, out spell)) { _mobiles.Add(mob.Serial, spell = new SpellHandle()); } spell.Value = value; }
public static SpellAction ParseAndCreateSpell(string fileName) { if (allAbilites == null) allAbilites = new Dictionary<string, SpellAction>(); LuaFile file = new LuaFile(); file.Setup( "Spells/" + fileName); SpellAction newSpell = new SpellAction(); newSpell.name = file.GetValue("Name").ToString(); newSpell.targetType = (TargetType)Convert.ToInt32(file.GetValue("TargetType")); newSpell.targetFilter = (TargetFilter)Convert.ToInt32(file.GetValue("TargetFilter")); newSpell.targetRange = (TargetRange)Convert.ToInt32(file.GetValue("TargetRange")); newSpell.targetAOE = (TargetAOE)Convert.ToInt32(file.GetValue("TargetAOE")); if(newSpell.targetRange == TargetRange.Range) { newSpell.range = Convert.ToInt32(file.GetValue("Range")); } else { newSpell.range = 1; } Table table = (Table)file.GetValue("Events"); Table insideTable; foreach(DynValue dy in table.Values) { insideTable = dy.Table; switch (insideTable.Get("Type").String) { case "DamageEvent": newSpell.protoEvents.Add(DamageEventPrototype.Builder(insideTable)); break; case "SpawnEvent": newSpell.protoEvents.Add(SpawnEventPrototype.Builder(insideTable)); break; case "BuffCastEvent": newSpell.protoEvents.Add(BuffCastEventPrototype.Builder(insideTable)); break; default: break; } } return newSpell; }
public static void Update(double totalMS) { if (!IsEnabled || World.Player.IsDead) { return; } if (_timer <= totalMS) { if (TargetManager.IsTargeting) { if (mob == null) { return; } SpellAction spell = SpellManager.LastSpell; if (spell == SpellAction.Unknown) { spell = (SpellAction)GameActions.LastSpellIndexCursor; } int h1 = 0; int h2 = 0; if (!mob.IsDead && spell == SpellAction.GreaterHeal && (mob.IsPoisoned && mob.Hits < (h1 = _rand.Next(65, 80)) || mob.Hits < (h2 = _rand.Next(40, 70)))) { GameActions.Print($"{h2}"); TargetManager.Target(mob); _timer += 250; } } } if (mob != null) { mob = null; } }
//Function called from the Sort X Actions functions to check and see if there are more spells recharging than we're able to add private bool CanAddSpellToList(SpellAction spellToCheck_) { //Int to track how many charges of this spell are in the spell actions list. Starts at the number of charges for the current spell int spellCharges = spellToCheck_.spellCharges; //Looping through all of the spells currently in the spell actions list foreach (SpellAction spell in this.allSpellActions) { //If this current spell is the same as the one we're sorting, we add the number of charges to the current total if (spell.actionName == spellToCheck_.actionName) { spellCharges += spell.spellCharges; } } //Int to track how many charges of this spell are currently recharging int spellsRecharging = 0; //Looping through all of the recharging spells to see if any match the one we're sorting foreach (SpellRecharge spell in this.rechargingSpells) { //If this current spell is the same as the one we're sorting, we add it to the total if (spell.spellThatsCharging.actionName == spellToCheck_.actionName) { spellsRecharging += 1; } } //If there are more spell charges than recharging, this spell can be added to the actions list if (spellsRecharging < spellCharges) { return(true); } //If there are more spells recharging than available, we shouldn't add it to the action list else { return(false); } }
public override void StartAttack(GameObject attackTarget) { if (attackTarget == null) return; if (attackTarget is GameLiving && GameServer.ServerRules.IsAllowedToAttack(this, (GameLiving)attackTarget, true) == false) return; if (Brain is IControlledBrain) { if ((Brain as IControlledBrain).AggressionState == eAggressionState.Passive) return; GamePlayer playerowner; if ((playerowner = ((IControlledBrain)Brain).GetPlayerOwner()) != null) playerowner.Stealth(false); } TargetObject = attackTarget; if (TargetObject.Realm == 0 || Realm == 0) m_lastAttackTickPvE = m_CurrentRegion.Time; else m_lastAttackTickPvP = m_CurrentRegion.Time; if (m_attackers.Count == 0) { if (SpellTimer == null) SpellTimer = new SpellAction(this); if (!SpellTimer.IsAlive) SpellTimer.Start(1); } if (Brain is TurretMainPetTankBrain) { base.StartAttack(TargetObject); } }
public static SpellCircle GetCircle(SpellAction spell) { switch (spell) { case SpellAction.Clumsy: case SpellAction.CreateFood: case SpellAction.Feeblemind: case SpellAction.MiniHeal: case SpellAction.MagicArrow: case SpellAction.NightSight: case SpellAction.ReactiveArmor: case SpellAction.Weaken: return(SpellCircle.First); case SpellAction.Agility: case SpellAction.Cunning: case SpellAction.Cure: case SpellAction.Harm: case SpellAction.MagicTrap: case SpellAction.MagicUntrap: case SpellAction.Protection: case SpellAction.Strength: return(SpellCircle.Second); case SpellAction.Bless: case SpellAction.Fireball: case SpellAction.MagicLock: case SpellAction.Poison: case SpellAction.Telekinesis: case SpellAction.Teleport: case SpellAction.Unlock: case SpellAction.WallOfStone: return(SpellCircle.Third); case SpellAction.ArchCure: case SpellAction.ArchProtection: case SpellAction.Curse: case SpellAction.FireField: case SpellAction.GreaterHeal: case SpellAction.Lightning: case SpellAction.ManaDrain: case SpellAction.Recall: return(SpellCircle.Fourth); case SpellAction.BladeSpirits: case SpellAction.DispelField: case SpellAction.Incognito: case SpellAction.MagicReflection: case SpellAction.MindBlast: case SpellAction.Paralyze: case SpellAction.PoisonField: case SpellAction.SummonCreature: return(SpellCircle.Fifth); case SpellAction.Dispel: case SpellAction.EnergyBolt: case SpellAction.Explosion: case SpellAction.Invisibility: case SpellAction.Mark: case SpellAction.MassCurse: case SpellAction.ParalyzeField: case SpellAction.Reveal: return(SpellCircle.Sixth); case SpellAction.ChainLightning: case SpellAction.EnergyField: case SpellAction.Flamestrike: case SpellAction.GateTravel: case SpellAction.ManaVampire: case SpellAction.MassDispel: case SpellAction.MeteorSwarm: case SpellAction.Polymorph: return(SpellCircle.Seventh); case SpellAction.Earthquake: case SpellAction.EnergyVortex: case SpellAction.Ressurection: case SpellAction.AirElemental: case SpellAction.SummonDaemon: case SpellAction.EarthElemental: case SpellAction.FireElemental: case SpellAction.WaterElemental: return(SpellCircle.Eighth); } throw new InvalidOperationException(); }
void SpellAction(Action slot) { if (characterStats.currentStamina < slot.staminaCost) { return; } if (slot.spellClass != inventoryManager.currentSpell.Instance.spellClass || characterStats.currentMana < slot.manaCost) { //Failed to cast spell Debug.Log("Cant cast spell!"); PlayAnimation(StaticStrings.animState_CantCastSpell, slot.mirror); return; } ActionInput inp = actionManager.GetActionInput(this); if (inp == ActionInput.lb) { inp = ActionInput.rb; } if (inp == ActionInput.lt) { inp = ActionInput.rt; } Spell spellInst = inventoryManager.currentSpell.Instance; SpellAction spellSlot = spellInst.GetAction(spellInst.actions, inp); if (spellSlot == null) { Debug.Log("CAN'T FIND SPELL SLOT"); return; } SpellEffectManager.Instance.UseSpellEffect(spellInst.spellEffect, this); isSpellCasting = true; spellCastTime = 0; max_SpellCastTime = spellSlot.castTime; spellTargetAnim = spellSlot.throwAnim; spellIsMirorred = slot.mirror; currentSpellType = spellInst.spellType; string targetAnim = spellSlot.targetAnim; if (spellIsMirorred) { targetAnim += StaticStrings._leftPrefix; } else { targetAnim += StaticStrings._rightPrefix; } projectileCandidate = inventoryManager.currentSpell.Instance.projectile; //If spellIsMirorred == true --> Left hand inventoryManager.CreateSpellParticle(inventoryManager.currentSpell, spellIsMirorred, (spellInst.spellType == SpellType.Looping)); animator.SetBool(StaticStrings.animParam_SpellCasting, true); animator.SetBool(StaticStrings.animParam_Mirror, slot.mirror); PlayAnimation(targetAnim); currentManaCost = spellSlot.manaCost; currentStaminaCost = spellSlot.staminaCost; animHook.InitIKForBreathSpell(spellIsMirorred); if (spellCastStart != null) { spellCastStart(); } }
//Function called from SpellAction.cs when a spell is used public void StartSpellRecharge(SpellAction spellUsed_) { this.rechargingSpells.Add(new SpellRecharge(spellUsed_, spellUsed_.hoursUntilRecharged)); }
public void OnStartTurn() { actionPoints = 3; currentAction = allowedActions["Move"]; fallbackAction = (SpellAction)allowedActions["basic"]; }
void OnDestroy() { workingSpell = null; }
private void Awake() { CastLine = new List <Cell> (); objects = FindObjectOfType <ObjectsHolder> (); spellAction = FindObjectOfType <SpellAction> (); }
void OnDestroy() { workingSpell = null; }
//Constructor for this class public SpellRecharge(SpellAction spell_, int hours_) { this.spellThatsCharging = spell_; this.hoursRemaining = hours_; }
private void StartMeleeAttackTimer() { if (m_attackers.Count == 0) { if (SpellTimer == null) SpellTimer = new SpellAction(this); if (!SpellTimer.IsAlive) SpellTimer.Start(1); } }
public void OnStartTurn() { actionPoints = 3; currentAction = allowedActions["Move"]; fallbackAction = (SpellAction)allowedActions["basic"]; }
void SpellAction(Action slot) { if (characterStats._stamina < slot.staminaCost) { return; } if (slot.spellClass != inventoryManager.currentSpell.instance.spellClass || characterStats._focus < slot.focusCost) { PlayAnimation("cant_spell", slot.mirror); return; } ActionInput inp = actionManager.GetActionInput(this); if (inp == ActionInput.lb) { inp = ActionInput.rb; } if (inp == ActionInput.lt) { inp = ActionInput.rt; } Spell s_inst = inventoryManager.currentSpell.instance; SpellAction s_slot = s_inst.GetAction(s_inst.spellActions, inp); if (s_slot == null) { return; } SpellEffectManager.singleton.UseSpellEffect(s_inst.spell_effect, this); isSpellCasting = true; spellCastTime = 0; maxSpellCastTime = s_slot.castTime; spellTargetAnim = s_slot.throwAnim; spellIsMirrored = slot.mirror; curSpellType = s_inst.spellType; string targetAnim = s_slot.targetAnim; if (spellIsMirrored) { targetAnim += StaticStrings._l; } else { targetAnim += StaticStrings._r; } projectileCandidate = inventoryManager.currentSpell.instance.projectile; inventoryManager.CreateSpellParticle(inventoryManager.currentSpell, spellIsMirrored, s_inst.spellType == SpellType.looping); anim.SetBool(StaticStrings.spellCasting, true); anim.SetBool(StaticStrings.mirror, slot.mirror); anim.CrossFade(targetAnim, 0.2f); curFocusCost = s_slot.focusCost; curStaminaCost = s_slot.staminaCost; a_hook.InitIKForBreathSpell(spellIsMirrored); if (spellCast_Start != null) { spellCast_Start(); } }
public void OnAbilityButtonPressed(string name) { if (allowedActions.ContainsKey(name)) { currentAction = allowedActions[name]; if (currentAction.GetType() == typeof(SpellAction)) { fallbackAction = (SpellAction)currentAction; } } else { currentAction = allowedActions["Move"]; } }