//----------------------------------------------------------------------------- // Torque Game Engine // Copyright (C) GarageGames.com, Inc. //----------------------------------------------------------------------------- //----------------------------------------------------------------------------- // The AIPlayer C++ class implements the following methods. // // AIPlayer::stopMove(); // Stop the player where he is. // // AIPlayer::clearAim(); // Clear any current aim location or aim object. The player will // maintain his current orientation, or face towards his destination // if moving. // // AIPlayer::setMoveSpeed( float ); // Set the speed (0-1) at which the player moves. // // AIPlayer::setMoveDestination( "x y z" ); // Set the destination point to move towards. The Z location is ignored // though the player will face upwards (or downards) towards the destination // if no other aim target is set. // // AIPlayer::getMoveDestination(); // Returns the current destination point. // // AIPlayer::setAimLocation( \"x y z\" ); // Set a point to look at. The player maintains his orientation towards // this point even while moving towards a destination point. // // AIPlayer::setAimObject( obj ); // Set an object to look at. The player maintains his orientation towards // this object, even while moving towards a destination point. The aim // object can also be moving. // // AIPlayer::getAimLocation(); // Returns the current point the player is looking at. If the player has // an aimObject set, this would be the current position of the target // object. // // AIPlayer::getAimObject(); // Returns the current target object, if there is one. //----------------------------------------------------------------------------- // Callback Handlers //----------------------------------------------------------------------------- function servercmdbotspawn(%client,%name) { %pos2 = %client.player.getposition(); new AIPlayer(%name) { datablock="HorseArmor"; //position=localclientconnection.camera.getPosition(); position=%pos2; aiPlayer = true; }; %name.setshapename(%name); messageall(5,'Bot Has Been Added with name: %1',%name); } function AIPlayer::spawnPlayer() { // An example function which creates a new AIPlayer object // using the the example player datablock. %player = new AIPlayer() { dataBlock = LightMaleHumanArmor; aiPlayer = true; }; MissionCleanup.add(%player); // Player setup %player.setMoveSpeed(1); %player.setTransform(pickSpawnPoint()); %player.setEnergyLevel(60); %player.setShapeName(%this.name); return %player; } function servercmdfollowplayer(%client,%bot,%player) { if(%bot.active $= "1") { echo("this bot is already in use"); echo("stop the bot with the 'stop' command"); } else { %bot.setaimobject(%victim); %bot.clearaim(); %bot.setmovedestination(%player.getPosition()); %bot.clearaim(); %bot.active = 1; %bot.follow = schedule(100,100,"refreshbot",%bot,%player); } } function refreshbot(%bot,%player) { %bot.setaimlocation(%player.getposition()); %bot.setmovedestination(%player.getposition()); %bot.clearaim(); %bot.follow = schedule(100,100,"refreshbot",%bot,%player); } function followplayerevil(%bot,%player,%wep) { if(%bot.active $= "1") { echo("this bot is already in use"); echo("stop the bot with the 'stop' command"); } else { %bot.active = 1; %bot.evil = 1; %bot.setaimlocation(%player.player.getposition()); %bot.setmovedestination(%player.player.getposition()); %bot.clearaim(); %bot.follow = schedule(100,100,"refreshbot",%bot,%player); if(%wep $= "sword") { %bot.mountimage(swordimage,0); %bot.setimagetrigger(0,true); } if(%wep $= "spear") { %bot.mountimage(spearimage,0); %bot.setimagetrigger(0,true); } if(%wep $= "axe") { %bot.mountimage(axeimage,0); %bot.setimagetrigger(0,true); } if(%wep $= "bow") { %bot.mountimage(bowimage,0); %bot.setimagetrigger(0,true); } if(%wep $= "wand") { %bot.mountimage(wandimage,0); %bot.setimagetrigger(0,true); } } } function servercmdstopfollow(%client,%bot) { cancel(%bot.follow); } function servercmdkillbot(%client,%bot) { if(%bot.active $= "1") { cancel(%bot.follow); %bot.active = 0; %bot.setMoveDestination(%bot.getposition()); %bot.clearaim(); %bot.kill(); %bot.setshapename(""); } else { %bot.setshapename(""); %bot.kill(); } } function hahalol(%bot) { //get the x y and z axis and make the bot follow them %x = getrandom(-832934,381923); %y = getrandom(-2643923,38131289); %z = getrandom(-237832,38113278); //now start the process with the x y and z numbers %bot.setAimLocation('%x %y %z'); %bot.clearaim(); %bot.setmovedestination('%x %y %z'); %bot.clearaim(); %bot.follow = schedule(100,100,"refreshbot",%bot,%player); } function hahalol123(%bot) { //get the x y and z axis and make the bot follow them %x = getrandom(-832934,381923); %y = getrandom(-2643923,38131289); %z = getrandom(-237832,38113278); //now start the process with the x y and z numbers %bot.setAimLocation('%x %y %z'); %bot.clearaim(); %bot.setmovedestination('%x %y %z'); %bot.clearaim(); %bot.follow = schedule(100,100,"hahalol123",%bot,%player); }