• 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!

C++ House price based on walkable SQM

Sizaro

Advanced OT User
Joined
Aug 20, 2007
Messages
5,150
Solutions
5
Reaction score
209
Location
Sweden
GitHub
coldensjo
So right now in TFS 1.5 and probably in all others TFS. House prices are calculated based on how many house tiles are in RME. It doesn't factor in that many of those tiles might not even be a part of the house.

For example. The house uses the walls as SQM. What I want is for it to caclulate only based on the grass inside the house (see image).

The price of this house is 4x5 instead of 2x3.
1649579837741.png

I know there is a rent function in RME. But TFS doesn't seem to recognize this at all.
1649579967439.png
 
Solution
Is it possible to make the RME rent work?
I think it works. Thing you set it RME is RENT (per day/week/month), not PRICE.

If we are talking about newest 1.5. All house price functions were moved to Lua.
Door description price calculcation:
!buyhouse price calculation:

If you want to use rent from RME as price of house:

1. Replace in data/lib/core/item.lua:
Lua:
response[#response + 1] = string.format(" It costs %d gold coins.", pricePerSQM * house:getTileCount())
with:
Lua:
response[#response + 1] = string.format(" It...
U can skip South and East walls in definig house SQM. West and North is necessary for tapestry or other hangable stuff. And u still can put something in door SQM, so its
2x3+1 walkable + 3 west walls and 2 north walls. Just mark useable SQM.

" It doesn't factor in that many of those tiles might not even be a part of the house." everything that u mark as house zones is a part of house...

Rent ≠ House Price
Determine the value of the rent yourself,
Like, 200gp*(number of SQM)
 
The house is an example, thought I made that clear.

And I understand that it's possible to do in RME.

But if you take a look at this house for example.

1649581392898.png

You understand that making this house "perfect" would be extremely annoying.

The best would be for RME to work.

1649581627500.png

1649581651223.png
 
There's a function in src that it calculates the size of the house to create the price, all you need to do is put a check if the tile is walkable or hangable. Its as simple as that
 
Is it possible to make the RME rent work?
I think it works. Thing you set it RME is RENT (per day/week/month), not PRICE.

If we are talking about newest 1.5. All house price functions were moved to Lua.
Door description price calculcation:
!buyhouse price calculation:

If you want to use rent from RME as price of house:

1. Replace in data/lib/core/item.lua:
Lua:
response[#response + 1] = string.format(" It costs %d gold coins.", pricePerSQM * house:getTileCount())
with:
Lua:
response[#response + 1] = string.format(" It costs %d gold coins.", house:getRent())

2. Replace in data/talkactions/scripts/buyhouse.lua:
Lua:
local price = house:getTileCount() * housePrice
with:
Lua:
local price = house:getRent()

EDIT:
You can also replace pricePerSQM * house:getTileCount() with some custom formula. Ex.:
Lua:
function getHousePrice(house)
   local pricePerSQM = configManager.getNumber(configKeys.HOUSE_PRICE)
   local tiles = house:getTiles()
   local validTilesCount = 0
   for _, tile in pairs(tiles) do
      -- count only tiles thru which you can shot spells - should skip walls and closed doors/windows
      if not tile:hasProperty(CONST_PROP_BLOCKSOLID) then
         validTilesCount = validTilesCount + 1
      end
   end
  
   return pricePerSQM * validTilesCount
end
 
Last edited:
Solution

Similar threads

Back
Top