View unanswered posts | View active topics It is currently Wed Jan 08, 2025 10:21 pm



Reply to topic  [ 10 posts ] 
 Suicidal guided missile? 
Author Message

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Suicidal guided missile?
So I'm using the homing missile launcher (code) and for some reason the missile just randomly flips around and kicks the shooter out of the race with an insta kill blast.

... why the heck is it doing that?

Code:
--Find out who shot the weapon by finding the closest actor within 50 pixels.
    local curdist = 50;
    for actor in MovableMan.Actors do
   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 < curdist then
       curdist = dist;
       self.parent = actor;
   end
    end


Is the code from the original (Coalition weapon.)
Changing the range will, under the right circumstances, just make it blow up its own team or something like that.


EDIT:

Why was this moved?
I'm talking about a weapon that is in the original game that keeps constantly screwing me over.


Last edited by ajlw on Thu Mar 18, 2010 7:48 pm, edited 1 time in total.



Tue Mar 16, 2010 8:50 pm
Profile

Joined: Fri Apr 06, 2007 10:11 pm
Posts: 45
Reply with quote
Post Re: [Why was this moved?!] Suicidal guided missile?
I've never actually used the homing launcher but I trust that it does work right originally.

How close are you firing it to other actors? Trying starting out with an actor and this launcher in skirmish, and fire it.
If you still get the same results, think away from the lua. Which way are your emitters pointed?

It might help to put up the .rte for people to look at. The problem could be beyond given information.


Thu Mar 18, 2010 2:19 am
Profile WWW
User avatar

Joined: Wed Sep 09, 2009 3:16 am
Posts: 3032
Location: Somewhere in the universe
Reply with quote
Post Re: [Why was this moved?!] Suicidal guided missile?
ajlw wrote:
Why was this moved?


It was moved to the correct sub-forum.


Thu Mar 18, 2010 2:24 am
Profile
User avatar

Joined: Fri Dec 28, 2007 4:19 am
Posts: 1119
Reply with quote
Post Re: [Why was this moved?!] Suicidal guided missile?
Hrm I've humorously ran into this problem before, with my own homing missiles. Whats the fire velocity of the rocket?


Thu Mar 18, 2010 3:34 am
Profile

Joined: Fri Apr 06, 2007 10:11 pm
Posts: 45
Reply with quote
Post Re: [Why was this moved?!] Suicidal guided missile?
DSMK2 wrote:
Hrm I've humorously ran into this problem before, with my own homing missiles. Whats the fire velocity of the rocket?


This makes sense! Lua does not seem to operate until the frame after, so your projectile could have moved over the range. Very smart.


Thu Mar 18, 2010 4:23 am
Profile WWW
REAL AMERICAN HERO
User avatar

Joined: Sat Jan 27, 2007 10:25 pm
Posts: 5655
Reply with quote
Post Re: [Why was this moved?!] Suicidal guided missile?
Yeah, lua is all executed after the internal game engine has completed all its calculations for a frame, meaning that area-based parent checks sometimes have issues.

You can usually get away with the (slightly more complicated) method of casting a ray backwards from the path of the missile, and then (if you need extra confidence) checking the attachables of that MO for the gun that fires your projectile.


Thu Mar 18, 2010 5:53 am
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: [Why was this moved?!] Suicidal guided missile?
Well, if I remember correctly I notched up the firevelocity from 10 to 35 or something(? maybe more) and made it act more like a mortar (Add delay before turning and firing thrusters...) but then it still shouldn't come back to cap my own a**e if I increase the range...

Instead I just assigned it to the player team, seeing AI (rarely ever/)never uses the homing missile... and I never play against other people...
Works perfectly.


Thu Mar 18, 2010 7:27 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Suicidal guided missile?
The method I use to find the user of a device is to have the projectile start with a fire velocity of 1 to insure it is close enough to the user, and then do an MO PresetName and distance check. After the user-finding part is done, it applies a velocity to itself so it looks like it was shot out at a certain speed.

Code:
   self.firevel = 10;
   self.curdist = 15;
    for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == "Weapon Name" and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < self.curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);
   self.Vel = Vector(self.firevel,0):RadRotate(self.parent:GetAimAngle(true));
   end
    end
end


Pros of this:
-Reliable user-finding

Cons of this:
-The projectile is a frame behind in speed, since its velocity is applied after it finds its user.


Thu Mar 18, 2010 7:59 pm
Profile

Joined: Mon Mar 15, 2010 11:46 pm
Posts: 67
Reply with quote
Post Re: Suicidal guided missile?
So I do get the entire code but maybe you'd wanna elaborate for people walking in here going 'wtf?'

It took me a few minutes to remember what I taught myself >.>;


Thu Mar 18, 2010 8:31 pm
Profile
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Suicidal guided missile?
That chunk just finds the user of the device (self.parent) which you can use to replace your old one.

Code:
   self.firevel = 10; -- Desired velocity of projectile
   self.curdist = 15; -- Distance to search for gun
   self.weaponname = "Rawket Lawnchair" -- PresetName of your gun

    for i = 1,MovableMan:GetMOIDCount()-1 do
      gun = MovableMan:GetMOFromID(i);
    if gun.PresetName == self.weaponname and gun.ClassName == "HDFirearm" and (gun.Pos-self.Pos).Magnitude < self.curdist then
      actor = MovableMan:GetMOFromID(gun.RootID);
     if MovableMan:IsActor(actor) then
   self.parent = ToActor(actor);
   self.parentgun = ToHDFirearm(gun);
   self.Vel = Vector(self.firevel,0):RadRotate(self.parent:GetAimAngle(true));
   end
    end
end

Just replace your old parent detection system (the one in the OP) with this one and change the first 3 lines in the above code to the appropriate settings.


Thu Mar 18, 2010 8:36 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 10 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:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by STSoftware for PTF.
[ Time : 0.045s | 15 Queries | GZIP : Off ]