Page 9 of 24

Re: New Dynamic Script Ideas

PostPosted: 21 Nov 2013, 02:58
by Ben
Forgive me if I'm mistaken, but perhaps it doesn't work if the respective building is locked? The screen shows the stable is locked, (in normal circumstances anyway) and since the player can't actually change the distribution of corn to the stable himself, perhaps it can't be changed through scripts?

again, forgive me if I'm wrong. Scripts are not my forte, so I feel kinda like a noob here >.<

Re: New Dynamic Script Ideas

PostPosted: 21 Nov 2013, 04:56
by Lewin
Forgive me if I'm mistaken, but perhaps it doesn't work if the respective building is locked? The screen shows the stable is locked, (in normal circumstances anyway) and since the player can't actually change the distribution of corn to the stable himself, perhaps it can't be changed through scripts?

again, forgive me if I'm wrong. Scripts are not my forte, so I feel kinda like a noob here >.<
Ware distribution from the script works regardless of whether the house is locked.

@RandomLyrics: I'm having trouble understanding your code. Can you explain what it is supposed to be doing? In order to figure out why it isn't working I'd suggest doing stuff like this:
- Test a simplified version of it (e.g. remove all the Random and k stuff and just set it to a fixed value).
- Make it display debugging information on the overlay. For example, to make sure it is actually reaching the code inside the if-statements, add a command that sets the overlay to something (maybe the current tick count so you can see when the code is currently executing).
- After testing the script in game, check the latest log file (in the Logs folder) and see if there are any warnings/errors. If you use a command incorrectly (e.g. invalid parameters) it should be reported in the log file.

Debugging techniques like these should allow you to figure out why it isn't working.

Re: New Dynamic Script Ideas

PostPosted: 21 Nov 2013, 12:24
by RandomLyrics
im working on map where the number of pigs and flour in main storehouse represent +count to your army(1 pig - count) +ticks till die(1 flour - 75 ticks), and i want to player decide which tactic be choosen (more army or longer life ). The Script randomize distribution for AI and changes it each 10 min so the AI will be more 'human' and fun. 1 Corn ive get from 5 kills to main storehouse.
I awlays use ShowMsg to check whats happend , but in this case the GUI shows if the vaule was right.
i looked in the logs and found a lot of mistakes from previous scripts, but nothing with this WareDistribution ( ctrl +f ). Im starting to fix old scripts, after that getting into WareDistr. thanks for replay

logs are clear - zero mistakes.
With const values it doesnt work too.
here photo from random values:
Image Image

i think that when i give AI plaer Stables ( that are not allowed for all players ) it starts works unproperly. - changed to Farm - still the same, honstly i dont know why it desont work ;/

Script idea: Actions.ClearAllMsg(aPlayer: integer; Unread: boolean) - removes all read messages, if true removes read and unread. ( realy helps out while testing)

Re: New Dynamic Script Ideas

PostPosted: 22 Nov 2013, 00:09
by Lewin
Try breaking the problem down into something simpler. You said it doesn't work for constant values. Try making a script which sets the distribution in OnMissionStart, and contains nothing else. See if that works when the only thing in your script is that command. If not you might be using the command incorrectly, or there might be a mistake in the way we implemented the command.

You could also try checking that the values were set properly after the code is run. For example, when it sets the values make it display a message:
"Set corn mill distribution to 1"
then after it is set, use PlayerWareDistribution to check that it was set properly and print it out:
"PlayerWareDistribution says corn mill distribution is set to X" (make it display what PlayerWareDistribution returns with format or IntToStr).

Actually I just had another thought, is this problem applying only to AI players? (test your code on a non-AI player and see if it works differently) I'm not sure if AI players let you change their distribution, it might be fixed at the defaults (if this is the case we'll change it so you can set it from the script for AIs). I'll check this later and let you know.

Re: New Dynamic Script Ideas

PostPosted: 22 Nov 2013, 10:43
by RandomLyrics
OnMissionStart - Const value - Works.
After 10 mins - value changed - desont works. ( i disabled AI autobuilder etc )
it desont work for player and AI - they get lazy and take only 1 corn to pig farm or mill
ill check it with other vaules - the same - lazy serfs
  Code:
procedure OnTick; var j: integer; begin if ( States.GameTime = 6000 ) then begin Actions.PlayerWareDistribution(0, 9, 22, 5); //mill Actions.PlayerWareDistribution(0, 9, 16, 1); //pig farm Actions.ShowMsg(-1, '0: ' + IntToStr(States.PlayerWareDistribution(0, 9, 22)) + ' ' + IntToStr(States.PlayerWareDistribution(0, 9, 16))); Actions.PlayerWareDistribution(1, 9, 22, 2); //mill Actions.PlayerWareDistribution(1, 9, 16, 0); //pig farm Actions.ShowMsg(-1, '1: ' + IntToStr(States.PlayerWareDistribution(1, 9, 22)) + ' ' + IntToStr(States.PlayerWareDistribution(1, 9, 16))); Actions.PlayerWareDistribution(2, 9, 22, 0); //mill Actions.PlayerWareDistribution(2, 9, 16, 2); //pig farm Actions.ShowMsg(-1, '2: ' + IntToStr(States.PlayerWareDistribution(2, 9, 22)) + ' ' + IntToStr(States.PlayerWareDistribution(2, 9, 16))); end; end; // ON MISSION START procedure OnMissionStart; var j, k: integer; begin Actions.PlayerWareDistribution(0, 9, 22, 2); //mill Actions.PlayerWareDistribution(0, 9, 16, 3); //pig farm Actions.ShowMsg(-1, '0: ' + IntToStr(States.PlayerWareDistribution(0, 9, 22)) + ' ' + IntToStr(States.PlayerWareDistribution(0, 9, 16))); Actions.PlayerWareDistribution(1, 9, 22, 1); //mill Actions.PlayerWareDistribution(1, 9, 16, 5); //pig farm Actions.ShowMsg(-1, '1: ' + IntToStr(States.PlayerWareDistribution(1, 9, 22)) + ' ' + IntToStr(States.PlayerWareDistribution(1, 9, 16))); Actions.PlayerWareDistribution(2, 9, 22, 5); //mill Actions.PlayerWareDistribution(2, 9, 16, 1); //pig farm Actions.ShowMsg(-1, '2: ' + IntToStr(States.PlayerWareDistribution(2, 9, 22)) + ' ' + IntToStr(States.PlayerWareDistribution(2, 9, 16))); end;
Image
TestDistribution.rar

Re: New Dynamic Script Ideas

PostPosted: 22 Nov 2013, 11:02
by Lewin
What isn't working in the "after 10 minutes" case? The message in your screenshots seems to show that it is working.

Re: New Dynamic Script Ideas

PostPosted: 22 Nov 2013, 11:30
by RandomLyrics
the distribution says 2 corn per pig farm, and serf takes only 1 corn , i changed it to 5 per pig farm and they still carring only 1 corn, waiting till animal breedes used this 1 corn , when pig farm has 0 corn they carring another one. Its wrong in my opinion
look at amount of corn in buildings
Changed using script ( left new value - right old value (setted onmission start) ( 1 corn pig farm - 1 corn mill )
Image
Changed manually: ( works perfectly ) ( 5 corn in pig farm - 1 in mill as it should be)
Image
Here using script, set the same dristribution for both players ( red and teal):
Image

Re: New Dynamic Script Ideas

PostPosted: 22 Nov 2013, 12:37
by Lewin
Hi RandomLyrics,
Thanks for your help and patience with debugging this issue. I have discovered the cause of the problem, Actions.PlayerWareDistribution does not update house orders, so they will not notice that the distribution has changed. I have now fixed this bug so house orders will be updated when using that command.

I've uploaded a new nightly build, if you are interested please test it and check that it is fixed. Remember to keep a backup of your original r5503 game folder. The nightly build should be installed separately. Thank you for your help in finding this bug :)

Re: New Dynamic Script Ideas

PostPosted: 22 Nov 2013, 12:51
by RandomLyrics
Okey, ill test and report if somth works improperly :) thanks for your replay and fixing it so fast :D.

Re: New Dynamic Script Ideas

PostPosted: 23 Nov 2013, 18:14
by Ben
Could we have a script that highlights a certain button/entity? We already have play .mp3, but highlighting a certain button, unit, building, etc. would be GREAT for giving a tutorial with actual voicing. I don't have a great voice for story telling/briefing, but I think I can do a fine job voicing an English tutorial.

Re: New Dynamic Script Ideas

PostPosted: 24 Nov 2013, 03:14
by Lewin
Could we have a script that highlights a certain button/entity? We already have play .mp3, but highlighting a certain button, unit, building, etc. would be GREAT for giving a tutorial with actual voicing. I don't have a great voice for story telling/briefing, but I think I can do a fine job voicing an English tutorial.
A more interactive tutorial would be great, so I think we could consider adding commands to highlight the buttons that would be needed in the tutorial. Even without a voiceover it would greatly improve the tutorial if it highlighted stuff like the build button rather than just sending a message to the player saying "press the hammer button".

Re: New Dynamic Script Ideas

PostPosted: 24 Nov 2013, 04:13
by Ben
Could we have a script that highlights a certain button/entity? We already have play .mp3, but highlighting a certain button, unit, building, etc. would be GREAT for giving a tutorial with actual voicing. I don't have a great voice for story telling/briefing, but I think I can do a fine job voicing an English tutorial.
A more interactive tutorial would be great, so I think we could consider adding commands to highlight the buttons that would be needed in the tutorial. Even without a voiceover it would greatly improve the tutorial if it highlighted stuff like the build button rather than just sending a message to the player saying "press the hammer button".
Indeed, but do you think having a voiceover would still be nice?

Re: New Dynamic Script Ideas

PostPosted: 24 Nov 2013, 05:29
by Lewin
Indeed, but do you think having a voiceover would still be nice?
Yes definitely :)

Re: New Dynamic Script Ideas

PostPosted: 27 Nov 2013, 01:48
by RandomLyrics
UnitPositionSet(aUnit, X, Y: integer) - need this to RPG etc.
HouseSubtractWaresTo(aHouse, aWareType, aAmount: integer)

Re: New Dynamic Script Ideas

PostPosted: 27 Nov 2013, 11:35
by sado1
UnitPositionSet(aUnit, X, Y: integer) - need this to RPG etc.
HouseSubtractWaresTo(aHouse, aWareType, aAmount: integer)
1.
  Code:
procedure UnitPositionSet(aUnit, X, Y: Integer); var X, Y, UnitType, Player: Integer; begin Player := States.UnitOwner(aUnit); UnitType := States.UnitType(aUnit); X := States.UnitPositionX(aUnit); Y := States.UnitPositionY(aUnit); Actions.UnitKill(aUnit, True); Actions.GiveUnit(Player, UnitType, X, Y, 0);
2. Already asked for that, I was told that it's a bit complicated to implement without breaking the game, so it might take a while. (You can always silently destroy the house and create it again with less resources, if that's applicable to whatever you need to use it for)