DeadlySoldier!! Posted September 5, 2003 Report Posted September 5, 2003 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??
Smong Posted September 6, 2003 Report Posted September 6, 2003 if (gamestart) sendPrivate(p, "Game Started!"); else { //here sendPrivate(p, "Game Off!"); sendPublic("*arena Game Stopped!"); } //and hereI've made some changes, see if you can spot them.
CeinWyN MaN+ Posted September 6, 2003 Report Posted September 6, 2003 the bounty rabbit plugin picks a player randomly, you might want to take a look at that.
ExplodyThingy Posted September 6, 2003 Report Posted September 6, 2003 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.
DeadlySoldier!! Posted September 7, 2003 Author Report Posted September 7, 2003 Where would i put that? Where it needs to start the action??.. in the !start command somewhere??
Rifleman Posted September 7, 2003 Report Posted September 7, 2003 In a function or you can adept it to your !start command... I suggest you put it in a function for better readability.
DeadlySoldier!! Posted September 7, 2003 Author Report Posted September 7, 2003 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;
Mr Ekted Posted September 7, 2003 Report Posted September 7, 2003 Rand() is not a function in the standard run-time library. I think you want rand()
DeadlySoldier!! Posted September 8, 2003 Author Report Posted September 8, 2003 I changed Rand to rand still same error.
Mr Ekted Posted September 8, 2003 Report Posted September 8, 2003 You need to include stdlib.h It would really benefit people who "make" bots to put out a little effort to understand the language you are attempting to use.
DeadlySoldier!! Posted September 8, 2003 Author Report Posted September 8, 2003 #include "stdlib.h" Still, same error.
Mr Ekted Posted September 8, 2003 Report Posted September 8, 2003 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.
DeadlySoldier!! Posted September 8, 2003 Author Report Posted September 8, 2003 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?
»Dustpuppy Posted September 8, 2003 Report Posted September 8, 2003 Here's an idea: give us some errors. Have you defined rabbit? Does getIngame() exist?
DeadlySoldier!! Posted September 8, 2003 Author Report Posted September 8, 2003 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.
ExplodyThingy Posted September 9, 2003 Report Posted September 9, 2003 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.
DeadlySoldier!! Posted September 9, 2003 Author Report Posted September 9, 2003 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.
ExplodyThingy Posted September 9, 2003 Report Posted September 9, 2003 in the iterator (listnode), use parse->item-?name.
DeadlySoldier!! Posted September 9, 2003 Author Report Posted September 9, 2003 ... 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??
DeadlySoldier!! Posted September 9, 2003 Author Report Posted September 9, 2003 AND ALSO:.. How can i make it check if theres only one person on a team and if there is it uses *specall?
ExplodyThingy Posted September 10, 2003 Report Posted September 10, 2003 _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; }
DeadlySoldier!! Posted September 10, 2003 Author Report Posted September 10, 2003 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
ExplodyThingy Posted September 10, 2003 Report Posted September 10, 2003 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.
DeadlySoldier!! Posted September 10, 2003 Author Report Posted September 10, 2003 Well what should i do?? to fix it, and can you help me out with checking player on freq thingy too that i posted above
Recommended Posts