Skip to content

Commit

Permalink
Added action to reduce HP and/or MP from player
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBitz committed Aug 20, 2021
1 parent 3cf64f2 commit 42af1aa
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,24 @@ VALUES
);
```

19. Reduces health and/or mana points from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param02, -- HP reduced
Param02 -- MP reduced
)
VALUES
(
19,
'JellyBitz',
5000, -- Reducing HP only
0
);
```


### Action Result Code

Expand Down
13 changes: 13 additions & 0 deletions vSRO-GameServer/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,19 @@ DWORD WINAPI AppManager::DatabaseFetchThread()
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 19:
{
SQLINTEGER cParam02, cParam03, cParam04;
if (m_dbLink.sqlCmd.GetData(5, SQL_C_LONG, &cParam02, 0, NULL)
&& m_dbLink.sqlCmd.GetData(6, SQL_C_LONG, &cParam03, 0, NULL))
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
if (player)
player->ReduceHPMP(cParam02, cParam03, true);
else
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 3312: // For testing references
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
Expand Down
14 changes: 12 additions & 2 deletions vSRO-GameServer/Silkroad/Object/CGObjPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,19 @@ void CGObjPC::UpdateSP(int32_t Offset)
{
CallVirtual<void(__thiscall*)(CGObjPC*, int32_t, int8_t)>(this, 93)(this, Offset, 1);
}
void CGObjPC::UpdateHPMP(int32_t Health, int32_t Mana, uint16_t DisplayEffectType)
void CGObjPC::ReduceHPMP(uint32_t Health, uint32_t Mana, bool ShowEffect)
{
CallVirtual<void(__thiscall*)(CGObjPC*, int32_t, int32_t, uint16_t)>(this, 194)(this, Health, Mana, DisplayEffectType);
// Check if player will die by health reduction
bool died = Health > m_CInstancePC->CurHealth;
if (died)
{
Health = m_CInstancePC->CurHealth;
Mana = m_CInstancePC->CurMana;
}
CallVirtual<void(__thiscall*)(CGObjPC*, uint32_t, uint32_t, uint16_t)>(this, 194)(this, Health, Mana, ShowEffect ? 1024 : 0);
// Set dead status
if (died)
SetLifeState(false);
}
void CGObjPC::UpdatePVPCapeType(uint8_t CapeType)
{
Expand Down
4 changes: 2 additions & 2 deletions vSRO-GameServer/Silkroad/Object/CGObjPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class CGObjPC : public CGObjChar
void UpdateExperience(int64_t ExpOffset);
// Add skill experience
void AddSPExperience(uint32_t SPExpOffset);
// Updates the HP and MP
void UpdateHPMP(int32_t Health, int32_t Mana, uint16_t DisplayEffectType);
// Reduces health and/or mana points. If health reduced exceeds the current amount, the player will die
void ReduceHPMP(uint32_t Health, uint32_t Mana, bool ShowEffect);
// Updates the cape state from PVP
void UpdatePVPCapeType(uint8_t CapeType);
// Moves the player to the map location. Return success
Expand Down

0 comments on commit 42af1aa

Please sign in to comment.