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 e9bfaf2..4c5a38e 100644 --- a/src/game/char.cpp +++ b/src/game/char.cpp @@ -361,11 +361,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; @@ -4110,8 +4108,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(); @@ -4123,8 +4119,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 aa7f51c..435bf39 100644 --- a/src/game/char.h +++ b/src/game/char.h @@ -2045,8 +2045,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(); } @@ -2054,8 +2052,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 1d10bea..cd8ac45 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가 데미지를 입게 한다. // @@ -2312,13 +2328,9 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu // if (!cannot_dead) { -#ifdef FIX_NEG_HP - if (GetHP() - dam <= 0) - dam = GetHP(); -#endif -#ifdef FIX_BATTLE_INACTIVITY_TIMEOUT - // tw1x1: POS_FIGHTING timer fix + dam = std::min(GetHP(), dam); + // REAL combat activity only: final damage > 0 if (dam > 0) { @@ -2333,9 +2345,7 @@ bool CHARACTER::Damage(LPCHARACTER pAttacker, int dam, EDamageType type) // retu pAttacker->EnterCombat(); } } - // tw1x1: end -#endif - + PointChange(POINT_HP, -dam, false); } diff --git a/src/game/char_skill.cpp b/src/game/char_skill.cpp index ce7b750..dcae6de 100644 --- a/src/game/char_skill.cpp +++ b/src/game/char_skill.cpp @@ -2499,6 +2499,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;