Sorry, I meant *image in that post, not target. You were correct about target.
Very Happy awesome. I'll have fun with this.
Cool. As I said though, it's not working wit hTBM 2 nonbeta for some reason.
What does the log say happens when you try it?
Nothing, it just crashes the game instantly. Very Happy
ok. Very Happy also, did you notice that you are missing a semicolon in your script? Wink
Shock No, I didn't. That could have something to do with the crashing...
no, it doesn't. The script won't compile without the semicolon, and thus won't allow it the function to be called.

revised code wrote:
function createFighterBot(%image,%target)
{
%who = AIPlayer::spawnPlayer();
//MissionCleanup.add(%who);
%who.mountImage(%image,0);
schedule(1000,0,mybotreaim(%who,%target));
}
function mybotreaim(%who,%target)
{
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
%who.setAimLocation(VectorAdd(target.getPosition(),"0 0 1"));
schedule(1000,0,mybotreaim(%who,%target));
}


[edit]

It most certainly does print something to the error log after I fix that semicolon, and I think thats part of the crash. Nearly a megabyte of this, probably causing some sort of overflow:

Quote:
dtb/server/scripts/evilBotHunter.cs (12): Unable to find object: 'target' attempting to call function 'getPosition'


console.log was created for a reason Wink

[edit2]

and there is the problem:
new code wrote:

function mybotreaim(%who,%target)
{
%who.setAimObject(%target);
%who.setImageTrigger(0,1);
%who.setAimLocation(VectorAdd(%target.getPosition(),"0 0 1"));
schedule(1000,0,mybotreaim(%who,%target));
}


[edit3]

or one of them anyway..... the next one reads like this:
Console.log wrote:
dtb/server/scripts/evilBotHunter.cs (12): Unknown command getPosition.
Object LocalClientConnection(2720) GameConnection -> NetConnection -> SimGroup -> SimSet -> SimObject


and I have no idea how to fix it.
Post the code now and I'll take a look.
after some help from Gobbles, here's what I have:


Code:
function createFighterBot(%image,%target)
  {
     %who = AIPlayer::spawnPlayer();
    //MissionCleanup.add(%who);
     %who.mountImage(%image,0);
     schedule(1000,0,mybotreaim(%who,%target));
  }
function mybotreaim(%who,%target)
{
    %who.setAimObject(%target);
    %who.setImageTrigger(0,1);
     
    %targetlocation = getwords(%target.player.getTransform(),0,2);
    echo(%targetlocation);
    %who.setAimLocation(VectorAdd(%targetlocation,"0 0 1"));
    schedule(1000,0,mybotreaim(%who,%target));
}


the log file reveals several 100Kb of this:

Quote:
-9.01277 16.1593 0.0101304
dtb/server/scripts/evilBotHunter.cs (15): Player::VectorAdd - wrong number of arguments.
dtb/server/scripts/evilBotHunter.cs (15): usage: VectorAdd(vec1,vec2)
dtb/server/scripts/evilBotHunter.cs (15): Unable to find object: '1000' attempting to call function 'setAimLocation'


[edit]

revision:


Code:
function createFighterBot(%image,%target)
{
   %who = AIPlayer::spawnPlayer();
   //MissionCleanup.add(%who);
   %who.mountImage(%image,0);
   schedule(1000,0,mybotreaim(%who,%target));
}
function mybotreaim(%who,%target)
{
   %who.setAimObject(%target);
   %who.setImageTrigger(0,1);
   
   %targetlocation = %target.player.getTransform();
   %targetx = getWord(%targetlocation, 0);
   %targety = getWord( %targetlocation, 1);
   %targetz = getWord( %targetlocation, 2) + 1;
   %who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
   schedule(1000,0,mybotreaim(%who,%target));
}


Quote:
dtb/server/scripts/evilBotHunter.cs (10): Unable to find object: '1000' attempting to call function 'setAimObject'
dtb/server/scripts/evilBotHunter.cs (11): Unable to find object: '1000' attempting to call function 'setImageTrigger'
dtb/server/scripts/evilBotHunter.cs (13): Unable to find object: '' attempting to call function 'getTransform'
dtb/server/scripts/evilBotHunter.cs (17): Unable to find object: '1000' attempting to call function 'setAimLocation'

essentially every occurence of $who causes a problem
be sure to read above posts as well.
[edit]

another revision


Code:
function createFighterBot(%name,%image,%target)
{
   %who = new AIPlayer() {
      dataBlock = LightMaleHumanArmor;
      aiPlayer = true;
   };
   MissionCleanup.add(%player);

   // Player setup
   %who.setMoveSpeed(1);
   %who.setTransform(pickSpawnPoint());
   %who.setEnergyLevel(60);
   %who.setShapeName(%name);
   //MissionCleanup.add(%who);
   %who.mountImage(%image,0);
   schedule(1000,0,mybotreaim(%who,%target));
}
function mybotreaim(%who,%target)
{
   %who.setAimObject(%target);
   %who.setImageTrigger(0,1);
   
   %targetlocation = %target.player.getTransform();
   %targetx = getWord(%targetlocation, 0);
   %targety = getWord( %targetlocation, 1);
   %targetz = getWord( %targetlocation, 2) + 1;
   %who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
   schedule(1000,0,mybotreaim(%who,%target));
}



Quote:
==>createFighterBot('CLONE','MissileLauncher',2719);
Set::add: Object "" doesn't exist
dtb/server/scripts/evilBotHunter.cs (20): Unable to find object: '1000' attempting to call function 'setAimObject'
dtb/server/scripts/evilBotHunter.cs (21): Unable to find object: '1000' attempting to call function 'setImageTrigger'
dtb/server/scripts/evilBotHunter.cs (23): Unable to find object: '' attempting to call function 'getTransform'
dtb/server/scripts/evilBotHunter.cs (27): Unable to find object: '1000' attempting to call function 'setAimLocation'


it seems it only has trouble accessing objects which are passed as parameters to the mybotreaim function.
Try this:


Code:
function createFighterBot(%name,%image,%target)
{
   %who = new AIPlayer() {
      dataBlock = LightMaleHumanArmor;
      aiPlayer = true;
   };
   MissionCleanup.add(%player);

   // Player setup
   %who.setMoveSpeed(1);
   %who.setTransform(pickSpawnPoint());
   %who.setEnergyLevel(60);
   %who.setShapeName(%name);
   //MissionCleanup.add(%who);
   %who.mountImage(%image,0);
   schedule(1000,0,mybotreaim,%who,%target);
}
function mybotreaim(%who,%target)
{
   %who.setAimObject(%target);
   %who.setImageTrigger(0,1);
   
   %targetlocation = %target.player.getTransform();
   %targetx = getWord(%targetlocation, 0);
   %targety = getWord( %targetlocation, 1);
   %targetz = getWord( %targetlocation, 2) + 1;
   %who.setAimLocation(%targetx@" "@%targety@" "@%targetz);
   schedule(1000,0,mybotreaim(%who,%target));
}

whats the difference between them?
This:
Code:
schedule(1000,0,mybotreaim,%who,%target);
It may be the correct way to pass arguments; either that will fix it, or I'm getting confused with another scripting language.
dont forget to fix the bottom instance as well ^^. and I also noticed the MissionCleanup.add() should be %who and not %player
Ah yes. Well? Did it work for you? If so, I'll put this new version onto my server and start messing with it.
testing now....
elfprince13 wrote:
testing now....
Waiting in eager anticipation...
yes, it created the guy, minus the missilelauncher....that may be because I forgot quotes around it though...and he was turning to face me, although he didn't walk around at all.
That's perfect. I'll do some work on it later and post up what I come up with.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
» Goto page Previous  1, 2, 3, 4 ... 10, 11, 12  Next
» View previous topic :: View next topic  
Page 3 of 12
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement