資料庫WEAPON_SKILL新增欄位
`gfx_id` int(11) unsigned NOT NULL DEFAULT '0',
`gfx_id_target` int(1) unsigned NOT NULL DEFAULT '1',
`ref_str` int(6) NOT NULL DEFAULT '0',
`ref_int` int(6) NOT NULL DEFAULT '0',
`ref_wis` int(6) NOT NULL DEFAULT '0',
`ref_dex` int(6) NOT NULL DEFAULT '0',
`ref_con` int(6) NOT NULL DEFAULT '0',
`ref_cha` int(6) NOT NULL DEFAULT '0',
WeaponSkillTable.java
private void fillWeaponSkillTable(ResultSet rs) throws SQLException {
while (rs.next()) {
int weaponId = rs.getInt("weapon_id");
int probability = rs.getInt("probability");
int fixDamage = rs.getInt("fix_damage");
int randomDamage = rs.getInt("random_damage");
int area = rs.getInt("area");
int skillId = rs.getInt("skill_id");
int skillTime = rs.getInt("skill_time");
int effectId = rs.getInt("effect_id");
int effectTarget = rs.getInt("effect_target");
boolean isArrowType = rs.getBoolean("arrow_type");
int attr = rs.getInt("attr");
複製代碼
下面新增
int attr = rs.getInt("attr");
int gfxId = rs.getInt("gfx_id");
boolean gfxIdTarget = rs.getBoolean("gfx_id_target");
int refStr = rs.getInt("ref_str");
int refInt = rs.getInt("ref_int");
int refWis = rs.getInt("ref_wis");
int refCon = rs.getInt("ref_con");
int refDex = rs.getInt("ref_dex");
int refCha = rs.getInt("ref_cha");
L1WeaponSkill weaponSkill = new L1WeaponSkill(weaponId, probability,
fixDamage, randomDamage, area, skillId, skillTime, effectId,
effectTarget, isArrowType, attr,
gfxId,gfxIdTarget,refStr,refInt,refWis,refDex,refCon,
refCha);
_weaponIdIndex.put(weaponId, weaponSkill);
}
_log.config("武器技能名單 " + _weaponIdIndex.size() + "件");
}
public L1WeaponSkill getTemplate(int weaponId) {
return _weaponIdIndex.get(weaponId);
}
}
複製代碼
L1Weapon.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.
*
* https://www.gnu.org/copyleft/gpl.html
*/
package l1j.server.server.model;
import java.util.Random;
import java.util.logging.Logger;
import l1j.server.server.model.L1Poison2;
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.poison.L1DamagePoison;
import l1j.server.server.model.skill.L1SkillUse;
import l1j.server.server.serverpackets.S_CurseBlind;
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_SkillHaste;
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;
}
//增加武器技能欄位新增 by eric1300460
private int _refStr = 0;
private int _refInt = 0;
private int _refWis = 0;
private int _refDex = 0;
private int _refCon = 0;
private int _refCha = 0;
public void setRefStr(int int1) {
_refStr=int1;
}
public int getRefStr() {
return _refStr;
}
public void setRefInt(int int1) {
_refInt=int1;
}
public int getRefInt() {
return _refInt;
}
public void setRefWis(int int1) {
_refWis=int1;
}
public int getRefWis() {
return _refWis;
}
public void setRefDex(int int1) {
_refDex=int1;
}
public int getRefDex() {
return _refDex;
}
public void setRefCon(int int1) {
_refCon=int1;
}
public int getRefCon() {
return _refCon;
}
public void setRefCha(int int1) {
_refCha=int1;
}
public int getRefCha() {
return _refCha;
}
}
//~增加武器技能欄位新增 by eric1300460
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,int refStr,int refInt,
int refWis, int refDex,int refCon,int refCha,
) {
_gfxId=gfxId;
_gfxIdTarget=gfxIdTarget;
//~修改weapon_skill table 增加顯示圖案
//增加武器技能欄位新增 by eric1300460
_refStr = refStr;
_refInt = refInt;
_refWis = refWis;
_refDex = refDex;
_refCon = refCon;
_refCha = refCha;
//~增加武器技能欄位新增 by eric1300460
_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(pc, (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, false);
} 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 增加顯示圖案
複製代碼
下面新增
if (randomDamage != 0) { // 隨機傷害
damage =_random.nextInt(randomDamage);
}
if (weaponSkill.getRefStr() != 0) { // 力量加成
byte Str = (byte) pc.getStr();
damage += Str * weaponSkill.getRefStr();
}
if (weaponSkill.getRefDex() != 0) { // 敏捷加成
byte Dex = (byte) pc.getDex();
damage += Dex * weaponSkill.getRefDex();
}
if (weaponSkill.getRefInt() != 0) { // 智力加成
byte Int = (byte) pc.getInt();
damage += Int * weaponSkill.getRefInt();
}
if (weaponSkill.getRefWis() != 0) { // 精神加成
byte Wis = (byte) pc.getWis();
damage += Wis * weaponSkill.getRefWis();
}
int skillTime = weaponSkill.getSkillTime();
if (skillTime > 0) {
skillTime = skillTime * 1000;
}
複製代碼
二.負面效果
能力值加成的程式碼下面,新增
switch(weaponSkill.getSkillId())
{
case 1: {//衝暈效果
//int fettersTime = 8000;
/*if (isFreeze(cha)) { // 凍結状態orカウンターマジック中
return;
}
if ((random.nextInt(100) + 1) <= 5) {*/
L1EffectSpawn.getInstance().spawnEffect(81162, skillTime,
cha.getX(), cha.getY(), cha.getMapId());
if (cha instanceof L1PcInstance) {
L1PcInstance targetPc = (L1PcInstance) cha;
targetPc.setSkillEffect(SHOCK_STUN, skillTime);
targetPc.sendPackets(new S_SkillSound(targetPc.getId(), 4184));
targetPc.broadcastPacket(new S_SkillSound(targetPc.getId(),
4184));
targetPc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_STUN,
true));
} else if (cha instanceof L1MonsterInstance
|| cha instanceof L1SummonInstance
|| cha instanceof L1PetInstance) {
L1NpcInstance npc = (L1NpcInstance) cha;
npc.setSkillEffect(SHOCK_STUN, skillTime);
npc.broadcastPacket(new S_SkillSound(npc.getId(), 4184));
npc.setParalyzed(true);
}
}
break;
case 2: {//束縛效果
L1EffectSpawn.getInstance().spawnEffect(81182, skillTime,
cha.getX(), cha.getY(), cha.getMapId());
if (cha instanceof L1PcInstance) {
L1PcInstance targetPc = (L1PcInstance) cha;
targetPc.setSkillEffect(STATUS_FREEZE, skillTime);
targetPc.sendPackets(new S_SkillSound(targetPc.getId(), 4184));
targetPc.broadcastPacket(new S_SkillSound(targetPc.getId(),
4184));
targetPc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_BIND,
true));
} else if (cha instanceof L1MonsterInstance
|| cha instanceof L1SummonInstance
|| cha instanceof L1PetInstance) {
L1NpcInstance npc = (L1NpcInstance) cha;
npc.setSkillEffect(STATUS_FREEZE, skillTime);
npc.broadcastPacket(new S_SkillSound(npc.getId(), 4184));
npc.setParalyzed(true);
}
}
break;
case 3: {//冰凍效果
L1EffectSpawn.getInstance().spawnEffect(81168, skillTime,
cha.getX(), cha.getY(), cha.getMapId());
if (cha instanceof L1PcInstance) {
L1PcInstance targetPc = (L1PcInstance) cha;
targetPc.setSkillEffect(ICE_LANCE, skillTime);
targetPc.sendPackets(new S_SkillSound(targetPc.getId(), 4184));
targetPc.broadcastPacket(new S_SkillSound(targetPc.getId(),
4184));
targetPc.sendPackets(new S_Paralysis(S_Paralysis.TYPE_FREEZE,
true));
} else if (cha instanceof L1MonsterInstance
|| cha instanceof L1SummonInstance
|| cha instanceof L1PetInstance) {
L1NpcInstance npc = (L1NpcInstance) cha;
npc.setSkillEffect(ICE_LANCE, skillTime);
npc.broadcastPacket(new S_SkillSound(npc.getId(), 4184));
npc.setParalyzed(true);
}
}
break;
case 4: {//沉默效果
cha.setSkillEffect(64, skillTime);
pc.sendPackets(new S_SkillSound(cha.getId(), 2177));
pc.broadcastPacket(new S_SkillSound(cha.getId(), 2177));
}
break;
case 5: {//藥霜效果
cha.setSkillEffect(71, skillTime);
pc.sendPackets(new S_SkillSound(cha.getId(), 2232));
pc.broadcastPacket(new S_SkillSound(cha.getId(), 2232));
}
break;
case 6: {//緩速效果
if (cha instanceof L1PcInstance) {
L1PcInstance player = (L1PcInstance) cha;
if (player.getHasteItemEquipped() > 0) {
return weaponSkill.getFixDamage() + damage;
}
}
if (cha.getMoveSpeed() == 0) {
if (cha instanceof L1PcInstance) {
L1PcInstance player = (L1PcInstance) cha;
player.sendPackets(new S_SkillHaste(player.getId(), 2, skillTime));
}
cha.broadcastPacket(new S_SkillHaste(cha.getId(), 2, skillTime));
cha.setMoveSpeed(2);
cha.setSkillEffect(29, skillTime);
} else if (cha.getMoveSpeed() == 1) {
int skillNum = 0;
if (cha.hasSkillEffect(43)) {
skillNum = 43;
} else if (cha.hasSkillEffect(54)) {
skillNum = 54;
} else if (cha.hasSkillEffect(1001)) {
skillNum = 1001;
}
if (skillNum != 0) {
cha.removeSkillEffect(skillNum);
cha.removeSkillEffect(29);
cha.setMoveSpeed(0);
return weaponSkill.getFixDamage() + damage;
}
} else if (cha.getMoveSpeed() == 2) {
cha.setSkillEffect(29, skillTime);
}
//pc.sendPackets(new S_SkillSound(cha.getId(), 752));
//pc.broadcastPacket(new S_SkillSound(cha.getId(), 752));
}
break;
case 7: {//毒咒效果
L1DamagePoison.doInfection(pc, cha, 2000, 30); // 2秒30點傷害
//pc.sendPackets(new S_SkillSound(cha.getId(), 745));
//pc.broadcastPacket(new S_SkillSound(cha.getId(), 745));
}
break;
case 8: {//黑暗之影
if (cha instanceof L1PcInstance) {
L1PcInstance player = (L1PcInstance) cha;
if (player.hasSkillEffect(1012)) {
player.sendPackets(new S_CurseBlind(2));
} else {
player.sendPackets(new S_CurseBlind(1));
}
}
cha.setSkillEffect(40, skillTime);
//pc.sendPackets(new S_SkillSound(cha.getId(), 2175));
//pc.broadcastPacket(new S_SkillSound(cha.getId(), 2175));
}
break;
case 9: {//壞物術
if (cha instanceof L1PcInstance) {
L1PcInstance player = (L1PcInstance) cha;
L1ItemInstance weapon = player.getWeapon();
if (weapon != null) {
int weaponDamage = _random.nextInt(pc
.getInt() / 3) + 1;
// f1????%0?損傷????。
player.sendPackets(new S_ServerMessage(268, weapon.getLogName()));
player.getInventory().receiveDamage(weapon,
weaponDamage);
}
} else {
((L1NpcInstance) cha).setWeaponBreaked(true);
}
pc.sendPackets(new S_SkillSound(cha.getId(), 172));
pc.broadcastPacket(new S_SkillSound(cha.getId(), 172));
}
break;
/*case 10: {//吸血鬼之吻
int drainHp = (weaponSkill.getFixDamage() + damage) / 2;
if (cha.getCurrentHp() < drainHp) {
drainHp = cha.getCurrentHp();
}
if ((pc.getCurrentHp() + drainHp) > pc.getMaxHp()) {
pc.setCurrentHp(pc.getMaxHp());
} else {
pc.setCurrentHp(pc.getCurrentHp() + drainHp);
}
//S_UseAttackSkill packet = new S_UseAttackSkill(pc, cha, 236, false);
//pc.sendPackets(packet);
//pc.broadcastPacket(packet);
}
break;*/
case 11: {//魔力奪取
//pc.sendPackets(new S_SkillSound(cha.getId(), 2171));
//pc.broadcastPacket(new S_SkillSound(cha.getId(), 2171));
int radMp = _random.nextInt(8) + 3;
int drainMana = radMp + (pc.getInt() / 2);
if (cha.getCurrentMp() < drainMana) {
drainMana = cha.getCurrentMp();
cha.setCurrentMp(0);
} else {
cha.setCurrentMp(cha.getCurrentMp() - drainMana);
}
if ((pc.getCurrentMp() + drainMana) > pc.getMaxMp()) {
pc.setCurrentMp(pc.getMaxMp());
} else {
pc.setCurrentMp(pc.getCurrentMp() + drainMana);
}
}
break;
case 12: {//弱化術
if (cha.hasSkillEffect(47)) {
cha.setSkillEffect(47, skillTime);
} else {
cha.addDmgup(-5);
cha.addHitup(-1);
cha.setSkillEffect(47, skillTime);
}
pc.sendPackets(new S_SkillSound(cha.getId(), 2228));
pc.broadcastPacket(new S_SkillSound(cha.getId(), 2228));
}
break;
case 13: {//疾病術
if (cha.hasSkillEffect(56)) {
cha.setSkillEffect(56, skillTime);
} else {
cha.addHitup(-6);
cha.addAc(12);
cha.setSkillEffect(56, skillTime);
}
pc.sendPackets(new S_SkillSound(cha.getId(), 2230));
pc.broadcastPacket(new S_SkillSound(cha.getId(), 2230));
}
break;
}
//負面效果判斷 end
return calcDamageReduction(pc, cha, damage, weaponSkill.getAttr());
}
複製代碼
skillId 負面效果
skillTime 負面時效
負面效果:
1 = 衝暈效果
2 = 束縛效果
3 = 冰凍效果
4 = 沉默效果
5 = 藥霜效果
6 = 緩速效果
7 = 毒咒效果
8 = 黑暗之影
9 = 壞物術
10 = 吸血鬼之吻
11 = 魔力奪取
12 = 弱化術
13 = 疾病術
|