Beispiel #1
0
 //skill but on place
 public Action(ActiveSkill actSkill, Skill skill, Database.Entity attacker, Map.Nod pos)
 {
     this.skill    = skill;
     this.actSkill = actSkill;
     this.attacker = attacker;
     this.position = pos;
 }
Beispiel #2
0
 //skill
 public Action(ActiveSkill actSkill, Skill skill, Database.Entity attacker, int target)
 {
     this.skill    = skill;
     this.actSkill = actSkill;
     this.attacker = attacker;
     this.targetID = target;
     this.position = new Map.Nod();
 }
        public async Task <IEntityView> EntityAdd(IEntityAdd entityAdd)
        {
            try
            {
                var result = new EntityView();
                using (var db = new InvoiceContext())
                {
                    var entity = new Database.Entity();
                    db.Entitys.Add(entity);
                    if (entityAdd.Address == null)
                    {
                        entity.Address = new Address();
                    }
                    else
                    {
                        entity.Address = new Address()
                        {
                            AddresLine2        = entityAdd.Address.AddresLine2,
                            AddressExternalRef = entityAdd.Address.AddressExternalRef,
                            AddressLine1       = entityAdd.Address.AddressLine1,
                            AddressLine3       = entityAdd.Address.AddressLine3,
                            City        = entityAdd.Address.City,
                            Country     = entityAdd.Address.Country,
                            PostZipCode = entityAdd.Address.PostZipCode,
                            StateCounty = entityAdd.Address.StateCounty,
                        };
                    }
                    entity.EntityExternalRef = entityAdd.EntityExternalRef;
                    entity.LogoURL           = entityAdd.LogoURL;
                    entity.Name = entityAdd.Name;
                    entity.SMTPEmailDisplayName = entityAdd.SMTPEmailDisplayName;
                    entity.SMTPEmailFromAddress = entityAdd.SMTPEmailFromAddress;
                    entity.SMTPHost             = entityAdd.SMTPHost;
                    entity.SMTPPassword         = entityAdd.SMTPPassword;
                    entity.SMTPUserName         = entityAdd.SMTPUserName;
                    //UserCodeBlockStart-PreSave

                    //UserCodeBlockEnd-PreSave
                    await db.SaveChangesAsync();

                    result.Address                    = new AddressView();
                    result.Address.AddresLine2        = entity.Address.AddresLine2;
                    result.Address.AddressExternalRef = entity.Address.AddressExternalRef;
                    result.Address.AddressLine1       = entity.Address.AddressLine1;
                    result.Address.AddressLine3       = entity.Address.AddressLine3;
                    result.Address.City               = entity.Address.City;
                    result.Address.Country            = entity.Address.Country;
                    result.Address.PostZipCode        = entity.Address.PostZipCode;
                    result.Address.StateCounty        = entity.Address.StateCounty;
                    result.EntityExternalRef          = entity.EntityExternalRef;
                    result.EntityId                   = entity.EntityId;
                    result.LogoURL                    = entity.LogoURL;
                    result.Name = entity.Name;
                    result.SMTPEmailDisplayName = entity.SMTPEmailDisplayName;
                    result.SMTPEmailFromAddress = entity.SMTPEmailFromAddress;
                    result.SMTPHost             = entity.SMTPHost;
                    result.SMTPPassword         = entity.SMTPPassword;
                    result.SMTPUserName         = entity.SMTPUserName;
                    //UserCodeBlockStart-PreResult
                    //UserCodeBlockEnd-PreResult
                    return(result);
                }
            }
            catch (Exception e)
            {
                LogFactory.GetLogger().Log(LogLevel.Error, e);
                return(new EntityView()
                {
                    __CQRSSuccessful = false, __CQRSErrorMessage = "Unable to create EntityView", __CQRSStatusCode = 500
                });
            }
        }
Beispiel #4
0
        void Ism.Attack()
        {
            Output.WriteLine("Mob in ATTACK state");
            if (moving)//stop mob on current position...
            {
                /*
                 * moving = false;
                 * tmX = (int)(PosX * 10000);
                 * tmY = (int)(PosY * 10000);
                 * //GameServer.world.BroadcastPacket(PosX, PosY, World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.MoveStop(uniqueID, tmX, tmY));
                 * currentState = EntityState.STATE.STOP_MOVE;
                 * Map.Nod curNod = GameServer.world.GetTileAddress((uint)PosX, (uint)PosY);
                 * if (curNod.X != MapPosition.X || curNod.Y != MapPosition.Y)
                 * {
                 *  //player moved to new map tile
                 *  MapPosition.X = curNod.X;
                 *  MapPosition.Y = curNod.Y;
                 *  GameServer.world.MoveMobOnMap(this, OldMapPosition, MapPosition);
                 *  OldMapPosition.X = curNod.X;
                 *  OldMapPosition.Y = curNod.Y;
                 * }
                 */
            }
            //get the attacker
            Database.Entity attEntity = null;
            while (true)
            {
                int attackerId = AttackerID;
                if (attackerId == -1)
                {
                    //no attackers in list, back to stand state and return;
                    IsAttacked   = false;
                    cSM.SetState = AI.CoreStateMachine.State.STAND;
                    Output.WriteLine("No attackers found");
                    return;
                }
                attEntity = GameServer.world.GetEntity(attackerId);
                if (attEntity == null)
                {
                    RemoveAttacker(attackerId);
                    Output.WriteLine("Remove attacke that no longer exists");
                }
                else
                {
                    //continue with attacker we got from list
                    //Output.WriteLine("Got attacker from list  - continue");
                    break;
                }
            }
            //continue
            if (attEntity == null)
            {
                //shouldn't happens..
                IsAttacked   = false;
                cSM.SetState = AI.CoreStateMachine.State.STAND;
                Output.WriteLine("Enity is null! - shouldn't happens...");
                return;
            }
            //check range from attacker, if far go to him if we are close hit him
            int distance = GameServer.world.GetDistance(PosX, PosY, attEntity.PosX, attEntity.PosY);

            if (distance > AttackRange)
            {
                //goto attacker
                newX   = attEntity.PosX;
                newY   = attEntity.PosY;
                moving = true;
                //Output.WriteLine("Distance to attacker is biger then aattackRange -> go to him");
                //Output.WriteLine("GoTo: " + newX.ToString() + "," + newY.ToString() + " Distance: " + distance.ToString());
            }
            else
            {
                //hit attacker
                Output.WriteLine("MOB HIT ATTACKER..");
                IsAttacked   = false;
                cSM.SetState = AI.CoreStateMachine.State.WONDER;
            }
        }
Beispiel #5
0
 private async Task PreDeleting(Database.Entity entity)
 {
     await OnDeleting((TEntity)entity);
 }
Beispiel #6
0
 private async Task PostUpdated(Database.Entity entity)
 {
     await OnUpdated((TEntity)entity);
 }
Beispiel #7
0
 private async Task PostCreated(Database.Entity entity)
 {
     await OnCreated((TEntity)entity);
 }
Beispiel #8
0
        public void DoAction()
        {
            BroadcastPacket bPacket = null;

            //skill
            if (actSkill != null)
            {
                if (skill == null)
                {
                    Output.WriteLine("Action::DoAction skill can't be null");
                    return;
                }
                Output.WriteLine("Action::DoAction Skill attack");
                //check if target is correct one and is in skill range ect.
                //distance..
                switch (skill.demageFlag)
                {
                //skills that need to give target entity
                case SKILL_DEMAGE_FLAG.SINGLE_TARGET_FLAG:
                case SKILL_DEMAGE_FLAG.MULTI_TARGET_FLAG:
                {
                    int range = GameServer.world.GetDistance(attacker.PosX, attacker.PosY, targetID);
                    Output.WriteLine("Action::DoAction Range from attacker to target = " + range.ToString());
                    if (range > skill.range)
                    {
                        Output.WriteLine("Action::DoAction Target outside skill range! (" + range.ToString() + "->" + skill.range.ToString() + ")");
                        break;
                    }
                    Database.Entity entity = GameServer.world.GetEntity(targetID);
                    if (entity == null)
                    {
                        break;
                    }
                    Database.Entity.Attacker att = new Database.Entity.Attacker();
                    att.dmgDeal       = CalculateMagicDmg(attacker, entity);
                    att.attackerID    = attacker.InternalID;
                    entity.IsAttacked = true;
                    entity.AddAttacker(att);
                    position.X = (uint)entity.PosX;
                    position.Y = (uint)entity.PosY;
                    bPacket    = new BroadcastPacket((uint)attacker.PosX, (uint)attacker.PosY, (int)World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.AttackMag(attacker.InternalID, targetID, actSkill.skillID, actSkill.skillLvl));
                    entity.GetDemage(att.dmgDeal);
                    Output.WriteLine("Action::DoAction Attacker demage: " + att.dmgDeal.ToString());
                }
                break;

                //skills that are place related not target entity
                case SKILL_DEMAGE_FLAG.POSITION_TARGET_FLAG:
                case SKILL_DEMAGE_FLAG.CON_45_FLAG:
                case SKILL_DEMAGE_FLAG.CON_90_FLAG:
                case SKILL_DEMAGE_FLAG.AOE_TARGET_FLAG:
                {
                    int range = GameServer.world.GetDistance(attacker.PosX, attacker.PosY, (int)position.X, (int)position.Y);
                    Output.WriteLine("Action::DoAction Range from attacker to target = " + range.ToString());
                    if (range > skill.range)
                    {
                        Output.WriteLine("Action::DoAction Target outside skill range! (" + range.ToString() + "->" + skill.range.ToString() + ")");
                        break;
                    }
                    //GameServer.world.get
                    bPacket = new BroadcastPacket((uint)attacker.PosX, (uint)attacker.PosY, (int)World.DEBUG_SIGHT_RANGE, new Packet.SendPacketHandlers.AttackMag(attacker.InternalID, targetID, actSkill.skillID, actSkill.skillLvl));
                }
                break;

                default:
                    Output.WriteLine("Skill has inncorrect DEMAGE FLAG SET");
                    break;
                }
                if (bPacket != null)
                {
                    GameServer.world.BroadcastPacket((int)bPacket.X, (int)bPacket.Y, (uint)bPacket.Range, bPacket.Packet);
                }
                //GameServer.world.broadcastQueue.Enqueue(bPacket);
            }
            else//physical attack
            {
                Output.WriteLine("Action::DoAction Normall attack");
            }
        }
Beispiel #9
0
 //physicall attack
 public Action(Database.Entity attacker, int target)
 {
     this.attacker = attacker;
     this.targetID = target;
     this.position = new Map.Nod();
 }
Beispiel #10
0
        int CalculateMagicDmg(Database.Entity attacker, Database.Entity target)
        {
            int dmg     = 0;
            int fromInt = attacker.Intel / 2;
            int fromWiz = attacker.Wisdom / 8;
            int minDmg  = skill.minDmg + (((fromInt + fromWiz) * actSkill.skillLvl) * 5); // skill.minDmg + (((attacker.Intel / 2 + attacker.Wisdom / 8)* actSkill.skillLvl) * 5);
            int maxDmg  = skill.maxDmg + (((fromInt + fromWiz) * actSkill.skillLvl) * 5); // skill.maxDmg + (((attacker.Intel / 2 + attacker.Wisdom / 8) * actSkill.skillLvl) * 5);

            Output.WriteLine(ConsoleColor.Yellow, "Action::CalculateMagicDmg Att int: " + attacker.Intel.ToString() + " Att wiz: " + attacker.Wisdom.ToString() + " Skill lvl: " + actSkill.skillLvl.ToString());
            Output.WriteLine(ConsoleColor.Yellow, "Action::CalculateMagicDmg From int: " + fromInt.ToString() + " From wiz: " + fromWiz.ToString() + " min/max : " + skill.minDmg.ToString() + "/" + skill.maxDmg.ToString());

            switch (skill.magicType)
            {
            case SKILL_MAGIC_TYPE_FLAG.LIGHTENING_FLAG:
                int fromSkill = Program.random.Next(minDmg, maxDmg);
                int fromWeapo = Program.random.Next(attacker.WeaponMinMagDmg, attacker.WeaponMaxMagDmg);
                int resist    = target.ResistLight;
                Output.WriteLine("Action::CalculateMagicDmg From skill: " + fromSkill.ToString() + " From weapon: " + fromWeapo.ToString() + " Resist: " + resist.ToString());
                dmg = fromSkill + fromWeapo - resist;
                //dmg = Program.random.Next(minDmg, maxDmg) + Program.random.Next(attacker.WeaponMinMagDmg, attacker.WeaponMaxMagDmg) - target.ResistLight;
                if (dmg < 0)
                {
                    dmg = 0;
                }
                break;

            case SKILL_MAGIC_TYPE_FLAG.ICE_FLAG:
                dmg = Program.random.Next(minDmg, maxDmg) + Program.random.Next(attacker.WeaponMinMagDmg, attacker.WeaponMaxMagDmg) - target.ResistIce;
                if (dmg < 0)
                {
                    dmg = 0;
                }
                break;

            case SKILL_MAGIC_TYPE_FLAG.FIRE_FLAG:
                dmg = Program.random.Next(minDmg, maxDmg) + Program.random.Next(attacker.WeaponMinMagDmg, attacker.WeaponMaxMagDmg) - target.ResistFire;
                if (dmg < 0)
                {
                    dmg = 0;
                }
                break;

            case SKILL_MAGIC_TYPE_FLAG.EARTH_FLAG:
                dmg = Program.random.Next(minDmg, maxDmg) + Program.random.Next(attacker.WeaponMinMagDmg, attacker.WeaponMaxMagDmg) - target.ResistEarth;
                if (dmg < 0)
                {
                    dmg = 0;
                }
                break;

            case SKILL_MAGIC_TYPE_FLAG.DEATH_FLAG:
                dmg = Program.random.Next(minDmg, maxDmg) + Program.random.Next(attacker.WeaponMinMagDmg, attacker.WeaponMaxMagDmg) - target.ResistDeath;
                if (dmg < 0)
                {
                    dmg = 0;
                }
                break;

            case SKILL_MAGIC_TYPE_FLAG.NULL_FLAG:
                break;

            default:
                break;
            }
            return(dmg);
        }