Jump to content
SubSpace Forum Network

Recommended Posts

Posted

Hiya

 

For my little plugin I need to know where doors are on the map. I have seen that Mervbot has some kind of 'Map' list, like the flaglist. However I don't know how to use it.

 

I was thinking someting like this

 

_listnode <Map> *parse = map->head;
   
while (parse) {
Tile *t = parse->item;
sendPublic("Tile at "+ String(t->x) + "," + String(t->y) + ":" + String(t->type));
parse = parse->next;
}

 

Only problem is that there is no class 'Map' in Mervbot.

 

Same for 'bricklist'.

 

Does someone know how to do this?

Posted

I'm sure there was a map somewhere there... yea, there it is.

BYTE map[TILE_MAX_LINEAR];
_linkedlist <Brick> brickList;

in class Host.

 

Although it probably isn't accessible from plugins (that shouldn't be too hard to change).

 

Bricklist should be in plugins already.

Posted

Uint32 getLinear(Uint32 x, Uint32 y)

{

return ((y & 1023) << 10) | (x & 1023);

}

 

Check out Map.h and Map.cpp

 

The BYTE *map in the plugin code is passed the address of the huge map array. When you use the formula above you will get the linear index value for the array.

Example:

 

bool botInfo::CheckTile(Uint32 x,Uint32 y)//takes tile coords
{
bool Found=false;
BYTE tile=map[((y & 1023) << 10) | (x & 1023)];

if((tile > 0 && tile < 170) || (tile >= 219 && tile <=220))
{Found=true;}
return Found;
}

 

Read through some of the core's code, i believe that the map is updated when bricks are laid down. The brick list also contains the bricks in the arena, its parsed in the same way the player list is.

Guest
This topic is now closed to further replies.
×
×
  • Create New...