Code: Show/Hide sendPrivate(p,"Hello "p); |
Code: Show/Hide sendPrivate(p,p->name" hi!"); |
Code: Show/Hide sendPrivate(p, "Hello, " + (String)p->name); |
Code: Show/Hide sendPrivate(p,"I rolled a "(int)odice1", "(int)odice2", and a "(int)odice3); |
Code: Show/Hide 1>c:\documents and settings\owner\desktop\programing\c++\a3 dll\tutorial\default\command.cpp(215) : error C2144: syntax error : 'int' should be preceded by ')'
1>c:\documents and settings\owner\desktop\programing\c++\a3 dll\tutorial\default\command.cpp(215) : error C2064: term does not evaluate to a function taking 0 arguments 1>c:\documents and settings\owner\desktop\programing\c++\a3 dll\tutorial\default\command.cpp(215) : error C2059: syntax error : ')' |
Code: Show/Hide cout<<"You rolled "<<number; |
Code: Show/Hide cout<<"You rolled"<<+number; |
Code: Show/Hide sendPrivate(p,"I rolled a "+(int)odice1+(string)", "+(int)odice2+(string)", and a "+(int)odice3);
|
Code: Show/Hide sendPrivate(p,"I rolled a "+(int)odice1+", "+(int)odice2+", and a "+(int)odice3); |
Code: Show/Hide while (p->bounty!=(Uint16)neededbty||c->check("abortmission"));
if (c->check("abortmission")) { sendPrivate(p, "aborted"); } |
hellzlaker wrote: |
is there a source code the rampage.dll or any one sprees? |
Code: Show/Hide Uint16 neededbty = 16; while (p->bounty!=(Uint16)neededbty||!c->check("abortmission")); { c->check("abortmission"); p->bounty; } |
Code: Show/Hide //Tag of index 0 is for the Mission value set_tag(p, 0, 1); |
Code: Show/Hide c->check("abortmission");
p->bounty; |
Code: Show/Hide if (set_tag(p,0,1)){} |
Code: Show/Hide #define INDEX 2 // This is your "int index". Call it whatever you want. |
Code: Show/Hide if (c->check("sneeze")) { if (get_tag(p, INDEX) != 1) // This checks to see if '1' isn't stored for this player, meaning he didn't call !sneeze before. set_tag(p, INDEX, 1); // This will set the player's tag to '1', meaning he is calling !sneeze for the first time. } |
Code: Show/Hide if (get_tag(p, INDEX) != 1) |
Code: Show/Hide set_tag(p, INDEX, 1); |
Code: Show/Hide int value = get_tag(p,455); |
Code: Show/Hide #define APPLE int main()
#define SAUCE return 0; APPLE { SAUCE } |
Bak wrote: | |
a player* is like a book
an index is like the page number data is the contents of the page, so set_tag(p,455,70) writes the value "70" on page 455 of player p's book. to get the value on page 455 do
|
Code: Show/Hide // EASY MISSION BOUNTY HUNTER CODE
else if (c->check("easymission:1")) // start easy bounty hunter mission { if (get_tag(p,mission1)!=on) { sendPrivate(p,"You started an easy mission \"Bounty Hunter\" Type !abort:easy:1 anytime during the game to abort this mission"); set_tag(p, mission1, on); } else if (get_tag(p,mission1)==on) { sendPrivate(p,"You already started easy mission \"Bounty Hunter\" Type !abort:easy:1 to abort mission."); } } else if ( get_tag(p,mission1)==on && p->bounty>=30 ) { sendPrivate(p,"You beated easy mission \"Bounty Hunter\" Congratulations!"); sendPrivate(p,"*points 5000"); set_tag(p,mission1,off); } else if (c->check("abort:easy:1")) { if (get_tag(p,mission1)==on) { sendPrivate(p,"You aborted easy mission \"Bounty Hunter\""); set_tag(p,mission1,off); } else if (get_tag(p,mission1)!=on) { sendPrivate(p,"You never started easy mission \"Bounty Hunter\""); } } // END OF EASY MISSION BOUNTY HUNTER CODE |
Code: Show/Hide #define mission1 1
#define on 1 // mission is on #define off 0 // mission is off |
Code: Show/Hide if (get_tag(p,mission1)!=on)
{ sendPrivate(p,"You started an easy mission \"Bounty Hunter\" Type !abort:easy:1 anytime during the game to abort this mission"); set_tag(p, mission1, on); } else if (get_tag(p,mission1)==on) sendPrivate(p,"You already started easy mission \"Bounty Hunter\" Type !abort:easy:1 to abort mission."); } |
Code: Show/Hide if (get_tag(p,mission1)==off)
{ sendPrivate(p,"You started an easy mission \"Bounty Hunter\" Type !abort:easy:1 anytime during the game to abort this mission"); set_tag(p, mission1, on); } else { sendPrivate(p,"You already started easy mission \"Bounty Hunter\" Type !abort:easy:1 to abort mission."); } |
Code: Show/Hide #include <ctime> // header |
Code: Show/Hide if (get_tag(p,0)==1) { time_t breaktime=time(0); int freezetime = (int) breaktime; if (breaktime==freezetime+300) { set_tag(p,0,0); } } |
Code: Show/Hide // inside EVENT_TICK // go through every player in the arena for (_listnode <Player> *parse = playerlist->head; parse; parse = parse->next) { Player* p = parse->item; int playing = get_tag(p,TAG_INDEX_PLAYING); if (playing == ON) { int remaining = get_tag(p,TAG_INDEX_TIME); if (remaining <= 0) // you lose set_tag(p,TAG_INDEX_PLAYING,OFF); else set_tag(p,TAG_INDEX_TIME, remaining - 1); } |
Code: Show/Hide // go through every player in the arena for (_listnode <Player> *parse = playerlist->head; parse; parse = parse->next) |
Code: Show/Hide {
for (int i = 0; i < 4; ++i) --countdown[i]; if (get_tag(p,breaktime)!=0) { int remainingtime = get_tag(p,breaktime); set_tag(p,breaktime,remainingtime-1); } } |
Code: Show/Hide 1>------ Build started: Project: default, Configuration: Debug Win32 ------
1>Compiling... 1>spawn.cpp 1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\src\player.cpp(108) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 9.0\vc\include\string.h(157) : see declaration of 'strncpy' 1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\src\player.cpp(109) : warning C4996: 'strncpy': This function or variable may be unsafe. Consider using strncpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. 1> c:\program files\microsoft visual studio 9.0\vc\include\string.h(157) : see declaration of 'strncpy' 1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(11) : warning C4005: 'UNASSIGNED' : macro redefinition 1> c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\src\clientprot.h(14) : see previous definition of 'UNASSIGNED' 1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(59) : error C2065: 'p' : undeclared identifier 1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(61) : error C2065: 'p' : undeclared identifier 1>c:\documents and settings\owner\desktop\programing\c++\dc missons\dcmissions\spawn.cpp(62) : error C2065: 'p' : undeclared identifier 1>Build log was saved at "file://c:\Documents and Settings\Owner\Desktop\Programing\c++\DC missons\DCmissions\Debug\BuildLog.htm" 1>default - 3 error(s), 3 warning(s) ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ========== |
Code: Show/Hide _listnode <Player> *parse = playerlist->head; while (parse) { Player *p = parse->item; if (get_tag(p,breaktime)!=0) { int remainingtime = get_tag(p,breaktime); set_tag(p,breaktime,remainingtime-1); } parse = parse->next; } |
Code: Show/Hide case EVENT_PlayerDeath:
{ Player *p = (Player*)event.p[0], *k = (Player*)event.p[1]; Uint16 bounty = (Uint16)(Uint32)event.p[2]; Uint16 flags = (Uint16)event.p[3]; } |
Code: Show/Hide case EVENT_PlayerDeath: { curentspree = get_tag(spree); set_tag(k,spree,curentspree+1); Player *p = (Player*)event.p[0], *k = (Player*)event.p[1]; Uint16 bounty = (Uint16)(Uint32)event.p[2]; Uint16 flags = (Uint16)event.p[3]; } |
hellzlaker wrote: | |
ye but how do you check every time player kills?
anything like?
i don't understand it, above i gave the killer a point to the spree every time he kills, but how do i control when he dies, anyway i know the code above is wrong its just i don't understand how to access it correctly |
Code: Show/Hide case EVENT_PlayerDeath: { Player *p = (Player*)event.p[0]; Player *k = (Player*)event.p[1]; Uint16 bounty = (Uint16)(Uint32)event.p[2]; Uint16 flags = (Uint16)event.p[3]; //do stuff here } |
Code: Show/Hide int curentspree = get_tag(k, spree); set_tag(k,spree,curentspree+1); |
Code: Show/Hide set_tag(p,spree,0); |
Code: Show/Hide #define SPREE 0 ... case EVENT_PlayerDeath: { Player *p = (Player*)event.p[0]; Player *k = (Player*)event.p[1]; Uint16 bounty = (Uint16)(Uint32)event.p[2]; Uint16 flags = (Uint16)event.p[3]; if (k != NULL) { int currentspree = get_tag(k, SPREE); set_tag(k, SPREE, currentspree+1); //Send arena messages if you want if (currentspree == 5) sendPublic("*arena OMG " + (String)k->name + " is on a killing spree! (" + (String)currentspree + ":0)"); } if (p != NULL) { //Reset dead player's spree set_tag(p, SPREE, 0); } } |
Code: Show/Hide for (_listnode <Flag> *parse = flaglist->head; parse; parse = parse->next); |
Code: Show/Hide struct Flag
{ Uint16 x, y; Uint16 team; Uint16 ident; }; |
Code: Show/Hide int flagcount[2] = { 0 , 0 }; for (...) { Flag* f = parse->item; flagcount[ f->team ]++; } |
Code: Show/Hide void ShowFlags(Player * p) { int ownedflags=0; int enemyflags=0; for (_listnode <Flag> *parse = flaglist->head; parse; parse = parse->next) { Flag* f = parse->item; if (f->team == p->team) ownedflags++; else enemyflags++; } sendPrivate(p, "Your team owns " + (String)ownedflags + "/" + (String)(ownedflags+enemyflags) + " flags."); } |
Code: Show/Hide int flagcount[NTEAMS]; ZeroMemory(flagcount, sizeof(int)*NTEAMS); //Sets to 0 the whole array for (_listnode <Flag> *parse = flaglist->head; parse; parse = parse->next) { Flag* f = parse->item; if (f->team >= 0 && f->team <= NTEAMS) flagcount[ f->team ]++; } |
Code: Show/Hide (String)ownedflags |
Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote: | |
I still think
It looks like you're actually casting the integer into a String. But that's not the case. (Because an int simply isn't a String. The memory structure of them has nothing in common.) That works, because Catid wrote it's own string class and overloaded the () operator. What happens here is, it's constructing a new String object from the integer, and after that exposing its internal char*. So it isn't casted to a String, but to a char*. *shudder* My point is, all that won't work outside of MERVBot. So you can as well do it the right way. Convert the int into a char*, because sendPrivate expects a char* anyways. And while you're at it, use C++ casting operators instead of the old C ones. |
Purge wrote: |
Don't forget to add parse = parse->next right before you close the loop or else the bot will crash. |
Purge wrote: |
Ah, I overlooked the for loop... I thought everything was in a while loop.
I believe the bot would crash considering it did when I left out the parse = parse->next when I was messing around. An infinite for loop would crash the bot, wouldn't it? |
Code: Show/Hide ((int*)0) = 0xbeef; |
Code: Show/Hide case EVENT_CreateTurret: { Player *turreter = (Player*)event.p[0]; Player *turretee = (Player*)event.p[1]; sendPublic((String)turreter + " attached to " + (String)turretee); } break; case EVENT_DeleteTurret: { Player *turreter = (Player*)event.p[0]; Player *turretee = (Player*)event.p[1]; sendPublic((String)p->turreter + " detached from " + (String)p->turretee); } break; |
Quote: |
-edit-
and since ive already posted here, an example of checking the first part of an arena message or server error, and doing something with it would be nice =) (because my way sucks and doesnt work half the time) aka Team goal!/Enemy goal! |