📄 l1pcinstance.java
字号:
public void setHighLevel(int i) {
_highLevel = i;
}
private int _bonusStats; // ● 割り振ったボーナスステータス
public int getBonusStats() {
return _bonusStats;
}
public void setBonusStats(int i) {
_bonusStats = i;
}
private int _elixirStats; // ● エリクサーで上がったステータス
public int getElixirStats() {
return _elixirStats;
}
public void setElixirStats(int i) {
_elixirStats = i;
}
private int _elfAttr; // ● エルフの属性
public int getElfAttr() {
return _elfAttr;
}
public void setElfAttr(int i) {
_elfAttr = i;
}
private int _expRes; // ● EXP復旧
public int getExpRes() {
return _expRes;
}
public void setExpRes(int i) {
_expRes = i;
}
private int _partnerId; // ● 結婚相手
public int getPartnerId() {
return _partnerId;
}
public void setPartnerId(int i) {
_partnerId = i;
}
private int _onlineStatus; // ● オンライン状態
public int getOnlineStatus() {
return _onlineStatus;
}
public void setOnlineStatus(int i) {
_onlineStatus = i;
}
private int _homeTownId; // ● ホームタウン
public int getHomeTownId() {
return _homeTownId;
}
public void setHomeTownId(int i) {
_homeTownId = i;
}
private int _contribution; // ● 貢献度
public int getContribution() {
return _contribution;
}
public void setContribution(int i) {
_contribution = i;
}
// 地獄に滞在する時間(秒)
private int _hellTime;
public int getHellTime() {
return _hellTime;
}
public void setHellTime(int i) {
_hellTime = i;
}
private boolean _banned; // ● 凍結
public boolean isBanned() {
return _banned;
}
public void setBanned(boolean flag) {
_banned = flag;
}
private int _food; // ● 満腹度
public int get_food() {
return _food;
}
public void set_food(int i) {
_food = i;
}
public L1EquipmentSlot getEquipSlot() {
return _equipSlot;
}
public static L1PcInstance load(String charName) {
L1PcInstance result = null;
try {
result = CharacterTable.getInstance().loadCharacter(charName);
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
return result;
}
/**
* このプレイヤーの状態をストレージへ書き込む。
*
* @throws Exception
*/
public void save() throws Exception {
if (isGhost()) {
return;
}
CharacterTable.getInstance().storeCharacter(this);
}
/**
* このプレイヤーのインベントリアイテムの状態をストレージへ書き込む。
*/
public void saveInventory() {
for (L1ItemInstance item : getInventory().getItems()) {
getInventory().saveItem(item, item.getRecordingColumns());
}
}
public static final int REGENSTATE_NONE = 4;
public static final int REGENSTATE_MOVE = 2;
public static final int REGENSTATE_ATTACK = 1;
public void setRegenState(int state) {
_mpRegen.setState(state);
_hpRegen.setState(state);
}
public double getMaxWeight() {
int str = getStr();
int con = getCon();
double maxWeight = 150 * (Math.floor(0.6 * str + 0.4 * con + 1));
double weightReductionByArmor = getWeightReduction(); // 防具による重量軽減
weightReductionByArmor /= 100;
double weightReductionByDoll = 0; // マジックドールによる重量軽減
Object[] dollList = getDollList().values().toArray();
for (Object dollObject : dollList) {
L1DollInstance doll = (L1DollInstance) dollObject;
weightReductionByDoll += doll.getWeightReductionByDoll();
weightReductionByDoll /= 100;
}
int weightReductionByMagic = 0;
if (hasSkillEffect(L1SkillId.DECREASE_WEIGHT)) { // ディクリースウェイト
weightReductionByMagic = 180;
}
double originalWeightReduction = 0; // オリジナルステータスによる重量軽減
originalWeightReduction += 0.04 * (getOriginalStrWeightReduction()
+ getOriginalConWeightReduction());
double weightReduction = 1 + weightReductionByArmor
+ weightReductionByDoll + originalWeightReduction;
maxWeight *= weightReduction;
maxWeight += weightReductionByMagic;
maxWeight *= Config.RATE_WEIGHT_LIMIT; // ウェイトレートを掛ける
return maxWeight;
}
public boolean isFastMovable() {
return (hasSkillEffect(L1SkillId.HOLY_WALK)
|| hasSkillEffect(L1SkillId.MOVING_ACCELERATION)
|| hasSkillEffect(L1SkillId.WIND_WALK)
|| hasSkillEffect(L1SkillId.STATUS_RIBRAVE));
}
public boolean isBrave() {
return hasSkillEffect(L1SkillId.STATUS_BRAVE);
}
public boolean isElfBrave() {
return hasSkillEffect(L1SkillId.STATUS_ELFBRAVE);
}
public boolean isHaste() {
return (hasSkillEffect(L1SkillId.STATUS_HASTE)
|| hasSkillEffect(L1SkillId.HASTE)
|| hasSkillEffect(L1SkillId.GREATER_HASTE) || getMoveSpeed() == 1);
}
private int invisDelayCounter = 0;
public boolean isInvisDelay() {
return (invisDelayCounter > 0);
}
private Object _invisTimerMonitor = new Object();
public void addInvisDelayCounter(int counter) {
synchronized (_invisTimerMonitor) {
invisDelayCounter += counter;
}
}
private static final long DELAY_INVIS = 3000L;
public void beginInvisTimer() {
addInvisDelayCounter(1);
GeneralThreadPool.getInstance().pcSchedule(new L1PcInvisDelay(getId()),
DELAY_INVIS);
}
public synchronized void addExp(int exp) {
_exp += exp;
if (_exp > ExpTable.MAX_EXP) {
_exp = ExpTable.MAX_EXP;
}
}
public synchronized void addContribution(int contribution) {
_contribution += contribution;
}
public void beginExpMonitor() {
_expMonitorFuture = GeneralThreadPool.getInstance()
.pcScheduleAtFixedRate(new L1PcExpMonitor(getId()), 0L,
INTERVAL_EXP_MONITOR);
}
private void levelUp(int gap) {
resetLevel();
// 復活のポーション
if (getLevel() == 99 && Config.ALT_REVIVAL_POTION) {
try {
L1Item l1item = ItemTable.getInstance().getTemplate(43000);
if (l1item != null) {
getInventory().storeItem(43000, 1);
sendPackets(new S_ServerMessage(403, l1item.getName()));
} else {
sendPackets(new S_SystemMessage("無法獲得轉生藥水。可能此道具不存在!"));
}
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
sendPackets(new S_SystemMessage("無法獲得轉生藥水。可能此道具不存在!"));
}
}
for (int i = 0; i < gap; i++) {
short randomHp = CalcStat.calcStatHp(getType(), getBaseMaxHp(),
getBaseCon(), getOriginalHpup());
short randomMp = CalcStat.calcStatMp(getType(), getBaseMaxMp(),
getBaseWis(), getOriginalMpup());
addBaseMaxHp(randomHp);
addBaseMaxMp(randomMp);
//TODO 升級後血魔補滿
setCurrentHp(getMaxHp());
setCurrentMp(getMaxMp());
//end
}
resetBaseHitup();
resetBaseDmgup();
resetBaseAc();
resetBaseMr();
if (getLevel() > getHighLevel()) {
setHighLevel(getLevel());
}
try {
// DBにキャラクター情報を書き込む
save();
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
// ボーナスステータス
if (getLevel() >= 51 && getLevel() - 50 > getBonusStats()) {
if ((getBaseStr() + getBaseDex() + getBaseCon() + getBaseInt()
+ getBaseWis() + getBaseCha()) < 210) {
sendPackets(new S_bonusstats(getId(), 1));
}
}
sendPackets(new S_OwnCharStatus(this));
l1j.william.Reward.getItem(this); //TODO 升級獎勵道具 by 阿傑
//TODO 超過 13等傳出新手村 By AMD 改case by hot183
if (getLevel() >= 13) {
short outmap = getMapId();
switch(outmap){
case 69:
L1Teleport.teleport(this, 33080, 33392, (short)4, (byte)5, true); //<-銀騎士村の座標
break;
case 68:
L1Teleport.teleport(this, 32580, 32931, (short)0, (byte)5, true); //<-說話之島の座標
break;
}
}
//end
if (getLevel() >= 52) { // 指定レベル
if (getMapId() == 777) { // 見捨てられた者たちの地(影の神殿)
L1Teleport.teleport(this, 34043, 32184, (short) 4, 5, true); // 象牙の塔前
} else if (getMapId() == 778
|| getMapId() == 779) { // 見捨てられた者たちの地(欲望の洞窟)
L1Teleport.teleport(this, 32608, 33178, (short) 4, 5, true); // WB
}
}
}
private void levelDown(int gap) {
resetLevel();
for (int i = 0; i > gap; i--) {
// レベルダウン時はランダム値をそのままマイナスする為に、base値に0を設定
short randomHp = CalcStat.calcStatHp(getType(), 0, getBaseCon(), getOriginalHpup());
short randomMp = CalcStat.calcStatMp(getType(), 0, getBaseWis(), getOriginalMpup());
addBaseMaxHp((short) -randomHp);
addBaseMaxMp((short) -randomMp);
}
resetBaseHitup();
resetBaseDmgup();
resetBaseAc();
resetBaseMr();
if (Config.LEVEL_DOWN_RANGE != 0) {
if (getHighLevel() - getLevel() >= Config.LEVEL_DOWN_RANGE) {
sendPackets(new S_ServerMessage(64)); // ワールドとの接続が切断されました。
sendPackets(new S_Disconnect());
_log.info(String.format("超過了降低水平的容許範圍的登場人物的進入要求。",
getName()));
}
}
try {
// DBにキャラクター情報を書き込む
save();
} catch (Exception e) {
_log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
sendPackets(new S_OwnCharStatus(this));
}
public void beginGameTimeCarrier() {
new L1GameTimeCarrier(this).start();
}
private boolean _ghost = false; // ゴースト
public boolean isGhost() {
return _ghost;
}
private void setGhost(boolean flag) {
_ghost = flag;
}
private boolean _ghostCanTalk = true; // NPCに話しかけられるか
public boolean isGhostCanTalk() {
return _ghostCanTalk;
}
private void setGhostCanTalk(boolean flag) {
_ghostCanTalk = flag;
}
private boolean _isReserveGhost = false; // ゴースト解除準備
public boolean isReserveGhost() {
return _isReserveGhost;
}
private void setReserveGhost(boolean flag) {
_isReserveGhost = flag;
}
public void beginGhost(int locx, int locy, short mapid, boolean canTalk) {
beginGhost(locx, locy, mapid, canTalk, 0);
}
public void beginGhost(int locx, int locy, short mapid, boolean canTalk,
int sec) {
if (isGhost()) {
return;
}
setGhost(true);
_ghostSaveLocX = getX();
_ghostSaveLocY = getY();
_ghostSaveMapId = getMapId();
_ghostSaveHeading = getHeading();
setGhostCanTalk(canTalk);
L1Teleport.teleport(this, locx, locy, mapid, 5, true);
if (sec > 0) {
_ghostFuture = GeneralThreadPool.getInstance().pcSchedule(
new L1PcGhostMonitor(getId()), sec * 1000);
}
}
public void makeReadyEndGhost() {
setReserveGhost(true);
L1Teleport.teleport(this, _ghostSaveLocX, _ghostSaveLocY,
_ghostSaveMapId, _ghostSaveHeading, true);
}
public void endGhost() {
setGhost(false);
setGhostCanTalk(true);
setReserveGhost(false);
}
private ScheduledFuture<?> _ghostFuture;
private int _ghostSaveLocX = 0;
private int _ghostSaveLocY = 0;
private short _ghostSaveMapId = 0;
private int _ghostSaveHeading = 0;
private ScheduledFuture<?> _hellFuture;
public void beginHell(boolean isFirst) {
// 地獄以外に居るときは地獄へ強制移動
if (getMapId() != 666) {
int locx = 32701;
int locy = 32777;
short mapid = 666;
L1Teleport.teleport(this, locx, locy, mapid, 5, false);
}
if (isFirst) {
if (get_PKcount() <= 10) {
setHellTime(300);
} else {
setHellTime(300 * (get_PKcount() - 10) + 300);
}
// あなたのPK回数が%0になり、地獄に落とされました。あなたはここで%1分間反省しなければなりません。
sendPackets(new S_BlueMessage(552, String.valueOf(get_PKcount()),
String.valueOf(getHellTime() / 60)));
} else {
// あなたは%0秒間ここにとどまらなければなりません。
sendPackets(new S_BlueMessage(637, String.valueOf(getHellTime())));
}
if (_hellFuture == null) {
_hellFuture = GeneralThreadPool.getInstance()
.pcScheduleAtFixedRate(new L1PcHellMonitor(getId()), 0L,
1000L);
}
}
public void endHell() {
if (_hellFuture != null) {
_hellFuture.cancel(false);
_hellFuture = null;
}
// 地獄から脱出したら火田村へ帰還させる。
int[] loc = L1TownLocation
.getGetBackLoc(L1TownLocation.TOWNID_ORCISH_FOREST);
L1Teleport.teleport(this, loc[0], loc[1], (short) loc[2], 5, true);
try {
save();
} catch (Exception ignore) {
// ignore
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -