Jump to content
    1. Welcome to GTAForums!

    1. GTANet.com

    1. GTA Online

      1. Los Santos Drug Wars
      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

Happy Holidays from the GTANet team!

Can anyone help me tweak this remove blood/damage script so that it applies to all current npcs in your group?


jimmyoneshot
 Share

Recommended Posts

I'm trying to create a script to remove all blood/damage from the player character and all characters currently in his group. For example if Franklin and Lamar are in a shootout then it will remove any damage from both of them whenever they get hit.

It currently works for just the player character at the moment but I need to change it so that it only applies constantly so that whenever anyone in the group gets hit the damage will never show. For now I have bound it to a keypress just for testing:-

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using GTA;
using GTA.Native;
using GTA.Math;
using GTA.UI;

namespace Tutorial_Script
{
    public class Class1 : Script
    {
        public Class1()
        {
            Tick += onTick;
            KeyDown += onKeyDown;
        }
        private void onTick(object sender, EventArgs e)
        {

        }
        private void onKeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyCode == Keys.H)
            {
                Game.Player.Character.ClearBloodDamage();
                Game.Player.Character.ClearLastWeaponDamage();
                Game.Player.Character.ClearVisibleDamage();

                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, Game.Player.Character);

                GTA.UI.Screen.ShowSubtitle("Blood Cleared");
            }
        }
    }
}

 

Link to comment
Share on other sites

40 minutes ago, jimmyoneshot said:

I'm trying to create a script to remove all blood/damage from the player character and all characters currently in his group. For example if Franklin and Lamar are in a shootout then it will remove any damage from both of them whenever they get hit.

It currently works for just the player character at the moment but I need to change it so that it only applies constantly so that whenever anyone in the group gets hit the damage will never show. For now I have bound it to a keypress just for testing:-

 

It all depends on how you define the "group". If you are going to store them in a List<Ped> or a Ped[] then a normal foreach loop will do it

 

void ClearPedDamage()
{
    foreach (Ped p in MyPedGroup)
    {
        p.ClearBloodDamage();
        p.ClearLastWeaponDamage();
        p.ClearVisibleDamage();
    }
}

 

The last two show as errors in VS for me, so I presume you are using SHVDN 3.0, I only use V2.0 which is probably why.

 

Just call that function each frame from your onTick()

 

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

2 minutes ago, LeeC22 said:

 

It all depends on how you define the "group". If you are going to store them in a List<Ped> or a Ped[] then a normal foreach loop will do it

 

void ClearPedDamage()
{
    foreach (Ped p in MyPedGroup)
    {
        p.ClearBloodDamage();
        p.ClearLastWeaponDamage();
        p.ClearVisibleDamage();
    }
}

 

The last two show as errors in VS for me, so I presume you are using SHVDN 3.0, I only use V2.0 which is probably why.

 

Just call that function each frame from your onTick()

 

Thanks very much for the help and very quick reply Lee. In that case should the following do it? :-

 

namespace Tutorial_Script
{
    public class Class1 : Script
    {
        public Class1()
        {
            Tick += clearPedDamage;
        }


        private void clearPedDamage(object sender, EventArgs e)
        {

            Game.Player.Character.ClearBloodDamage();
            Game.Player.Character.ClearLastWeaponDamage();
            Game.Player.Character.ClearVisibleDamage();
            Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, Game.Player.Character);

            foreach (Ped p in Game.Player.Character.PedGroup)
            {
                p.ClearBloodDamage();
                p.ClearLastWeaponDamage();
                p.ClearVisibleDamage();
            }
        }

    }
}

 

Link to comment
Share on other sites

9 minutes ago, jimmyoneshot said:

Thanks very much for the help and very quick reply Lee. In that case should the following do it? :-

 

It should do, I haven't used PedGroups in over 4 years, so I can't remember how they work.

 

Out of curiosity, that native you call on the player, does that do something different than the SHVDN call with the similar name?

 

Edit: Just thinking, isn't the player part of its own PedGroup?

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

53 minutes ago, LeeC22 said:

 

It should do, I haven't used PedGroups in over 4 years, so I can't remember how they work.

 

Out of curiosity, that native you call on the player, does that do something different than the SHVDN call with the similar name?

 

Edit: Just thinking, isn't the player part of its own PedGroup?

No problem Lee. I've only just started modding today myself so I'm not sure haha.

 

I've just tested it and it seems to work great for the playable characters i.e. Michael, Trevor and Franklin but NOT for others that are with them such as Brad in the Prologue and Lamar with Franklin early on because they still get blood on them. I'm wondering if there is a group that lets us target them somehow. If so that would be perfect.

Edited by jimmyoneshot
Link to comment
Share on other sites

@LeeC22 Actually, it looks like this works. Basically gets all peds within a 20 feet radius of he player and checks if their relationship type is "Respect" which applies to the other playable characters and people like Lamar and Brad :-

 

foreach (Ped p in Game.Player.Character.PedGroup)
{
    p.ClearBloodDamage();
    p.ClearLastWeaponDamage();
    p.ClearVisibleDamage();
}

foreach (Ped p in World.GetNearbyPeds(Game.Player.Character, 20f))
{
    if (p.GetRelationshipWithPed(Game.Player.Character).ToString() == "Respect")
    {
        p.ClearBloodDamage();
        p.ClearLastWeaponDamage();
        p.ClearVisibleDamage();
    }
}

Only issue is there are some cutscenes such as the one where the gang crash in the prologue where some visible damage gets applied and in that case it makes sense but the above script wrongly removes it. The reason I wanted to remove damage was to make things look more cinematic but this kind of screws that up. Not sure if there is any way around that unless if there is a method to check if a cutscene is currently playing maybe.

Edited by jimmyoneshot
Link to comment
Share on other sites

8 hours ago, jimmyoneshot said:

@LeeC22 Actually, it looks like this works. Basically gets all peds within a 20 feet radius of he player and checks if their relationship type is "Respect" which applies to the other playable characters and people like Lamar and Brad :-

 




foreach (Ped p in Game.Player.Character.PedGroup)
{
    p.ClearBloodDamage();
    p.ClearLastWeaponDamage();
    p.ClearVisibleDamage();
}

foreach (Ped p in World.GetNearbyPeds(Game.Player.Character, 20f))
{
    if (p.GetRelationshipWithPed(Game.Player.Character).ToString() == "Respect")
    {
        p.ClearBloodDamage();
        p.ClearLastWeaponDamage();
        p.ClearVisibleDamage();
    }
}

Only issue is there are some cutscenes such as the one where the gang crash in the prologue where some visible damage gets applied and in that case it makes sense but the above script wrongly removes it. The reason I wanted to remove damage was to make things look more cinematic but this kind of screws that up. Not sure if there is any way around that unless if there is a method to check if a cutscene is currently playing maybe.

 

Ah, I thought the peds might have been ones you were spawning, which would have meant you could have added them to the player's PedGroup. As that's not the case, then collecting peds like you are doing is how you need to do it. Just beware that as this causes the game to check the distance of every ped in the world at that point, this can impact performance if you're not careful. I'm not sure if the distance checking is done with the faster VDIST2 native or not.

 

Edit: Just checked the SHVDN source and it uses distance-squared for the distance checking, so it's not as bad as I imagined.

 

Another Edit: Try removing the player specific code from that and see if it still works. If the player gets included in the GetNearbyPeds() then you will be doing it twice on the player.

 

For cutscenes:

IS_CUTSCENE_PLAYING
IS_CUTSCENE_ACTIVE
HAS_CUTSCENE_FINISHED

 

One or more of those will probably help with that.

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

2 hours ago, LeeC22 said:

 

Ah, I thought the peds might have been ones you were spawning, which would have meant you could have added them to the player's PedGroup. As that's not the case, then collecting peds like you are doing is how you need to do it. Just beware that as this causes the game to check the distance of every ped in the world at that point, this can impact performance if you're not careful. I'm not sure if the distance checking is done with the faster VDIST2 native or not.

 

Edit: Just checked the SHVDN source and it uses distance-squared for the distance checking, so it's not as bad as I imagined.

 

Another Edit: Try removing the player specific code from that and see if it still works. If the player gets included in the GetNearbyPeds() then you will be doing it twice on the player.

 

For cutscenes:

IS_CUTSCENE_PLAYING
IS_CUTSCENE_ACTIVE
HAS_CUTSCENE_FINISHED

 

One or more of those will probably help with that.

Thanks man. I tried this yesterday and it seems to work well:-

 

private void clearPedDamage(object sender, EventArgs e)
{

    if (!Game.IsCutsceneActive && Game.Player.Character.IsInCombat) { 

        foreach (Ped p in Game.Player.Character.PedGroup)
        {
            if (p.IsUpright) { 
                p.ClearBloodDamage();
                p.ClearLastWeaponDamage();
                p.ClearVisibleDamage();
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, p);
            }
        }

        foreach (Ped p in World.GetNearbyPeds(Game.Player.Character, 20f))
        {
            if (p.GetRelationshipWithPed(Game.Player.Character).ToString() == "Respect" && p.IsUpright)
            {
                p.ClearBloodDamage();
                p.ClearLastWeaponDamage();
                p.ClearVisibleDamage();
                Function.Call(Hash.CLEAR_PED_LAST_WEAPON_DAMAGE, p);
            }

        }
    }

}

This seems to have taken care of the cutscene issue too and I added the IsUpright part because without that the blood was disappearing from the bodies of Michael and Brad in the prologue after the cutscene ended as they were lying there haha. Ye you're probably right. I think the player specific stuff is likely covered by Game.Player.Character.PedGroup which seems to just be literally all the currently playable characters.

 

It's a shame we have to use the GetNearbyPeds thing too like you said because it seems it will be constantly being triggered by regular pedestrians and everything else so I also added the Game.Player.Character.IsInCombat part which should help that out hopefully.

 

Off the top of your head do you know if there are any methods to remove blood splashes when characters get hit? That would be the final straw I think but if it's not possible it doesn't really matter. I'm trying to make combat like RDR2 ha.

Link to comment
Share on other sites

26 minutes ago, jimmyoneshot said:

Off the top of your head do you know if there are any methods to remove blood splashes when characters get hit? That would be the final straw I think but if it's not possible it doesn't really matter. I'm trying to make combat like RDR2 ha.

 

I honestly don't know, there was a mod that made the game more family-friendly, don't know if that did anything to remove the blood spatters. https://www.gta5-mods.com/scripts/family-friendly-free-roaming

 

What I meant about the character specific stuff was that World.GetNearbyPeds() might include the player as it gets all peds. So that one loop might do all characters and you won't need the one that works on the Game.Player.Character.PedGroup.

 

If you want that to work only on specific characters, you could store a List<int> with all the hashes you want it to work on, then check if p.Model.Hash is in that list.

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

1 minute ago, LeeC22 said:

 

I honestly don't know, there was a mod that made the game more family-friendly, don't know if that did anything to remove the blood spatters. https://www.gta5-mods.com/scripts/family-friendly-free-roaming

 

What I meant about the character specific stuff was that World.GetNearbyPeds() might include the player as it gets all peds. So that one loop might do all characters and you won't need the one that works on the Game.Player.Character.PedGroup.

Good idea. I'll try it out, thanks. There is an 'IsPlayer' method so I could change it to:-

 

if (
	(p.IsPlayer || p.GetRelationshipWithPed(Game.Player.Character).ToString() == "Respect") && p.IsUpright
)

 

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.