Page 2 of 2

Re: Problem with give house to different player.

PostPosted: 08 Aug 2014, 02:48
by Lewin
The problem was not in the script, it was a bug in the KaM Remake. I found the crash report you sent us and used it to fix the bug, so thanks! :) The problem was that some units were killed while inside their house at the same time that the house was instantly destroyed and replaced. Then there was a bug which caused the units to be recorded as died twice, meaning the statistic for the total number of units went negative (which it is not allowed to do) and this caused a crash.

There is no problem with the original version of the script, it doesn't matter that it keeps happening every tick. "for i:=0 to -1 do" will just skip the loop, it will not loop backwards from 0 to -1 (you need to use "for i:=0 downto -1 do" to do that).

Your script will work fine in the next version of KaM Remake. For now you could make it work by destroying the houses/units on different ticks:
  Code:
if (States.StatArmyCount(1) = 0) then begin if (States.StatHouseCount(1) = 0) then begin ludzie:= States.PlayerGetAllUnits(1); for i:=0 to (length(ludzie)-1) do begin Actions.UnitKill(ludzie[i],true); end; end; budynki:= States.PlayerGetAllHouses(1); for i:=0 to (length(budynki)-1) do begin t:= States.HouseType(budynki[i]); x:= States.HousePositionX(budynki[i]); y:= States.HousePositionY(budynki[i]); Actions.HouseDestroy(budynki[i],true); Actions.GiveHouse(0, t, x, y); end; end;
As you can see units will be destroyed on the tick after the houses, which should stop the crash from happening :) But remember that your original script is ok, it's just there's a bug in the KaM Remake.

Using non-English names in scripts is a personal choice. It will make it harder for others to help you, but it's your script so it's your choice.

Re: Problem with give house to different player.

PostPosted: 26 Aug 2014, 15:56
by Adimax
I sent to you another error report two weeks ago. I'm afraid that for some reason have not received it so I sent it again.

Description of error:

The above solution is good, but does not have the "States.StatHouseCount". It would be good if in the future, this feature was available. I managed to replace it. The program works, everything is fine, but sometimes after running the script pops up a new bug.

My new code:
  Code:
begin if (States.StatArmyCount(1) = 0) then begin budynki:= States.PlayerGetAllHouses(1); if (length(budynki) = 0) then begin ludzie:= States.PlayerGetAllUnits(1); for i:=0 to (length(ludzie)-1) do begin Actions.UnitKill(ludzie[i],true); end; end; for i:=0 to (length(budynki)-1) do begin t:= States.HouseType(budynki[i]); x:= States.HousePositionX(budynki[i]); y:= States.HousePositionY(budynki[i]); Actions.HouseDestroy(budynki[i],true); Actions.GiveHouse(0, t, x, y); end; end;
New Error:

page: http://prntscr.com/4go2fo

Image

Re: Problem with give house to different player.

PostPosted: 26 Aug 2014, 17:08
by Skypper
The above solution is good, but does not have the "States.StatHouseCount". It would be good if in the future, this feature was available. I managed to replace it. The program works, everything is fine, but sometimes after running the script pops up a new bug.
That function is already made States.StatHouseTypeCount for a specific house or States.PlayerGetAllHouses and then get the amount of houses in the array.
Or did you mean something else?
https://code.google.com/p/castlesand/wi ... ptsDynamic

Re: Problem with give house to different player.

PostPosted: 26 Aug 2014, 20:34
by Adimax
I know this page.

I copied the solution sent to me by Lewin, and jumped me a message that "States.StatHouseCount" does not exist. On page from you does not have this feature. You can check it (ctrl + f).

But this is not a problem as I wrote I managed it for the same thing using a different code. The problem is that now I have the error from screen.

Re: Problem with give house to different player.

PostPosted: 27 Aug 2014, 08:03
by Lewin
Hi Adimax,
If you want support with a crash report it is probably best to contact us directly. We receive a lot of crash reports each day and mostly we don't look at crashes for r5503 anymore since we've fixed most of the bugs there, and we are currently busy fixing bugs in the beta version of the upcoming release.

The crash report you sent is still caused by the same situation as last time. Unfortunately there isn't really a way to avoid this bug affecting your script in r5503. Would you like to try the release candidate (beta version) of the upcoming release? This bug is fixed and there are new script commands that you might find useful. Send me your email address in a PM (private message) or by email and I can add you to our beta tester mailing list.
Cheers,
Lewin.