Ok, this is what I have...
$horses=1;
$horse_times_per_second=6;//times a second the horses are updated
$max_horses=10;//total number of horses allowed
function init_horses()
{
if($horses==1&&$horse_times_per_second>0)
{
horses();
}
}
function horses()
{
for(%i=1;%i<=$max_horses;%i++)
{
if($horse[%i]>0)
{
if($horsepid[%i]>0&&$horsebot[%i]>0&&!Player::isDead($horsepid[%i])&&!Player::isDead($horsebot[%i]))
{
//move horse and player by BOT since BOT is controled by the client
%pos=GameBase::getPosition($horsebot[%i]);
%rot=GameBase::getRotation($horsebot[%i]);
//%pos=GetWord(%pos,0)+2 @ " " @ GetWord(%pos,1)+2 @ " " @ GetWord(%pos,2);
//%pos=GetWord(%pos,0) @ " " @ GetWord(%pos,1) @ " " @ GetWord(%pos,2)+1;
%pos=GetWord(%pos,0) @ " " @ GetWord(%pos,1) @ " " @ GetWord(%pos,2)+5;
GameBase::setPosition($horse[%i],%pos);
GameBase::setRotation($horse[%i],%rot);
//GameBase::setPosition($horsepid[%i],GetWord(%pos,0) @ " " @ GetWord(%pos,1) @ " " @ GetWord(%pos,2)+1);//z+=1
GameBase::setPosition($horsepid[%i],%pos);
GameBase::setRotation($horsepid[%i],%rot);
}
else
{
//for all cids -- check distance
%pos=GameBase::getPosition($horse[%i]);
%found=false;
for(%id=Client::getFirst();%id!=-1;%id=Client::getNext(%id))
{
//for all cids -- check distance
%dist=Vector::getDistance(GameBase::getPosition(%id),%pos);
if(%dist<100)
{
%found=true;
break;
}
}
//or delete it if distance to nearest client is >100 m
if(%found==false)
{
delete_horse(%i);
}
}
}
}
if($horses==1&&$horse_times_per_second>0)
{
schedule("horses();",1/$horse_times_per_second);
}
}
function make_horse(%pos)
{
for(%i=1;%i<=$max_horses;%i++)
{
if($horse[%i]<=0)
{
//make horse
$horse[%i]=newObject("Horse","InteriorShape","horse.dis",true);
//$horse[%i]=newObject("Horse","StaticShape","PoweredElectricalBeam",true);
if($horse[%i])
{
addToSet("MissionCleanup",$horse[%i]);
GameBase::setPosition($horse[%i],%pos);
//make bot--need an invis NULL texture skin for the bot...
//$horsebot[%i]=newObject("HorseBot","Player",malehumanarmor10,true);
$horsebot[%i]=newObject("HorseBot","Player",Armor22,true);
if($horsebot[%i])
{
addToSet("MissionCleanup",$horsebot[%i]);
GameBase::startFadeOut($horsebot[%i]);
GameBase::setPosition($horsebot[%i],%pos);
//try and mount it
//for all cids -- check distance
for(%id=Client::getFirst();%id!=-1;%id=Client::getNext(%id))
{
//for all cids -- check distance
%dist=Vector::getDistance(GameBase::getPosition(%id),%pos);
if(%dist<4)
{
mount_horse(%i,Client::getOwnedObject(%id));
}
}
}
else
{
deleteObject($horse[%i]);
$horse[%i]=0;
}
}
break;
}
}
}
function delete_horse(%i)
{
//unmount horse
unmount_horse(%i);
//delete horse
if(isObject($horse[%i]))
{
deleteObject($horse[%i]);
}
$horse[%i]=0;
//delete bot
if(isObject($horsebot[%i]))
{
deleteObject($horsebot[%i]);
}
$horsebot[%i]=0;
}
function mount_horse(%i,%pid)
{
if(isObject($horse[%i])&&isObject($horsebot[%i])&&$horsepid[%i]<=0)
{
$horsepid[%i]=%pid;
$horsecid[%i]=Player::getClient(%pid);
if($horsecid[%i]>0)
{
Client::setControlObject($horsecid[%i],$horsebot[%i]);
}
}
}
function unmount_horse(%i)
{
if($horsecid[%i]>0&&$horsepid[%i]>0)
{
Client::setControlObject($horsecid[%i],$horsepid[%i]);
//Player::applyImpulse($horsepid[%i],"0 0 100");
}
$horsepid[%i]=0;
$horsecid[%i]=0;
GameBase::setPosition($horse[%i],GameBase::getPosition($horsebot[%i]));
}
function mount_player(%pid)
{
for(%i=1;%i<=$max_horses;%i++)
{
if(isObject($horse[%i])&&isObject($horsebot[%i])&&$horsepid[%i]<=0)
{
//try and mount it
%pos=GameBase::getPosition($horse[%i]);
%dist=Vector::getDistance(GameBase::getPosition(%pid),%pos);
if(%dist<4)
{
mount_horse(%i,%pid);
break;
}
}
}
}
function unmount_player(%pid)
{
for(%i=1;%i<=$max_horses;%i++)
{
if($horsepid[%i]==%pid)
{
%pos=GameBase::getPosition(%pid);
GameBase::setPosition(%pid,GetWord(%pos,0) @ " " @ GetWord(%pos,1) @ " " @ GetWord(%pos,2)+2);//z+=1
unmount_horse(%i);
break;
}
}
How would I apply this to RPG and make a bot that spawned one for X coins?