public RPGEffect(RPGEffect copy) { range = copy.range; durationType = copy.durationType; targetBuff = copy.targetBuff; targetAttack = copy.targetAttack; effectIsABuff = copy.effectIsABuff; trigger = copy.trigger; status = copy.status; location = copy.location; sourceObject = copy.sourceObject; targetObject = copy.targetObject; distance = copy.distance; radius = copy.radius; durationValue = copy.durationValue; minPower = copy.minPower; maxPower = copy.maxPower; m_Power = copy.Power; lastStart = copy.lastStart; lastPause = copy.lastPause; durationRemaining = copy.durationRemaining; repeatCount = copy.repeatCount; m_repeatDelay = copy.m_repeatDelay; m_lastRepeat = copy.m_lastRepeat; m_shouldReverse = copy.m_shouldReverse; powerType = copy.PowerType; }
public static RPGSpell CreateRandomSpell() { RPGSpell spell = new RPGSpell(); spell.Stage = SpellStage.Dormant; spell.Effect = RPGEffect.CreateRandomSpellEffect(); spell.Realm = new RPGCalc().RandomSpellRealm(); return(spell); }
public static RPGPotion CreatePotionHealing(int minPower, int maxPower) { RPGEffect effect = new RPGEffect(RPGEffect.DurationType.Permanent, RPGEffect.EffectRange.Self, RPGEffect.EffectTargetBuff.RestoreHP, RPGEffect.EffectTargetAttack.DoPhysicalDamage, true, RPGEffect.EffectTrigger.Immediately, 0, 0, new TimeSpan(0, 0, 0), minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, false); return(new RPGPotion(effect)); }
public bool AddEffect(RPGEffect effect) { bool result = false; for (int i = 0; i < Effects.Length; i++) { if (Effects[i] == null) { Effects[i] = effect; result = true; break; } } // then no open slots return(result); }
public bool AreaEffectAppliesToActor(RPGEffect effect, Actor a) { switch (effect.Range) { case (RPGEffect.EffectRange.Area): { // then if actor a is in the area defined by a point and radius return(ActorIsInArea(a, effect.Location, effect.Radius)); } case (RPGEffect.EffectRange.Self): { return(a == effect.SourceObject); } case (RPGEffect.EffectRange.Target): { return(a == effect.TargetObject); } case (RPGEffect.EffectRange.TargetArea): { return(ActorIsInArea(a, effect.TargetObject.Location, effect.Radius)); } case (RPGEffect.EffectRange.Touch): { // ammend, not only the target, but also within touch range return(a == effect.TargetObject); } default: { //when in doubt, it doesn't apply return(false); } } }
public static RPGEffect CreateRandomSpellEffect() { #region Setup Vars RPGCalc calc = new RPGCalc(); DurationType t = DurationType.Permanent; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); EffectTrigger trigger = EffectTrigger.Immediately; EffectTargetBuff targetBuff = EffectTargetBuff.RestoreHP; EffectTargetAttack targetAttack = EffectTargetAttack.DoMagicalDamage; bool isBuff = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; bool reverse = true; #endregion #region Buff or Attack // 50/50 percent of offensive for completely random if (calc.Roll(2) == 1) { isBuff = true; } else { isBuff = false; } #endregion #region Range and Distance // check to avoid attacking self while (!isBuff && r == EffectRange.Self) { r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); } // roll for distance depending on range dist = 0; switch (r) { case (EffectRange.Self): { break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch #endregion #region Attack and Buff Effects // target buff effect targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); // target attack effect // 20% chance of being completely random if (calc.Roll(10) >= 8) { targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); } else // 80% chance of being magical damage { targetAttack = EffectTargetAttack.DoMagicalDamage; } #endregion #region Set Duration Types based on effect // isBuff and is restore, or isNotBuff and is Dmg if (isBuff) { // then we want to reverse all but the restore if (targetBuff == EffectTargetBuff.RestoreHP || targetBuff == EffectTargetBuff.RestoreMP) { reverse = false; t = DurationType.Permanent; } else { reverse = true; duration = calc.RollRandomEffectDuration(0, 0, 0, 60); t = DurationType.ForTime; } } else // it's an attack { // check to avoid reverse on dmg spells if (targetAttack == EffectTargetAttack.DoMagicalDamage || targetAttack == EffectTargetAttack.DoPhysicalDamage) { reverse = false; t = DurationType.Permanent; } else { reverse = true; duration = calc.RollRandomEffectDuration(0, 0, 0, 60); t = DurationType.ForTime; } } #endregion #region Power // roll for min/max power - start with generic minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // NOTE: dmg depends on duration and duration type - if long, then small dmg... #endregion #region Trigger // trigger - spell will cause effect immediately. trigger = EffectTrigger.Immediately; #endregion RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }
public static RPGEffect CreateRandomPotionEffect() { RPGCalc calc = new RPGCalc(); DurationType t = DurationType.ForTime; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r = EffectRange.Touch; EffectTrigger trigger = EffectTrigger.Immediately; EffectTargetBuff targetBuff = EffectTargetBuff.RestoreHP; EffectTargetAttack targetAttack = EffectTargetAttack.DoPhysicalDamage; bool isBuff = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; bool reverse = true; // roll for target targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); if (targetBuff == EffectTargetBuff.RestoreHP || targetBuff == EffectTargetBuff.RestoreMP) { reverse = false; } else { duration = calc.RollRandomEffectDuration(); } // roll for range while (r == EffectRange.Touch) { r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); } // roll for distance depending on range dist = 0; switch (r) { case (EffectRange.Self): { break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch // roll for min/max power minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // trigger - potion will cause effect to be used immediately. trigger = EffectTrigger.Immediately; RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }
public static RPGEffect CreateRandomWeaponEffect() { RPGCalc calc = new RPGCalc(); DurationType t = DurationType.WhileEquipped; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r; EffectTrigger trigger = EffectTrigger.onAttackLanded; EffectTargetBuff targetBuff; EffectTargetAttack targetAttack; bool isBuff = false; bool reverse = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; // roll for range r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); // roll for distance depending on range switch (r) { case (EffectRange.Self): { isBuff = true; break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch // roll for target targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); // roll for min/max power minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // roll for trigger while (trigger == EffectTrigger.onUse || trigger == EffectTrigger.onHit) { trigger = (EffectTrigger)calc.GetRandomEnum(typeof(EffectTrigger)); } RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }
public static RPGEffect CreateRandomEffect() { RPGCalc calc = new RPGCalc(); DurationType t = DurationType.ForTime; TimeSpan duration = new TimeSpan(0, 0, 0); EffectRange r = EffectRange.Target; EffectTrigger trigger = EffectTrigger.Immediately; EffectTargetBuff targetBuff; EffectTargetAttack targetAttack; bool isBuff = true; bool reverse = true; int dist = 0; int radius = 0; int minPower = 0; int maxPower = 0; // roll for type t = (DurationType)calc.GetRandomEnum(typeof(DurationType)); duration = new TimeSpan(0); if (t == DurationType.ForTime) { duration = calc.RollRandomEffectDuration(); // ticks (I think) } // roll for range r = (EffectRange)calc.GetRandomEnum(typeof(EffectRange)); // roll for distance depending on range dist = 0; switch (r) { case (EffectRange.Self): { break; } case (EffectRange.Touch): { dist = RPGCalc.DEFAULT_TOUCH_RANGE; break; } case (EffectRange.Target): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.Area): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } case (EffectRange.TargetArea): { dist = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); radius = calc.Roll(RPGCalc.DEFAULT_LOS_RANGE); break; } } // end switch // roll for target targetBuff = (EffectTargetBuff)calc.GetRandomEnum(typeof(EffectTargetBuff)); targetAttack = (EffectTargetAttack)calc.GetRandomEnum(typeof(EffectTargetAttack)); isBuff = (calc.Roll(2) == 1); // roll for min/max power minPower = calc.Roll(10); maxPower = minPower + calc.Roll(10); // roll for trigger trigger = (EffectTrigger)calc.GetRandomEnum(typeof(EffectTrigger)); RPGEffect e = new RPGEffect(t, r, targetBuff, targetAttack, isBuff, trigger, dist, radius, duration, minPower, maxPower, RPGEffect.EffectPowerType.StaticAmount, reverse); return(e); }
private void CheckEffects() { for (int i = 0; i < Effects.Length; i++) { if (Effects[i] != null) { RPGEffect effect = Effects[i]; // check to activate effect now if (effect.Status == RPGEffect.EffectStatus.Ready) { // decide if we should activate it right now. if (effect.Trigger == RPGEffect.EffectTrigger.Immediately) { effect.Status = RPGEffect.EffectStatus.ActiveToDo; } // Other triggers should have their status set as active at the event. } // once activeToDo or activeDone if (effect.IsActive) { // do effect if (effect.Status == RPGEffect.EffectStatus.ActiveToDo) { effect.Resume(); // sets the start time. effect.ApplyToTarget(this); effect.Status = RPGEffect.EffectStatus.ActiveDone; } // Now, decide what to do once the effect has taken place. // repeat immediately if (effect.ShouldRepeatNow()) { effect.Status = RPGEffect.EffectStatus.ActiveToDo; } // repeat later else if (effect.ShouldRepeat()) { effect.Status = RPGEffect.EffectStatus.Ready; } // don't repeat, just be done. else if (effect.HasExpired()) { effect.Status = RPGEffect.EffectStatus.Done; } } //once done, see if we should undo the effect. if (effect.Status == RPGEffect.EffectStatus.Done) { if (effect.ShouldReverse) { effect.UnApplyToTarget(this); } if (!effect.ShouldRepeat()) { // remove it. Effects[i] = null; } } } } }
public RPGPotion(RPGEffect effect) : base() { this.AddEffect(effect); this.Name = "P." + Enum.GetName(typeof(RPGEffect.EffectTargetBuff), effect.TargetBuff); this.UpdateDescription(); }
public static RPGPotion CreateRandomPotion() { RPGEffect effect = RPGEffect.CreateRandomPotionEffect(); return(new RPGPotion(effect)); }