Dear forum users! In compliance with the new European GDPR regulations, we'd just like to inform you that if you have an account, your email address is stored in our database. We do not share your information with third parties, and your email address and password are encrypted for security reasons.

New to the forum? Say hello in this topic! Also make sure to read the rules.

Add PlayerMeleeHitArg.MeleeAction

Give us your input on how we may improve the ScriptAPI in the game in future versions.
Forum rules
By using the forum you agree to the following rules.
Post Reply
NearHuscarl
Superfighter
Superfighter
Posts: 97
Joined: Thu Feb 07, 2019 4:36 am

Add PlayerMeleeHitArg.MeleeAction

Post by NearHuscarl » Sat Mar 19, 2022 3:02 pm

I'd like to have a way to know what melee action is being performed. Is the attacker doing a single punch, a combo or a knock out. Below is an example in code:

Code: Select all

public enum MeleeAction { Attack1, Attack2, Attack3 }

public struct PlayerMeleeHitArg
{
    public readonly int ObjectID;
    public readonly IObject HitObject;
    public readonly Vector2 HitPosition;
    public readonly bool IsPlayer;
    public readonly float HitDamage;
    // new property
    public readonly MeleeAction MeleeAction;

    public PlayerMeleeHitArg(int objectID, IObject hitObject, Vector2 hitPosition, bool isPlayer, float hitDamage, MeleeAction meleeAction);
}

Code: Select all

Events.PlayerMeleeActionCallback.Start(OnPlayerMeleeAction);

// ...

private static void OnPlayerMeleeAction(IPlayer attacker, PlayerMeleeHitArg[] args)
{
    foreach (var arg in args)
    {
        if (arg.MeleeAction == MeleeAction.Attack1) { /* ... */ }
        if (arg.MeleeAction == MeleeAction.Attack2) { /* ... */ }
        if (arg.MeleeAction == MeleeAction.Attack3) { /* Activate powerup... */ }
    }
}
0 x
Image

Post Reply