123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445 |
- using System;
- using System.Collections.Generic;
- using System.Text;
- using CommonLang.Log;
- using System.Xml;
- using System.IO;
- using CommonAI.Zone.ZoneEditor;
- using CommonLang.Concurrent;
- using CommonLang;
- using CommonAI.Zone.UnitTriggers;
- using CommonAI.Zone.Instance;
- using CommonLang.XCSV;
- using static CommonAI.Zone.Instance.InstanceUnit;
- using CommonAI.Data;
- using CommonAI.Zone.Helper;
- using CommonAI.ZoneServer.JSGModule;
- namespace CommonAI.Zone.Formula
- {
- public class AttackSource
- {
-
-
-
- public readonly AttackProp Attack;
-
-
-
- public readonly SkillTemplate FromSkill;
-
-
-
- public readonly SpellTemplate FromSpell;
-
-
-
- public readonly BuffTemplate FromBuff;
-
-
-
- public readonly InstanceUnit.SkillState FromSkillState;
-
-
-
- public readonly InstanceUnit.BuffState FromBuffState;
-
-
-
- public readonly InstanceSpell FromSpellUnit;
-
-
-
- public readonly XmdsSkillType FromSkillType = XmdsSkillType.none;
-
-
-
- public bool OutSendEvent = true;
-
-
-
- public bool OutHitted;
-
-
-
- public bool OutIsDamage;
-
-
-
- public bool OutIsCrush;
-
-
-
- public bool OutHasFly;
-
-
-
- public bool OutHasKnockDown;
-
-
-
- public int OutKnockDownTimeMS;
-
-
-
- public LaunchEffect OutHitEffect;
- public float OutWeight;
- public StartMove OutHitMove;
-
-
-
- public object OutExtendsResult;
-
-
-
- public byte OutClientState;
- public int OutClientStateExt;
-
- public int ignoreDef;
-
- private bool hasHitted;
-
- public float mDmgAddPer;
- public bool HasHitted { get { return hasHitted; } set {
- if(value && !hasHitted)
- {
- callHitTarget();
- }
- hasHitted = value;
- }
- }
- public AttackSource(InstanceUnit.SkillState skill, AttackProp attack)
- {
- this.Attack = attack;
- this.FromSkill = skill.Data;
- this.FromSkillState = skill;
- this.FromSpell = null;
- this.FromSpellUnit = null;
- this.FromBuff = null;
- this.FromBuffState = null;
- this.FromSkillType = skill.GetSkillType();
- }
- public AttackSource(InstanceUnit.BuffState buff, AttackProp attack)
- {
- this.Attack = attack;
- this.FromSkill = null;
- this.FromSkillState = null;
- this.FromSpell = null;
- this.FromSpellUnit = null;
- this.FromBuff = buff.Data;
- this.FromBuffState = buff;
- }
- public AttackSource(InstanceSpell spell, AttackProp attack)
- {
- this.Attack = attack;
- this.FromSkill = null;
- this.FromSkillState = null;
- this.FromSpell = spell.Info;
- this.FromSpellUnit = spell;
- this.FromBuff = null;
- this.FromBuffState = null;
- this.FromSkillType = spell.FromSkillType;
- }
- public void Begin(InstanceUnit target)
- {
- this.OutIsCrush = CUtils.RandomPercent(target.RandomN, Attack.CrushPercent);
- this.OutHitEffect = Attack.Effect;
- this.OutWeight = (Attack.Weight - target.Weight);
- this.OutIsDamage = (OutWeight > 0) && (Attack.MaskDamage) && (!target.IsNoneBlock);
- this.OutHitted = true;
- if (OutIsDamage)
- {
- this.OutHasFly = Attack.MaskHitFly;
- this.OutHasKnockDown = Attack.MaskKnockDown;
- this.OutKnockDownTimeMS = Attack.KnockOutTimeMS;
- this.OutHitMove = Attack.HitMove;
- }
- else
- {
- this.OutHasFly = false;
- this.OutHasKnockDown = false;
- this.OutKnockDownTimeMS = 0;
- this.OutHitMove = null;
- }
- if (this.FromSpellUnit != null && this.FromSpellUnit.ChainInfo != null)
- {
- this.FromSpellUnit.ChainInfo.AddTarget(target);
- }
- }
- public ITemplateData Weapon
- {
- get
- {
- if (FromSkill != null) { return FromSkill; }
- if (FromSpell != null) { return FromSpell; }
- if (FromBuff != null) { return FromBuff; }
- return null;
- }
- }
- public AttackSource GenAttackSource(AttackProp attack)
- {
- if (FromSkillState != null)
- {
- return new AttackSource(this.FromSkillState, attack);
- }
- if (FromBuffState != null)
- {
- return new AttackSource(this.FromBuffState, attack);
- }
- if (FromSpellUnit != null)
- {
- return new AttackSource(this.FromSpellUnit, attack);
- }
- return null;
- }
- public SkillTemplate.CastTarget FromExpectTarget
- {
- get
- {
- if (FromSkill != null)
- {
- return FromSkill.ExpectTarget;
- }
- if (FromSpell != null)
- {
- return FromSpell.ExpectTarget;
- }
- return SkillTemplate.CastTarget.NA;
- }
- }
- public void callHitTarget()
- {
- InstanceUnit attacker = null;
- if (FromSkillState != null)
- {
- attacker = FromSkillState.Owner;
- }
- else if (FromSpellUnit !=null)
- {
- attacker = FromSpellUnit.Launcher;
- }
- if (attacker != null)
- attacker.onSkillHitTarget();
- }
- }
- public interface IVirtualUnit
- {
- void OnInit(InstanceUnit owner, bool pointLv);
- void OnDispose(InstanceUnit owner);
- bool ChangeSkill(int oldSkillID, int newSkillID, SkillLevelData data);
-
- void SyncBattlePropsFields(ulong mask);
-
-
-
- BattleStatus GetBattleStatus();
- int GetInventorySize();
- bool IsInPVP();
- bool IsInPVE();
-
- void SetCombatState(BattleStatus value, byte reason = 0, string pvpTriggerID = "");
-
- bool IsAllies(IVirtualUnit target, bool includeSelf = true, bool onlyForTeam = false);
-
- void doEvent(JSGCustomOpType type);
- void TakeOffMount();
- void SendMsgToClient(string msg);
- void SendMsgToPlayer(ObjectEvent evt, bool force = false);
-
- int GetForceID();
-
- string GetGuildID();
-
- bool IsGuildMember(string id);
-
- PKLevel GetCurPKLevel();
-
- bool IsServerMember(int id);
-
- int GetServerID();
-
- int GetBaseSkillID();
-
- PKMode GetCurPKMode();
-
- int GetHealedEffect();
-
- int GetHealEffect();
-
- XmdsUnitPro GetUnitPro();
-
- int GetUnitSex();
-
- int GetPetTalentAddition(UnitFateType type);
-
- UnitFateType GetUnitFateType();
-
- bool IsInSafeArea();
- bool LaunchSkillCheckTalentInfo(InstanceUnit.SkillState skill);
-
- void DispatchSkillBlockEvent(InstanceUnit.StateSkill skill, InstanceUnit.State newState);
-
- int DispatchAddOtherHPEvent(int hp, InstanceUnit sender, AttackSource source);
-
- void DispatchAddMPEvent(int mp, InstanceUnit sender, out int finalMP, AttackSource source);
-
- void DispatchSendSpellOverEvent(LaunchSpell launch, SpellTemplate spt, float startX, float startY);
-
- void SetSkillActive(int skillTemplateID, bool active, bool pause_on_deactive = false);
-
- bool DispatchKillOtherEvent(IVirtualUnit attacker, IVirtualUnit deader);
-
- void OnPlayerKillMonster(InstanceUnit monster);
-
-
-
- int GetMaType();
- bool IsBoss();
- uint GetMasterID();
- InstanceUnit GetMasterUnit();
- void StartRecoverMP(bool reset = false);
- bool IsCanReduceMP(bool force);
-
- InstanceUnit GetPetUnit();
- }
- public interface IVirtualClientUnit
- {
- void OnInit(ZoneClient.ZoneUnit owner);
- void OnDispose(ZoneClient.ZoneUnit owner);
- }
- public abstract class IFormula
- {
-
- #region SYSTEM
-
-
-
-
- public virtual void BindLogger(Logger log)
- {
- }
-
-
-
-
- public virtual void InitPluginsData(EditorTemplates data_root)
- {
- }
-
-
-
-
-
-
-
- public virtual void OnEditorSaving(EditorTemplatesData datas, DirectoryInfo data_root, List<FileInfo> savedfiles, AtomicFloat progress_percent)
- {
- }
-
-
-
-
-
- public virtual void ListXCSVFiles(DirectoryInfo data_root, List<FileInfo> xls_files)
- {
- }
-
-
-
-
-
-
-
- public virtual void OnEditorPluginSaved(ZoneEditor.EditorTemplatesData datas, List<XCSVMeta> xls2csv, List<FileInfo> savedfiles, AtomicFloat progress_percent)
- {
- }
- #endregion
-
- #region HIT_AND_DAMAGE
- public virtual int OnHit(InstanceUnit attacker, AttackSource attack, InstanceUnit targget) { return attack.Attack.Attack; }
- public virtual void OnUnitDead(InstanceUnit targget, InstanceUnit killer) { }
- public virtual void OnUnitRemoved(InstanceUnit unit) { }
- public virtual bool TryLaunchSkill(InstanceUnit attacker, InstanceUnit.SkillState skill, ref InstanceUnit.LaunchSkillParam param) { return true; }
- public virtual bool TriggerPetSkill(InstanceUnit attacker, InstanceUnit.SkillState skill, ref InstanceUnit.LaunchSkillParam param) { return true; }
- public virtual bool TryResetSkill(InstanceUnit owner) { return true; }
- public virtual bool TryLaunchSpell(InstanceUnit launcher, LaunchSpell launch, ref SpellTemplate spell, out JSGCreateSpellData createData, ref float startX, ref float startY)
- {
- createData = null;
- return true;
- }
- public virtual bool TryAddBuff(InstanceUnit owner, InstanceUnit sender, ref BuffTemplate buff, out object tag) { tag = null; return true; }
- public virtual bool TryLaunchTrigger(InstanceUnit owner, UnitTriggerTemplate trigger, UnitTriggers.BaseTriggerEvent evt, AttackSource source) { return true; }
- public virtual bool TrySummonUnit(InstanceUnit owner, SummonUnit summon, ref UnitInfo summonUnit, ref string name) { return true; }
- public virtual bool TryUseItem(InstanceUnit owner, ItemTemplate item, InstanceUnit item_creater) { return true; }
- public virtual void SendAddBuffEvent(InstanceUnit owner, InstanceUnit sender, BuffTemplate buff) {}
- #endregion
-
- #region STATUS
- public virtual void OnTriggerStart(InstanceUnit unit, InstanceUnit.TriggerState trigger, InstanceUnit target) { }
- public virtual void OnUpdateTriggerSkill(InstanceUnit unit, int intervalMS, bool slowRefresh) { }
- public virtual void OnBuffBegin(InstanceUnit unit, InstanceUnit.BuffState buff, InstanceUnit sender) { }
- public virtual void OnBuffUpdate(InstanceUnit unit, InstanceUnit.BuffState buff, int time) { }
- public virtual void OnBuffEnd(InstanceUnit unit, InstanceUnit.BuffState buff, string result, bool replace) { }
- public virtual void OnGotInventoryItem(InstanceUnit unit, ItemTemplate item) { }
- public virtual void OnLostInventoryItem(InstanceUnit unit, ItemTemplate item) { }
- public virtual void OnUseItem(InstanceUnit unit, ItemTemplate item, InstanceUnit item_creater) { }
- #endregion
-
- #region NET
- public virtual void OnZoneHandleNetMessage(InstanceZone zone, Action action) { }
- public virtual void OnUnitHandleNetMessage(InstanceUnit unit, ObjectAction action) { }
- #endregion
-
- }
- }
|