public SpellData(SpellItem item) { Position = item.position; SpellId = item.spellId; SpellLevelId = item.spellLevel; miniSpell = GameDataAdapter.GetClass <SpellLevel>((int)GameDataAdapter.GetClass <Spell>((int)this.SpellId).SpellLevels[(int)this.SpellLevelId - 1]); }
/// <summary> /// /// </summary> /// <param name="spell"></param> /// <param name="spellId"></param> /// <param name="targetId"></param> public void Actualize(SpellLevel spell, int spellId, long targetId) { if (spell.Cooldown > 0) { if (!m_cooldowns.ContainsKey(spellId)) { m_cooldowns.Add(spellId, new SpellCooldown(spell.Cooldown)); } else { m_cooldowns[spellId].Cooldown = spell.Cooldown; } } if (spell.MaxLaunchPerTurn == 0 && spell.MaxLaunchPerTarget == 0) { return; } if (!m_targets.ContainsKey(spellId)) { m_targets.Add(spellId, new List <SpellTarget>()); } m_targets[spellId].Add(new SpellTarget(targetId)); }
public FightGroundLayer(FightObjectType myObjectType, Fighter Caster, SpellLevel CastSpell, FightCell CastCell, int MasterSpellId, int MasterSpellSpriteId, String Zone, short Duration = -1) { this.myObjectType = myObjectType; this.myCell = CastCell; this.Caster = Caster; this.CastSpell = CastSpell; this.Size = (short)StringHelper.HashToInt(Zone[1]); this.Duration = Duration; this.MasterSpellId = MasterSpellId; this.MasterSpellSpriteId = MasterSpellSpriteId; //CastCell.AddObject(this); Fight.addLayer(this); Fight.RegisterFightListener(this); foreach (int cellId in CellZone.GetCells(this.Fight.Map, CellId, CellId, Zone)) { var Cell = this.Fight.GetCell(cellId); if (Cell != null) { myCells.Add(Cell); Cell.AddObject(this); } } Show(Caster); }
public void AssignFields(object d2oObject) { SpellLevel spellLevel = (SpellLevel)d2oObject; this.Id = (uint)spellLevel.id; this.SpellId = spellLevel.spellId; this.SpellBreed = spellLevel.spellBreed; this.ApCost = spellLevel.apCost; this.Range = spellLevel.range; this.CastInLine = spellLevel.castInLine; this.CastInDiagonal = spellLevel.castInDiagonal; this.CastTestLos = spellLevel.castTestLos; this.CriticalHitProbability = spellLevel.criticalHitProbability; this.StatesRequired = spellLevel.statesRequired.ToArray(); this.CriticalFailureProbability = spellLevel.criticalFailureProbability; this.NeedFreeCell = spellLevel.needFreeCell; this.NeedFreeTrapCell = spellLevel.needFreeTrapCell; this.NeedTakenCell = spellLevel.needTakenCell; this.RangeCanBeBoosted = spellLevel.rangeCanBeBoosted; this.MaxStack = spellLevel.maxStack; this.MaxCastPerTarget = spellLevel.maxCastPerTarget; this.MinCastInterval = spellLevel.minCastInterval; this.InitialCooldown = spellLevel.initialCooldown; this.GlobalCooldown = spellLevel.globalCooldown; this.MinPlayerLevel = spellLevel.minPlayerLevel; this.CriticalFailureEndsTurn = spellLevel.criticalFailureEndsTurn; this.HideEffects = spellLevel.hideEffects; this.Hidden = spellLevel.hidden; this.MinRange = spellLevel.minRange; this.StatesForbidden = spellLevel.statesForbidden.ToArray(); this.m_effectsBin = Singleton <EffectManager> .Instance.SerializeEffects(spellLevel.effects); this.m_criticalEffectsBin = Singleton <EffectManager> .Instance.SerializeEffects(spellLevel.criticalEffect); }
public ActionResult GetSpellbookLevel(int characterid, int spellLevel) { Character character = GetCharacter(characterid).Value; if (character == null) { return(NotFound("No Character with this id")); } if (character.Spellbook == null) { return(NotFound("This character doesn't have a spellbook")); } if (spellLevel > character.Spellbook.SpellLevels.Length || spellLevel < 0) { return(BadRequest("spell level is out of bounds")); } SpellLevel spellbookLevel = character.Spellbook.SpellLevels[spellLevel]; if (spellbookLevel == null) { return(NotFound(String.Format("{0} doesn't have any spells for {1} level spells", character.Name, spellLevel))); } return(Ok(spellbookLevel)); }
private bool IsInLineIfNeeded(Cell cell, SpellLevel spell) { if (!spell.castInLine) { return(true); } return(Cell.X == cell.X || Cell.Y == cell.Y); }
public void LevelUp() { if (this.Level < 6) { this.Level++; this.SpellLevel = SpellTable.Cache[Id].GetLevel(this.Level); this.SpellLevel.Initialize(); } }
public IASpell(int spellId, int relaunchs, SpellTarget target, bool handToHand, bool moveFirst, SpellLevel spellLevel) { SpellId = spellId; Relaunchs = relaunchs; Target = target; HandToHand = handToHand; MoveFirst = moveFirst; Name = D2OParsing.GetSpellName(SpellId); Spell = spellLevel; }
public bool IsInSpellRange(Cell cell, SpellLevel spell) { var range = GetRealSpellRange(spell); var dist = Cell.ManhattanDistanceTo(cell); if (!(dist >= spell.minRange && dist <= range)) { return(false); } return(IsInLineIfNeeded(cell, spell)); }
public int GetRealSpellRange(SpellLevel spell) { var range = (int)(spell.rangeCanBeBoosted ? Stats.Range + spell.range : spell.range); if (range < spell.minRange) { return((int)spell.minRange); } return(range); }
/// <summary> /// /// </summary> /// <param name="spellId"></param> /// <param name="spellLevel"></param> /// <returns></returns> public SpellLevel GetSpellLevel(int spellId, int spellLevel) { SpellTemplate spell = null; SpellLevel level = null; if (m_templateById.TryGetValue(spellId, out spell)) { level = spell.GetLevel(spellLevel); } return(level); }
public SpellInfo(int Id, int Level = 1, int Position = 25) { this.Id = Id; this.Level = Level; this.Position = Position; if (this.Level > 0) { this.SpellLevel = SpellTable.Cache[Id].GetLevel(this.Level); this.SpellLevel.Initialize(); } }
public void createSpellLevel(int level) { SpellLevel temp_slot = new SpellLevel(); GameObject slot = Instantiate(spellSlotButton, spellParent); slot.name = level.ToString(); slot.transform.GetChild(0).GetComponent <Text>().text = "Level " + slot.name + " spells"; slot.GetComponent <RectTransform>().anchoredPosition = new Vector2(206, -105 + (30 * level)); slot.GetComponent <SpellButton>().levelSwitch = level; temp_slot.level = level; temp_slot.slotButton = slot; temp_slot.groupSpells = new List <GameObject>(); spellLevels.Add(temp_slot); }
public SpellLevel DesiredLevel(SpellLevel level) { if (Level == SpellLevel.Cantrip) { return(SpellLevel.Cantrip); } if (level <= Level) { return(Level); } return(level); }
/// <summary> /// /// </summary> /// <param name="spell"></param> /// <param name="spellId"></param> /// <param name="targetId"></param> /// <returns></returns> public bool CanLaunchSpell(SpellLevel spell, int spellId, long targetId) { if (spell.Cooldown > 0) { if (m_cooldowns.ContainsKey(spellId)) { if (m_cooldowns[spellId] != null) { if (m_cooldowns[spellId].Cooldown > 0) { return(false); } } } } if (spell.MaxLaunchPerTurn == 0 && spell.MaxLaunchPerTarget == 0) { return(true); } if (spell.MaxLaunchPerTurn > 0) { if (m_targets.ContainsKey(spellId)) { if (m_targets[spellId].Count >= spell.MaxLaunchPerTurn) { return(false); } } } if (targetId == 0) { return(true); } if (spell.MaxLaunchPerTarget > 0) { if (m_targets.ContainsKey(spellId)) { if (m_targets[spellId].Count(spellTarget => spellTarget.TargetId == targetId) >= spell.MaxLaunchPerTarget) { return(false); } } } return(true); }
/// <summary> /// /// </summary> /// <param name="type"></param> /// <param name="activeType"></param> /// <param name="fight"></param> /// <param name="caster"></param> /// <param name="castInfos"></param> /// <param name="cell"></param> /// <param name="duration"></param> /// <param name="actionId"></param> /// <param name="canGoThrough"></param> /// <param name="canStack"></param> /// <param name="hide"></param> protected AbstractActivableObject(FightObstacleTypeEnum type, ActiveType activeType, AbstractFight fight, AbstractFighter caster, CastInfos castInfos, int cell, int duration, int actionId, bool canGoThrough, bool canStack, bool hide = false) { m_fight = fight; m_caster = caster; m_spellId = castInfos.SpellId; m_actionSpell = SpellManager.Instance.GetTemplate(castInfos.Value1); m_actionEffect = m_actionSpell.GetLevel(castInfos.Value2); Cell = fight.GetCell(cell); ObstacleType = type; ActivationType = activeType; CanGoThrough = canGoThrough; CanStack = canStack; Color = castInfos.Value3; Targets = new List <AbstractFighter>(); Length = Pathfinding.GetDirection(castInfos.RangeType[1]); AffectedCells = new List <FightCell>(); Duration = duration; ActionId = actionId; Hide = hide; foreach (var effect in m_actionEffect.Effects) { if (CastInfos.IsDamageEffect(effect.TypeEnum)) { Priority--; } } // On ajout l'objet a toutes les cells qu'il affecte foreach (var cellId in CellZone.GetCircleCells(fight.Map, cell, Length)) { var fightCell = m_fight.GetCell(cellId); if (fightCell != null) { fightCell.AddObject(this); AffectedCells.Add(fightCell); } } if (Hide) { Appear(caster.Team); } else { AppearForAll(); } }
static public bool SpellsDumper(string XMLFileName) { Directory.CreateDirectory("XML/Spells"); foreach (SpellType type in ObjectDataManager.Instance.EnumerateObjects <SpellType>()) //foreach (BreedEnum breed in Enum.GetValues(typeof(BreedEnum))) { string typeName = I18NDataManager.Instance.ReadText(type.longNameId); string breedFileName = "XML/Spells/" + typeName + "_" + XMLFileName; using (XmlTextWriter writer = new XmlTextWriter(breedFileName, null)) { Type D2oClass = typeof(Spell); Type[] types = { typeof(SpellLevel), typeof(EffectInstanceDice) };// asm.GetTypes().Where(entry => entry.Namespace != null && entry.GetConstructor(System.Type.EmptyTypes) != null && entry.Namespace.StartsWith("BiM.Protocol.Data")).ToArray<Type>(); XmlSerializer d2oSerializer = new XmlSerializer(typeof(Spell), types); XmlSerializer d2oSerializerLv = new XmlSerializer(typeof(SpellLevel), types); //Use indenting for readability. writer.Formatting = Formatting.Indented; writer.WriteProcessingInstruction("xml", "version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\""); writer.WriteStartElement("Spells_root"); // write foreach (Spell obj in ObjectDataManager.Instance.EnumerateObjects <Spell>()) { if (obj.spellLevels.Count == 0 || obj.typeId == (uint)type.id) { //writer.WriteStartElement("Spell"); //writer.WriteAttributeString("Name", I18NDataManager.Instance.ReadText(obj.nameId)); //writer.WriteAttributeString("Description", I18NDataManager.Instance.ReadText(obj.descriptionId)); d2oSerializer.Serialize(writer, obj); // your instance foreach (var lv in obj.spellLevels) { SpellLevel spellLv = ObjectDataManager.Instance.Get <SpellLevel>(lv); //writer.WriteStartElement("SpellLevel"); d2oSerializerLv.Serialize(writer, spellLv); // your instance //writer.WriteEndElement(); } //writer.WriteEndElement(); } } writer.WriteEndElement(); } // Open a file for reading cleanXML(breedFileName, true); } return(true); }
public void Actualise(SpellLevel Spell, long TargetId) { if (Spell.TurnNumber > 0) { if (!this.myTurnNumber.ContainsKey(Spell.SpellCache.ID)) { this.myTurnNumber.Add(Spell.SpellCache.ID, new SpellTurnNumber(Spell.TurnNumber)); } else { this.myTurnNumber[Spell.SpellCache.ID].TurnNumber = Spell.TurnNumber; } } if (Spell.MaxPerTurn == 0 && Spell.MaxPerPlayer == 0) { return; } if (Spell.MaxPerTurn > 0) { if (!this.myTargets.ContainsKey(Spell.SpellCache.ID)) { this.myTargets.Add(Spell.SpellCache.ID, new List <SpellTarget>()); } else { this.myTargets[Spell.SpellCache.ID].Add(new SpellTarget(TargetId)); } } if (Spell.MaxPerPlayer > 0) { if (this.myTargets.ContainsKey(Spell.SpellCache.ID)) { this.myTargets[Spell.SpellCache.ID].Add(new SpellTarget(TargetId)); } else { this.myTargets.Add(Spell.SpellCache.ID, new List <SpellTarget> { new SpellTarget(TargetId) }); } } }
public void SpellLevelMenuChange(int spellLevel) { SpellLevel active = new SpellLevel(); foreach (SpellLevel s in Menu.menu.spellLevels) { if (s.level == spellLevel) { active = s; } s.slotButton.SetActive(false); } foreach (GameObject g in active.groupSpells) { g.SetActive(true); } }
public bool CanLaunchSpell(SpellLevel Spell, long TargetId) { if (Spell.TurnNumber > 0) { if (this.myTurnNumber.ContainsKey(Spell.SpellCache.ID)) { if (this.myTurnNumber[Spell.SpellCache.ID] != null) { if (this.myTurnNumber[Spell.SpellCache.ID].TurnNumber > 0) { return(false); } } } } if (Spell.MaxPerTurn == 0 && Spell.MaxPerPlayer == 0) { return(true); } if (Spell.MaxPerTurn > 0) { if (this.myTargets.ContainsKey(Spell.SpellCache.ID)) { if (this.myTargets[Spell.SpellCache.ID].Count >= Spell.MaxPerTurn) { return(false); } } } if (Spell.MaxPerPlayer > 0) { if (this.myTargets.ContainsKey(Spell.SpellCache.ID)) { if (this.myTargets[Spell.SpellCache.ID].Count(x => x.TargetId == TargetId) >= Spell.MaxPerPlayer) { return(false); } } } return(true); }
protected override SpellLevel GetLevelTemplate(int level) { LevelTemplate = new SpellLevel(); // We only take effects with a duration or damage or healing effect into considération. Others are probably constant effects on the caster when holding the weapon. LevelTemplate.effects = _weapon.possibleEffects.OfType <EffectInstanceDice>().Where(effect => (effect.duration != 0) || ((GetEffectCategories(effect.effectId, 0) & (SpellCategory.Damages | SpellCategory.Healing)) > 0)).ToList(); foreach (var effect in LevelTemplate.effects) { effect.rawZone = _weapon.type.rawZone; } LevelTemplate.criticalEffect = LevelTemplate.effects; Level = 1; LevelTemplate.minRange = (uint)_weapon.minRange; LevelTemplate.range = (uint)_weapon.range; LevelTemplate.apCost = (uint)_weapon.apCost; LevelTemplate.castInDiagonal = _weapon.castInDiagonal; LevelTemplate.castInLine = _weapon.castInLine; LevelTemplate.castTestLos = _weapon.castTestLos; LevelTemplate.criticalHitProbability = (uint)_weapon.criticalHitProbability; LevelTemplate.criticalFailureProbability = (uint)_weapon.criticalFailureProbability; return(LevelTemplate); }
protected virtual SpellLevel GetLevelTemplate(int level) { if (Template.spellLevels.Count < Level) { throw new InvalidOperationException(string.Format("Level {0} doesn't exist in spell {1}", Level, Template.id)); } SpellLevel lv = ObjectDataManager.Instance.Get <SpellLevel>((int)Template.spellLevels[level - 1]); if (Template.id == 158) // For Iops, Concentration effects are wrong in D2o { lv.effects[0].targetId = (int)(SpellTargetType.ALLIES_NON_SUMMON | SpellTargetType.ENEMIES_NON_SUMMON | SpellTargetType.SELF); lv.effects[1].targetId = (int)(SpellTargetType.ALLIES_SUMMON | SpellTargetType.ENEMIES_SUMMON); } if (Template.id == 126) // For Eni, Mot stimulant also affects the enemies (2nd effect) { lv.effects[1].targetId = (int)(SpellTargetType.ALL); } return(lv); }
public void Dispose() { if (myEnnemies != null) { myEnnemies.Clear(); myEnnemies = null; } myAttacked = false; if (myReachableCells != null) { myReachableCells.Clear(); myReachableCells = null; } if (myScoreInvocations != null) { myScoreInvocations.Clear(); myScoreInvocations = null; } myBestSpell = null; myFirstTargetIsMe = false; myBestMoveCell = myBestCastCell = myBestScore = 0; }
private void loadSpells() { JsonData s = JsonMapper.ToObject(File.ReadAllText(Application.dataPath + "/scripts/combat/spells.json")); List <Spell> spellList = new List <Spell>(); List <int> existingLevels = new List <int>(); for (int i = 0; i < s["spells"].Count; i++) { Spell temp = new Spell(); temp.Id = (int)s["spells"][i][0]; temp.name = (string)s["spells"][i][1]; temp.lowerBound = (int)s["spells"][i][2]; temp.upperBound = (int)s["spells"][i][3]; temp.level = (int)s["spells"][i][4]; if (!existingLevels.Contains(temp.level)) { Menu.menu.createSpellLevel(temp.level); existingLevels.Add(temp.level); } SpellLevel activeSlot = new SpellLevel(); foreach (SpellLevel level in Menu.menu.spellLevels) { if (level.level == temp.level) { activeSlot = level; } } Debug.Log(temp.name); activeSlot.groupSpells.Add(Menu.menu.createSpell(temp.name, temp.Id, temp.level)); spellList.Add(temp); } spells = spellList; }
/// <summary> /// Finds the index in which a spell is stored in the spellbook based on the spellId /// </summary> /// <param name="character"></param> /// <param name="spellLevel">The spell level you want to find the spell in</param> /// <param name="spellIndex">The index of the spell</param> /// <returns>The index of the spell</returns> public KnownSpell GetSpellFromSpellbook(Character character, int spellLevel, int spellIndex) { Spellbook spellbook = GetSpellBook(character); if (spellLevel > spellbook.SpellLevels.Length || spellLevel < 0) { return(null); } SpellLevel curLevel = spellbook.SpellLevels[spellLevel]; if (spellIndex >= curLevel.Spells.Count || spellIndex < 0) { return(null); } KnownSpell spell = curLevel.Spells[spellIndex]; if (spell == null) { return(null); } return(spell); }
private static string SpellLevelToString(SpellLevel level) { switch (level) { case SpellLevel.CANTRIP: return(CANTRIP); case SpellLevel.FIRST_LEVEL: return(FIRST_LEVEL); case SpellLevel.SECOND_LEVEL: return(SECOND_LEVEL); case SpellLevel.THIRD_LEVEL: return(THIRD_LEVEL); case SpellLevel.FOURTH_LEVEL: return(FOURTH_LEVEL); case SpellLevel.FIFTH_LEVEL: return(FIFTH_LEVEL); case SpellLevel.SIXTH_LEVEL: return(SIXTH_LEVEL); case SpellLevel.SEVENTH_LEVEL: return(SEVENTH_LEVEL); case SpellLevel.EIGHTH_LEVEL: return(EIGHTH_LEVEL); case SpellLevel.NINTH_LEVEL: return(NINTH_LEVEL); } return(""); }
/// <summary> /// Method used for the scaling, windup motion, and spell gestures for spell casts /// </summary> protected static float SpellAttributes(string account, uint spellId, out float castingDelay, out MotionCommand windUpMotion, out MotionCommand spellGesture) { float scale; SpellComponentsTable comps = DatManager.PortalDat.SpellComponentsTable; SpellTable spellTable = DatManager.PortalDat.SpellTable; if (!spellTable.Spells.ContainsKey(spellId)) { windUpMotion = MotionCommand.Invalid; spellGesture = MotionCommand.Invalid; castingDelay = 0.0f; return(-1.0f); } SpellBase spell = spellTable.Spells[spellId]; ////Determine scale of the spell effects and windup animation SpellLevel spellLevel = CalculateSpellLevel(spell.Power); if (account == null) { switch (spellLevel) { case SpellLevel.One: scale = 0.1f; break; case SpellLevel.Two: scale = 0.2f; break; case SpellLevel.Three: scale = 0.4f; break; case SpellLevel.Four: scale = 0.5f; break; case SpellLevel.Five: scale = 0.6f; break; case SpellLevel.Six: scale = 1.0f; break; default: scale = 1.0f; break; } spellGesture = MotionCommand.Magic; windUpMotion = 0; castingDelay = 0.0f; return(scale); } switch (spellLevel) { case SpellLevel.One: scale = 0.1f; castingDelay = 1.3f; windUpMotion = MotionCommand.MagicPowerUp01; break; case SpellLevel.Two: scale = 0.2f; castingDelay = 1.4f; windUpMotion = MotionCommand.MagicPowerUp02; break; case SpellLevel.Three: scale = 0.4f; castingDelay = 1.5f; windUpMotion = MotionCommand.MagicPowerUp03; break; case SpellLevel.Four: scale = 0.5f; castingDelay = 1.7f; windUpMotion = MotionCommand.MagicPowerUp04; break; case SpellLevel.Five: scale = 0.6f; castingDelay = 1.9f; windUpMotion = MotionCommand.MagicPowerUp05; break; case SpellLevel.Six: scale = 1.0f; castingDelay = 2.0f; windUpMotion = MotionCommand.MagicPowerUp06; break; default: scale = 1.0f; castingDelay = 2.0f; windUpMotion = MotionCommand.MagicPowerUp07Purple; break; } var formula = SpellTable.GetSpellFormula(spellTable, spellId, account); spellGesture = (MotionCommand)comps.SpellComponents[formula[formula.Count - 1]].Gesture; return(scale); }
public Spell(string name, SpellClass c, SpellLevel l) { sName = name; sClass = c; sLevel = l; }
public FightTrapLayer(Fighter Caster, SpellLevel CastSpell, FightCell CastCell, int MasterSpellId, int MasterSpellSpriteId, String Zone) : base(FightObjectType.OBJECT_TRAP, Caster, CastSpell, CastCell, MasterSpellId, MasterSpellSpriteId, Zone, -1) { }
public virtual void onApplyGroundLayer(Fights.FightObjects.FightGroundLayer layer, Fighter Caster, SpellLevel Spell, int TargetCellId, Fighter TargetFighter, Dictionary <EffectInfos, List <Fighter> > TargetEffects) { }
public virtual void onLaunchSpell(Fighter Launcher, SpellLevel Spell, int TargetCellId, Fighter TargetFighter, Dictionary <EffectInfos, List <Fighter> > TargetEffects, bool IsCC, bool IsEchec) { }