// ------------------------------------------------------------------------------- // DamageTargets // ------------------------------------------------------------------------------- public static void DamageTargets(CharacterBase source, InstanceBase activator, int amount, CharacterBase[] targets) { foreach (CharacterBase target in targets) { if (target != null) { int level = 0; int accuracy = 0; TemplateAdvanced template = null; if (activator is InstanceItem) { template = ((InstanceItem)activator).template; //level = ((InstanceItem)activator).level; } else if (activator is InstanceSkill) { template = ((InstanceSkill)activator).template; level = ((InstanceSkill)activator).level; } amount += template.CalculatedEffect(source, target, level); if (source != null) { accuracy = source.stats.Accuracy; } amount = RPGHelper.CalculateFinalDamage(amount, template.attackType, template.element, target); if (source != null) { amount += source.CalculateHitType(amount, target, template); } target.InflictBuffs(template.useBuffType, accuracy, false, template.removeBuff); if (target.parent != null && template.hitEffect != null) { Finder.fx.SpawnEffect(target.parent.transform, template.hitEffect); } amount = target.InflictDamage(amount); Finder.log.Add(string.Format("{0} {1} {2} {3}", target.Name, Finder.txt.actionNames.takes, amount, Finder.txt.basicVocabulary.damage)); } } }
// ------------------------------------------------------------------------------- // ActionRecover // ------------------------------------------------------------------------------- protected void ActionRecover(InstanceBase activator, bool targetAll = false) { int amount = 0; CharacterBase[] targets; if (targetAll) { targets = Finder.party.characters.ToArray(); } else { targets = RPGHelper.getRandomPlayer(); } RPGHelper.RecoverTargets(null, activator, amount, targets); }
// ------------------------------------------------------------------------------- // RecoverTargets // ------------------------------------------------------------------------------- public static void RecoverTargets(CharacterBase source, InstanceBase activator, int amount, CharacterBase[] targets) { foreach (CharacterBase target in targets) { if (target != null) { int level = 0; int accuracy = 0; string text_before = ""; string text_after = ""; TemplateAdvanced template = null; if (activator is InstanceItem) { template = ((InstanceItem)activator).template; //level = ((InstanceItem)activator).level; } else if (activator is InstanceSkill) { template = ((InstanceSkill)activator).template; level = ((InstanceSkill)activator).level; } amount = template.CalculatedEffect(source, target, level); if (target.parent != null && template.hitEffect != null) { Finder.fx.SpawnEffect(target.parent.transform, template.hitEffect); } if (source != null) { accuracy = source.stats.Accuracy; } target.InflictBuffs(template.useBuffType, accuracy, true, template.removeBuff); // -- Apply Stat Boost if (template.recoveryStat != null) { CharacterAttribute attrib = target.stats.attributes.FirstOrDefault(x => x.template == template.recoveryStat); if (attrib != null) { attrib.value += amount; } Finder.log.Add(string.Format("{0} {1} {2} {3}", target.Name, Finder.txt.actionNames.gained, amount, template.recoveryStat.fullName)); } // -- Apply Recovery switch (template.recoveryType) { case RecoveryType.HP: amount = target.RestoreHP(amount); text_before = Finder.txt.actionNames.recovered; text_after = Finder.txt.basicDerivedStatNames.HP; break; case RecoveryType.MP: amount = target.RestoreMP(amount); text_before = Finder.txt.actionNames.recovered; text_after = Finder.txt.basicDerivedStatNames.MP; break; case RecoveryType.HPandMP: target.RestoreMP(amount); amount = target.RestoreHP(amount); text_before = Finder.txt.actionNames.recovered; text_after = Finder.txt.basicDerivedStatNames.HP + " & " + Finder.txt.basicDerivedStatNames.MP; break; case RecoveryType.XP: target.XP += amount; text_before = Finder.txt.actionNames.gained; text_after = Finder.txt.basicDerivedStatNames.XP; break; } if (template.recoveryType != RecoveryType.None) { Finder.log.Add(string.Format("{0} {1} {2} {3}", target.Name, text_before, amount, text_after)); } } } }