Some kind of pet

I made this as a joke for use on dreamscape a while back, i’ll just leave this here for people to get an idea on how to
create a pet that does more then just follow you around.

//NPC made by tricxta
if (playerenters){
  toweapons aPet;
  this.speed = .45;
  setstring this.ganis,idle,walk,pull,swim,sit;
  this.tPlayer = 0;
  this.rape = 0;
  this.followDist = 2;
  this.brag = 0;
  this.chairTiles = {
    0x2A9,0x2AA,0x676,0x677,0x678,
    0x2B9,0x2BA,0x686,0x687,0x688
  };
  setstring this.quotes,"#a is so great","Fear #a, coz he's a sexy beast!","Watch out! it's #a the awesome!";
  this.pC = {playerx,playery};
  timeout=0.05;
}

if (timeout && isweapon){
  if (this.tPlayer >= 0){
    this.tC = {players[this.tPlayer].x,players[this.tPlayer].y};
    this.dist = ((this.pC[0]-this.tC[0])^2+(this.pC[1]-this.tC[1])^2)^0.5;
    this.tAng = getangle(this.tC[0]-this.pC[0],this.tC[1]-this.pC[1]);
    this.pDir = (int((this.tAng+(pi/4))/(pi/2))+3)%4;
    if (this.dist > this.followDist && !onwall(this.pC[0]+1.5+vecx(this.pDir)*2,this.pC[1]+2+vecy(this.pDir)*2)){
      this.pC[0]+=cos(this.tAng)*this.speed;
      this.pC[1]+=sin((pi*2)-this.tAng)*this.speed;
      setstring this.sGani,#I(this.ganis,1);
    }
    else {
      if (this.rape == 0)setstring this.sGani,#I(this.ganis,0);
      else setstring this.sGani,#I(this.ganis,2);
    }
  }
  else setstring this.sGani,#I(this.ganis,0);
  
  if (onwater(this.pC[0]+1.5,this.pC[1]+2))setstring this.sGani,#I(this.ganis,3);
  else if (tiles[this.pC[0] + 1.5,this.pC[1] + 2] in this.chairTiles)setstring this.sGani,#I(this.ganis,4);
  
  showani 1,this.pC[0],this.pC[1],this.pDir,#s(this.sGani),;
  if (this.cTimer <= 0 && random(1,100)<4 && this.brag == 1){setstring this.chat,#I(this.quotes,int(random(0,3)));this.cTimer = 5;}
  if (this.cTimer > 0){
    showtext 2,this.pC[0]+1.5,this.pC[1]-.5,,bc,#s(this.chat);
    this.cTimer-=0.05;
  }
  else hideimg 2;
  timeout=0.05;
}

if (playerchats){
  if (strequals(#c,/follow me)){this.tPlayer = 0;this.rape = 0;}
  
  else if (startswith(/rape,#c) || startswith(/follow,#c)){
    tokenize #c;
    if (strequals(#t(0),/rape))this.rape = 1;
    for (this.i=0;this.i<playerscount;this.i++){
      if (strequals(#a(this.i),#t(1)))this.tPlayer = this.i;
    }
  }
  else if (strequals(#c,/stay))this.tPlayer = -1;
  
  else if (strequals(#c,/brag))this.brag = 1;
  else if (strequals(#c,/don't brag))this.brag = 0;
}

if (weaponfired){
  say2 Commands:#b
/rape account#b
/follow account#b
/follow me#b
/stay#b
/brag#b
/don't brag;
}