-
Notifications
You must be signed in to change notification settings - Fork 15
Red Stone Combat and Skill Logic Analysis
This report details the execution flow of combat and skills in Red Stone, tracing the path from player input (mouse clicks, hotkeys) to the final network packet sent to the server.
Key Findings:
-
Input Processing:
CGamePlay::UpdateMainis the central hub. It delegates detailed input handling toCActorManager::updateInpdev(mouse/targeting) andCGamePlay::UpdateBottomInterface(hotkeys/UI). -
Targeting: Mouse targeting is handled by
CActorManager::findFocusActor, which updatesCGamePlay::s_iFocusActor. -
Skill Execution: The core functions are
CHero::useSkillToTarget(targeted skills) andCHero::useSkillToGround(ground/AOE skills). -
Hotkeys: The "Quick Slot" system (keys Q-T, A-G) is managed by the UI system (
CGameBottomInterface), which treats hotkeys as button presses that triggerCHero::useQuickSlotSkill.
Location: CActorManager.cpp -> updateInpdev
The game updates mouse state every frame. updateInpdev calls updateActor, which triggers findFocusActor.
-
findFocusActor(): Iterates through visible actors. - Detection: Checks if the mouse cursor resides within an actor's bounding box.
-
Result: Sets the global variable
CGamePlay::s_iFocusActorto the serial ID of the hovered actor.
Location: CGameBottomInterface.cpp -> UpdateBottomInterface
The bottom UI bar manages skill hotkeys (Q, W, E, R, T, A, S, D, F, G).
-
Mapping: Keys are mapped to button IDs (e.g.,
KEY_Q->eBIM_QUICK_SKILL1). -
Detection:
s_bmBottomMenu.update()checks for key presses. -
Trigger: If a key is pressed, UpdateBottomInterface receives the corresponding ID and calls:
g_hero.useQuickSlotSkill(dwBottomButtonMenu - eBIM_QUICK_SKILL1);
Location: CHeroUseSkill.cpp
This function acts as a router for hotkey skills:
- Retrieval: Looks up the skill ID associated with the slot.
- Validation: Checks if the player is dead, sitting, or transformed.
- Special Handling: Toggles actions (like "Sit") or passive adjustments immediately.
-
Targeting Decision:
-
Quick Cast: If
isQuickCastSkill()is true, calls useSkillToGround (uses cursor coordinates). -
Focus Target: If a valid target is under the mouse (
s_iFocusActor), calls useSkillToTarget. -
Engaged Target: If currently fighting (
m_wEngageTarget), calls useSkillToTarget on that enemy. - Fallback: Defaults to useSkillToGround if no target is found.
-
Quick Cast: If
Location: CHeroUseSkill.cpp
The core function for executing a skill on a specific actor.
-
Validation: Checks cooldowns (
isUseAbleSkill), mana/CP requirements, and line-of-sight (isMissileBlockedLine). -
Range Check:
- Calculates
iAttackRangebased on the skill. -
In Range: If
isTouchAbleTargetreturns true, proceeds to attack. - Out of Range: If not engaged, initiates moveTo to approach the target.
- Calculates
-
Execution:
- Updates
m_iLastActionTime. - Sets
m_wEngageTargetto the target ID (locking the player into combat state). - Calls
s_agent.sendUseSkillToTargetto notify the server.
- Updates
Location: CHeroUseSkill.cpp
Handles persistent combat states (e.g., auto-attacking after clicking once).
- Periodically called when
m_wLockedTargetis set. - Repeats the validation and range check logic found in useSkillToTarget.
- Ensures the player continues to chase or attack the target automatically.
Location: CAgentSendPacket.cpp
The function CAgent::sendUseSkillToTarget is the final step on the client side.
-
Packet Construction: Creates a packet containing:
- Target Serial ID
- Skill ID
- Left/Right/Sub Skill IDs (current setup)
-
Sending: Pushes the packet to the output queue (
m_socket.send).
graph TD
Input[User Input] -->|Mouse Hover| Focus[s_iFocusActor Set]
Input -->|Hotkey Press| UI[UpdateBottomInterface]
UI -->|Quick Slot ID| QuickSkill{CHero::useQuickSlotSkill}
QuickSkill -->|Quick Cast| Ground[useSkillToGround]
QuickSkill -->|Has Focus Target| Targeted[useSkillToTarget]
QuickSkill -->|Has Engaged Target| Targeted
QuickSkill -->|No Target| Ground
Targeted --> RangeCheck{Is in Range?}
RangeCheck -->|No| Move[moveTo Target]
RangeCheck -->|Yes| SendPacket[s_agent.sendUseSkillToTarget]
Move -->|Tick Updates| Targeted