Author |
Message |
Squeegy Mackpy
Joined: Tue Mar 20, 2007 10:16 am Posts: 186 Location: Australia
|
Instant targeting and lead firing
So I have this turret that I intend to have almost one-shotting any fast moving actor that comes within a few hundred meters of it, but to do so, it needs to aim better. What I want it to do, is fire instantly upon any actor not of its team that falls below a certain (large) distance, and fire not at the actor, but at a point that is the actor's position + (it's velocity * (it's distance * x )). x is yet to be determined, but if it helps, shots travel at a velocity of 90. Oh yeah, and it shouldn't attempt to do any of that unless it's ammo is above 0. The actor is all sorted, as is its gun, now I just need it to hit things now with 100% proficiency instead of 40% or so. For some reason I can't get the wiki to load, so I havent a clue what variables I'd be using if I were to do this myself. Help please?
|
Tue Feb 08, 2011 3:59 am |
|
|
none
Joined: Fri Dec 18, 2009 11:00 pm Posts: 167
|
Re: Instant targeting and lead firing
Here try this, dot point theorem ♥♥♥♥ ohhh yeah. Code: function Update(self) for actor in MovableMan.Actors do if actor.ClassName == "AHuman" then local avgx = actor.Pos.X - self.Pos.X; local avgy = actor.Pos.Y - self.Pos.Y; local dist = math.sqrt(avgx ^ 2 + avgy ^ 2); if dist < 300 then local calcx = (actor.Pos.X + ((dist / 90) * actor.Vel.X)) - self.Pos.X; local calcy = (actor.Pos.Y + ((dist / 90) * actor.Vel.Y)) - self.Pos.Y; local dp = (calcx * 300) + (calcy * 0); local lengtha = math.sqrt(calcx ^ 2 + calcy ^ 2); local lengthb = 300; local ang = math.acos( dp / (lengtha * lengthb)); local shot = CreateMOPixel("shot"); shot.Pos = self.Pos; shot.Vel.X = math.cos(ang) * 90; shot.Vel.Y = math.sin(ang) * 90 * -1; MovableMan:AddParticle(shot); end end end end
you should be able to modify it to suit this is just the aim code, if you need help I'll write it for ya.
|
Tue Feb 08, 2011 5:49 am |
|
|
Squeegy Mackpy
Joined: Tue Mar 20, 2007 10:16 am Posts: 186 Location: Australia
|
Re: Instant targeting and lead firing
Excellent <3
But, rather than shoot spawned particles, what would I put in order to have the turret aim at the coords and 'click'?
And, so the one shot isnt followed by it repeatedly dry firing (has one bullet per magazine), how would I test for having ammo?
|
Tue Feb 08, 2011 7:55 am |
|
|
none
Joined: Fri Dec 18, 2009 11:00 pm Posts: 167
|
Re: Instant targeting and lead firing
Is the script attached to a gun HDFirearm? and is it held by an actor, AHuman or ACrab? if so you need to disable the actor and set aim angle manually. Could you send me the rte and I'll fix it up for ya, much easier for both of us I think
|
Tue Feb 08, 2011 8:33 am |
|
|
Squeegy Mackpy
Joined: Tue Mar 20, 2007 10:16 am Posts: 186 Location: Australia
|
Re: Instant targeting and lead firing
none wrote: Is the script attached to a gun HDFirearm? and is it held by an actor, AHuman or ACrab? if so you need to disable the actor and set aim angle manually. Could you send me the rte and I'll fix it up for ya, much easier for both of us I think It's a HDFirearm held by an Acrab. I've sent a PM
|
Tue Feb 08, 2011 12:48 pm |
|
|
none
Joined: Fri Dec 18, 2009 11:00 pm Posts: 167
|
Re: Instant targeting and lead firing
I think you will be most pleased with this, it can even hit an actor traveling at almost terminal vel.
I would rather it have a single bullet rather than a spray though (flack shot), it would be much more elegant and add to the aww factor.
Anyway, here you go. It should be attached to the ACrab actor.
enjoy.
Attachments:
Thumper.rar [809 Bytes]
Downloaded 183 times
|
Tue Feb 08, 2011 9:35 pm |
|
|
Squeegy Mackpy
Joined: Tue Mar 20, 2007 10:16 am Posts: 186 Location: Australia
|
Re: Instant targeting and lead firing
They're incredibly proficient , I love you. But, they have one major issue. After a while they start shooting away from the target. You can see it track something perfectly as it flies overhead, but it's following it with the butt of the gun instead of the muzzle. I'll also make the gun sprite symmetrical seeing as it doesnt flip when looking backwards. Actually, they have a few more and probably related issues. I found that taking control and flipping it around and then releasing control is what causes them to hsoot so perfectly backwards, but, without even touching the gun a second time around, this happened: It fired about 5 shots at that one enemy, in the same direction. It later couldnt hit anything and died because of it.
Attachments:
ScreenDump553.bmp [ 1.37 MiB | Viewed 4601 times ]
|
Wed Feb 09, 2011 5:12 am |
|
|
none
Joined: Fri Dec 18, 2009 11:00 pm Posts: 167
|
Re: Instant targeting and lead firing
Here ya go a full 360* now plus all fixed up no more spazing out. This is how safe I feel with just one of these things Attachment:
ScreenDump000.PNG [ 189.53 KiB | Viewed 4595 times ]
|
Wed Feb 09, 2011 6:53 am |
|
|
Squeegy Mackpy
Joined: Tue Mar 20, 2007 10:16 am Posts: 186 Location: Australia
|
Re: Instant targeting and lead firing
I did the same just now. They're brilliant marksmen <3
I also lessened the amount of frags and added a slug in the middle of the shot.
Although, taking control, aiming and turning around will still mess them up, any way to prevent that? or prevent the player from taking control? Perhaps upon releasing control it sets its facing to the right and its weapon back to its original angle?
Oh yeah, and the guns will sometimes dissapear for some reason. The actor still has its turret though.
|
Wed Feb 09, 2011 9:18 am |
|
|
none
Joined: Fri Dec 18, 2009 11:00 pm Posts: 167
|
Re: Instant targeting and lead firing
ok, this should be it it flips no need to resprite, is disabled and should stop gun disapearing.
|
Wed Feb 09, 2011 10:14 am |
|
|
Squeegy Mackpy
Joined: Tue Mar 20, 2007 10:16 am Posts: 186 Location: Australia
|
Re: Instant targeting and lead firing
none wrote: ok, this should be it it flips no need to resprite, is disabled and should stop gun disapearing. It's perfect, and you are awesome <3
|
Wed Feb 09, 2011 10:40 am |
|
|
|