TempleOfLight Posted September 26, 2014 Share Posted September 26, 2014 (edited) Not more than two days ago, I stumbled upon Lorenzo3024's EFLC weapons pack for the IV base game, which I downloaded instantly, knowing it would breathe some new life back into a game we all already love. It absolutely did, and I've been having a whole lot of new fun shooting heads up with AA12s and P90s so far. There's still a problem making this pack less enjoyable by a good amount, though : The closest people have come so far to replicating the "explosive rounds" effect of the TBOGT AA12 via WeaponInfo editing was by making it shoot actual rockets, which somewhat gets the job done, but is totally ridiculous when it comes to damage and realism, obviously. Despite the initial bummer, I thought this was exactly one of the classic cases where scripting was the solution, and decided to try my hand at it with my extremely limited C# knowledge ------------------------------ namespace ExplosiveShotgun{ using System; using System.Drawing; using System.Windows.Forms; using GTA; public class Main : Script { public Main() { Tick += ShotgunCheck_Tick; } private void ShotgunCheck_Tick(object sender, EventArgs e) { if (Player.Character.Weapons.CurrentType == Weapon.Episodic_10) { Ped[] pedArray = World.GetPeds(Player.Character.Position, 50f); foreach (Ped pede in pedArray) { if (pede.HasBeenDamagedBy(Player.Character.Weapons.CurrentType)) { GTA.Native.Function.Call("ADD_EXPLOSION", pede.Position.X, pede.Position.Y, pede.Position.Z, 16, 1f, true, true, 0f); GTA.Native.Function.Call("TRIGGER_PTFX", "exp_molotov", pede.Position.X, pede.Position.Y, pede.Position.Z, 0, 0, 0, 1.0f); GTA.Native.Function.Call("CLEAR_CHAR_LAST_WEAPON_DAMAGE", pede); } } } } }} ------------------------------- Wanna know something funny about it? Despite how incredibly clunky and clumsy this small code is looking, it actually does the job rather well. To me, there's still the HUGE downside of it not really relying on "bullets" per se and only triggering explosions on damaged peds, which is far from being good enough to be decent looking in-game I came up with a way to make it somewhat actually detect bullet collision, which is normally not something possible due to the lack of appropriate native functions for that, from what I understood, but this is something I thought maybe some of you people would be interested in messing around with : - Instead of detecting damaged peds, detecting if the player is aiming and using the isFiring bool to determine when script actions should be done - If the conditions are fulfilled, get where the player is aiming (This is where I'm completely stuck, unfortunately. Is there any way to natively detect the position of the crosshair on-screen? If not, I'm assuming there are still ways this could be done, like getting screen center coordinates or using a combination of Player.Character.Heading and CurrentCamera.Position, but this is too far beyond my scripting knowledge) - Create a small object at that position (think apple, knife, dart or something to that effect), make it invisible and apply forward force to it sufficient for it to travel in a straight line at bullet speed. - Set it to trigger an explosion and delete itself upon colliding with anything else. All in all, I know I'm oversimplying this and that this is probably much more complicated than I'm making it sound, but I know this is within the grasp of a lot of experienced coders out there, which is why I'm reaching out to the community. Needless to say, I'd appreciate it IMMENSELY if you guys tried to work something out with this and tried to get closer to the way this weapon behaves in TBOGT. Thanks in advance, and keep up the good work. By the way, I wrote it to work with Lorenzo's weapon pack in mind. If you want to make that particular script work the unedited WeaponInfo.xml and explosionfx.dat files, just replace Weapon.Episodic_10 with the vanilla shotgun along with the ADD_EXPLOSION parameter (16 is not going to work with vanilla, but 7 does the job pretty well). Have fun with this. Edited September 26, 2014 by TempleOfLight Link to comment Share on other sites More sharing options...
Jitnaught Posted September 26, 2014 Share Posted September 26, 2014 I've actually tried this exact same thing, but ran into some problems, quit developing it, and soon forgot about it. Now that you reminded me, I'll try and fix those problems TempleOfLight 1 Link to comment Share on other sites More sharing options...
maro_hannover Posted September 26, 2014 Share Posted September 26, 2014 Good Idea. Link to comment Share on other sites More sharing options...
byteMe420 Posted September 26, 2014 Share Posted September 26, 2014 (edited) the problem with detecting if ur shooting another ped is where ur aiming is not a single location but a bunch of locations on a straight line coming from the direction of the camera so to get where the player is aiming and check for potential targets requires u to loop like this (not perfect but just an example)... also this may lag the game and u need to make more efficient... oh an another thought, this code does not keep checking if it finds a ped and misses their bone... so technically ud have to jump back into the loop looking for peds, obviously this would need to be rewritten but this is the idea and yeah u can just fire an invisible object by applying force to it and detecting it's collision, i made a rocket launcher doing this except i added like 50 more explosions > const float WEAPON_RANGE = 50f;...Ped target = null;for (Vector3 position = Game.CurrentCamera.Position; position.DistanceTo(Game.CurrentCamera.Position) < WEAPON_RANGE; position += Game.CurrentCamera.Direction){ foreach (Ped ped in World.GetPeds(position, 1f))//1f might be too large radius, u probably need to check if ur aiming at a bone too so get bone positions when target is found { if (Game.Exists(ped) && ped.isAliveAndWell) { target = ped; break; } } if (Game.Exists(target)) break;} if (!Game.Exists(target)) return; bool hit = false;foreach (Bone bone in (Bone[])Enum.GetValues(typeof(Bone))){ Vector3 bonePos = target.GetBonePosition(bone); //i would check the position returned before proceeding, u may need to continue if it is a bone that does not exist, not all bones exist on peds in that enum if (bonePos.DistanceTo(Game.CurrentCamera.Position + Game.CurrentCamera.Direction * Game.CurrentCamera.Position.DistanceTo(bonePos)) < 0.1f)//different bones may require larger or smaller for another layer of accuracy { hit = true; break; }}if (hit) target.AttachBlip(); Edited September 26, 2014 by byteMe420 Link to comment Share on other sites More sharing options...
TempleOfLight Posted September 26, 2014 Author Share Posted September 26, 2014 Ah, I see. This way of doing it is insanely complex, though, damnit, haha. I can almost feel my framerate being reduced by half just reading that code. Thanks for the tip, though, man. I'll be sure to save that piece of code for later use. Do you happen to have that rocket launcher script still sitting on your hard drive somewhere, by the way? I'd appreciate looking into the code you wrote. Firing invisible objects sounds much more like my style, if you ask me ;p Link to comment Share on other sites More sharing options...
DaBOSS54320 Posted September 28, 2014 Share Posted September 28, 2014 Big scripts reduce FPS? I didn't know that, or at least never experienced it. Link to comment Share on other sites More sharing options...
byteMe420 Posted September 28, 2014 Share Posted September 28, 2014 Ah, I see. This way of doing it is insanely complex, though, damnit, haha. I can almost feel my framerate being reduced by half just reading that code. Thanks for the tip, though, man. I'll be sure to save that piece of code for later use. Do you happen to have that rocket launcher script still sitting on your hard drive somewhere, by the way? I'd appreciate looking into the code you wrote. Firing invisible objects sounds much more like my style, if you ask me ;p the code basically travels in a straight line in the direction of the camera searching for peds each step of the way, when it finds a ped then it tries to determine which bone the camera is pointing at... it needs some editing but that is the idea Big scripts reduce FPS? I didn't know that, or at least never experienced it. doing loops in loops and a bunch of calcs can cause the game to lag depending what ur doing, actually the code i wrote shouldnt be noticeable each tick... u can loop all peds very quick if not checking too many things each one lpgunit 1 Link to comment Share on other sites More sharing options...
maro_hannover Posted September 30, 2014 Share Posted September 30, 2014 i know if we used World.GetAllPeds then The Game will extremely Lag. julio said that Link to comment Share on other sites More sharing options...
Jitnaught Posted September 30, 2014 Share Posted September 30, 2014 i know if we used World.GetAllPeds then The Game will extremely Lag. julio said thatI wouldn't say extremely. I've used that many times and it doesn't lag too bad. Link to comment Share on other sites More sharing options...
leftas Posted September 30, 2014 Share Posted September 30, 2014 i know if we used World.GetAllPeds then The Game will extremely Lag. julio said that Again what ? :DDD (died.) Of course it would lag if in 1 m³(maths) is more that 3 peds(very high density). Also I put wait(0); after each(Thanks byteme420). It helps from lag. Best regards, Paul. Link to comment Share on other sites More sharing options...
byteMe420 Posted September 30, 2014 Share Posted September 30, 2014 (edited) i know if we used World.GetAllPeds then The Game will extremely Lag. julio said that Again what ? :DDD (died.) Of course it would lag if in 1 m³(maths) is more that 3 peds(very high density). Also I put wait(0); after each(Thanks byteme420). It helps from lag. Best regards, Paul. u can loop all peds no problem every tick... zero lag... if ur just checking some property values and setting some properties it is fast i know if we used World.GetAllPeds then The Game will extremely Lag. julio said that julio is wrong or you did not understand what he said correctly Edited September 30, 2014 by byteMe420 Link to comment Share on other sites More sharing options...
leftas Posted September 30, 2014 Share Posted September 30, 2014 Oh okay, so sorry, never knew that. Best regards, Paul. Link to comment Share on other sites More sharing options...
Silent Posted September 30, 2014 Share Posted September 30, 2014 Unless this function's implementation is horribly slow, but something would have to be real f*cked up in it then. lpgunit 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