Skip to content

Commit

Permalink
Added actions for experience and skill experience
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyBitz committed Jul 18, 2021
1 parent 7c0f939 commit ccd931d
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 11 deletions.
50 changes: 41 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ Execute gameserver actions in realtime with a simple `INSERT` query into `SRO_VT

### Examples

1. Adds item(s) to the inventory from character
1. Adds item(s) to the inventory from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param01, -- CodeName
Param02, -- Amount
Param03, -- Randomize stats
Param03, -- Random stats (0 = Clean, 1 = Random)
Param04 -- Plus
)
VALUES
Expand All @@ -36,7 +36,7 @@ VALUES
);
```

2. Updates the gold amount from character by increasing (positive) or decreasing (negative)
2. Updates the gold amount from player by increasing (positive) or decreasing (negative)
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -52,7 +52,7 @@ VALUES
);
```

3. Updates the Hwan level (Berserk rank) from character by level
3. Updates the Hwan level (Berserk title) from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -68,7 +68,7 @@ VALUES
);
```

4. Moves the character to the position on map
4. Moves the player to the position on map
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -90,7 +90,7 @@ VALUES
);
```

5. Moves the character to the position on map through game world id
5. Moves the player to the position on map through game world id
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -114,7 +114,7 @@ VALUES
);
```

6. Drops an item near character
6. Drops an item near player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand Down Expand Up @@ -152,7 +152,7 @@ VALUES
);
```

8. Force reloading the character information by teleporting it on the same place
8. Force reloading the player information by teleporting it on the same place
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand All @@ -166,7 +166,7 @@ VALUES
);
```

9. Adds a buff to the character. The duration will not be lost through teleports
9. Adds a buff to the player. The duration will not be lost through teleports
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Expand Down Expand Up @@ -298,6 +298,38 @@ VALUES
);
```

16. Updates level experience from player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param02 -- Level Experience
)
VALUES
(
16,
'JellyBitz',
1000000 -- Increase experience by 1m
);
```

17. Add skill points experience to player
```sql
INSERT INTO [SRO_VT_SHARD].[dbo].[_ExeGameServer]
(
Action_ID,
CharName16,
Param02 -- Skill Points Experience
)
VALUES
(
17,
'JellyBitz',
1000000 -- Increase experience by 1m (equivalent to 2500 SP)
);
```

### Action Result Code

```C++
Expand Down
24 changes: 24 additions & 0 deletions vSRO-GameServer/AppManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,30 @@ DWORD WINAPI AppManager::DatabaseFetchThread()
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 16: // Update Experience
{
SQLBIGINT cParam02;
if (m_dbLink.sqlCmd.GetData(5, SQL_C_SBIGINT, &cParam02, 0, NULL))
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
if (player)
player->UpdateExperience(cParam02);
else
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 17: // Add Skill Point Experience
{
SQLUINTEGER cParam02;
if (m_dbLink.sqlCmd.GetData(5, SQL_C_ULONG, &cParam02, 0, NULL))
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
if (player)
player->AddSPExperience(cParam02);
else
actionResult = FETCH_ACTION_STATE::CHARNAME_NOT_FOUND;
}
} break;
case 3312: // For testing references
{
CGObjPC* player = CGObjManager::GetObjPCByCharName16(cCharName);
Expand Down
2 changes: 2 additions & 0 deletions vSRO-GameServer/Silkroad/Object/CGObj.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ class CGObj
{
protected: /// Protected Members
uint32_t m_ptrVTable;
// Unique Identifier from this object
uint32_t m_UniqueID;
public: /// Public Properties
// Gets the game world id as reference
void GetGameWorldId(uint32_t* OutGameWorldId);
Expand Down
8 changes: 8 additions & 0 deletions vSRO-GameServer/Silkroad/Object/CGObjPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ void CGObjPC::UpdateHwan(uint8_t Level)
{
reinterpret_cast<void(__thiscall*)(CGObjPC*, uint8_t)>(0x004A9F40)(this, Level);
}
void CGObjPC::UpdateExperience(int64_t ExpOffset)
{
CallVirtual<void(__thiscall*)(CGObjPC*, uint32_t, int64_t, uint32_t, std::uintptr_t*)>(this, 92)(this, m_UniqueID, ExpOffset, 0, nullptr);
}
void CGObjPC::AddSPExperience(uint32_t SPExpOffset)
{
CallVirtual<void(__thiscall*)(CGObjPC*, uint32_t, int64_t, uint32_t, std::uintptr_t*)>(this, 92)(this, m_UniqueID, 0, SPExpOffset, nullptr);
}
void CGObjPC::UpdateSP(int32_t Offset)
{
CallVirtual<void(__thiscall*)(CGObjPC*, int32_t, int8_t)>(this, 93)(this, Offset, 1);
Expand Down
7 changes: 5 additions & 2 deletions vSRO-GameServer/Silkroad/Object/CGObjPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
class CGObjPC : public CGObjChar
{
private: /// Private Members
uint32_t m_UniqueID;
char pad_0x8[44];
CInstancePC* m_CInstancePC;
char pad_0x38[76];
Expand All @@ -25,8 +24,12 @@ class CGObjPC : public CGObjChar
void UpdateGold(int64_t Offset);
// Update hwan title by level
void UpdateHwan(uint8_t Level);
// Update the current SP Experience
// Update the current Skill Points
void UpdateSP(int32_t Offset);
// Update level experience
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);
// Moves the player to the map location. Return success
Expand Down

0 comments on commit ccd931d

Please sign in to comment.