Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → Autoaim Code
Autoaim Code
2004-11-03, 7:33 AM #1
The problem is, the autoaim engages even if I dont have the victim in my point of view. I want it to only autoaim in a 30 degree angle.

Code:
fire:
 target = FirstThingInView(player, 30, 200, 0x404);
  if(mode == 0)
   {
      dummy = FireProjectile(player, projectile, fireSound, 18, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
      SetThingLook(dummy, VectorSub(GetThingPos(target), GetThingPos(player))); 
      SetThingVel(dummy, VectorScale(GetThingLVec(dummy), 7));
   }
   else
   {
      dummy = FireProjectile(player, projectile3, fireSound, 18, '0.0 0.0 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
      SetThingLook(dummy, VectorSub(GetThingPos(target), GetThingPos(player))); 
      SetThingVel(dummy, VectorScale(GetThingLVec(dummy), 7));
   }

   jkPlayPOVKey(player, povfireAnim, 1, 0x38);

   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);

   Return;


I want to cut the AutoAimFOV down.

Any ideas would be great.

[T0rN]
2004-11-03, 9:48 AM #2
Code:
fire:
 target = FirstThingInView(player, 30, 200, 0x404);
  if(mode == 0 && HasLOS(player, target))
   {
      dummy = FireProjectile(player, projectile, fireSound, 18, '0.02 0.15 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
      SetThingLook(dummy, VectorSub(GetThingPos(target), GetThingPos(player))); 
      SetThingVel(dummy, VectorScale(GetThingLVec(dummy), 7));
   }
   else
   {
      if(HasLOS(player, target))
      {
      dummy = FireProjectile(player, projectile3, fireSound, 18, '0.0 0.0 0.0', '0 0 0', 1.0, 0x20, autoAimFOV, autoAimMaxDist);
      SetThingLook(dummy, VectorSub(GetThingPos(target), GetThingPos(player))); 
      SetThingVel(dummy, VectorScale(GetThingLVec(dummy), 7));
      }
   }

   jkPlayPOVKey(player, povfireAnim, 1, 0x38);

   powerBoost = GetInv(player, 63);
   ChangeFireRate(player, fireWait/powerBoost);
   target = -1;
   Return;


I added check to make sure the player can see the target, and then reset the target to null after it's done firing. The code was fine, but it was still targeting the old target which is why it would seem to lock on to someone behind you.
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2004-11-03, 3:28 PM #3
Perfect. Thank you very much.
2004-11-04, 6:18 AM #4
Sorry, I spoke too soon. I think there is something wrong with the if() statement, but I'm not sure. When you select conc it swiches to repeater.

But it looks right to me, I'm going to rearrange the If part and I'll let you know the result.

Any help would still be great.

Thanks for all the help.

[T0rN]
2004-11-04, 5:54 PM #5
Try posting the whole cog. I didn't change anything that should cause it to pull out the repeater instead.
</sarcasm>
<Anovis> mmmm I wanna lick your wet, Mentis.
__________
2004-11-09, 8:12 AM #6
This is the original cog im working with, Primary and secondary should autoaim, and only on a victim in the player Point of View.

I figure if victim = -1 I have to change to victim = NextThingInView or something like that.

[T0rN]

↑ Up to the top!