Map Database  •  FAQ  •  RSS  •  Register  •  Login

Bug in dynamic scripting

<<

Toxic

Recruit

Posts: 34

Joined: 22 Feb 2017, 19:04

Post 22 Feb 2017, 19:21

Bug in dynamic scripting

Hi,

I have a problem in my script when I want to create trees. Command Actions.MapTileObjectSet(X,Y,TREE_NUMBER); (for example Actions.MapTileObjectSet(10,10,88);) gives me nice small tree seedlings. The problem is that it will never grow up + if I create big trees, woodcutters are not able to cut it down :? . Can you help me solve this problem?

(tested for objects: Tree:=[88,89,90,92,93,94,95,97,98,99,100,102,103,104,105,107,108,109,110,149,150,151,153,154,155,157,158,159,160,162,163,164,165,167,168,169,170];)
<<

Rey

Pikeman

Posts: 160

Joined: 12 Oct 2016, 07:41

Location: Moscow

KaM Skill Level: Skilled

Post 23 Feb 2017, 17:49

Re: Bug in dynamic scripting

Andreus (scripts developer), said, that this bug is not possible to fix in current version (r6720), but it was already fixed and will come with next release version
<<

Toxic

Recruit

Posts: 34

Joined: 22 Feb 2017, 19:04

Post 24 Feb 2017, 14:52

Re: Bug in dynamic scripting

Thank you. I suppose that you will not be able to tell me when this update will be released, am I right?
<<

Rey

Pikeman

Posts: 160

Joined: 12 Oct 2016, 07:41

Location: Moscow

KaM Skill Level: Skilled

Post 24 Feb 2017, 17:59

Re: Bug in dynamic scripting

In the future, for sure. Just wait for updates :)
<<

Ben

User avatar

Prince Lothar

Posts: 3602

Joined: 08 Jan 2009, 23:00

Location: United States of America GMT-5

KaM Skill Level: Beginner

Post 25 Feb 2017, 00:32

Re: Bug in dynamic scripting

A remarkable political answer from our dear Rey!
Liberté, Égalité, KaM
<<

Rey

Pikeman

Posts: 160

Joined: 12 Oct 2016, 07:41

Location: Moscow

KaM Skill Level: Skilled

Post 25 Feb 2017, 05:17

Re: Bug in dynamic scripting

Sorry, but I can say no more for now ... :wink:
But let's hope for the best.
There is still a hope with us :D
<<

Toxic

Recruit

Posts: 34

Joined: 22 Feb 2017, 19:04

Post 25 Feb 2017, 19:58

Re: Bug in dynamic scripting

I have another (it is not so important). Make this script in new (empty) map:
  Code:
procedure OnHousePlanRemoved(aPlayer, aX, aY, aType: Integer);
begin
   Actions.log('Removed: X='+intToStr(aX)+' Y='+intToStr(aY));
end;

procedure OnHousePlanPlaced(aPlayer, aX, aY, aType: Integer);
begin
   Actions.log('Placed: X='+intToStr(aX)+' Y='+intToStr(aY));
end;

This bug appears if you place schoolhouse plan and then immediately remove it. When you check .LOG file you will see that coordination X is different for event OnHousePlanRemoved (+-1 dependent on the building). This happens also when you choose the exactly same tile for placing and removing (i.e. building entrance).

Here are differences (index of array = house type from Lookups):
  Code:
FixConstant := [-1,0,-1,-1,0,0,-1,1,-1,0,-1,-1,0,-1,0,-1,1,0,0,-1,-1,-1,0,0,1,0,0,-1,1,1];
<<

Rey

Pikeman

Posts: 160

Joined: 12 Oct 2016, 07:41

Location: Moscow

KaM Skill Level: Skilled

Post 25 Feb 2017, 23:05

Re: Bug in dynamic scripting

Thanks, we didn't noticed that bug before.
It comes not because of entrance offsets for different houses, but because in OnHousePlanRemoved coordinates of tile, where player click to remove house, were used. So. f.e. if you place school plan on 5,5, then click on 4,3 - top left corner of house, then you will get 4,3 in OnHousePlanRemoved.
Fixed here https://github.com/Kromster80/kam_remake/pull/298, thanks!
<<

Toxic

Recruit

Posts: 34

Joined: 22 Feb 2017, 19:04

Post 26 Feb 2017, 07:53

Re: Bug in dynamic scripting

Rey wrote:... where player click to remove house, were used.

I know and I have not problem with it.

Rey wrote:So. f.e. if you place school plan on 5,5, then click on 4,3 - top left corner of house, then you will get 4,3 in OnHousePlanRemoved.

This is wrong. Check my script - you will not get 4,3 but 3,3! This is why I wrote my post because X coordinates are changing +-1 in depent on building. To sum up each specific building after demolition returns you different X coordinates.
<<

Rey

Pikeman

Posts: 160

Joined: 12 Oct 2016, 07:41

Location: Moscow

KaM Skill Level: Skilled

Post 26 Feb 2017, 11:22

Re: Bug in dynamic scripting

Yes I understand. But if we show real house position(entrance actually, not position), instead of where user click on the map, then this issue will be resolved automatically.
So finally in new version when you place any house plan and then remove this house plan, same coordinates are logged with your script code.
For all houses there are 2 coordinates - one is house position, smth like house center, and other is house entrance, which has +-1 offset with house position for some houses. These 2 commands above both use entrance coordinates now.
<<

Ben

User avatar

Prince Lothar

Posts: 3602

Joined: 08 Jan 2009, 23:00

Location: United States of America GMT-5

KaM Skill Level: Beginner

Post 26 Feb 2017, 17:55

Re: Bug in dynamic scripting

To expand on Rey's answer:
It may seem weird that some houses "center" is not where the door is. I agree that is very odd, but it's important to keep the game this way to keep compatibility with original mission files for Knights and Merchants, TSK/TPR. Why they didn't just set all houses to have a center at the door, I really don't know, but it's a legacy that the Remake appropriately continues.
Liberté, Égalité, KaM
<<

Krom

User avatar

KaM Remake Developer

Posts: 3156

Joined: 09 May 2006, 22:00

Location: Russia

KaM Skill Level: Fair

Post 26 Feb 2017, 18:16

Re: Bug in dynamic scripting

Original KaM did not set the houses center on the door likely due to memory and CPU considerations. Each house is described by 4x4 matrix (element = tile usage). So to allow for 4 tile wide houses with door at any place it would have need a 7x4 matrix. This is much larger. So instead offsets were used.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de

Return to Bugs

Who is online

Users browsing this forum: Baidu [Spider] and 1 guest