Author Topic: [SCRIPT] Holobot  (Read 758 times)

Holobot

Holobot is literally a bot that does everything you do, except moving.
It mounts the same items and plays the same animations (except for moving, crouching, jumping, and bending over because I couldn't figure out how to do it)

I saw the holograph events and thought it would do this but it doesn't so I made my own little script. It's not so great as to be it's own mod (I didn't even package it) so I just made this.

Report any errors here. Oh wait right

So basically what this does it add to events/a command /MakeHoloBot and holoBot and removeHolobot (all 3 are admin only). And when you do it if you use the event the bot will spawn at the brick, and if you use the command it will spawn right in you. Then it does what expected.

Code
registerOutputEvent("fxDTSBrick", "holoBot","",1);
registerOutputEvent("fxDTSBrick", "removeHoloBot","",1);
function fxDTSBrick::holoBot(%this,%client)
{
   if(!%client.isAdmin)return;
   if(isObject(%client.player.holobot))
      %client.player.holobot.delete();
   %client.player.holobot = new AIPlayer()
   {
      datablock = %client.player.getDatablock();
      position = %this.getPosition();
      rotation = %client.player.rotation;
   };
   MissionCleanup.add(%client.player.holobot);
   holoLoop(%client.player.holobot,%client.player);
}

function fxDTSBrick::removeHoloBot(%this,%client)
{
   if(isObject(%client.player.holobot))
      %client.player.holobot.delete();
}

function serverCmdMakeHoloBot(%client)
{
   if(!%client.isAdmin)return;
   %client.player.holobot = new AIPlayer()
   {
      datablock = %client.player.getDatablock();
      position = %client.player.getPosition();
      rotation = %client.player.rotation;
   };
   MissionCleanup.add(%client.player.holobot);
   holoLoop(%client.player.holobot,%client.player);
}

function holoLoop(%this,%player)
{
   cancel(%this.loop);
   if(!isObject(%this))
      return;
   if(!isObject(%player))
   {
      %this.delete();
      return;
   }
   %this.setTransform(%this.getPosition() SPC getWords(%player.getTransform(),3));
   schedule(40,0,"holoLoop",%this,%player);
}
if(isPackage(Holobot))
   deactivatepackage(Holobot);
package Holobot
{
   function Player::mountImage(%this,%slot,%image)
   {
      parent::mountImage(%this,%slot,%image);
      if(isObject(%this.holobot))
         %this.holobot.mountImage(%slot,%image);
   }
   function Player::unMountIMage(%this,%slot)
   {
      parent::unMountImage(%this,%slot);
      if(isObject(%this.holobot))
         %this.holobot.unMountImage(%slot);
   }
   function Player::onRemove(%player)
   {
      parent::onRemove(%player);
      if(isObject(%player.holobot))
         %player.holobot.delete();
   }
   function Player::delete(%player)
   {
      parent::delete(%player);

      if(isObject(%player.holobot))
         %player.holobot.delete();
   }
   function player::playthread(%player,%slot,%thread)
   {
      parent::playthread(%player,%slot,%thread);
      if(isObject(%player.holobot))
         %player.holobot.playThread(%slot,%thread);
   }
};activatepackage(Holobot);


Credits
me.
« Last Edit: January 13, 2013, 06:20:26 PM by Brian Smithers »



Now make it transparent and yay for holocommunications!

Now make it transparent and yay for holocommunications!
uh later.
if i do this I'd probably end up packaging the mod and putting in add-ons.