Author Topic: Schedule help.  (Read 909 times)


In
Code: [Select]
package Headshot{
function projectileData::damage(%this, %obj, %col, %fade, %pos, %normal)
{
%trans = %col.getTransform();
if(%col.getClassName() $= "player" && strStr(%col.getDamageLocation(%pos), "back") != -1 && %col.getMountedImage(0) == stratmtwoImage.getID())
{
//echo("test");


%p = new Projectile()
{
dataBlock = tankShellProjectile;
initialVelocity  = "0 0 0";
initialPosition  = %trans;
sourceObject     = %obj;
sourceSlot       = 0;
client           = %obj.client;
};
MissionCleanup.add(%p);

}


parent::damage(%this, %obj, %col, %fade, %pos, %normal);
}

};
ActivatePackage(Headshot);

how do i schedule the
Code: [Select]
%p = new Projectile()
{
dataBlock = tankShellProjectile;
initialVelocity  = "0 0 0";
initialPosition  = %trans;
sourceObject     = %obj;
sourceSlot       = 0;
client           = %obj.client;
};
MissionCleanup.add(%p);
part?

Create a new function with all the arguments you need (%obj,%trans).  Then you can just schedule the function like schedule(timeMS,0,function,argument,argument);

There might be a different way but this is what I came up with off the top of my head.

That projectile will damage the object. Hence causing a headshot. Repeat.

Give the projectile no client, then it cannot damage anybody.

Code: [Select]
if(%col.getClassName() $= "player" && strStr(%col.getDamageLocation(%pos), "back") != -1 && %col.getMountedImage(0) == stratmtwoImage.getID())- You can only be headshot if you're holding the sniper rifle?
- You cannot headshot bots?
- You can't be headshot from the back, even though your head is just as large?
- That doesn't even test for headshots...

Not a sniper. Flamethrower with a tank on the back. Also, thanks for the help

Don't name the package "Headshot", then, that will most likely kill some other headshot-based weapon that exists.

Eval is an extremely useful but underused function if you ask me. I'm pretty sure this'll work for you.
Code: [Select]
schedule(5000,0,eval,"
   %p = new Projectile()
   {
      dataBlock = tankShellProjectile;
      initialVelocity  = \"0 0 0\";
      initialPosition  = " @ %trans @ ";
      sourceObject     = " @ %obj @ ";
      sourceSlot       = 0;
      client           = " @ %obj.client @ ";
   };
   MissionCleanup.add(%p);
");

Eval is an extremely useful but underused function if you ask me. I'm pretty sure this'll work for you.
Code: [Select]
schedule(5000,0,eval,"
   %p = new Projectile()
   {
      dataBlock = tankShellProjectile;
      initialVelocity  = \"0 0 0\";
      initialPosition  = " @ %trans @ ";
      sourceObject     = " @ %obj @ ";
      sourceSlot       = 0;
      client           = " @ %obj.client @ ";
   };
   MissionCleanup.add(%p);
");

:o I've been looking for somthing like this thanks :D Also, do I just put that into one line?
« Last Edit: July 25, 2009, 11:21:25 PM by Stratofortress »

Yes. Paste it where you would have the new bullet function

Give the projectile no client, then it cannot damage anybody.
Instead of hacking it with schedules.

Also, do I just put that into one line?
Remove the line breaks?

No need to reformat it to one line.
It will work perfectly fine.

Oh, I read what he said wrong. Azimuth is correct.