78
156
 
156
 
157
        public static bool InLine(Map Map, int BeginCell, int EndCell)
157
        public static bool InLine(Map Map, int BeginCell, int EndCell)
158
        {
158
        {
159
            return GetX(Map, BeginCell) == GetX(Map, EndCell) || GetY(Map, BeginCell) == GetY(Map, EndCell);
159
            try
 
 
160
            {
 
 
161
                return GetX(Map, BeginCell) == GetX(Map, EndCell) || GetY(Map, BeginCell) == GetY(Map, EndCell);
 
 
162
            }
 
 
163
            catch (Exception ex)
 
 
164
            {
 
 
165
                return false;
 
 
166
            }
160
        }
167
        }
161
 
168
 
162
        public static int GoalDistance(Map Map, int BeginCell, int EndCell)
169
        public static int GoalDistance(Map Map, int BeginCell, int EndCell)
...
 
...
 
224
 
231
 
225
        public static int OppositeDirection(int Direction)
232
        public static int OppositeDirection(int Direction)
226
        {
233
        {
227
            return (Direction >=4 ? Direction - 4 : Direction + 4);
234
            return (Direction >= 4 ? Direction - 4 : Direction + 4);
228
        }
235
        }
229
 
236
 
230
        public static int NextCell(Map Map, int Cell, int Direction)
237
        public static int NextCell(Map Map, int Cell, int Direction)
...
 
...
 
292
                var Length = Pathfinder.IsValidLine(Fight, Fighter, FinalPath, TransitCell, DecodedPath.GetDirection(TransitCell),
DecodedPath.TransitCells[Index + 1]);
299
                var Length = Pathfinder.IsValidLine(Fight, Fighter, FinalPath, TransitCell, DecodedPath.GetDirection(TransitCell),
DecodedPath.TransitCells[Index + 1]);
293
                if (Length == -1)
300
                if (Length == -1)
294
                    return null;
301
                    return null;
295
                else if (Length == -2)                
302
                else if (Length == -2)
296
                    break;
303
                    break;
297
                
304
 
298
                                
305
 
299
                Index++;
306
                Index++;
300
 
307
 
301
            }
308
            }
...
 
...
 
320
            {
327
            {
321
                ActualCell = Pathfinder.NextCell(Map, ActualCell, Direction);
328
                ActualCell = Pathfinder.NextCell(Map, ActualCell, Direction);
322
                if (!Map.IsCellWalkable(ActualCell)) ;
329
                if (!Map.IsCellWalkable(ActualCell)) ;
323
                    //return -1;
 
 
324
               
 
 
325
                //return -1;
330
                //return -1;
 
 
331
 
 
 
332
                //return -1;
326
            }
333
            }
327
 
334
 
328
            return Length;
335
            return Length;
...
 
...
 
349
                Path.MovementLength++;
356
                Path.MovementLength++;
350
 
357
 
351
                if (Pathfinder.IsStopCell(Fighter.Fight, Fighter.Team, ActualCell))
358
                if (Pathfinder.IsStopCell(Fighter.Fight, Fighter.Team, ActualCell))
352
                     return -2;   
359
                    return -2;
353
            }
360
            }
354
 
361
 
355
            return Length;
362
            return Length;
...
 
...
 
359
        {
366
        {
360
            var Ennemies = Pathfinder.GetEnnemyNear(Fighter.Fight, Fighter.Team, Fighter.Cell.Id);
367
            var Ennemies = Pathfinder.GetEnnemyNear(Fighter.Fight, Fighter.Team, Fighter.Cell.Id);
361
 
368
 
362
            if (Ennemies.Count == 0)
369
            if (Ennemies.Count == 0 || Ennemies.All(x => x.States.HasState(FighterStateEnum.STATE_ENRACINER)))
363
                return -1;
370
                return -1;
364
 
371
 
365
            return Pathfinder.TryTacle(Fighter, Ennemies);
372
            return Pathfinder.TryTacle(Fighter, Ennemies);
...
 
...
 
371
            int EnnemiesAgility = 0;
378
            int EnnemiesAgility = 0;
372
 
379
 
373
            foreach (var Ennemy in NearestEnnemies)
380
            foreach (var Ennemy in NearestEnnemies)
374
                EnnemiesAgility += Ennemy.Stats.GetTotal(EffectEnum.AddAgilite);
381
                if (!Ennemy.States.HasState(FighterStateEnum.STATE_ENRACINER)) // Etat enraciner, ne peu pas etre taclé et ne tacle pas
 
 
382
                    EnnemiesAgility += Ennemy.Stats.GetTotal(EffectEnum.AddAgilite);
375
 
383
 
376
            var A = FighterAgility + 25;
384
            var A = FighterAgility + 25;
377
            var B = FighterAgility + EnnemiesAgility + 50;
385
            var B = FighterAgility + EnnemiesAgility + 50;
...
 
...
 
378
            var Chance = (int)((long)(300 * A / B) - 100);
386
            var Chance = (int)((long)(300 * A / B) - 100);
379
            var Rand = Pathfinder.PATHFIND_RANDOM.Next(0, 99);
387
            var Rand = Pathfinder.PATHFIND_RANDOM.Next(0, 99);
380
 
388
 
381
            return Rand > Chance ? Rand : - 1 ;
389
            return Rand > Chance ? Rand : -1;
382
        }
390
        }
383
 
391
 
384
        /// <summary>
392
        /// <summary>
...
 
...
 
399
            return false;
407
            return false;
400
        }
408
        }
401
 
409
 
402
 
 
 
403
        public static List<Fighter> GetEnnemyNear(Fight Fight, FightTeam Team, int CellId)
410
        public static List<Fighter> GetEnnemyNear(Fight Fight, FightTeam Team, int CellId)
404
        {
411
        {
405
            List<Fighter> Ennemies = new List<Fighter>();
412
            List<Fighter> Ennemies = new List<Fighter>();
...
 
...
 
408
            {
415
            {
409
                var Ennemy = Fight.HasEnnemyInCell(Pathfinder.NextCell(Fight.Map, CellId, Direction), Team);
416
                var Ennemy = Fight.HasEnnemyInCell(Pathfinder.NextCell(Fight.Map, CellId, Direction), Team);
410
                if (Ennemy != null)
417
                if (Ennemy != null)
411
                    if(!Ennemy.Dead)
418
                    if (!Ennemy.Dead)
412
                        Ennemies.Add(Ennemy);
419
                        Ennemies.Add(Ennemy);
413
            }
420
            }
414
 
421
 
415
            return Ennemies;
422
            return Ennemies;
416
        }
423
        }
 
 
424
 
 
 
425
        public static int ForViewOrientation(int Orientation)
 
 
426
        {
 
 
427
            switch (Orientation)
 
 
428
            {
 
 
429
                case 0:
 
 
430
                    return 1;
 
 
431
                case 2:
 
 
432
                    return 3;
 
 
433
                case 4:
 
 
434
                    return 5;
 
 
435
                case 6:
 
 
436
                    return 7;
 
 
437
            }
 
 
438
            return 1;
 
 
439
        }
 
 
440
 
 
 
441
        public static int GetAggroDistanceByLevel(int lvl)
 
 
442
        {
 
 
443
            int aggro = 0;
 
 
444
            aggro = (int)(lvl / 50);
 
 
445
            if (lvl > 500)
 
 
446
            {
 
 
447
                aggro = 3;
 
 
448
            }
 
 
449
            return aggro;
 
 
450
        }
417
    }
451
    }
418
}
452
}