• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Tutorial] Adding more tiles to game window - Updated 7/6/2018

I see you are typing in the values individually, rather than using:
Code:
       static const int32_t maxViewportX = 10; //min value: maxClientViewportX + 1
       static const int32_t maxViewportY = 10; //min value: maxClientViewportY + 1
       static const int32_t maxClientViewportX = 10;
       static const int32_t maxClientViewportY = 10;

Do you not have these values in map.h?

Anyways...
Your OTX changes look fine, even though you might have other issues, the screen should be drawing correctly.

I'd say you did something wrong when updating the OTClient.
 
Last edited:
I see you are typing in the values individually, rather than using:
Code:
       static const int32_t maxViewportX = 10; //min value: maxClientViewportX + 1
       static const int32_t maxViewportY = 10; //min value: maxClientViewportY + 1
       static const int32_t maxClientViewportX = 10;
       static const int32_t maxClientViewportY = 10;

Do you not have these values in map.h?

Anyways...
Your OTX changes look fine, even though you might have other issues, the screen should be drawing correctly.

I'd say you did something wrong when updating the OTClient.

Yes, i first tried to use the maxclientviewport variable, but i failed, so i thought i would put the values manually in case it does not draw the variable. When i used numbers it seemed to be improved(little lesser mess). (What do i hate it when i am searching hours for a flaw or the logic behidn a error...., Especially if it is a noob error :p)

I've checked map.h/protocolbase.h/protocolgamebase.h all variants..

"Your OTX changes look fine, even though you might have other issues, the screen should be drawing correctly."
I thought exactly the same after reading your post 10 times and compiling a shitload of times, checking every line/variable/ if then else statements etc.

Code:
       static constexpr int32_t maxViewportX = 18; //min value: maxClientViewportX + 1
       static constexpr int32_t maxViewportY = 18; //min value: maxClientViewportY + 1
       static constexpr int32_t maxClientViewportX = 14;
       static constexpr int32_t maxClientViewportY = 12;
Those are mine, i've also tried 15/11 or 15/13.

Code:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 14;
    range.top = 12;
    range.bottom = 13;
    range.right = 15;
    setAwareRange(range);
}
Yes, i've also tried range.left+1 stuff.
 
Start over, follow my tutorial again using viewport and the below for OTC:

Code:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 14;
    range.top = 12;
    range.bottom = 13;
    range.right = 15;
    setAwareRange(range);
}
Should be:
Code:
{
   AwareRange range;
   range.left = 8; //Change this to = maxClientViewportX
   range.top = 6; //Change this to = maxClientViewportY
   range.bottom = range.top+1;
   range.right = range.left+1;
   setAwareRange(range);
}

Trust my tutorial. It works.

Once you have followed my tutorial, and it doesn't work, post your protocol game.cpp then, and i'll be able to help you.
But if you don't follow my tutorial I cannot help you.
 
Start over, follow my tutorial again using viewport and the below for OTC:

Code:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 14;
    range.top = 12;
    range.bottom = 13;
    range.right = 15;
    setAwareRange(range);
}
Should be:
Code:
{
   AwareRange range;
   range.left = 8; //Change this to = maxClientViewportX
   range.top = 6; //Change this to = maxClientViewportY
   range.bottom = range.top+1;
   range.right = range.left+1;
   setAwareRange(range);
}

Trust my tutorial. It works.

Once you have followed my tutorial, and it doesn't work, post your protocol game.cpp then, and i'll be able to help you.
But if you don't follow my tutorial I cannot help you.

Allright will give it a another swing in a couple of hours. I´d appericiate your efforts :)
 
Start over, follow my tutorial again using viewport and the below for OTC:

Code:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 14;
    range.top = 12;
    range.bottom = 13;
    range.right = 15;
    setAwareRange(range);
}
Should be:
Code:
{
   AwareRange range;
   range.left = 8; //Change this to = maxClientViewportX
   range.top = 6; //Change this to = maxClientViewportY
   range.bottom = range.top+1;
   range.right = range.left+1;
   setAwareRange(range);
}

Trust my tutorial. It works.

Once you have followed my tutorial, and it doesn't work, post your protocol game.cpp then, and i'll be able to help you.
But if you don't follow my tutorial I cannot help you.


result:
JybucuL.png


Using numbers was better i guess :p (i think my server has paulo torresism)

[C++] protocolgame.cpp (part2) - Pastebin.com
 
Also post what your otclient is showing for your:
Code:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 14;
    range.top = 12;
    range.bottom = 13;
    range.right = 15;
    setAwareRange(range);
}


I do not see that you have the following function in Protocolgame.cpp
Code:
bool ProtocolGame::canSee(int32_t x, int32_t y, int32_t z) const

DO you know where this function is in your source? Did you edit it?
 
Last edited:
Also post what your otclient is showing for your:
Code:
void Map::resetAwareRange()
{
    AwareRange range;
    range.left = 14;
    range.top = 12;
    range.bottom = 13;
    range.right = 15;
    setAwareRange(range);
}


I do not see that you have the following function in Protocolgame.cpp
Code:
bool ProtocolGame::canSee(int32_t x, int32_t y, int32_t z) const

DO you know where this function is in your source? Did you edit it?

The cansee function is by default on protocolgamebase.cpp for some reasons(why i do not know)..

[C++] protocolgamebase.cpp - Pastebin.com

[C++] map.cpp - Pastebin.com

Here you are.
 
Why 1 guys compiling for windows this and Upload? I cant compiling becouse i dont have files and cant download.
Please make 1 windows .exe for all.
 
@Flatlander Hello, thanks for the tutorial, i've been trying to do this today and found me into the same problem then
result:
JybucuL.png


Using numbers was better i guess :p (i think my server has paulo torresism)

[C++] protocolgame.cpp (part2) - Pastebin.com

Mixed map, no inventory, -1 skills, etc...

Followed the tutorial several times and had no success, someone please can give me a hint to solve this?

I'm using the last OTC and TFS 1.2

protocolgame.cpp
protocolgame.cpp - Pastebin.com
map.h
map.h - Pastebin.com
map.cpp
map.cpp - Pastebin.com

Appreciate the help,
 
localplayer.cpp
Code:
m_skillsLevel.fill(-1);
into
Code:
m_skillsLevel.fill(10);

this will fix your skills problem kek.

Below you have more -1 integers assigned to fields, change those to 1 and you are basically ready to go
 
localplayer.cpp
Code:
m_skillsLevel.fill(-1);
into
Code:
m_skillsLevel.fill(10);

this will fix your skills problem kek.

Below you have more -1 integers assigned to fields, change those to 1 and you are basically ready to go
Thanks for the reply @Erexo , however i'm not sure this is the root of the problem, since then I compile OTC with these values:

  1. void Map::resetAwareRange()
  2. {
  3. AwareRange range;
  4. range.left = 8;
  5. range.top = 6;
  6. range.bottom = 7;
  7. range.right = 9;
  8. setAwareRange(range);
  9. }
Instead of these

  1. void Map::resetAwareRange()
    {
    AwareRange range;
    range.left = 14; //Change this to = maxClientViewportX
    range.top = 12; //Change this to = maxClientViewportY
    range.bottom = range.top+1;
    range.right = range.left+1;
    setAwareRange(range);
    }
The game will run perfectly.
 
I was just kidding, the problem you have is that the communication between server and client is broken. Propably you are sending more/less data than the client expects and because of this whole UI went wild.
 
Hello, thanks @Erexo thanks to you I was able to solve the problem.
It happens that in the tutorial I was adding variables:
static const int32_t maxViewportX = 18; //min value: maxClientViewportX + 1
static const int32_t maxViewportY = 18; //min value: maxClientViewportY + 1
static const int32_t maxClientViewportX = 14;
static const int32_t maxClientViewportY = 12;
Out of the Map class, It wasn't clear to me that these variables already existed, it was a flaw of interpretation, but maybe could be of use for mister @Animera.
My client was configured to receive more information then my server was sending.

Thanks for the reply, have a good one.
 
Hello, thanks @Erexo thanks to you I was able to solve the problem.
It happens that in the tutorial I was adding variables:
static const int32_t maxViewportX = 18; //min value: maxClientViewportX + 1
static const int32_t maxViewportY = 18; //min value: maxClientViewportY + 1
static const int32_t maxClientViewportX = 14;
static const int32_t maxClientViewportY = 12;
Out of the Map class, It wasn't clear to me that these variables already existed, it was a flaw of interpretation, but maybe could be of use for mister @Animera.
My client was configured to receive more information then my server was sending.

Thanks for the reply, have a good one.

Thank you for thinking with me, but i did understood the tutorial. Especially if you compile it over 40 times(just incase u made a mistake lol)..
I have solved the problem. For some reasons it doesn't function properly on OTX, but it does for TFS. (Even though mattyx claimed they are the same, while
the difference is noticable). So yeah.. rescripting... adding hardcoded changes again...
 
Ok, so I did everything here and it's work. But monsters won't do anything if not near them. Is there somewhere else I need to change something?
 
Ok, so I did everything here and it's work. But monsters won't do anything if not near them. Is there somewhere else I need to change something?
Haven't found this solution either, i've tried the custom viewrange edit by flatlander, but it resulted in crashes or compiling failure or something i do not remember..

Might check it out in the next week. If i find the solution i will share it here :)
 
Ok, so I did everything here and it's work. But monsters won't do anything if not near them. Is there somewhere else I need to change something?

Solution:


//Creature.CPP

Change this:
Code:
bool Creature::canSee(const Position& myPos, const Position& pos, int32_t viewRangeX, int32_t viewRangeY)
{
   if (myPos.z <= 7) {
       //we are on ground level or above (7 -> 0)
       //view is from 7 -> 0
       if (pos.z > 7) {
           return false;
       }
   } else if (myPos.z >= 8) {
       //we are underground (8 -> 15)
       //view is +/- 2 from the floor we stand on
       if (Position::getDistanceZ(myPos, pos) > 2) {
           return false;
       }
   }

   const int_fast32_t offsetz = myPos.getZ() - pos.getZ();
   return (pos.getX() >= myPos.getX() - viewRangeX + offsetz) && (pos.getX() <= myPos.getX() + viewRangeX + offsetz)
       && (pos.getY() >= myPos.getY() - viewRangeY + offsetz) && (pos.getY() <= myPos.getY() + viewRangeY + offsetz);
}
To this:
Code:
bool Creature::canSee(const Position& myPos, const Position& pos, int32_t viewRangeX, int32_t viewRangeY)
{
   if (myPos.z <= 7) {
       //we are on ground level or above (7 -> 0)
       //view is from 7 -> 0
       if (pos.z > 7) {
           return false;
       }
   } else if (myPos.z >= 8) {
       //we are underground (8 -> 15)
       //view is +/- 2 from the floor we stand on
       if (Position::getDistanceZ(myPos, pos) > 2) {
           return false;
       }
   }

   const int_fast32_t offsetz = myPos.getZ() - pos.getZ();
   return (pos.getX() >= myPos.getX() - Map::maxViewportX + offsetz) && (pos.getX() <= myPos.getX() + Map::maxViewportX + offsetz)
       && (pos.getY() >= myPos.getY() - Map::maxViewportY + offsetz) && (pos.getY() <= myPos.getY() + Map::maxViewportY + offsetz);
}

That's all folks! [Tested it and worked properly on TFS 1.3, Cannot guarantee anything for other distro's]


Animera
 
I have added some fixes and stuff to this tutorial that I was notified of by @Animera .

Thanks Animera for letting me know i missed a few lines!
 
Back
Top