View unanswered posts | View active topics It is currently Wed Dec 11, 2024 8:27 am



Reply to topic  [ 4 posts ] 
 Parent of the bullet 
Author Message
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Parent of the bullet
So yeah, I've been forgetting all the lua stuff we used to use before lua on attachables.

Code:
function Create(self)
   for actor in MovableMan.Actors do
      if SceneMan:ShortestDistance(self.Pos,actor.Pos,true) < 100 and actor.EquippedItem.PresetName == "Tactical Grenade Launcher" then
         self.Parent = actor
      end
   end
end

function Update(self)
   for actor in MovableMan.Actors do
      if SceneMan:ShortestDistance(self.Pos,actor.Pos,true) < 100 and actor.Team ~= self.Parent.Team then
         self.PinStrength = 99999
         self.Vel = (actor.Pos-self.Pos)
         self:GibThis()
      end
   end
end


It's just the old school way to find out who is the parent of the bullet (the script is attached to the bullet) and then ignoring the parent's team to explode against enemies. Basically some sort of proximity-detector with added directed blast.

The error I'm getting is at line 11 (the first if of function Update(self)), in which it says it can't compare nil with a number, which probably means it isn't detecting any parent and hence can't compare the non-existing parent's team with the soon-to-be-killed actor's team.

What the hell am I doing wrong?


Mon Oct 15, 2012 12:12 am
Profile
User avatar

Joined: Fri Feb 16, 2007 8:43 pm
Posts: 1695
Location: AH SHIT FUCK AUGH
Reply with quote
Post Re: Parent of the bullet
From what i can see, you forgot to grab the magnitude of SceneMan:ShortestDistance(), since that function returns a vector. Appending ".Magnitude" to the end of the function oughta fix at least SOME of your worries.

However, what i also can tell you is that we now have a super awesome variable called self.IgnoresWhichTeam. It returns, conveniently enough, the team that the projectile doesn't collide with, which generally is the same as the guy who fired the gun. Just compare the potential target's team with that, and you should be good to go. There's not even the tiny risk of detecting an enemy actor with the same gun instead of yourself to begin with. c:


Mon Oct 15, 2012 12:51 am
Profile WWW
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Parent of the bullet
Code:
function Update(self)
   for actor in MovableMan.Actors do
      if SceneMan:ShortestDistance(self.Pos,actor.Pos,true).Magnitude < 100 and actor.Team ~= self.IgnoresWhichTeam then
         self.PinStrength = 99999
         self.Vel = (actor.Pos-self.Pos)
         self:GibThis()
      end
   end
end


Like this?

Shook you are lovely, I didn't know we had that function!

EDIT:
Yes, that did it, Shook, I luv u c:


Mon Oct 15, 2012 1:08 am
Profile
Data Realms Elite
Data Realms Elite
User avatar

Joined: Fri Jan 07, 2011 8:01 am
Posts: 6211
Location: In your office, earning your salary.
Reply with quote
Post Re: Parent of the bullet
Yes, Non, but at times I'm very dumb and compare vectors with integers just because.

Also, I read on the wiki that if SceneMan:CastMORay() didn't collide with a MO it would return nil. Well, it returns 255.
If someone can fix it I'd be glad.


Tue Oct 16, 2012 8:25 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 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.031s | 15 Queries | GZIP : Off ]