Server Help

Bot Questions - Counting turf flags possessed by frequency

SamHughes - Mon Jan 31, 2005 1:58 am
Post subject: Counting turf flags possessed by frequency
I am making a MERVbot plugin to use in place of the base wars plugin. How should I detect if a team possesses all of the turf flags?

I have considered three options:

1. Every time there's an EVENT_Tick, iterate through the flag list, comparing each flag's team with the team of list's first flag. Once we find one that doesn't match, we stop. If all have the same team, then that team possesses all the turf flags.

2. The same, but on EVENT_FlagGrab, instead.

3. Store a map of frequencies and how many flags each possesses, and update the map every EVENT_FlagGrab.

I have abandoned the third option, since it requires storing which team _used_ to own each flag.

So that leaves the first two options. I will now ask my real question: Is EVENT_FlagGrab reliable? Is there any chance of missing a touching of a flag, due to lost packets or phases of the sun, moon, and/or space station? For if the bot missed the touching of the team's final flag, it would not notice that team's victory, should I choose option two.

Which do you recommend?
Smong - Mon Jan 31, 2005 4:37 am
Post subject:
There is a packet just for turf flags. I don't know how merv handles it.

If you've noticed EVENT_FlagGrab getting signalled lots of times in a short space of time then merv may be turning the turf packet into individual flag grab events. This is unlikely though.

What is more likely is merv already stores the flag states and calls the flag grab event if a owner changes after a flag pickup or turf packet.

If it doesn't do either of those I would make it count the flags every 5 seconds.
Anonymous - Mon Jan 31, 2005 9:56 am
Post subject:
Quote:
Is EVENT_FlagGrab reliable?


Yes. And if it weren't, your other options wouldn't work either.

Code: Show/Hide

case EVENT_FlagGrab:
{
   Player *p = (Player*)event.p[0];
   Flag *f = (Flag*)event.p[1];
   
        int team = f->team;
        bool victory = true;

        _listnode <Flag> *parse = flaglist->head;
   
        while (parse)
        {
            Flag *g= parse->item;
   
            if (g->team != team)
            {
                       victory = false;
                        break;
            }
   
                 parse = parse->next;
         }

          if (victory)
          {
            // team possesses all of the turf flags
          }
}

SamHughes - Mon Jan 31, 2005 12:22 pm
Post subject:
Thank you for your answers.
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group