View unanswered posts | View active topics It is currently Sat Dec 28, 2024 3:40 pm



Reply to topic  [ 4 posts ] 
 Help - Homing for the head 
Author Message
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post Help - Homing for the head
Heads are only attachables, so all i can do is aim for
Code:
ClassName == "Attachable"

but that wont quite cut it.

The forum search brought up that someone already created a weapon that god head-homing ammunition, but I can't find said mod, also it seems this mod is years old and with the new lua stuff there should be a better way already.

I can do the target finding and the projectile moving/aiming but how to get the head from the targeted actor?

OFFTOPIC:
Is there some official CC chat/IRC?


Tue Sep 20, 2011 11:47 am
Profile WWW
User avatar

Joined: Tue Jun 12, 2007 11:52 pm
Posts: 13144
Location: Here
Reply with quote
Post Re: Help - Homing for the head
Try:
Code:
ToAHuman(actor).Head

Source.


Tue Sep 20, 2011 2:47 pm
Profile
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post Re: Help - Homing for the head
Thanks! Seems the wiki actualy got some usefull information, at least for lua.
So this should work I suppose?
Code:
self.targetHeadPos = ToAHuman(target).Head.Pos


Tue Sep 20, 2011 3:31 pm
Profile WWW
User avatar

Joined: Fri Aug 19, 2011 4:02 pm
Posts: 40
Reply with quote
Post Re: Help - Homing for the head
Hmm I use "local raycast = SceneMan:CastMORay(...)" to get a MO in the line of sight.
How to check wether it is a AHuman?

Code:
if raycast ~= 255 and ToAHuman(targetID) ~= nil then

this seems not to work :/


EDIT:
This works, but it fails for actors without head like crabs
Code:
   local raycast = SceneMan:CastMORay(ToHDFirearm(gun).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(owner):GetAimAngle(true)),owner.ID,0,false,2);
   if raycast ~= 255 then
      local raycast2 = MovableMan:GetMOFromID(MovableMan:GetMOFromID(raycast).RootID);
      if MovableMan:IsActor(raycast2) then
      self.target = raycast2;
      end
   end



EDIT: Solved!

Code:
         local raycast = SceneMan:CastMORay(ToHDFirearm(gun).MuzzlePos,Vector(self.weaponRange,0):RadRotate(ToActor(owner):GetAimAngle(true)),owner.ID,0,false,2);
         if raycast ~= 255 then
            local raycast2 = MovableMan:GetMOFromID(MovableMan:GetMOFromID(raycast).RootID);
            if raycast2.ClassName == "AHuman" then
               self.target = raycast2;
            end
         end


Tue Sep 20, 2011 4:02 pm
Profile WWW
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: Google [Bot]


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.030s | 14 Queries | GZIP : Off ]