|
|

樓主 |
發表於 2026-3-14 16:44
|
顯示全部樓層
 | |  |  | 本帖最後由 IQN 於 2026-3-14 16:57 編輯
你贴出来的那些档都不对,不应该在那些档里加施放技能的方法。应该还是在L1PcInstance档里,我给你完整的代码吧。这里我只加了骑士的冲晕和妖精的拿弓就用三重,拿刀就烈炎术,其他职业的你可以自己加。
- /**
- * 攻击技能
- * by IQN 20260116
- */
- public void attack_skill(final L1PcInstance pc, final L1Character targets, final int skillrng, final int location, final int randomSkillId) {
- try {
- if (skillrng > 0 && location > skillrng) { // 如果技能距离大于0 就判断与目标的距离是否滿足技能距离
- return;
- }
- if (pc.isSkillDelay()) { // 技能延迟施放中
- return;
- }
- if (pc.hasSkillEffect(64)||pc.hasSkillEffect(161)||pc.hasSkillEffect(202)) {//被封印了
- return;
- }
- final L1Skills skill = SkillsTable.get().getTemplate(randomSkillId);
- final L1SkillUse skillUse = new L1SkillUse();
- if (pc.getCurrentMp() >= skill.getMpConsume()) { // 施放该技能需要的魔力
- if (targets.isDead()) // 加入施放前判斷目標是否已死亡
- return;
- skillUse.handleCommands(pc, randomSkillId, targets.getId(), targets.getX(), targets.getY(), skill.getBuffDuration(), L1SkillUse.TYPE_NORMAL);
- Thread.sleep(skill.getReuseDelay()); // 延迟
- }
-
- } catch (Exception e) {
- }
- }
- private void attack(L1Character target) {
- // System.out.println("攻击可能位置");
- // 攻击可能位置
- int attack_Range = 1;
- if (this.getWeapon() != null) {
- attack_Range = this.getWeapon().getItem().getRange();
- }
- if (attack_Range < 0) {
- attack_Range = 15;
- }
- if (isAttackPosition(target.getX(), target.getY(), attack_Range)) {// 已经到达可以攻击的距离
- setHeading(targetDirection(target.getX(), target.getY()));
- attackTarget(target);
- ///<font color="#ff0000">start从这里开始添加 by IQN 20260314</font>
- final int location = getLocation().getTileLineDistance(target.getLocation());
- int physicalRange = 1;
- L1ItemInstance weapon = getWeapon();
- if (weapon != null) {
- physicalRange = weapon.getItem().getRange();
- }
- if(isKnight())//添加位置 2
- {
- if (weapon != null && !target.hasSkillEffect(87)) {
- int weaponType = weapon.getItem().getType();
- if(weaponType==3)
- {
- attack_skill(this, target, -1, location, 87);//冲晕
- }
- }
- }
- if(isElf())//添加位置 2
- {
- int weaponType = weapon.getItem().getType();
- int skillId = (weaponType == 4 || weaponType == 13) ? 132 : 46;//三重矢或烈焰术
- attack_skill(this, target, -1, location, skillId);
- }
- ///<font color="#ff0000">end从这里开始结束 by IQN 20260314</font>
- // XXX
- if (_pcMove != null) {
- _pcMove.clear();
- }
- } else { // 攻击不可能位置
- if (_pcMove != null) {
- final int dir = _pcMove.moveDirection(target.getX(), target.getY());
- if (dir == -1) {
- _AItarget.setSkillEffect(this.getId() + 100000, 20000);// 给予20秒状态
- allTargetClear();
- } else {
- _pcMove.setDirectionMove(dir);
- // setSleepTime(calcSleepTime(getPassispeed(), MOVE_SPEED));
- }
- }
- }
- }
複製代碼
| |  | |  |
|
|