Please help.

I added pet system with spells so pet(npc) can use spells randomly.

Can someone please write down how can I use pet spells manually when i click on button or something ? ty :)

Second problem is when I try to summon pet on the end of the map i get error ?

Error code:

If MapNpc(mapnum).NPC(LoopI).IsPet = YES Then
If Map(mapnum).Tile(x, y).Type = TILE_TYPE_WALKABLE Or Map(mapnum).Tile(x, y).Type = TILE_TYPE_NPCAVOID Or Map(mapnum).Tile(x,y).Type = TILE_TYPE_HEAL Then
                   NpcTileIsOpen = True
       Exit Function
        End If
        End If