Changeset 5092
- Timestamp:
- Nov 22, 2011 7:03:54 AM (6 months ago)
- Location:
- branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver
- Files:
-
- 3 edited
-
ai/L2AttackableAI.java (modified) (1 diff)
-
ai/L2ControllableMobAI.java (modified) (30 diffs)
-
model/actor/L2Npc.java (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2AttackableAI.java
r5090 r5092 2378 2378 private FastList<L2Skill> shortRangeSkillRender() 2379 2379 { 2380 shortRangeSkills = _skillrender.get LongRangeSkills();2380 shortRangeSkills = _skillrender.getShortRangeSkills(); 2381 2381 if (shortRangeSkills.isEmpty()) 2382 2382 { -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/ai/L2ControllableMobAI.java
r5090 r5092 47 47 public class L2ControllableMobAI extends L2AttackableAI 48 48 { 49 private static final Logger _log = Logger.getLogger(L2 AttackableAI.class.getName());49 private static final Logger _log = Logger.getLogger(L2ControllableMobAI.class.getName()); 50 50 51 51 public static final int AI_IDLE = 1; … … 75 75 int randY = Rnd.nextInt(MobGroupTable.FOLLOW_RANGE); 76 76 77 moveTo(getForcedTarget().getX() + signX * randX, getForcedTarget().getY() + signY * randY, getForcedTarget().getZ());77 moveTo(getForcedTarget().getX() + (signX * randX), getForcedTarget().getY() + (signY * randY), getForcedTarget().getZ()); 78 78 } 79 79 } … … 83 83 { 84 84 if (isThinking()) 85 { 85 86 return; 87 } 86 88 87 89 setThinking(true); … … 93 95 case AI_IDLE: 94 96 if (getIntention() != CtrlIntention.AI_INTENTION_ACTIVE) 97 { 95 98 setIntention(CtrlIntention.AI_INTENTION_ACTIVE); 99 } 96 100 break; 97 101 case AI_FOLLOW: … … 109 113 default: 110 114 if (getIntention() == AI_INTENTION_ACTIVE) 115 { 111 116 thinkActive(); 117 } 112 118 else if (getIntention() == AI_INTENTION_ATTACK) 119 { 113 120 thinkAttack(); 121 } 114 122 break; 115 123 } … … 125 133 L2Attackable npc = (L2Attackable) _actor; 126 134 127 if ( getAttackTarget() == null|| getAttackTarget().isAlikeDead())135 if ((getAttackTarget() == null) || getAttackTarget().isAlikeDead()) 128 136 { 129 137 setAttackTarget(findNextRndTarget()); … … 132 140 133 141 if (getAttackTarget() == null) 142 { 134 143 return; 144 } 135 145 136 146 npc.setTarget(getAttackTarget()); 137 147 138 148 L2Skill[] skills = null; 139 // double dist2 = 0;149 // double dist2 = 0; 140 150 141 151 try 142 152 { 143 153 skills = _actor.getAllSkills(); 144 // dist2 = _actor.getPlanDistanceSq(getAttackTarget().getX(), getAttackTarget().getY());154 // dist2 = _actor.getPlanDistanceSq(getAttackTarget().getX(), getAttackTarget().getY()); 145 155 } 146 156 catch (NullPointerException e) … … 156 166 for (L2Skill sk : skills) 157 167 { 158 if (Util.checkIfInRange(sk.getCastRange(), _actor, getAttackTarget(), true) && !_actor.isSkillDisabled(sk) && _actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))168 if (Util.checkIfInRange(sk.getCastRange(), _actor, getAttackTarget(), true) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))) 159 169 { 160 170 _accessor.doCast(sk); … … 166 176 167 177 if (!isNotMoving()) 178 { 168 179 moveToPawn(getAttackTarget(), max_range); 180 } 169 181 170 182 return; … … 175 187 { 176 188 L2Character target = getForcedTarget(); 177 if ( target == null|| target.isAlikeDead())189 if ((target == null) || target.isAlikeDead()) 178 190 { 179 191 // try to get next group target … … 183 195 184 196 if (target == null) 197 { 185 198 return; 199 } 186 200 187 201 L2Skill[] skills = null; … … 208 222 } 209 223 210 if (!_actor.isMuted() && dist2 > (range + 20) * (range + 20))224 if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20)))) 211 225 { 212 226 // check distant skills … … 215 229 int castRange = sk.getCastRange(); 216 230 217 if ( castRange * castRange >= dist2 && !_actor.isSkillDisabled(sk) && _actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))231 if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))) 218 232 { 219 233 _accessor.doCast(sk); … … 225 239 226 240 if (!isNotMoving()) 241 { 227 242 moveToPawn(target, range); 243 } 228 244 229 245 return; … … 234 250 protected void thinkForceAttack() 235 251 { 236 if ( getForcedTarget() == null|| getForcedTarget().isAlikeDead())252 if ((getForcedTarget() == null) || getForcedTarget().isAlikeDead()) 237 253 { 238 254 clientStopMoving(null); … … 259 275 } 260 276 261 if (!_actor.isMuted() && dist2 > (range + 20) * (range + 20))277 if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20)))) 262 278 { 263 279 // check distant skills … … 266 282 int castRange = sk.getCastRange(); 267 283 268 if ( castRange * castRange >= dist2 && !_actor.isSkillDisabled(sk) && _actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))284 if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))) 269 285 { 270 286 _accessor.doCast(sk); … … 276 292 277 293 if (!isNotMoving()) 278 moveToPawn(getForcedTarget(), _actor.getPhysicalAttackRange()/*range*/); 294 { 295 moveToPawn(getForcedTarget(), _actor.getPhysicalAttackRange()/* range */); 296 } 279 297 280 298 return; … … 286 304 protected void thinkAttack() 287 305 { 288 if ( getAttackTarget() == null|| getAttackTarget().isAlikeDead())306 if ((getAttackTarget() == null) || getAttackTarget().isAlikeDead()) 289 307 { 290 308 if (getAttackTarget() != null) … … 305 323 306 324 Collection<L2Object> objs = _actor.getKnownList().getKnownObjects().values(); 307 325 308 326 for (L2Object obj : objs) 309 327 { 310 328 if (!(obj instanceof L2Npc)) 329 { 311 330 continue; 331 } 312 332 313 333 L2Npc npc = (L2Npc) obj; 314 334 315 335 if (!faction_id.equals(npc.getFactionId())) 336 { 316 337 continue; 338 } 317 339 318 if (_actor.isInsideRadius(npc, npc.getFactionRange(), false, true) && Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200)340 if (_actor.isInsideRadius(npc, npc.getFactionRange(), false, true) && (Math.abs(getAttackTarget().getZ() - npc.getZ()) < 200)) 319 341 { 320 342 npc.getAI().notifyEvent(CtrlEvent.EVT_AGGRESSION, getAttackTarget(), 1); … … 341 363 } 342 364 343 if (!_actor.isMuted() && dist2 > (range + 20) * (range + 20))365 if (!_actor.isMuted() && (dist2 > ((range + 20) * (range + 20)))) 344 366 { 345 367 // check distant skills … … 348 370 int castRange = sk.getCastRange(); 349 371 350 if ( castRange * castRange >= dist2 && !_actor.isSkillDisabled(sk) && _actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))372 if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() > _actor.getStat().getMpConsume(sk))) 351 373 { 352 374 _accessor.doCast(sk); … … 365 387 366 388 if (_actor.isConfused()) 389 { 367 390 hated = findNextRndTarget(); 391 } 368 392 else 393 { 369 394 hated = getAttackTarget(); 395 } 370 396 371 397 if (hated == null) … … 376 402 377 403 if (hated != getAttackTarget()) 404 { 378 405 setAttackTarget(hated); 379 380 if (!_actor.isMuted() && skills.length > 0 && Rnd.nextInt(5) == 3) 406 } 407 408 if (!_actor.isMuted() && (skills.length > 0) && (Rnd.nextInt(5) == 3)) 381 409 { 382 410 for (L2Skill sk : skills) … … 384 412 int castRange = sk.getCastRange(); 385 413 386 if ( castRange * castRange >= dist2 && !_actor.isSkillDisabled(sk) && _actor.getCurrentMp() < _actor.getStat().getMpConsume(sk))414 if (((castRange * castRange) >= dist2) && !_actor.isSkillDisabled(sk) && (_actor.getCurrentMp() < _actor.getStat().getMpConsume(sk))) 387 415 { 388 416 _accessor.doCast(sk); … … 402 430 403 431 if (_actor.isConfused()) 432 { 404 433 hated = findNextRndTarget(); 434 } 405 435 else 436 { 406 437 hated = getAttackTarget(); 438 } 407 439 408 440 if (hated != null) … … 415 447 private boolean autoAttackCondition(L2Character target) 416 448 { 417 if (target == null || !(_actor instanceof L2Attackable)) 449 if ((target == null) || !(_actor instanceof L2Attackable)) 450 { 418 451 return false; 452 } 419 453 L2Attackable me = (L2Attackable) _actor; 420 454 421 if (target instanceof L2NpcInstance || target instanceof L2DoorInstance) 455 if ((target instanceof L2NpcInstance) || (target instanceof L2DoorInstance)) 456 { 422 457 return false; 423 424 if (target.isAlikeDead() || !me.isInsideRadius(target, me.getAggroRange(), false, false) || Math.abs(_actor.getZ() - target.getZ()) > 100) 458 } 459 460 if (target.isAlikeDead() || !me.isInsideRadius(target, me.getAggroRange(), false, false) || (Math.abs(_actor.getZ() - target.getZ()) > 100)) 461 { 425 462 return false; 463 } 426 464 427 465 // Check if the target isn't invulnerable 428 466 if (target.isInvul()) 467 { 429 468 return false; 469 } 430 470 431 471 // Spawn protection (only against mobs) 432 if(target instanceof L2PcInstance && ((L2PcInstance)target).isSpawnProtected()) 472 if ((target instanceof L2PcInstance) && ((L2PcInstance) target).isSpawnProtected()) 473 { 433 474 return false; 475 } 434 476 435 477 // Check if the target is a L2PlayableInstance … … 438 480 // Check if the target isn't in silent move mode 439 481 if (((L2Playable) target).isSilentMoving()) 482 { 440 483 return false; 484 } 441 485 } 442 486 443 487 if (target instanceof L2Npc) 488 { 444 489 return false; 490 } 445 491 446 492 return me.isAggressive(); … … 461 507 { 462 508 if (!(obj instanceof L2Character)) 509 { 463 510 continue; 511 } 464 512 465 513 npcX = npc.getX(); … … 471 519 dy = npcY - targetY; 472 520 473 if (dx * dx + dy * dy > dblAggroRange) 521 if (((dx * dx) + (dy * dy)) > dblAggroRange) 522 { 474 523 continue; 524 } 475 525 476 526 L2Character target = (L2Character) obj; 477 527 478 if (autoAttackCondition(target)) // check aggression 528 if (autoAttackCondition(target)) 529 { 479 530 potentialTarget.add(target); 480 } 481 482 483 if (potentialTarget.isEmpty()) // nothing to do 531 } 532 } 533 534 if (potentialTarget.isEmpty()) 535 { 484 536 return null; 537 } 485 538 486 539 // we choose a random target -
branches/unstable/L2J_Server_BETA/java/com/l2jserver/gameserver/model/actor/L2Npc.java
r5083 r5092 297 297 public FastList<L2Skill> getLongRangeSkill() 298 298 { 299 FastList<L2Skill> skilldata = new FastList<L2Skill>(); 300 boolean hasLrange = false; 299 final FastList<L2Skill> skilldata = new FastList<>(); 301 300 if (_staticAIData == null || _staticAIData.getLongRangeSkill() == 0) 301 { 302 302 return null; 303 303 } 304 304 switch (_staticAIData.getLongRangeSkill()) 305 305 { … … 318 318 { 319 319 skilldata.add(sk); 320 hasLrange = true;321 320 } 322 321 } … … 333 332 { 334 333 skilldata.add(sk); 335 hasLrange = true;336 334 } 337 335 } … … 346 344 { 347 345 skilldata.add(sk); 348 hasLrange = true;349 346 } 350 347 } 351 348 } 352 349 } 353 354 return (hasLrange ? skilldata : null); 350 return skilldata; 355 351 } 356 352 357 353 public FastList<L2Skill> getShortRangeSkill() 358 354 { 359 FastList<L2Skill> skilldata = new FastList<L2Skill>(); 360 boolean hasSrange = false; 355 final FastList<L2Skill> skilldata = new FastList<>(); 361 356 if (_staticAIData == null || _staticAIData.getShortRangeSkill() == 0) 362 return null; 363 357 { 358 return skilldata; 359 } 364 360 switch (_staticAIData.getShortRangeSkill()) 365 361 { … … 373 369 { 374 370 if (sk == null || sk.isPassive() || sk.getTargetType() == L2TargetType.TARGET_SELF) 371 { 375 372 continue; 376 373 } 377 374 if (sk.getCastRange() <= 200) 378 375 { 379 376 skilldata.add(sk); 380 hasSrange = true;381 377 } 382 378 } … … 393 389 { 394 390 skilldata.add(sk); 395 hasSrange = true;396 391 } 397 392 } … … 406 401 { 407 402 skilldata.add(sk); 408 hasSrange = true;409 403 } 410 404 } 411 405 } 412 406 } 413 414 return (hasSrange ? skilldata : null); 407 return skilldata; 415 408 } 416 409
Note: See TracChangeset
for help on using the changeset viewer.
