diff --git a/src/common/tables.h b/src/common/tables.h index 4359033..6002e9c 100644 --- a/src/common/tables.h +++ b/src/common/tables.h @@ -380,14 +380,14 @@ typedef struct SPlayerTable int16_t st, ht, dx, iq; uint32_t exp; - INT gold; + int32_t gold; - uint8_t dir; - INT x, y, z; - INT lMapIndex; + uint8_t dir; + int32_t x, y, z; + int32_t lMapIndex; - int32_t lExitX, lExitY; - int32_t lExitMapIndex; + int32_t lExitX, lExitY; + int32_t lExitMapIndex; // int16_t hp; // int16_t sp; diff --git a/src/game/char.cpp b/src/game/char.cpp index 4f0332a..228c3a5 100644 --- a/src/game/char.cpp +++ b/src/game/char.cpp @@ -364,11 +364,9 @@ void CHARACTER::Initialize() m_bIsLoadedAffect = false; cannot_dead = false; -#ifdef FIX_BATTLE_INACTIVITY_TIMEOUT // tw1x1: POS_FIGHTING timer fix m_dwLastCombatTime = 0; // tw1x1: end -#endif #ifdef __PET_SYSTEM__ m_petSystem = 0; @@ -4098,8 +4096,6 @@ void CHARACTER::UpdateStateMachine(DWORD dwPulse) if (IsDead()) return; -#ifdef FIX_BATTLE_INACTIVITY_TIMEOUT - // tw1x1: POS_FIGHTING timer fix if (IsPC() && IsPosition(POS_FIGHTING)) { const DWORD now = get_dword_time(); @@ -4111,8 +4107,6 @@ void CHARACTER::UpdateStateMachine(DWORD dwPulse) if (now - m_dwLastCombatTime >= 10000) SetVictim(NULL); // triggers battle_end() -> POS_STANDING } - // tw1x1: end -#endif Update(); m_dwNextStatePulse = dwPulse + m_dwStateDuration; diff --git a/src/game/char.h b/src/game/char.h index 8209fc5..0c02ad1 100644 --- a/src/game/char.h +++ b/src/game/char.h @@ -2048,8 +2048,6 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider int m_iLastPMPulse; int m_iPMCounter; -#ifdef FIX_BATTLE_INACTIVITY_TIMEOUT - // tw1x1: POS_FIGHTING timer fix public: void EnterCombat(); void UpdateLastCombatTime() { m_dwLastCombatTime = get_dword_time(); } @@ -2057,8 +2055,6 @@ class CHARACTER : public CEntity, public CFSM, public CHorseRider private: DWORD m_dwLastCombatTime; - // tw1x1: end -#endif }; ESex GET_SEX(LPCHARACTER ch); diff --git a/src/game/char_battle.cpp b/src/game/char_battle.cpp index cff0afc..538d2e6 100644 --- a/src/game/char_battle.cpp +++ b/src/game/char_battle.cpp @@ -1600,6 +1600,22 @@ void CHARACTER::SendDamagePacket(LPCHARACTER pAttacker, int Damage, BYTE DamageF } } +void CHARACTER::EnterCombat() +{ + if (!IsPC()) + return; + + if (!IsPosition(POS_FIGHTING)) + { + SetPosition(POS_FIGHTING); + SetNextStatePulse(1); + } + + // Start the 10s window if it hasn't started yet. + if (m_dwLastCombatTime == 0) + m_dwLastCombatTime = get_dword_time(); +} + // // CHARACTER::Damage 메소드는 this가 데미지를 입게 한다. // @@ -2315,6 +2331,8 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu if (GetHP() - dam <= 0) dam = GetHP(); + dam = std::min(GetHP(), dam); + // tw1x1: POS_FIGHTING timer fix // REAL combat activity only: final damage > 0 if (dam > 0) diff --git a/src/game/char_skill.cpp b/src/game/char_skill.cpp index 1a55f10..b91295a 100644 --- a/src/game/char_skill.cpp +++ b/src/game/char_skill.cpp @@ -2489,6 +2489,11 @@ bool CHARACTER::UseSkill(DWORD dwVnum, LPCHARACTER pkVictim, bool bUseGrandMaste if (!pkSk) return false; + if (IsPC() && IS_SET(pkSk->dwFlag, SKILL_FLAG_ATTACK)) + { + EnterCombat(); + } + if (bCanUseHorseSkill && pkSk->dwType != SKILL_TYPE_HORSE) return BATTLE_NONE;