Server Help

Bot Questions - Own variables in MERVBot DLL

Doggeti - Wed Jan 22, 2003 2:17 pm
Post subject: Own variables in MERVBot DLL
Here is what I made:

In spawn.h I added in class-definition of botInfo:

int goals[2];

and

goals[0] = 0;
goals[1] = 0;

In spawn.cpp I changed in botInfo::gotEvent the case EVENT_SoccerGoal. It now looks like this:

int team = *(int*)&event.p[0];
int reward = *(int*)&event.p[1];
goals[team]++;
String s;
s = "SCORE - Evens: ";
s += goals[0];
s += " Odds: ";
s += goals[1];
sendPublic(s);

But the Bot doesn't display the message when I score.
SOS - Wed Jan 22, 2003 3:01 pm
Post subject:
Looks fine here...
Maybe you are not loading the dll into the bot? sa_tongue.gif
Anonymous - Thu Jan 23, 2003 9:42 am
Post subject: blah
try sending it as an arena message. prefix "*arena".

i think there might be a problem with plain old public messages, lemme check it out
Doggeti - Thu Jan 23, 2003 1:25 pm
Post subject:
I changed it to this:

int team = *(int*)&event.p[0];
int reward = *(int*)&event.p[1];
goals[team]++;
String s;
s = "*arena SCORE - Evens: ";
s += goals[0];
s += " Odds: ";
s += goals[1];
sendPublic(s);

is that what you meant? (it doesn't work) new_puppy_dog_eyes.gif
SOS - Thu Jan 23, 2003 1:37 pm
Post subject:
Try putting a breakpoint there. Am thinkink that maybe it is not beink run for some reason.
Doggeti - Thu Jan 23, 2003 2:11 pm
Post subject:
where exactly you want me to put it?
SOS - Fri Jan 24, 2003 1:00 am
Post subject:
Any of those lines under EVENT_SoccerGoal
Anonymous - Fri Jan 24, 2003 5:44 am
Post subject:
Doggeti wrote:
I changed it to this:

int team = *(int*)&event.p[0];
int reward = *(int*)&event.p[1];
goals[team]++;
String s;
s = "*arena SCORE - Evens: ";
s += goals[0];
s += " Odds: ";
s += goals[1];
sendPublic(s);

is that what you meant? (it doesn't work) new_puppy_dog_eyes.gif


It does have staff access right? Just checking
Doggeti - Fri Jan 24, 2003 5:55 am
Post subject:
The bot acctually has mod-access and as i read in www.shanky.com/server/commands.html this should be enough for *arena command.
I will try it with higher levels and post it later whether it worked or not.
Doggeti - Fri Jan 24, 2003 6:18 am
Post subject:
I gave Smod and after that SysOp powers to the bot but that didn't help.
Mine GO BOOM - Fri Jan 24, 2003 9:19 am
Post subject:
You might want to just try to send a test public message before and afterwards, to see if the bot screwed up somewhere around it. Before and after that code section, just send a public message like "test1", and after it, send something like "test2". If it only sends test1, your code is wrong somehow. If it sends test1 and test2, then your goal[0] isn't being added to the string correctly.
Doggeti - Sat Jan 25, 2003 4:47 am
Post subject:
I now tried this as well but the bot doesn't say anything. The only thing that works until now are private messages when player enter the arena.
SOS - Sat Jan 25, 2003 5:32 am
Post subject:
Erm... well maybe you have messed something up there.
Post the entire gotEvent() function
Doggeti - Sat Jan 25, 2003 8:50 am
Post subject:
Ok, here are the both case-blocks I have changed so far:

Code: Show/Hide

case EVENT_SoccerGoal:
{
int team = *(int*)&event.p[0];
int reward = *(int*)&event.p[1];
goals[team]++;
String s;
s = "SCORE - Evens: ";
s += goals[0];
s += " Odds: ";
s += goals[1];
sendPublic(s);
}
break;


and

Code: Show/Hide

case EVENT_PlayerEntering:
{
Player *p = (Player*)event.p[0];
String s;
s = "Hello ";
s += p->name;
s += "!";
sendPrivate(p, s);
}
break;


As I said, the code in EVENT_PlayerEntering works but not the one in EVENT_SoccerGoal
Anonymous - Sat Jan 25, 2003 12:14 pm
Post subject:
The Soccer Goal Event doesn't happen when a soccer goal is scored. just put a simple sendPublic("Goal Scored"); to prove it. Dunno what to tell you.
Doggeti - Sun Jan 26, 2003 4:26 am
Post subject:
I put following line into case EVENT_PlayerEntering:

Code: Show/Hide

sendPublic("Hello!");


Guess what, he didn't say it. BUT icon_exclaim.gif Now I know the problem is not that EVENT_SoccerGoal doesn't get called; The problem is in sendPublic() or in one of the functions related to it.

So I looked for the definition of sendPublic(). At the bottom of spawn.cpp I found all the message-functions including two sendPublic(). One of them was with sound the other one without.

Code: Show/Hide

void botInfo::sendPublic(char *msg)
{
    tell(makeSay(MSG_Public, 0, 0, msg));
}

void botInfo::sendPublic(BYTE snd, char *msg)
{
    tell(makeSay(MSG_Public, snd, 0, msg));
}


I found 'makeSay' in dllcore.cpp. It simply sets the properties of an event and returns this event.
This event is then given to 'tell'. 'tell' is a method if botInfo. It's located at top of spawn.cpp.

Code: Show/Hide

void botInfo::tell(BotEvent &event)
{
    if (callback && handle)
    {
        event.handle = handle;
        callback(event);
    }
}


'callback' should now be called with our little event. The problem is that i couldn't find this function 'callback'. Where is it icon_question.gif What does it do icon_question.gif
SOS - Sun Jan 26, 2003 7:56 am
Post subject:
callback tells the EXE that you want to do something. It's in the EXE source.

Quote:
Now I know the problem is not that EVENT_SoccerGoal doesn't get called;


And you say this because... why?

sendPublic() works fine for everyone else...
Are you using all latest sources?
Doggeti - Sun Jan 26, 2003 10:44 am
Post subject:
new_color_.gif Yes. I am using the latest source directly from icon_arrow.gif catid.sscentral.com.

Ok, you are right. i can't tell if the EVENT_SoccerGoal gets called or not but i can be sure that something must be wrong with the function 'sendPublic' or may way of using it sa_keke.gif .
SOS - Sun Jan 26, 2003 11:59 am
Post subject:
No, you can't sa_tongue.gif
There's nothing special to use about it, so that's out...

As I said, post the entire getEvent() function and I might be able to find the error
Doggeti - Mon Jan 27, 2003 9:39 am
Post subject:
icon_rolleyes.gif OK. Though I don't know why you need the entire code here you have it (it's my spawn.cpp in attachment). I think that's the file that contains 'gotEvent'. If not please don't slap me biggrin.gif
tikiman - Tue Jan 28, 2003 4:03 am
Post subject:
Has anyone gotten this working? I tried it similar to the way Doggeti did and I have the same problem: sendPrivate seems to work, sendPublic doesn't, no matter where I put it.

I looked up the !say command that comes with the bot core. It's in command.cpp and the only difference is that it gets passed a Host object and uses the Host sendPublic() function like the following:

h->sendPublic("hi");

If h is of type Host*. I tried creating one of these in spawn.cpp but with multiple errors. Here's what I did.

Host* h = new Host;
h->sendPublic("hi");

It doesn't seem to work. My C++ is really rusty though so that may be completely wrong.
SOS - Tue Jan 28, 2003 8:47 am
Post subject:
Well, sendPublic() always worked for me and it has not changed in the latest MERV versions...

A thought occurs: Can people talk public chat in your zone? There is that bug where only moderators can use public chat. Hrm, altough usually bots have staff access... so I dunno...
Dr Brain - Tue Jan 28, 2003 9:45 am
Post subject:
It works for me too, altho I have not tested it with the latest MERV version.

I HATE that pub chat bug, I had an event in my zone with 10 people, and I was the only one talkin... I thought they just didn't like speaking.
ExplodyThingy - Tue Jan 28, 2003 11:10 am
Post subject:
Since we dont seem to know the source of the problem, ever thought of doing a sendTeam(); or similar to see if that event is called? That will tell you if its the event or sendPublic();
Doggeti - Tue Jan 28, 2003 3:00 pm
Post subject:
LOL! I put sendTeam(s); into EVENT_SoccerGoal as Explody suggested and it didn't work.
SoccerGoal happens when the powerball crosses the goal-tile, right?
Anonymous - Wed Jan 29, 2003 1:21 pm
Post subject:
EVENT_SoccerGoal never happens and this is the problem. MERV bot has a bug.
Doggeti - Wed Jan 29, 2003 3:35 pm
Post subject:
I found a bug! *proud* grav_smile.gif

Ok, then i will download one of the older versions.
ExplodyThingy - Wed Jan 29, 2003 4:59 pm
Post subject:
If it doesnt work now, why would it have worked then?

And where are the older versions? Id like to get my hands on one of the 'emptier' ones, like build 2 or so, so i can see how it works by trial and fire a lot easier.
Doggeti - Thu Jan 30, 2003 1:57 pm
Post subject:
EEK, you are right. There's just one link on catid's site to the newest version. Mhm, then I have to wait until the next build icon_sad.gif grav_update.gif
Anonymous - Mon Feb 03, 2003 7:07 pm
Post subject:
You can get the soccergoal event to run if your server's setting for every soccer goal is to give a reward. Just figured this out so apparently it's not an enormous bug(most zones will have a reward).
Doggeti - Tue Feb 04, 2003 8:10 am
Post subject:
I set server.cfg:Soccer:Reward to 1 and -1. Both didn't work. Are there other settings I have to change icon_question.gif Is this the correct Reward that you meant icon_question.gif
Anonymous - Tue Feb 04, 2003 1:50 pm
Post subject:
[Soccer]
BallBounce=1
AllowBombs=0
AllowGuns=0
PassDelay=0
Mode=1
BallBlankDelay=200
UseFlagger=1
BallLocation=1
BallCount=1
SendTime=200
Reward=-1
CapturePoints=0
CatchMinimum=5
CatchPoints=10
WinBy=2

These are the setting in which I got the event to work.
Doggeti - Tue Feb 04, 2003 2:40 pm
Post subject:
Oops! That was my fault. There was still sendTeam in EVENT_SoccerGoal because I have tested it in order to know if it's EVENT_SoccerGoal or sendPublic that makes trouble. Giving Reward is the right solution. What shell I say ... IT WORKS icon_exclaim.gif new_eggface.gif
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group