Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
help with creating a dll for mervbot
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic Printable version
 View previous topic  ASSS Bot Post :: Post mervbot and .40  View next topic  
Author Message
Purge
Episode I > Eposide III
Jar-Jar is kool


Age:34
Gender:Gender:Male
Joined: Sep 08 2004
Posts: 2018
Offline

PostPosted: Mon Apr 14, 2008 7:17 pm    Post subject: Reply to topic Reply with quote

Yes, the pointer *k is used for the killer.

To check for sprees, a simple way to do it is to check the player every time he kills. At each kill, increment an integer variable by 1, which will represent the amount of kills the player has before he dies. Whenever the player dies, reset that variable to 0.
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Mon Apr 14, 2008 8:32 pm    Post subject: Reply to topic Reply with quote

<what purge said> using tags, of course.
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
tcsoccerman
Server Help Squatter


Age:31
Gender:Gender:Male
Joined: Jan 15 2007
Posts: 694
Location: Atlantis
Offline

PostPosted: Mon Apr 14, 2008 9:35 pm    Post subject: Reply to topic Reply with quote

for more information, you could check out smongs spree module for ASSS (not merv). search for it in asss custom modules.
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Tue Apr 15, 2008 12:27 am    Post subject: Reply to topic Reply with quote

ye but how do you check every time player kills?
anything like?

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];
      }


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
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Purge
Episode I > Eposide III
Jar-Jar is kool


Age:34
Gender:Gender:Male
Joined: Sep 08 2004
Posts: 2018
Offline

PostPosted: Tue Apr 15, 2008 9:53 am    Post subject: Reply to topic Reply with quote

Every time a player kills or dies the event Player_Death gets called. So you would just write something that will keep track of the players' kills using an integer variable (like int kills).

You can use tags to keep track of the actual players that are currently spreeing (like set_tag(k, SPREE, 1)) so you can differentiate them from other players. You must also remember to check if a player on a spree dies to reset his int kills back to 0 and remove the tag (using killTags(k)).

There should be a rampage plugin out there for MERV made by 50% Packetloss that is open source, so you may learn by that.
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Tue Apr 15, 2008 11:19 am    Post subject: Reply to topic Reply with quote

hellzlaker wrote:
ye but how do you check every time player kills?
anything like?

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];
      }


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


You're not 'too' far of the answer...

First, you must do your stuff AFTER the *p and *k variables have been assigned, else it makes no sense:
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
}

Same goes for all other events... depending on the event, the information is first grabbed from the event data, then you can use it.

Now, you incremented the killer's spree... well, almost... your get_tag was missing the player argument, and your 'currentspree' variable wasn't declared correctly (no type):

Code: Show/Hide

int curentspree = get_tag(k, spree);
set_tag(k,spree,curentspree+1);


Now, only thing you need to do to reset the killed player's bounty is add:

Code: Show/Hide

set_tag(p,spree,0);


Now... a small thing that could give you some hard-to-find bugs... what if player A lays some mines, then leaves the arena... and someone gets killed by these mines. The killer pointer 'k' will be 'NULL', and the tags will already be removed (see Player_Leave event). So you have to check if k is not NULL before attempting to do anything. And just because it is always safer to check for NULL pointers before using them, I'd do the same with 'p', even if it shouldn't ever be NULL... But when you see these error messageboxes saying stuff like 'Memory cannot be read at 0x00000000', it's because the program tried to use a NULL pointer. NULL being simply the value 0 (see #define NULL 0, somewhere in the code)

One last thing, constant values are usually used with all caps... so your variable 'spree' should be 'SPREE'; doesn't change anything in how the code works, but it's cleaner/more standard.

Final result:
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);
   }
}


Also, you might want to reset a player's spree on the Player_Ship and Player_Team events.
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Fri Apr 25, 2008 6:13 pm    Post subject: Reply to topic Reply with quote

My bot DLL is coming very good but im running in some problems on the way

my question is this

in a turf zone and can you find out how many flags is the team holding (or player, same thing in turf right?)

i tried using p->flagCount but it didn't work

any one know?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri Apr 25, 2008 6:58 pm    Post subject: Reply to topic Reply with quote

Similar to the playerlist, there is a 'flaglist'. You scroll through it in the same way you'd scroll through the playerlist, except the data items are not 'Player' structs, but 'Flag' structs. Each 'Flag' item holds the ID of the flag, the position of the flag, and the team that holds it. (If no one is owning the flag, I believe the 'team' is 0xFFFF, or -1, or UNASSIGNED)
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Wed Apr 30, 2008 8:32 pm    Post subject: Reply to topic Reply with quote

thanks Samapico ur amazing but i got few more questions

like if i do something if player types !checkFlags the bot will tell him how many flags his team owns and how many doesn't,

i did the scroll through flags

Code: Show/Hide
for (_listnode <Flag> *parse = flaglist->head; parse; parse = parse->next);


but then i kinda got confused

using the
Code: Show/Hide
struct Flag
{
   Uint16 x, y;
   Uint16 team;
   Uint16 ident;
};


i guess you access each flag with 'Flag.team' to find out which team flag belongs to but i dont get which one ? is it more like Flag.1.team ? u understand that there is ident but you would access it with Flag.ident to find flag' identity right?

i just found out that you access flag like a namespace with the '::' so its Flag::team

but my question is the same, how do you check which flag is on which team since you cant do Flag::ident1::team ?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Purge
Episode I > Eposide III
Jar-Jar is kool


Age:34
Gender:Gender:Male
Joined: Sep 08 2004
Posts: 2018
Offline

PostPosted: Wed Apr 30, 2008 9:56 pm    Post subject: Reply to topic Reply with quote

You should be able to check the values within the struct using f->(Uint16). For example, to check for flags on a team, use f->team.

Notice how this is similar to checking entries in the playerlist.
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Thu May 01, 2008 1:35 am    Post subject: Reply to topic Reply with quote

if you scroll through the whole flag list, you don't have to worry about the ident, especially if you just want to count them.

just something like

Code: Show/Hide


int flagcount[2] = { 0 , 0 };
for (...)
{
  Flag* f = parse->item;
  flagcount[ f->team ]++;
}


To access the 'team' field, you have to use -> because you have a pointer.

Basically, the -> operator is a shortcut for 'field of the object pointed by'
For example,
f->team
is exactly the same as
(*f).team (The * operator before a variable name refers to the object pointed by a pointer)
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Thu May 01, 2008 9:57 pm    Post subject: Reply to topic Reply with quote

honestly i am confused

int flagcount[2] = { 0 , 0 };

you just declared an array which contains 2 variables and both of them are 0, :\ i dont get that at all, i mean i get that its an array but why 2 values?

Flag* f = parse->item


This part i kinda get but for some reason VC++ told me "error C2065: 'parse' : undeclared identifier"

flagcount[ f->team ]++;

this part is just as confusing as first, as i understand, it checks what team flag is on, and writes a value for flagcount[ number of the team] to increase by 1

so if flag was on freq 5, then flagcount[5] would increase by one?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Thu May 01, 2008 11:57 pm    Post subject: Reply to topic Reply with quote

oh.. yeah I did a couple of mistakes...

I put 2 values because I supposed there were only 2 teams. And if I did that, I should have included checks to make sure that f->team is either 0 or 1. And for the 'undeclared identifier: parse', the 'for (...)' I put in there was the for loop used to scroll through the flags (see below), just felt lazy.


If you have private freqs and can have like 9999 different freqs, and if you only want to know how many flags YOU have and how many flags you don't, you could do it like this:
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.");
}


If you call this function for a player, it will send him something like:

BOT> Your team owns 5/16 flags.



If you have a fixed number of teams, and want to know the flags of each team:
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 ]++;
}
Back to top
View users profile Send private message Add User to Ignore List
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Fri May 02, 2008 2:39 am    Post subject: Reply to topic Reply with quote

I still think
Code: Show/Hide
(String)ownedflags
is a bad idea.

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.
_________________
It's a shark! Oh my god! Unbelievable!
Back to top
View users profile Send private message Add User to Ignore List
Purge
Episode I > Eposide III
Jar-Jar is kool


Age:34
Gender:Gender:Male
Joined: Sep 08 2004
Posts: 2018
Offline

PostPosted: Fri May 02, 2008 8:00 am    Post subject: Reply to topic Reply with quote

Don't forget to add parse = parse->next right before you close the loop or else the bot will crash.
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri May 02, 2008 1:57 pm    Post subject: Reply to topic Reply with quote

Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote:
I still think
Code: Show/Hide
(String)ownedflags
is a bad idea.

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.
Yeah... I do it because it works tongue.gif And the first example of displaying numbers I saw was made like that, so I kept using it... But I guess it's not the best way. But it works and it's visually simple icon_wink.gif
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri May 02, 2008 1:58 pm    Post subject: Reply to topic Reply with quote

Purge wrote:
Don't forget to add parse = parse->next right before you close the loop or else the bot will crash.
It's in the 'for' statement
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri May 02, 2008 2:55 pm    Post subject: Reply to topic Reply with quote

and if it wasn't the bot wouldn't crash; it would loop forever icon_smile.gif

using explicit String casting is fine for mervbot.
_________________
SubSpace Discretion: A Third Generation SubSpace Client
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Purge
Episode I > Eposide III
Jar-Jar is kool


Age:34
Gender:Gender:Male
Joined: Sep 08 2004
Posts: 2018
Offline

PostPosted: Fri May 02, 2008 6:19 pm    Post subject: Reply to topic Reply with quote

Ah, I overlooked the for loop... I thought everything was in a while loop. sa_tongue.gif

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?
Back to top
View users profile Send private message Add User to Ignore List
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


Gender: NEVER ENOUGH!
Joined: Oct 27 2005
Posts: 34
Offline

PostPosted: Fri May 02, 2008 8:11 pm    Post subject: Reply to topic Reply with quote

Purge wrote:
Ah, I overlooked the for loop... I thought everything was in a while loop. sa_tongue.gif

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?


yes any infinite loop would, since when the bot is in a loop it doesn't send packets and gets kicked

(correct me if i am wrong)


to samapico: thanks i get it now but just a quick question, wouldn't just by declaring flagCount easier like int flagcount[], instead of int flagcount[2] ?
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
Bak
?ls -s
0 in


Age:24
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Fri May 02, 2008 10:35 pm    Post subject: Reply to topic Reply with quote

in general you can't declare arrays without giving sizes. In this case you can since you initialize it right away the compiler can figure out it's size is 2. If you try to compile "int flagcount[];" it will complain whereas "int flagcount[2];" is fine.

the bot getting kicked is not a crash. If you want to see what a crash looks like do
Code: Show/Hide
((int*)0) = 0xbeef;
and run it.
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Thu Jun 26, 2008 2:30 am    Post subject: Reply to topic Reply with quote

as long as this is here, ive got
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;


doesnt compile, obviously, because p->turreter sucks.
neither (String)p->turreter nor (String)turreter works...
how would i get it to work?



-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!
_________________
SSC Distension Owner
SSCU Trench Wars Developer
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
k0zy
Server Help Squatter


Gender:Gender:Male
Joined: Jan 11 2003
Posts: 571
Location: Germany
Offline

PostPosted: Thu Jun 26, 2008 10:50 am    Post subject: Reply to topic Reply with quote

Try turreter->name or something...

Of course you can't cast a pointer to the string class Catid wrote.

Like I explained before, the casting in this thread only worked because Catid did some nasty things with his string class.
Back to top
View users profile Send private message Add User to Ignore List
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Thu Jun 26, 2008 5:58 pm    Post subject: Reply to topic Reply with quote

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!
emm... there is a 'score' event you know? tongue.gif
Back to top
View users profile Send private message Add User to Ignore List
Cheese
Wow Cheese is so helpful!


Joined: Mar 18 2007
Posts: 1017
Offline

PostPosted: Sat Jun 28, 2008 3:10 am    Post subject: Reply to topic Reply with quote

and yes, turreter->name worked very nicely, thanks...
Back to top
View users profile Send private message Add User to Ignore List Visit posters website AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> Bot Questions All times are GMT - 5 Hours
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 672 page(s) served in previous 5 minutes.

phpBB Created this page in 0.601244 seconds : 50 queries executed (80.3%): GZIP compression disabled