📄 l1weaponskill.java
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package l1j.server.server.model;
import java.util.Random;
import java.util.logging.Logger;
import l1j.server.server.ActionCodes;
import l1j.server.server.datatables.SkillsTable;
import l1j.server.server.datatables.WeaponSkillTable;
import l1j.server.server.model.L1Character;
import l1j.server.server.model.Instance.L1ItemInstance;
import l1j.server.server.model.Instance.L1MonsterInstance;
import l1j.server.server.model.Instance.L1NpcInstance;
import l1j.server.server.model.Instance.L1PcInstance;
import l1j.server.server.model.Instance.L1PetInstance;
import l1j.server.server.model.Instance.L1SummonInstance;
import l1j.server.server.model.skill.L1SkillUse;
import l1j.server.server.serverpackets.S_DoActionGFX;
import l1j.server.server.serverpackets.S_EffectLocation;
import l1j.server.server.serverpackets.S_Paralysis;
import l1j.server.server.serverpackets.S_ServerMessage;
import l1j.server.server.serverpackets.S_SkillSound;
import l1j.server.server.serverpackets.S_UseAttackSkill;
import l1j.server.server.templates.L1Skills;
import static l1j.server.server.model.skill.L1SkillId.*;
// Referenced classes of package l1j.server.server.model:
// L1PcInstance
public class L1WeaponSkill {
private static Logger _log = Logger
.getLogger(L1WeaponSkill.class.getName());
private static Random _random = new Random();
private int _weaponId;
private int _probability;
private int _fixDamage;
private int _randomDamage;
private int _area;
private int _skillId;
private int _skillTime;
private int _effectId;
private int _effectTarget; // エフェクトの対象 0:相手 1:自分
private boolean _isArrowType;
private int _attr;
//修改weapon_skill table 增加顯示圖案
private int _gfxId;
private boolean _gfxIdTarget;
public int getGfxId() {
return _gfxId;
}
public boolean getGfxIdTarget() {
return _gfxIdTarget;
}
public L1WeaponSkill(int weaponId, int probability, int fixDamage,
int randomDamage, int area, int skillId, int skillTime,
int effectId, int effectTarget, boolean isArrowType, int attr,
int gfxId,boolean gfxIdTarget) {
_gfxId=gfxId;
_gfxIdTarget=gfxIdTarget;
//~修改weapon_skill table 增加顯示圖案
_weaponId = weaponId;
_probability = probability;
_fixDamage = fixDamage;
_randomDamage = randomDamage;
_area = area;
_skillId = skillId;
_skillTime = skillTime;
_effectId = effectId;
_effectTarget = effectTarget;
_isArrowType = isArrowType;
_attr = attr;
}
public int getWeaponId() {
return _weaponId;
}
public int getProbability() {
return _probability;
}
public int getFixDamage() {
return _fixDamage;
}
public int getRandomDamage() {
return _randomDamage;
}
public int getArea() {
return _area;
}
public int getSkillId() {
return _skillId;
}
public int getSkillTime() {
return _skillTime;
}
public int getEffectId() {
return _effectId;
}
public int getEffectTarget() {
return _effectTarget;
}
public boolean isArrowType() {
return _isArrowType;
}
public int getAttr() {
return _attr;
}
public static double getWeaponSkillDamage(L1PcInstance pc, L1Character cha,
int weaponId) {
L1WeaponSkill weaponSkill = WeaponSkillTable.getInstance().getTemplate(
weaponId);
if (pc == null || cha == null || weaponSkill == null) {
return 0;
}
int chance = _random.nextInt(100) + 1;
if (weaponSkill.getProbability() < chance) {
return 0;
}
int skillId = weaponSkill.getSkillId();
if (skillId != 0) {
L1Skills skill = SkillsTable.getInstance().getTemplate(skillId);
if (skill != null && skill.getTarget().equals("buff")) {
if (!isFreeze(cha)) { // 凍結状態orカウンターマジック中
cha.setSkillEffect(skillId, weaponSkill
.getSkillTime() * 1000);
}
}
}
int effectId = weaponSkill.getEffectId();
if (effectId != 0) {
int chaId = 0;
if (weaponSkill.getEffectTarget() == 0) {
chaId = cha.getId();
} else {
chaId = pc.getId();
}
boolean isArrowType = weaponSkill.isArrowType();
if (!isArrowType) {
pc.sendPackets(new S_SkillSound(chaId, effectId));
pc.broadcastPacket(new S_SkillSound(chaId, effectId));
} else {
S_UseAttackSkill packet = new S_UseAttackSkill(pc, cha.getId(),
effectId, cha.getX(), cha.getY(), ActionCodes
.ACTION_Attack, false);
pc.sendPackets(packet);
pc.broadcastPacket(packet);
}
}
double damage = 0;
int randomDamage = weaponSkill.getRandomDamage();
if (randomDamage != 0) {
damage = _random.nextInt(randomDamage);
}
damage += weaponSkill.getFixDamage();
int area = weaponSkill.getArea();
if (area > 0 || area == -1) { // 範囲の場合
for (L1Object object : L1World.getInstance()
.getVisibleObjects(cha, area)) {
if (object == null) {
continue;
}
if (!(object instanceof L1Character)) {
continue;
}
if (object.getId() == pc.getId()) {
continue;
}
if (object.getId() == cha.getId()) { // 攻撃対象はL1Attackで処理するため除外
continue;
}
// 攻撃対象がMOBの場合は、範囲内のMOBにのみ当たる
// 攻撃対象がPC,Summon,Petの場合は、範囲内のPC,Summon,Pet,MOBに当たる
if (cha instanceof L1MonsterInstance) {
if (!(object instanceof L1MonsterInstance)) {
continue;
}
}
if (cha instanceof L1PcInstance
|| cha instanceof L1SummonInstance
|| cha instanceof L1PetInstance) {
if (!(object instanceof L1PcInstance
|| object instanceof L1SummonInstance
|| object instanceof L1PetInstance
|| object instanceof L1MonsterInstance)) {
continue;
}
}
damage = calcDamageReduction((L1Character) object, damage,
weaponSkill.getAttr());
if (damage <= 0) {
continue;
}
if (object instanceof L1PcInstance) {
L1PcInstance targetPc = (L1PcInstance) object;
targetPc.sendPackets(new S_DoActionGFX(targetPc.getId(),
ActionCodes.ACTION_Damage));
targetPc.broadcastPacket(new S_DoActionGFX(targetPc.getId(),
ActionCodes.ACTION_Damage));
targetPc.receiveDamage(pc, (int) damage);
} else if (object instanceof L1SummonInstance
|| object instanceof L1PetInstance
|| object instanceof L1MonsterInstance) {
L1NpcInstance targetNpc = (L1NpcInstance) object;
targetNpc.broadcastPacket(new S_DoActionGFX(targetNpc
.getId(), ActionCodes.ACTION_Damage));
targetNpc.receiveDamage(pc, (int) damage);
}
}
}
//修改weapon_skill table 增加顯示圖案
if (weaponSkill.getGfxId() != 0) {
if (weaponSkill.getGfxIdTarget()) {// 目標顯示
pc.sendPackets(new S_SkillSound(cha.getId(), weaponSkill
.getGfxId()));
pc.broadcastPacket(new S_SkillSound(cha.getId(), weaponSkill
.getGfxId()));
} else {// 自己身上顯示
pc.sendPackets(new S_SkillSound(pc.getId(), weaponSkill
.getGfxId()));
pc.broadcastPacket(new S_SkillSound(pc.getId(), weaponSkill
.getGfxId()));
}
}
//~修改weapon_skill table 增加顯示圖案
return calcDamageReduction(cha, damage, weaponSkill.getAttr());
}
public static double getBaphometStaffDamage(L1PcInstance pc,
L1Character cha) {
double dmg = 0;
int chance = _random.nextInt(100) + 1;
if (14 >= chance) {
int locx = cha.getX();
int locy = cha.getY();
int sp = pc.getSp();
int intel = pc.getInt();
double bsk = 0;
if (pc.hasSkillEffect(BERSERKERS)) {
bsk = 0.2;
}
dmg = (intel + sp) * (1.8 + bsk) + _random.nextInt(intel + sp)
* 1.8;
S_EffectLocation packet = new S_EffectLocation(locx, locy, 129);
pc.sendPackets(packet);
pc.broadcastPacket(packet);
}
return calcDamageReduction(cha, dmg, L1Skills.ATTR_EARTH);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -