Author |
Message |
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Mon Apr 14, 2008 7:17 pm Post subject: |
|
|
|
|
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 |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Mon Apr 14, 2008 8:32 pm Post subject: |
|
|
|
|
<what purge said> using tags, of course. _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
tcsoccerman Server Help Squatter
Age:32 Gender: Joined: Jan 15 2007 Posts: 694 Location: Atlantis Offline
|
Posted: Mon Apr 14, 2008 9:35 pm Post subject: |
|
|
|
|
for more information, you could check out smongs spree module for ASSS (not merv). search for it in asss custom modules. |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
|
Back to top |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Tue Apr 15, 2008 9:53 am Post subject: |
|
|
|
|
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 |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Tue Apr 15, 2008 11:19 am Post subject: |
|
|
|
|
hellzlaker wrote: | ye but how do you check every time player kills?
anything like?
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:
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):
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:
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:
#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 |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Fri Apr 25, 2008 6:13 pm Post subject: |
|
|
|
|
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 |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Fri Apr 25, 2008 6:58 pm Post subject: |
|
|
|
|
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 |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Wed Apr 30, 2008 8:32 pm Post subject: |
|
|
|
|
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
for (_listnode <Flag> *parse = flaglist->head; parse; parse = parse->next); |
but then i kinda got confused
using the 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 |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Wed Apr 30, 2008 9:56 pm Post subject: |
|
|
|
|
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 |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Thu May 01, 2008 9:57 pm Post subject: |
|
|
|
|
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 |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Thu May 01, 2008 11:57 pm Post subject: |
|
|
|
|
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:
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:
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 |
|
|
k0zy Server Help Squatter
Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Fri May 02, 2008 2:39 am Post subject: |
|
|
|
|
I still think 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 |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Fri May 02, 2008 8:00 am Post subject: |
|
|
|
|
Don't forget to add parse = parse->next right before you close the loop or else the bot will crash. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Fri May 02, 2008 1:57 pm Post subject: |
|
|
|
|
Bob Dole.. Bob Dole... Bob Dole...... bob dole.... bob... dole.... wrote: | I still think 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 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 |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Fri May 02, 2008 1:58 pm Post subject: |
|
|
|
|
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 |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
|
Back to top |
|
|
Purge Episode I > Eposide III Jar-Jar is kool
Age:34 Gender: Joined: Sep 08 2004 Posts: 2018 Offline
|
Posted: Fri May 02, 2008 6:19 pm Post subject: |
|
|
|
|
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? |
|
Back to top |
|
|
hellzlaker Registered Cap Buster Popping men in the ass since Oct 2005
Gender: NEVER ENOUGH! Joined: Oct 27 2005 Posts: 34 Offline
|
Posted: Fri May 02, 2008 8:11 pm Post subject: |
|
|
|
|
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? |
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 |
|
|
Bak ?ls -s 0 in
Age:25 Gender: Joined: Jun 11 2004 Posts: 1826 Location: USA Offline
|
Posted: Fri May 02, 2008 10:35 pm Post subject: |
|
|
|
|
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
and run it. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
|
Back to top |
|
|
k0zy Server Help Squatter
Gender: Joined: Jan 11 2003 Posts: 571 Location: Germany Offline
|
Posted: Thu Jun 26, 2008 10:50 am Post subject: |
|
|
|
|
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 |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Thu Jun 26, 2008 5:58 pm Post subject: |
|
|
|
|
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? |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Sat Jun 28, 2008 3:10 am Post subject: |
|
|
|
|
and yes, turreter->name worked very nicely, thanks... |
|
Back to top |
|
|
|