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  Next
 
Post new topic   Reply to topic Printable version
 View previous topic  ASSS Bot Post :: Post mervbot and .40  View next topic  
Author Message
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri Apr 04, 2008 8:17 pm    Post subject: Reply to topic Reply with quote

it's pretty much it... go check the Merv functions of get_tag and set_tag, might help you understanding.

When you get_tag, the code scrolls through all the tags you've set, and when the player AND the index matches, it returns you the current value of that tag (the data). If it doesn't find any tag for that player with that index, it returns 0 by default.
_________________
(Insert a bunch of dead links here)
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


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

PostPosted: Fri Apr 04, 2008 10:07 pm    Post subject: Reply to topic Reply with quote

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
int value = get_tag(p,455);

_________________
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 Apr 04, 2008 10:20 pm    Post subject: Reply to topic Reply with quote

Don't confuse #define with a standard definition like int i = 0. In the snippet I posted, #define INDEX 2 is saying that INDEX has 3 values; or using Bak's analogy, 3 pages. It is not the same as int INDEX = 3.
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


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

PostPosted: Fri Apr 04, 2008 10:26 pm    Post subject: Reply to topic Reply with quote

wat? are you sure purge?
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Fri Apr 04, 2008 11:57 pm    Post subject: Reply to topic Reply with quote

uh... no... #define INDEX 2 means that anywhere you put INDEX in your code, it is replaced by "2" before anything is even compiled.

For example, if I need 3 tags, I usually do something like:
#define TAG_SOMETAG 0
#define TAG_ANOTHERTAG 1
#define TAG_THIRDTAG 2

And I use these as index values.

And what purge said isn't true... last I checked, the tags is a linkedlist, not an array. Each tag on the linked list is a struct with Player* p, int index and int data.
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


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

PostPosted: Sat Apr 05, 2008 12:03 am    Post subject: Reply to topic Reply with quote

to drive the point home, you can compile
Code: Show/Hide
#define APPLE int main()
#define SAUCE return 0;

APPLE
{
SAUCE
}
Back to top
View users profile Send private message Add User to Ignore List AIM Address
Samapico
No, these DO NOT look like penises, ok?


Joined: May 08 2003
Posts: 1252
Offline

PostPosted: Sat Apr 05, 2008 12:45 am    Post subject: Reply to topic Reply with quote

in Mervbot, you can use

WHEN_COWS_FLY
{
//statements
}

for something that will never happen...
If I remember right, there is:
#define WHEN_COWS_FLY if(false)
somewhere in the code tongue.gif
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: Sat Apr 05, 2008 1:47 am    Post subject: Reply to topic Reply with quote

Meh, sorry about the bad info. This is why I'm premed and not computer anything.
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: Sun Apr 06, 2008 1:10 pm    Post subject: Reply to topic Reply with quote

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
int value = get_tag(p,455);


wow bak now i get it, lol thats a perfect explanation no joke,


and don't feel bad purge icon_wink.gif
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


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

PostPosted: Sun Apr 06, 2008 2:15 pm    Post subject: Reply to topic Reply with quote

Ok i get the tags now and made a bot with them that works just how do you do a code that if any point during game that event happens, then exectute other code

this is the code when i tried to make the bot and it works just the bot realizes you beat the mission only you type something to him

also here the mission is to collect 30 bounty

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


also i got this in spawn.h
Code: Show/Hide
#define mission1 1

#define on 1  // mission is on
#define off 0 // mission is off


also to samapico:
yup ur right its in datatypes.h
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: Sun Apr 06, 2008 8:19 pm    Post subject: Reply to topic Reply with quote

The bot only realizes the player won when he types in the command since that is the only place you are checking for a win. So you must check for a win in a player event in spawn.cpp like Player_Prize (I think).
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: Sun Apr 06, 2008 11:05 pm    Post subject: Reply to topic Reply with quote

Quick suggestion for cleaner code:
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.");

You defined the 'off' value, you might as well use it... and since you're doing the "else" part, you only need to get_tag once, since the tag only has 2 possible values.
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.");
}


And to fix your problem, you must do as Purge said. Typically, most of your plugin code should be in spawn.cpp, in the various events. The commands.cpp should only include stuff that are directly triggered by !commands, like turn on/off something, like you're doing with your mission. However, once the command is done, you have to rely on events to know what's going on.
You can also use global variables in spawn.cpp and command.cpp if you declare them in spawn.h, in the botInfo class declaration.
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: Mon Apr 07, 2008 3:50 pm    Post subject: Reply to topic Reply with quote

ok thanks
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
hellzlaker
Registered Cap Buster
Popping men in the ass since Oct 2005


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

PostPosted: Mon Apr 07, 2008 5:40 pm    Post subject: Reply to topic Reply with quote

Also I am going to create a tag that deals with current time, and where would exactly i would put in spawn.ccp? ( i was guessing like playermove =\)

this is just kind of how it will look like

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);
}
}
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:25
Gender:Gender:Male
Joined: Jun 11 2004
Posts: 1826
Location: USA
Offline

PostPosted: Mon Apr 07, 2008 8:48 pm    Post subject: Reply to topic Reply with quote

EVENT_TICK happens once a second. you can set like the time to 300 when they start and every EVENT_TICK have a countdown.

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);
}
Back to top
View users profile Send private message Add User to Ignore List 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: Mon Apr 07, 2008 9:11 pm    Post subject: Reply to topic Reply with quote

what do you mean by go through every person in arena ?

and i dont get that for()
Code: Show/Hide

// go through every player in the arena
for (_listnode <Player> *parse = playerlist->head; parse; parse = parse->next)


EDIT: also can you have more then 1 EVENT_TICK?
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: Mon Apr 07, 2008 11:22 pm    Post subject: Reply to topic Reply with quote

check how the get_tag function is done, it uses the same thing (except it's a while loop instead of a for loop).
Basically, "playerlist" is a linked list...

A linked list is made of "nodes"
Each node contains 3 important information:

A pointer to the previous node of the list
A pointer to the next node of the list (parse->next)
A pointer to the actual data (parse->item)

For example, in playerlist, the items are 'Player' structs.

So what that loop does, is initialize a pointer to the start of the list (playerlist->head). Once you've done what you wanted with that item, you advance to the next (parse = parse->next)
The stop condition of the loop is 'parse', which means as long as the pointer is not NULL, it will keep going. The last item of the list doesn't have any 'next' item, so at that point you will get the NULL value.
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 07, 2008 11:24 pm    Post subject: Reply to topic Reply with quote

As for you EVENT_TICK question... there is only one EVENT_TICK event, however, you can have more than one countdowns going at once. By default, there are 4 countdowns set. Look in spawn.h you will find the initialization of them; looks like 'int countdown[4];' or something. You can put as many countdowns as you wish. You just have to adjust the code in the EVENT_TICK part.
Back to top
View users profile Send private message Add User to Ignore List
Bak
?ls -s
0 in


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

PostPosted: Tue Apr 08, 2008 12:40 am    Post subject: Reply to topic Reply with quote

why would you want more than one EVENT_TICK ?

I'd try to explain the for loop but samapico is pretty much right. It involves pointers and structures and templates, which aren't hard on their own but if you're trying to learn all of them at once it can be overwhelming. Suffice it to say there's a list of every Player* in the arena called playerlist, and that's how you go through it.
Back to top
View users profile Send private message Add User to Ignore List 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: Sun Apr 13, 2008 8:28 pm    Post subject: Reply to topic Reply with quote

wtf this doesnt compile right!

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






      }
and get those errors
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 ==========


when i delete that code compiles just fine :\
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: Sun Apr 13, 2008 10:23 pm    Post subject: Reply to topic Reply with quote

You have to cycle through the playerlist so that it can search for a player to check tags.

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


That code should work. Also, you may want to fix those warnings regarding deprecated strings. Try declaring #define CRT_SECURE_NO_DEPRECATE in spawn.h.
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: Sun Apr 13, 2008 11:16 pm    Post subject: Reply to topic Reply with quote

yeah... there is no 'p' in the EVENT_TICK part of the code. (C2065: 'p' : undeclared identifier)
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: Mon Apr 14, 2008 3:54 pm    Post subject: Reply to topic Reply with quote

i declared that and still got same 3 errors also where could i find how to keep track of player kills? like bounty i know is p->bounty and there is EVENT player prize.. but is there a kill event?
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: Mon Apr 14, 2008 5:16 pm    Post subject: Reply to topic Reply with quote

there is a death event... where there's a death, there's a kill.


And you can't just declare 'p' in EVENT_TICK... well you can, but it will be useless, you have to do what purge said, which is cycle through ALL the players every tick.
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: Mon Apr 14, 2008 5:50 pm    Post subject: Reply to topic Reply with quote

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



kinda confusing and i assume *k is the killer, so if i would try something like keep track if a player killed 3 people without dying (like a spree) what would i do?
[/code]
Back to top
View users profile Send private message Add User to Ignore List Send email AIM Address MSN Messenger
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  Next
Page 2 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: 605 page(s) served in previous 5 minutes.

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