Author Topic: Request: Targeting, Automatic, Turret Event  (Read 1040 times)

There was one in the old wrench events and I was wondering if anyone could make one for the new wrench events.

Needs to search for near players constantly. So no.

but then how did it work in the old wrench events?


so, cant someone still make  it?

You know, it could work as a player wrench event... you'd stick it in a baseplate's onPlayerTouch, and then you'd have the player object to aim at right in the script.

Quote
function WrenchEvShoot(%brick,%ticknum,%state)
{
 %n = 10/%brick.evParam[%state,4];
 if(%ticknum % mFloor(%n) != 0) return;
 //Artillery_Rocket Homing_Turret Spread_Turret 3-Spread Spike Fire
 switch$(%brick.evParam[%state,1])
 {
  case "Fire":
   %projectile = wrenchFireProjectile;
   %flash = "";
   %d1 = %brick.evParam[%state,2];
   %d2 = %brick.evParam[%state,3];
   %vector = dirToNormal2(%d1,%d2);
  case "Artillery Rocket":
   %projectile = wrenchRocketProjectile;
   %flash = rocketLauncherFlashEmitter;
   %time = 70;
   %d1 = %brick.evParam[%state,2];
   %d2 = %brick.evParam[%state,3];
   %vector = dirToNormal2(%d1,%d2);
  case "Homing Turret":
   %projectile = wrenchBulletProjectile;
   %flash = gunFlashEmitter;
   %time = 70;
   %dist = 20;
   %found = -1;
   for(%i=0;%i<clientgroup.getCount();%i++)
   {
    %c = clientgroup.getobject(%i);
    if(%c.minigame $= %brick.getGroup().client.minigame && isObject(%c.player) && vectorDist(%c.player.getTransform(),%brick.getTransform()) < %dist)
    {
     %found = %c.player;
     %dist = vectorDist(%c.player.getTransform(),%brick.getTransform());
    }
   }
   if(%found == -1){return;}
   %vector = vectorNormalize(vectorSub(vectorAdd(%found.position,"0 0 2"),%brick.position));
  case "Spread Turret":
   %projectile = wrenchBulletProjectile;
   %flash = gunFlashEmitter;
   %time = 70;
   %d1 = %brick.evParam[%state,2];
   %d2 = %brick.evParam[%state,3];
   %vector = dirToNormal2(%d1,%d2);
   %x = (1 - 2*getRandom());
   %y = (1 - 2*getRandom());
   %z = (1 - 2*getRandom());
   %aimPoint = vectorAdd(%brick.getTransform(),vectorScale(%vector,80));
   %aimPoint = vectorAdd(%aimPoint,%x SPC %y SPC %z);
   %vector = vectorNormalize(vectorSub(%aimPoint,%brick.getTransform()));

  case "Spike":
   %projectile = wrenchSpikeProjectile;
   %d1 = %brick.evParam[%state,2];
   %d2 = %brick.evParam[%state,3];
   %vector = dirToNormal2(%d1,%d2);
  default:
   for(%i=0;%i<datablockgroup.getcount();%i++)
   {
    %d = datablockgroup.getobject(%i);
    if(%d.getClassname() $= "ItemData" && %d.uiname $= %brick.evParam[%state,1] && %d.image.projectile !$= "")
    {
     %projectile = %d.image.projectile;
     for(%j=0;%d.image.stateName[%j] !$= "";%j++)
     {
      if(%d.image.stateName[%j] $= "Fire" && isObject(%d.image.stateEmitter[%j])){%flash = %d.image.stateEmitter[%j];%time = %d.image.stateEmitterTime[%j]*1000;}
     }
    }
   }
   %d1 = %brick.evParam[%state,2];
   %d2 = %brick.evParam[%state,3];
   %vector = dirToNormal2(%d1,%d2);
 }
 if(!isObject(%projectile)){return;}
 //Having the source of the projectile as an item disables the "invalid source" error and allows the projectile to work at short range.
 %p = new Projectile()
 {
   dataBlock = %projectile;
   initialVelocity = vectorScale(%vector,%projectile.muzzleVelocity);
   initialPosition = %brick.getTransform(); //vectorSub(,vectorScale(%vector,%projectile.muzzleVelocity / 2));
   sourceObject = $wrenchItem;
   sourceSlot = 0;
   client = %brick.getGroup().client;
   override = 1;
   minigame = %brick.getGroup().client.minigame;
 };
 MissionCleanup.add(%p);
 if(!isObject(%flash)){return;}
   %d1 = %brick.evParam[%state,2];
   %d2 = %brick.evParam[%state,3];
 %p = new ParticleEmitterNode()
 {
  datablock = genericEmitterNode;
  emitter = %flash;
  scale = "0.1 0.1 0.1";
  rotation = dirToRot2(%d1,%d2);
  velocity = "1";
  position = vectorAdd(%brick.getTransform(),vectorScale(%vector,0.5));
  brick = %brick;
 };%p.schedule(%time,delete);
 MissionCleanup.add(%p);
}
So...

Some sort of output event like "spawnHomingProjectile" with available targets such as Nearest Player or Nearest Vehicle instead of a velocity? (like the player/bot spawnProjectile only provides a speed and not a vector)

Activating Player, Nearest Player, Nearest Vehicle ("anti-tank" turrets, also targets bots/player vehicles) - they shouldn't fire if that player is more than 10-20 studs away, though.

Why did you highlight the Spread Turret part of the script?
« Last Edit: September 12, 2008, 11:03:05 AM by Space Guy »

Some sort of output event like "spawnHomingProjectile" with available targets such as Nearest Player or Nearest Vehicle instead of a velocity? (like the player/bot spawnProjectile only provides a speed and not a vector)

Activating Player, Nearest Player, Nearest Vehicle ("anti-tank" turrets, also targets bots/player vehicles) - they shouldn't fire if that player is more than 10-20 studs away, though.
Badspot fail-bined the prox mod NiXiLL made for closest player.
Why did you highlight the Spread Turret part of the script?
No, I bolded the Homing Turret part. I needed you to fully explain the script incompatibility.

Badspot fail-bined the prox mod NiXiLL made for closest player.
Yeah due to possibility of abuse though.

Kill proximity events would really suck.

And I mentioned it because what space guy said is just like it.