Scripted Player Pawn Aiming help needed

Topics regarding Scripting with Reality Factory
Post Reply
Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Scripted Player Pawn Aiming help needed

Post by Masta_J »

Sup guys, I have two questions:

1) How do I enable my player pawn to fire projectiles in the direction of the mouse crosshair? I've tried the LowLevel, "MouseControlledPlayer(true);", command in my pawn's setup, but it does nothing (I assume this command refers to the built in player).

2) How do I get my player pawn to auto target the nearest enemy pawn? I would like to add this my attack commands, namely:

Code: Select all

Punch[() 
{ 
    if(ATTACKDELAY < self.time)  // see if enough time has passed since the animation started 
    { 
   FireProjectileBlind(FIREAMMO1,WEAPONHAND2,0,0,0,DAMAGEATTRIB);  // shoot the projectile (= do the damage) 
   attackdelay = self.time + 10000;   // make sure the damage is done only once 
    } 

    if(self.animate_at_end)  // check if the animation has finished 
    { 
        self.think="Test";  // go back to the basic routines 
        return 0; 
    } 

}]

AND

Blast[()
{
if(self.animate_at_end)
{
FireProjectileBlind(FIREAMMO4,WEAPONHAND,0,-8,10,DAMAGEATTRIB); // shoot the projectile (= do the damage)
FireProjectileBlind(FIREAMMO4,WEAPONHAND,0,-8,10,DAMAGEATTRIB);
if(self.animate_at_end)
{
self.think="GalickGunFire2"; // go back to the basic routines
return 0;
}
}]

Much appreciated
A good warrior knows his limits, but a great warrior finds his way around them.
User avatar
zany_001
Posts: 1047
Joined: Fri Mar 02, 2007 8:36 am
Location: Aotearoa

Post by zany_001 »

well i thought there was a tute,right here,stickied,for autoaim,but it seems to be gone,ill see if i can find it.
Once I was sad, and I stopped being sad and was awesome instead.
True story.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

1) what camera are you using? third person? first person? would be good to know, because it CAN be done but it is important to know which camera you are using...
Everyone can see the difficult, but only the wise can see the simple.
-----
Masta_J
Posts: 37
Joined: Tue Apr 17, 2007 1:35 pm
Location: Johannesburg South Africa

Post by Masta_J »

I'm using a third person camera view.
A good warrior knows his limits, but a great warrior finds his way around them.
Jay
RF Dev Team
Posts: 1232
Joined: Fri Jul 08, 2005 1:56 pm
Location: Germany

Post by Jay »

you 'just' have to compute a 'target point' relative to the pawn. This is the direction the pawn will shoot at. (this only works if the camera is directly behind the pawn). And then you have to fire the projectile in the direction specified.

FIREOFFSETX, -Y and -Z specify the source point in relation to the shoot bone.

Code: Select all

FIREOFFSETX   [0]
FIREOFFSETY   [0]
FIREOFFSETZ   [0]

Shoot[ ()
{
   SetTargetPoint(FIREOFFSETX,sin(self.camera_pitch)+FIREOFFSETY,1+FIREOFFSETZ);
   FireProjectile(FIREAMMO1,WEAPONHAND2,FIREOFFSETX,FIREOFFSETY,FIREOFFSETZ,DAMAGEATTRIB);
} ]
i am not 100% sure if this works though. You may have to replace

Code: Select all

   SetTargetPoint(FIREOFFSETX,sin(self.camera_pitch)+FIREOFFSETY,1+FIREOFFSETZ);
with

Code: Select all

   SetTargetPoint(FIREOFFSETX,sin(self.camera_pitch)*(-1)+FIREOFFSETY,1+FIREOFFSETZ);
Please tell me if this works, because i am just guessing here.
Everyone can see the difficult, but only the wise can see the simple.
-----
Post Reply