Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. The Contract
      2. Updates
      3. Find Lobbies & Players
      4. Guides & Strategies
      5. Vehicles
      6. Content Creator
      7. Help & Support
    2. Red Dead Online

      1. Blood Money
      2. Frontier Pursuits
      3. Find Lobbies & Outlaws
      4. Help & Support
    3. Crews

    1. Grand Theft Auto Series

      1. Bugs*
      2. St. Andrews Cathedral
    2. GTA VI

    3. GTA V

      1. Guides & Strategies
      2. Help & Support
    4. GTA IV

      1. The Lost and Damned
      2. The Ballad of Gay Tony
      3. Guides & Strategies
      4. Help & Support
    5. GTA San Andreas

      1. Classic GTA SA
      2. Guides & Strategies
      3. Help & Support
    6. GTA Vice City

      1. Classic GTA VC
      2. Guides & Strategies
      3. Help & Support
    7. GTA III

      1. Classic GTA III
      2. Guides & Strategies
      3. Help & Support
    8. Portable Games

      1. GTA Chinatown Wars
      2. GTA Vice City Stories
      3. GTA Liberty City Stories
    9. Top-Down Games

      1. GTA Advance
      2. GTA 2
      3. GTA
    1. Red Dead Redemption 2

      1. PC
      2. Help & Support
    2. Red Dead Redemption

    1. GTA Mods

      1. GTA V
      2. GTA IV
      3. GTA III, VC & SA
      4. Tutorials
    2. Red Dead Mods

      1. Documentation
    3. Mod Showroom

      1. Scripts & Plugins
      2. Maps
      3. Total Conversions
      4. Vehicles
      5. Textures
      6. Characters
      7. Tools
      8. Other
      9. Workshop
    4. Featured Mods

      1. Design Your Own Mission
      2. OpenIV
      3. GTA: Underground
      4. GTA: Liberty City
      5. GTA: State of Liberty
    1. Rockstar Games

    2. Rockstar Collectors

    1. Off-Topic

      1. General Chat
      2. Gaming
      3. Technology
      4. Movies & TV
      5. Music
      6. Sports
      7. Vehicles
    2. Expression

      1. Graphics / Visual Arts
      2. GFX Requests & Tutorials
      3. Writers' Discussion
      4. Debates & Discussion
    1. Announcements

    2. Support

    3. Suggestions

[Net] How to make a super punch mod?


nitanmarcel
 Share

Recommended Posts

I do not really know .NET, but try this:

Player player = Game.Player;Ped playerPed = Game.Player.Character;        if (Function.Call<bool>(Hash.IS_PLAYER_TARGETTING_ANYTHING, player)){      OutputArgument outTarget = new OutputArgument();      Function.Call<bool>(Hash.GET_PLAYER_TARGET_ENTITY, player, outTarget);      Ped target = outTarget.GetResult<Ped>();      if (Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, target, playerPed))      {          Vector3 fwdVector = Function.Call<Vector3>(Hash.GET_ENTITY_FORWARD_VECTOR, playerPed);          Vector3 force = fwdVector * 50.0f; //Make it over 50 to increase power, or below 50 to decrease power          Function.Call(((Hash)0xD05BFF0C0A12C68F), target, force.X, force.Y, force.Z, 1, 0, 1, 1); //_APPLY_FORCE_TO_ENTITY2          // ^^ change target to playerPed if you want to push the target with your player          Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, target);          }      }
Edited by whorse
Link to comment
Share on other sites

 

 

 

I do not really know .NET, but try this:

Player player = Game.Player;
Ped playerPed = Game.Player.Character;

if (Function.Call<bool>(Hash.IS_PLAYER_TARGETTING_ANYTHING, player))
{
OutputArgument outTarget = new OutputArgument();
Function.Call<bool>(Hash.GET_PLAYER_TARGET_ENTITY, player, outTarget);
Ped target = outTarget.GetResult<Ped>();

if (Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, target, playerPed))
{
Vector3 fwdVector = Function.Call<Vector3>(Hash.GET_ENTITY_FORWARD_VECTOR, playerPed);
Vector3 force = fwdVector * 50.0f; //Make it over 50 to increase power, or below 50 to decrease power
Function.Call(((Hash)0xD05BFF0C0A12C68F), target, force.X, force.Y, force.Z, 1, 0, 1, 1); //_APPLY_FORCE_TO_ENTITY2
// ^^ change target to playerPed if you want to push the target with your player
Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, target);
}

}

 

 

 

Is not working. Is something wrong with my code?

 

using System;

using System.Drawing;

using System.Windows.Forms;

using System.Collections.Generic;

using System.Linq;

using System.IO;

using System.Reflection;

using GTA;

using GTA.Native;

using GTA.Math;

using Menu = GTA.Menu;

public class Class1 : Script

{

public Class1()

{

Tick += OnTick;

KeyDown += OnKeyDown;

KeyUp += OnKeyUp;

Interval = 10;

 

 

}

 

 

 

 

void OnTick(object sender, EventArgs e)

{

Player player = Game.Player;

Ped playerPed = Game.Player.Character;

if (Function.Call<bool>(Hash.IS_PLAYER_TARGETTING_ANYTHING, player))

{

OutputArgument outTarget = new OutputArgument();

Function.Call<bool>(Hash.GET_PLAYER_TARGET_ENTITY, player, outTarget);

Ped target = outTarget.GetResult<Ped>();

if (Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, target, playerPed))

{

Vector3 fwdVector = Function.Call<Vector3>(Hash.GET_ENTITY_FORWARD_VECTOR, playerPed);

Vector3 force = fwdVector * 1000.0f; //Make it over 50 to increase power, or below 50 to decrease power

Function.Call(((Hash)0xD05BFF0C0A12C68F), target, force.X, force.Y, force.Z, 1, 0, 1, 1); //_APPLY_FORCE_TO_ENTITY2

// ^^ change target to playerPed if you want to push the target with your player

Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, target);

}

}

}

void OnKeyDown(object sender, KeyEventArgs e)

{

}

void OnKeyUp(object sender, KeyEventArgs e)

{

}

}

 

 

Edited by nitanmarcel
Link to comment
Share on other sites

InfamousSabre

Depends on what you want a "super punch" mod to do.

1: detect last ped punched by player

2: perform some action on that ped

  • Like 1
Link to comment
Share on other sites

Depends on what you want a "super punch" mod to do.

1: detect last ped punched by player

2: perform some action on that ped

 

2 :D I want like then when i hit the ped to appy force to that ped and launch him :D If you know what i mean

Link to comment
Share on other sites

 

 

 

 

I do not really know .NET, but try this:

Player player = Game.Player;

Ped playerPed = Game.Player.Character;

 

if (Function.Call<bool>(Hash.IS_PLAYER_TARGETTING_ANYTHING, player))

{

OutputArgument outTarget = new OutputArgument();

Function.Call<bool>(Hash.GET_PLAYER_TARGET_ENTITY, player, outTarget);

Ped target = outTarget.GetResult<Ped>();

 

if (Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, target, playerPed))

{

Vector3 fwdVector = Function.Call<Vector3>(Hash.GET_ENTITY_FORWARD_VECTOR, playerPed);

Vector3 force = fwdVector * 50.0f; //Make it over 50 to increase power, or below 50 to decrease power

Function.Call(((Hash)0xD05BFF0C0A12C68F), target, force.X, force.Y, force.Z, 1, 0, 1, 1); //_APPLY_FORCE_TO_ENTITY2

// ^^ change target to playerPed if you want to push the target with your player

Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, target);

}

 

}

 

 

 

Is not working. Is something wrong with my code?

 

using System;

using System.Drawing;

using System.Windows.Forms;

using System.Collections.Generic;

using System.Linq;

using System.IO;

using System.Reflection;

using GTA;

using GTA.Native;

using GTA.Math;

using Menu = GTA.Menu;

public class Class1 : Script

{

public Class1()

{

Tick += OnTick;

KeyDown += OnKeyDown;

KeyUp += OnKeyUp;

Interval = 10;

 

 

}

 

 

 

 

void OnTick(object sender, EventArgs e)

{

Player player = Game.Player;

Ped playerPed = Game.Player.Character;

if (Function.Call<bool>(Hash.IS_PLAYER_TARGETTING_ANYTHING, player))

{

OutputArgument outTarget = new OutputArgument();

Function.Call<bool>(Hash.GET_PLAYER_TARGET_ENTITY, player, outTarget);

Ped target = outTarget.GetResult<Ped>();

if (Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, target, playerPed))

{

Vector3 fwdVector = Function.Call<Vector3>(Hash.GET_ENTITY_FORWARD_VECTOR, playerPed);

Vector3 force = fwdVector * 1000.0f; //Make it over 50 to increase power, or below 50 to decrease power

Function.Call(((Hash)0xD05BFF0C0A12C68F), target, force.X, force.Y, force.Z, 1, 0, 1, 1); //_APPLY_FORCE_TO_ENTITY2

// ^^ change target to playerPed if you want to push the target with your player

Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, target);

}

}

}

void OnKeyDown(object sender, KeyEventArgs e)

{

}

void OnKeyUp(object sender, KeyEventArgs e)

{

}

}

 

 

 

I dont know, like I said I do not know .NET, only C++. I just made that code up based on how I've seen others use .NET for GTA scripting.

Also, it would only work while you are locked on to an enemy in melee combat. That is what the first if statement is all about - "is player targeting anything".

The thing with multiplying the XYZ of the player's forward-vector by 50 most definitely works in launching the player forward, so I assume it would also work if you applied that same force to a ped you are fighting that is in front of the player. I tried to make it so that if you damaged the ped while locked on to them, it would apply the force, and then immediately clear the damage done so you could potentially launch the ped forward again if you were to hit the ped again

 

Maybe someone who knows .NET syntax could tell if there's something wrong with the code? Like the OutputArgument stuff?

Link to comment
Share on other sites

What you could do is find the entity by iterating through World.GetAllPeds(). The code also doesn't check if the ped was attacked by a melee attack. Try this:

using System;using System.Collections.Generic;using GTA;using GTA.Math;using GTA.Native; namespace SuperPunch{    public class SuperPunch : Script    {        private float force = 100.0f; //Change this to change the force applied         public SuperPunch()        {            Tick += SuperPunch_Tick;        }         void SuperPunch_Tick(object sender, EventArgs e)        {            Ped player = Game.Player.Character;             //Loop through all peds            foreach (Ped ped in World.GetAllPeds())            {                //Check for damage by player                if (Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, ped, player, true))                {                    //Check for damage by melee                    if (Function.Call<bool>(Hash.HAS_PED_BEEN_DAMAGED_BY_WEAPON, ped, 0, 1))                    {                        //Get player direction                        Vector3 direction = Vector3.Multiply(player.ForwardVector, force);                         //Apply force to ped                        ped.ApplyForce(direction);                         //Clear all damage                        Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, ped);                         //Break loop                        break;                    }                }            }        }    }}

Since this only checks for a melee weapon, you could also get out your baseball bat and send people flying, smash bros style.

Edited by WedgedWolf
  • Like 1
Link to comment
Share on other sites

nice, that should work. I forgot to put the "true" after HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, but it didnt show up as an intellisense error (I guess it wouldn't), so I didn't notice :facedesk:

Link to comment
Share on other sites

InfamousSabre

If you want it to look realistic, figure out which of the Player's bones the Player used to hit the Ped, then figure out the direction and speed that bone was last moving to know how to apply force. Pretty nice when uppercutting someone sends them flying in the air, and giving a downwards punch or kick slams them on the ground. also, this keeps a slow moving blow from sending the ped flying. You want to multiply the Player's power. Not use a fixed value.

I did this and it looks great, but of course, I understand if nobody else cares to do all this work just for a Super-Melee script.

Edited by InfamousSabre
Link to comment
Share on other sites

If you want it to look realistic, figure out which of the Player's bones the Player used to hit the Ped, then figure out the direction and speed that bone was last moving to know how to apply force. Pretty nice when uppercutting someone sends them flying in the air, and giving a downwards punch or kick slams them on the ground. also, this keeps a slow moving blow from sending the ped flying. You want to multiply the Player's power. Not use a fixed value.

I did this and it looks great, but of course, I understand if nobody else cares to do all this work just for a Super-Melee script.

Nice idea :D What i'm trying to do is a super mod xD https://youtu.be/9EoRqAlExSk I really like your idea

Link to comment
Share on other sites

using System;using System.Drawing;using System.Windows.Forms;using System.Collections.Generic;using System.Linq;using System.IO;using System.Reflection;using GTA;using GTA.Native;using GTA.Math;using Menu = GTA.Menu;namespace superman{public class superman : Script{     private float force = 100.0f; //Change this to change the force applied    public superman()    {                Tick += ONTICK;        KeyUp += onKEYUP;        KeyDown += OnKeyDown;                    }    private void ONTICK(object sender, EventArgs e)    {        Ped player = Game.Player.Character;        //Loop through all peds        foreach (Ped ped in World.GetAllPeds())        {            //Check for damage by player            if (Function.Call<bool>(Hash.HAS_ENTITY_BEEN_DAMAGED_BY_ENTITY, ped, player, true))            {                //Check for damage by melee                if (Function.Call<bool>(Hash.HAS_PED_BEEN_DAMAGED_BY_WEAPON, ped, 0, 1))                {                    //Get player direction                    Vector3 direction = Vector3.Multiply(player.ForwardVector, force);                    //Apply force to ped                    ped.ApplyForce(direction);                    //Clear all damage                    Function.Call(Hash.CLEAR_ENTITY_LAST_DAMAGE_ENTITY, ped);                    //Break loop                    break;                }            }        }    }    private void onKEYUP(object sender, KeyEventArgs e)    {    }    private void OnKeyDown(object sender, KeyEventArgs e)    {    }}}

I did it! This is my code.. Thanks for helping me

 

Thank you WedgedWolf for code

Edited by nitanmarcel
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • 1 User Currently Viewing
    0 members, 0 Anonymous, 1 Guest

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.