Data Realms Fan Forums http://45.55.195.193/ |
|
Instant targeting and lead firing http://45.55.195.193/viewtopic.php?f=73&t=21432 |
Page 1 of 1 |
Author: | Squeegy Mackpy [ Tue Feb 08, 2011 3:59 am ] |
Post subject: | 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? |
Author: | none [ Tue Feb 08, 2011 5:49 am ] |
Post subject: | 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. |
Author: | Squeegy Mackpy [ Tue Feb 08, 2011 7:55 am ] |
Post subject: | 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? |
Author: | none [ Tue Feb 08, 2011 8:33 am ] |
Post subject: | 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 |
Author: | Squeegy Mackpy [ Tue Feb 08, 2011 12:48 pm ] |
Post subject: | 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 |
Author: | none [ Tue Feb 08, 2011 9:35 pm ] | ||
Post subject: | 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.
|
Author: | none [ Wed Feb 09, 2011 6:53 am ] | ||
Post subject: | 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
|
Author: | Squeegy Mackpy [ Wed Feb 09, 2011 9:18 am ] |
Post subject: | 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. |
Author: | none [ Wed Feb 09, 2011 10:14 am ] | ||
Post subject: | Re: Instant targeting and lead firing | ||
ok, this should be it it flips no need to resprite, is disabled and should stop gun disapearing.
|
Author: | Squeegy Mackpy [ Wed Feb 09, 2011 10:40 am ] |
Post subject: | 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 |
Page 1 of 1 | All times are UTC [ DST ] |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |