View unanswered posts | View active topics It is currently Thu Dec 26, 2024 6:20 pm



Reply to topic  [ 11 posts ] 
 Instant targeting and lead firing 
Author Message
User avatar

Joined: Tue Mar 20, 2007 10:16 am
Posts: 186
Location: Australia
Reply with quote
Post 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
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Mar 20, 2007 10:16 am
Posts: 186
Location: Australia
Reply with quote
Post 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
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post 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 :grin:


Tue Feb 08, 2011 8:33 am
Profile
User avatar

Joined: Tue Mar 20, 2007 10:16 am
Posts: 186
Location: Australia
Reply with quote
Post 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 :grin:

It's a HDFirearm held by an Acrab.

I've sent a PM


Tue Feb 08, 2011 12:48 pm
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post 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
Profile
User avatar

Joined: Tue Mar 20, 2007 10:16 am
Posts: 186
Location: Australia
Reply with quote
Post Re: Instant targeting and lead firing
They're incredibly proficient :0, 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:

Image

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
ScreenDump553.bmp [ 1.37 MiB | Viewed 4602 times ]
Wed Feb 09, 2011 5:12 am
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post 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
ScreenDump000.PNG [ 189.53 KiB | Viewed 4596 times ]


Attachments:
Thumper 2.rar [928 Bytes]
Downloaded 197 times
Wed Feb 09, 2011 6:53 am
Profile
User avatar

Joined: Tue Mar 20, 2007 10:16 am
Posts: 186
Location: Australia
Reply with quote
Post 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
Profile

Joined: Fri Dec 18, 2009 11:00 pm
Posts: 167
Reply with quote
Post Re: Instant targeting and lead firing
ok, this should be it it flips no need to resprite, is disabled and should stop gun disapearing.


Attachments:
Thumper 3.rar [869 Bytes]
Downloaded 182 times
Wed Feb 09, 2011 10:14 am
Profile
User avatar

Joined: Tue Mar 20, 2007 10:16 am
Posts: 186
Location: Australia
Reply with quote
Post 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
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 11 posts ] 

Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.317s | 15 Queries | GZIP : Off ]