jimmyoneshot Posted December 27, 2020 Share Posted December 27, 2020 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 More sharing options...
LeeC22 Posted December 27, 2020 Share Posted December 27, 2020 (edited) 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 December 27, 2020 by LeeC22 jimmyoneshot 1 Link to comment Share on other sites More sharing options...
jimmyoneshot Posted December 27, 2020 Author Share Posted December 27, 2020 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(); } } } } LeeC22 1 Link to comment Share on other sites More sharing options...
LeeC22 Posted December 27, 2020 Share Posted December 27, 2020 (edited) 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 December 27, 2020 by LeeC22 jimmyoneshot 1 Link to comment Share on other sites More sharing options...
jimmyoneshot Posted December 27, 2020 Author Share Posted December 27, 2020 (edited) 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 December 27, 2020 by jimmyoneshot LeeC22 1 Link to comment Share on other sites More sharing options...
jimmyoneshot Posted December 27, 2020 Author Share Posted December 27, 2020 (edited) @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 December 27, 2020 by jimmyoneshot LeeC22 1 Link to comment Share on other sites More sharing options...
LeeC22 Posted December 27, 2020 Share Posted December 27, 2020 (edited) 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 December 27, 2020 by LeeC22 jimmyoneshot 1 Link to comment Share on other sites More sharing options...
jimmyoneshot Posted December 27, 2020 Author Share Posted December 27, 2020 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. LeeC22 1 Link to comment Share on other sites More sharing options...
LeeC22 Posted December 27, 2020 Share Posted December 27, 2020 (edited) 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 December 27, 2020 by LeeC22 jimmyoneshot 1 Link to comment Share on other sites More sharing options...
jimmyoneshot Posted December 27, 2020 Author Share Posted December 27, 2020 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 ) LeeC22 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now