suriyun-production / mmorpg-kit-docs

This is document for MMORPG KIT project (https://www.assetstore.unity3d.com/#!/content/110188?aid=1100lGeN)
https://suriyun-production.github.io/mmorpg-kit-docs
49 stars 10 forks source link

Grab #2633

Closed lnpro34 closed 1 day ago

lnpro34 commented 5 days ago

Creating a grab with combo system in a game developed with Unity using the MMORPG Kit and Dev Extensions without modifying the core is a challenging but feasible task. Here's a detailed step-by-step guide to implementing this functionality:

  1. Planning the Grab System You aim to:

Allow a player to perform a grab on another player. Immobilize the target player during the grab. Enable the attacker to execute a skill combo while the target is immobilized. For this, you’ll need:

A trigger to initiate the grab (e.g., via a skill or command). Player states (attacker and target) to control actions during the grab. Movement restriction for the target during the grab. A synchronization system to ensure proper server-client behavior (essential for MMORPGs).

  1. Creating the Grab State The MMORPG Kit uses states to manage skills and actions. With Dev Extensions, you can extend these states.

Step 1: Add a New State for Grab Create a new script named PlayerGrabState. This state will handle immobilizing the target and allowing combos from the attacker. Example:

csharp Copiar código using UnityEngine;

public class PlayerGrabState : BaseCharacterState { public override void EnterState() { // Immobilize the target owner.SetCanMove(false); owner.SetCanAttack(false); Debug.Log($"{owner.CharacterName} has been grabbed!"); }

public override void UpdateState(float deltaTime)
{
    // Update timers or other logic for the grab duration
}

public override void ExitState()
{
    // Restore movement and actions for the target
    owner.SetCanMove(true);
    owner.SetCanAttack(true);
    Debug.Log($"{owner.CharacterName} is free from the grab!");
}

} Step 2: Create the Grab Skill In the MMORPG Kit, skills are managed by Skill Scripts. You can create a new skill that applies the grab state.

Create a new script named GrabSkill. Extend BaseSkill to define the behavior of the grab skill. Example:

csharp Copiar código using UnityEngine;

public class GrabSkill : BaseSkill { public override void ApplySkillEffect(BaseCharacterEntity attacker, BaseCharacterEntity target) { if (target != null) { // Apply the grab state to the target target.SetState(new PlayerGrabState());

        // Notify the attacker
        Debug.Log($"{attacker.CharacterName} grabbed {target.CharacterName}!");
    }
}

} Configure the skill in the MMORPG Kit interface (set cooldown, mana cost, etc.).

  1. Implementing the Combo During the grab, the attacker needs to execute a combo.

Step 1: Combo System Create a script GrabComboManager to handle combos during the grab. Use the attacker’s state to check if they’re in the middle of a combo. Example:

csharp Copiar código using UnityEngine;

public class GrabComboManager : MonoBehaviour { private int comboStep = 0; private float comboTimer = 0f; private const float maxComboTime = 2f;

public void ExecuteCombo()
{
    if (comboTimer > 0)
    {
        comboStep++;
        Debug.Log($"Combo step: {comboStep}");
        comboTimer = maxComboTime;

        // Add specific effects for each combo step here
    }
    else
    {
        // Reset the combo if the timer expires
        comboStep = 1;
        comboTimer = maxComboTime;
        Debug.Log("Combo restarted!");
    }
}

private void Update()
{
    if (comboTimer > 0)
        comboTimer -= Time.deltaTime;
}

} Step 2: Integrate Combo with Grab During the grab state, allow the attacker to execute skills that advance the combo. Use a reference to the GrabComboManager on the attacker.

  1. Server Synchronization The MMORPG Kit is designed to synchronize states and events between the client and server. Ensure that:

The grab state is synchronized using network events (Rpc or Cmd). The movement and attack restrictions on the target are applied on the server to prevent exploits. Example of synchronization:

csharp Copiar código [Command] void CmdApplyGrabEffect(string targetId) { var target = FindPlayerById(targetId); if (target != null) { target.SetState(new PlayerGrabState()); RpcNotifyGrabEffect(targetId); } }

[ClientRpc] void RpcNotifyGrabEffect(string targetId) { var target = FindPlayerById(targetId); if (target != null) { target.SetState(new PlayerGrabState()); } }

  1. Setting Up in the MMORPG Kit Configure the GrabSkill in the skill database. Attach the GrabComboManager script to the attacker. Test thoroughly to ensure restrictions and combos work as expected.
  2. Refinement and Polishing Add animations for the grab and combo for better immersion. Include visual and audio feedback (e.g., particles and sound effects). Adjust grab and combo durations for PvP balance.

With these steps, you can implement a grab and combo system in the MMORPG Kit using Dev Extensions without modifying the core.

this info from gpt is valid?

Niinra commented 3 days ago

I'll be honest with you, to use an AI for things with code you have to know how to program anyway, you can't just come and copy the code and put it here to tell you if it's okay

insthync commented 1 day ago

I don't know too, I have to try to answer it, and I don't want to try.