Jump to content
SubSpace Forum Network

Recommended Posts

Posted

Is there a way i can make the bot choose a player at random in the arena THAT MUST BE IN GAME, NOT IN SPEC..??

 

Would be greatly appreciated..

 

Oh and i need it to choose the player when i do !start on..

 

 if (c->check("start"))

	 {



sendPublic("*arena ------------- Riot Rules --------------");

sendPublic("*arena : Everyone starts off as a warbird     :");

sendPublic("*arena : To win be the last surviving Warbird :");

sendPublic("*arena ---------------------------------------"); 	 

   if (c->checkParam("on"))

  	 gamestart = true;

   else if (c->checkParam("off"))

  	 gamestart = false;



   if (gamestart)

  	 sendPrivate(p, "Game Started!");

   else

  	 sendPrivate(p, "Game Off!");

  	 sendPublic("*arena Game Stopped!");

	 }

 

Theres the code, thanks..

 

OH YEAH! And also, is there a way i can make the bot check how many people are on team 1??? And make it so that if there is 1 person on team 1 it does *specall??

Posted
   if (gamestart)

  	 sendPrivate(p, "Game Started!");

   else

   { //here

  	 sendPrivate(p, "Game Off!");

  	 sendPublic("*arena Game Stopped!");

   } //and here

I've made some changes, see if you can spot them.
Posted

get random:

int InShip=0;

int InSpec=0;

_listnode <Player> *parse = playerlist->head;

while(parse)

{

  if(p->ship != SHIP_Spectator)

     InShip++;

  else

     InSpec++;

  parse=parse->next;

}

int rand=Rand()%InShip;

int temp=0;

parse=playerlist->head;

while(parse)

{

 if(p->ship != SHIP_Spectator)

    temp++;

 if(temp==rand)

 {

    //Heres a random player.

 }

  parse=parse->next;

}

 

This gets you the random player, a pop count for in the game, and a pop count for specers.

Posted

Gave me this error:

 

command.cpp(169) : error C2064: term does not evaluate to a function

 

 if (c->check("choose"))

	 {

int InShip=0; 

int InSpec=0; 

_listnode <Player> *parse = playerlist->head; 

while(parse) 

{ 

  if(p->ship != SHIP_Spectator) 

     InShip++; 

  else 

     InSpec++; 

  parse=parse->next; 

} 

int rand=Rand()%InShip; 

int temp=0; 

parse=playerlist->head; 

while(parse) 

{ 

 if(p->ship != SHIP_Spectator) 

    temp++; 

 if(temp==rand) 

 { 

sendPrivate(p, "Blah your the chosen one (Test)");

 } 

  parse=parse->next; 

} 



	 }

 

The error is on this line:

 

int rand=Rand()%InShip;

Posted
You really need to consult the help for that error in your particular compiler's help system. However, my guess is that the error is because you are using the name "rand" as a variable. You can't have a variable AND a function called the same things.
Posted

Well i tried the bounty rabbit choose random player thing, didnt work i got like 25 gay errors..

 

void botInfo::GetRabbit()

{

if (getIngame() < 2) return;



rabbit = 0;



int t = GetTickCount() % getIngame();



_listnode <Player> *parse = playerlist->head;



while (parse)

{

 Player *p = parse->item;

 

 if ((p->ship != SHIP_Spectator) && (p->ship != SHIP_Javelin) && (p->safety == 0))

	 if (!(--t)) // if done counting random down playerlist

	 {

   // prize 2k bounty if they are below 2k

   if ( p->bounty < 2000 ) 

  	 sendPrivate(p, "*prize 2000");



   rabbit = p;

   

   // timer for rabbit

   countdown[0] = 10 * 60;



   /*

   String s;

   s = "New Bounty Rabbit: ";

   s += p->name;

   s += " at ";

   s += getCoords(p->pos.x, p->pos.y);

   s += ". Kill the Rabbit to steal the 2000 bounty reward.";

   sendPublic(s);

   */



   sendPrivate(p,"You're the new Bounty Rabbit. Reward: 2000 bounty. Lose it if you die, ship change, spec, attach to a jav, leave arena, or go in a safe zone. New bounty rabbit chosen in 10 minutes.");



   break;

	 }



 parse = parse->next;

}

 

Didnt edit any of that.. and got 29 errors :/

 

Or i could just use the code that explody gave me if someone helps me fix it?

Posted

Okay, fixed it up a bit to fix my settings, now it has some *wierd* error.. first off, heres the code..

 

void botInfo::GetLevi()

{

if (getIngame() < 2) return;





int t = GetTickCount() % getIngame();



_listnode <Player> *parse = playerlist->head;



while (parse)

{

 Player *p = parse->item;

 

 if ((p->ship != SHIP_Spectator))

	 if (!(--t))

	 {

   sendPrivate(p, "Blah");



   break;

	 }



 parse = parse->next;

}

}

 

Now heres the error..

 

Compiling...

command.cpp

Linking...

  Creating library Debug/riot.lib and object Debug/riot.exp

spawn.obj : error LNK2001: unresolved external symbol "public: int __thiscall botInfo::getIngame(void)" (?getIngame@botInfo@@QAEHXZ)

Debug/riot.dll : fatal error LNK1120: 1 unresolved externals

Error executing link.exe.

Posted

Ok, linker errors are where you have declared the function and called it, byt not set anything to it. For example, in your riot.dll, you have "class botInfo { void getInGame(); }", and you also call it somewhere. However, you do not have any "void botInfo::getInGame(){..}" in any of the .cpp files.

 

To fix my code, rename Rand() ro rand(), and rename the int rand to int randnum;

 

In the future, 29 gay errors is not helpful. Try pasting the errors, and the line of the error (some cases prededing line)

 

EDIT: Just a second passing glance shows me this: I think that that break; is invalid, your not inside a switch. true return;. Also, it looks like youre missin a } in the for loop.

Posted

Alrighty now..

 

That compiles fine, then i do !choose and it does this:

 

    sendPrivate(p, "Your the chosen one..");

 sendPublic("*arena " +(String)p->name +" is the randomly chosen Levi!");

 

Thats good, there, but, its just showing the name of whoever types !choose, how can i make it choose someone Random.

Posted

...

 if (c->check("choose"))

         { 

int InShip=0; 

int InSpec=0; 

[b]_listnode <Player> *parse = parse->item[/b]

while(parse);

{ 

  if(p->ship != SHIP_Spectator) 

     InShip++; 

  else 

     InSpec++; 

  parse=parse->next; 

} 

int randnum=rand()%InShip; 

int temp=0; 

parse=playerlist->head; 

while(parse) 

{ 

 if(p->ship != SHIP_Spectator) 

    temp++; 

 if(temp==randnum) 

 { 

    sendPrivate(p, "Your the chosen one..");

 sendPublic("*arena " +(String)p->name +" is the randomly chosen Levi.");

 } 

  parse=parse->next; 

} 



         }

 

Do i change the bold text to that??

Posted

_listnode <Player> *parse = parse->item

while(parse);

{ 

  if(p->ship != SHIP_Spectator) 

     InShip++; 

  else 

     InSpec++; 

  parse=parse->next; 

}

_listnode <Player> *parse = playerlist.head;

while(parse);

{ 

  if(parse->item->ship != SHIP_Spectator) 

     InShip++; 

  else 

     InSpec++; 

  parse=parse->next; 

}

Posted

Compiling...

command.cpp

C:Do-*BAD WORD*-ents and Settings~!~RoBBiE~!~DesktopBotsMy Pluginsriotcommand.cpp(175) : error C2440: 'initializing' : cannot convert from 'struct Player *' to 'class _listnode<struct Player> *'

       Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast

Error executing cl.exe.



riot.dll - 1 error(s), 0 warning(s)

 

on line

 

_listnode <Player> *parse = parse->item;

 

gay lol

Posted
repeated type. Cant declare and use on the same line. You delcare parse, and then when to the head of parse, doesnt work. try playerlist->head. In the future, look in the header for _linkedlist BlehList; That way when you want to itterate the ClassBleh list, you have to goto the head of BlehList.
Guest
This topic is now closed to further replies.
×
×
  • Create New...