// Shield of thorns spell entity public static int createShieldOfThornsSpell(int targetEntityId, string damageDie, float radius, List<Faction> factionsToAffect) { int entityId = EntityManager.createEntity(); TrackEntityPositionComponent trackEntityPositionComponent = new TrackEntityPositionComponent(entityId, targetEntityId); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId, factionsToAffect); DamageShieldComponent damageShieldComponent = new DamageShieldComponent(entityId, damageDie); AreaOfEffectComponent areaOfEffectComponent; Body sensor = BodyFactory.CreateCircle(SystemManager.physicsSystem.world, radius, 1f); sensor.UserData = entityId; sensor.CollidesWith = (ushort)CollisionCategory.None; sensor.BodyType = BodyType.Static; areaOfEffectComponent = new AreaOfEffectComponent(entityId, sensor); EntityManager.addComponent(entityId, trackEntityPositionComponent); EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, damageShieldComponent); EntityManager.addComponent(entityId, areaOfEffectComponent); EntityManager.addComponent(entityId, new IgnoreBridgeRaycastComponent(entityId)); EntityManager.addComponent(entityId, new IgnoreRopeRaycastComponent(entityId)); return entityId; }
// Create rain of fire spell public static int createRainOfFireSpell(int ownerId, Vector2 position, float width, string damageDie, int tickDelay, int tickCount, List<Faction> factionsToAffect) { int entityId = EntityManager.createEntity(); DamageOverTimeComponent damageOverTimeComponent = new DamageOverTimeComponent(entityId, DamageType.Fire, damageDie, tickDelay); TimeToLiveComponent timeToLiveComponent = new TimeToLiveComponent(entityId, tickDelay * tickCount); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId, factionsToAffect); Body sensor = BodyFactory.CreateRectangle(SystemManager.physicsSystem.world, width, 100f, 1f, position); AreaOfEffectComponent areaOfEffectComponent = new AreaOfEffectComponent(entityId, sensor); sensor.UserData = entityId; sensor.BodyType = BodyType.Static; sensor.CollidesWith = (ushort)CollisionCategory.None; EntityManager.addComponent(entityId, damageOverTimeComponent); EntityManager.addComponent(entityId, timeToLiveComponent); EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, areaOfEffectComponent); EntityManager.addComponent(entityId, new SpellTypeComponent(entityId, SpellType.RainOfFire)); EntityManager.addComponent(entityId, new SpellOwnerComponent(entityId, ownerId)); EntityManager.addComponent(entityId, new IgnoreBridgeRaycastComponent(entityId)); EntityManager.addComponent(entityId, new IgnoreRopeRaycastComponent(entityId)); return entityId; }
// Create riposte spell public static int createRiposteSpell(int ownerId, int timeToLive, string chanceToRiposte) { int entityId = EntityManager.createEntity(); AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(ownerId); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId); affectedEntitiesComponent.entities.Add(ownerId); affectedBySpellEntitiesComponent.spellEntities.Add(entityId); EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, new RiposteComponent(entityId, chanceToRiposte)); EntityManager.addComponent(entityId, new TimeToLiveComponent(entityId, timeToLive)); return entityId; }
// Create piercing spell public static int createPiercingSpell(int ownerId) { int entityId = EntityManager.createEntity(); FactionComponent ownerFactionComponent = EntityManager.getFactionComponent(ownerId); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId, new List<Faction>(new[] { ownerFactionComponent.faction })); AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(ownerId); Action<Skill, int, int> onHitOther = (skill, attackerId, defenderId) => { PiercingSkill piercingSkill; // Skip if not the piercing skill if (skill.type != SkillType.Piercing) { return; } piercingSkill = skill as PiercingSkill; // Skip if defender is dead if (!EntityManager.doesEntityExist(defenderId)) { return; } // Roll chance to proc if (Roller.roll(piercingSkill.bleedingChanceToProc) == 1) { EntityFactory.createDoTSpell(defenderId, DamageType.Physical, piercingSkill.bleedingDamageDie, piercingSkill.bleedingTickDelay, piercingSkill.bleedingTickCount); } }; affectedEntitiesComponent.entities.Add(ownerId); affectedBySpellEntitiesComponent.spellEntities.Add(entityId); EntityManager.addComponent(entityId, new ProcComponent(entityId, onHitOther, null)); EntityManager.addComponent(entityId, affectedEntitiesComponent); return entityId; }
// Create general proc spell public static int createProcSpell(int targetEntityId, Action<Skill, int, int> onHitOther = null, Action<Skill, int, int> onHitByOther = null) { int entityId = EntityManager.createEntity(); ProcComponent procComponent = new ProcComponent(entityId, onHitOther, onHitByOther); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId); AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(targetEntityId); affectedEntitiesComponent.entities.Add(targetEntityId); affectedBySpellEntitiesComponent.spellEntities.Add(entityId); EntityManager.addComponent(entityId, procComponent); EntityManager.addComponent(entityId, affectedEntitiesComponent); return entityId; }
// Create infusion spell public static int createInfusionSpell(int targetEntityId, int maxHpMod, int strengthMod, int armorClassMod, int timeToLive) { int entityId = EntityManager.createEntity(); TimeToLiveComponent timeToLiveComponent = new TimeToLiveComponent(entityId, timeToLive); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId); AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(targetEntityId); StatModifierComponent statModifierComponent = new StatModifierComponent(entityId); affectedEntitiesComponent.entities.Add(targetEntityId); affectedBySpellEntitiesComponent.spellEntities.Add(entityId); statModifierComponent.maxHpMod = maxHpMod; statModifierComponent.strengthMod = strengthMod; statModifierComponent.armorClassMod = armorClassMod; EntityManager.addComponent(entityId, timeToLiveComponent); EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, statModifierComponent); return entityId; }
// Create golem stance spell public static int createGolemStanceSpell(int ownerId, float mitigationPercentage) { int entityId = EntityManager.createEntity(); AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(ownerId); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId); affectedEntitiesComponent.entities.Add(ownerId); affectedBySpellEntitiesComponent.spellEntities.Add(entityId); EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, new DamageMitigationComponent(entityId, mitigationPercentage)); EntityManager.addComponent(entityId, new SpellTypeComponent(entityId, SpellType.GolemStance)); return entityId; }
// Create frenzy spell public static int createFrenzySpell(int ownerId, int damageBonus, int attackDelayBonus, int timeToLive) { int entityId = EntityManager.createEntity(); AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(ownerId); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId); StatModifierComponent statModifierComponent = new StatModifierComponent(entityId); affectedEntitiesComponent.entities.Add(ownerId); affectedBySpellEntitiesComponent.spellEntities.Add(entityId); statModifierComponent.attackDelayMod = -attackDelayBonus; statModifierComponent.damageDieMod = damageBonus; EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, statModifierComponent); EntityManager.addComponent(entityId, new TimeToLiveComponent(entityId, timeToLive)); return entityId; }
// Create flame aura spell public static int createFlameAuraSpell(int targetId, float radius, string chanceToProc, string damageDie, int tickDelay, int tickCount, List<Faction> factionsToAffect) { int entityId = EntityManager.createEntity(); PositionComponent positionComponent = EntityManager.getPositionComponent(targetId); TrackEntityPositionComponent trackEntityPositionComponent = new TrackEntityPositionComponent(entityId, targetId); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId, factionsToAffect); AreaOfEffectComponent areaOfEffectComponent; Body sensor = BodyFactory.CreateCircle(SystemManager.physicsSystem.world, radius, 1f, positionComponent.position); Action<Skill, int, int> onHitOther; sensor.UserData = entityId; sensor.BodyType = BodyType.Static; sensor.CollidesWith = (ushort)CollisionCategory.None; areaOfEffectComponent = new AreaOfEffectComponent(entityId, sensor); onHitOther = (skill, attackerId, defenderId) => { // Skip if defender doesn't exist if (!EntityManager.doesEntityExist(defenderId)) { return; } if (Roller.roll(chanceToProc) == 1) { createDoTSpell(defenderId, DamageType.Fire, damageDie, tickDelay, tickCount); } }; EntityManager.addComponent(entityId, trackEntityPositionComponent); EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, areaOfEffectComponent); EntityManager.addComponent(entityId, new ProcComponent(entityId, onHitOther, null)); EntityManager.addComponent(entityId, new IgnoreBridgeRaycastComponent(entityId)); EntityManager.addComponent(entityId, new IgnoreRopeRaycastComponent(entityId)); return entityId; }
// Generic dot spell -- TODO: Incorporate the type of damage public static int createDoTSpell(int targetEntityId, DamageType damageType, string damageDie, int tickDelay, int tickCount) { int entityId = EntityManager.createEntity(); FactionComponent factionComponent = EntityManager.getFactionComponent(targetEntityId); DamageOverTimeComponent damageOverTimeComponent = new DamageOverTimeComponent(entityId, damageType, damageDie, tickDelay); TimeToLiveComponent timeToLiveComponent = new TimeToLiveComponent(entityId, tickCount * tickDelay); AffectedEntitiesComponent affectedEntitiesComponent = new AffectedEntitiesComponent(entityId); AffectedBySpellEntitiesComponent affectedBySpellEntitiesComponent = EntityManager.getAffectedBySpellEntitiesComponent(targetEntityId); DispellableComponent dispellableComponent = new DispellableComponent(entityId, new List<Faction>(new [] { factionComponent.faction })); affectedEntitiesComponent.entities.Add(targetEntityId); affectedBySpellEntitiesComponent.spellEntities.Add(entityId); EntityManager.addComponent(entityId, damageOverTimeComponent); EntityManager.addComponent(entityId, timeToLiveComponent); EntityManager.addComponent(entityId, affectedEntitiesComponent); EntityManager.addComponent(entityId, dispellableComponent); return entityId; }