Skip to content

Red Stone Combat and Skill Logic Analysis

LostMyCode edited this page Dec 6, 2025 · 1 revision

1. Executive Summary

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::UpdateMain is the central hub. It delegates detailed input handling to CActorManager::updateInpdev (mouse/targeting) and CGamePlay::UpdateBottomInterface (hotkeys/UI).
  • Targeting: Mouse targeting is handled by CActorManager::findFocusActor, which updates CGamePlay::s_iFocusActor.
  • Skill Execution: The core functions are CHero::useSkillToTarget (targeted skills) and CHero::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 trigger CHero::useQuickSlotSkill.

2. Input Handling Flow

2.1 Mouse Input & Targeting

Location: CActorManager.cpp -> updateInpdev

The game updates mouse state every frame. updateInpdev calls updateActor, which triggers findFocusActor.

  1. findFocusActor(): Iterates through visible actors.
  2. Detection: Checks if the mouse cursor resides within an actor's bounding box.
  3. Result: Sets the global variable CGamePlay::s_iFocusActor to the serial ID of the hovered actor.

2.2 Hotkey Input (Quick Slots)

Location: CGameBottomInterface.cpp -> UpdateBottomInterface

The bottom UI bar manages skill hotkeys (Q, W, E, R, T, A, S, D, F, G).

  1. Mapping: Keys are mapped to button IDs (e.g., KEY_Q -> eBIM_QUICK_SKILL1).
  2. Detection: s_bmBottomMenu.update() checks for key presses.
  3. Trigger: If a key is pressed, UpdateBottomInterface receives the corresponding ID and calls:
    g_hero.useQuickSlotSkill(dwBottomButtonMenu - eBIM_QUICK_SKILL1);

3. Skill Logic & Execution

3.1 CHero::useQuickSlotSkill

Location: CHeroUseSkill.cpp

This function acts as a router for hotkey skills:

  1. Retrieval: Looks up the skill ID associated with the slot.
  2. Validation: Checks if the player is dead, sitting, or transformed.
  3. Special Handling: Toggles actions (like "Sit") or passive adjustments immediately.
  4. 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.

3.2 CHero::useSkillToTarget

Location: CHeroUseSkill.cpp

The core function for executing a skill on a specific actor.

  1. Validation: Checks cooldowns (isUseAbleSkill), mana/CP requirements, and line-of-sight (isMissileBlockedLine).
  2. Range Check:
    • Calculates iAttackRange based on the skill.
    • In Range: If isTouchAbleTarget returns true, proceeds to attack.
    • Out of Range: If not engaged, initiates moveTo to approach the target.
  3. Execution:
    • Updates m_iLastActionTime.
    • Sets m_wEngageTarget to the target ID (locking the player into combat state).
    • Calls s_agent.sendUseSkillToTarget to notify the server.

3.3 CHero::actionToLockedTarget

Location: CHeroUseSkill.cpp

Handles persistent combat states (e.g., auto-attacking after clicking once).

  • Periodically called when m_wLockedTarget is set.
  • Repeats the validation and range check logic found in useSkillToTarget.
  • Ensures the player continues to chase or attack the target automatically.

4. Network Layer (The End of the Chain)

4.1 Packet Transmission

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).

5. Visual Flowchart

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
Loading