Page 26 of 26
Re: Dynamic Script Usage Questions
PostPosted: 11 Aug 2015, 18:41
by Vatrix
I have some fog revealers in static script and I want to see only what those revealers revealed (you can look on them in mapED if you download TPR1) and not what my ally revealed on mission start.
Hm, tried a couple of things, but nothing seems to be working. I seems like the vision from the allies is somehow applies before the OnMissionStart() procedure. However, I'll try something else and get back to you.

Thank you very much

Re: Dynamic Script Usage Questions
PostPosted: 11 Aug 2015, 18:41
by thibmo
That does not do what I want

. Look into fast chat for more info.
I am afraid it's gone, but if I understand well you only want to show what the FoW reveal points give and hide initial allied vision?
- Code:
procedure OnMissionStart;
begin
//Disables Sharing Fog With Ally
Actions.PlayerShareFog(1, 0, False); // Set fog share of player 1 to player 0 as false
Actions.PlayerShareFog(2, 0, False); // Set fog share of player 2 to player 0 as false
Actions.FogCoverCircle(0, 9, 10, 10); // PlayerId, LocationX, LocationY, Radius
Actions.FogCoverCircle(0, 56, 7, 10); // PlayerId, LocationX, LocationY, Radius
end;
This covered it all up nicely in my test case(2 allied AI and one normal player)
Re: Dynamic Script Usage Questions
PostPosted: 11 Aug 2015, 19:15
by Strangelove
This should do everything you wanted. You can remove the Fog-Reveal-circles from the StaticScript now.
- Code:
procedure OnMissionStart();
var i, j: Integer;
var aUnits, aHouses: array of Integer;
var XU, YU, XH, YH: array[0..255] of Byte;
begin
//Stops Sharing Fog with Allies
Actions.PlayerShareFog(0, 1, False);
Actions.PlayerShareFog(1, 0, False);
Actions.PlayerShareFog(0, 2, False);
Actions.PlayerShareFog(2, 0, False);
//Covers up all of Players Vision
Actions.FogCoverAll(0);
//Reveals Terrain for Units and Buildings
aUnits := States.PlayerGetAllUnits(0);
for i := 0 to Length(aUnits)-1 do
begin
XU[i] := States.UnitPositionX(aUnits[i]);
YU[i] := States.UnitPositionY(aUnits[i]);
Actions.FogRevealCircle(0, XU[i], YU[i], 8);
end;
aHouses := States.PlayerGetAllHouses(0);
for j := 0 to Length(aHouses)-1 do
begin
XH[j] := States.HousePositionX(aHouses[j]);
YH[j] := States.HousePositionY(aHouses[j]);
Actions.FogRevealCircle(0, XH[j], YH[j], 15);
end;
//Reveal the rest manually
Actions.FogRevealCircle(0, 25, 12, 17);
Actions.FogRevealCircle(0, 11, 21, 18);
Actions.FogRevealCircle(0, 19, 34, 12);
Actions.FogRevealCircle(0, 41, 21, 16);
Actions.FogRevealCircle(0, 54, 29, 17);
Actions.FogRevealCircle(0, 37, 34, 11);
Actions.FogRevealCircle(0, 49, 45, 8);
Actions.FogRevealCircle(0, 35, 34, 12);
end;
procedure OnTick;
begin
if States.GameTime = 100 then
Actions.ShowMsg(0, '<$0>');
end;
Re: Dynamic Script Usage Questions
PostPosted: 11 Aug 2015, 19:20
by thibmo
Darn, you were faster.

But this is another method
- Code:
procedure OnMissionStart;
begin
Actions.PlayerShareFog(1, 0, False); // Set fog share of player 1 to player 0 as false
Actions.PlayerShareFog(2, 0, False); // Set fog share of player 2 to player 0 as false
// Cover all the ugly map spoiling
Actions.FogCoverCircle(0, 8, 25, 32);
Actions.FogCoverCircle(0, 33, 21, 25);
Actions.FogCoverCircle(0, 52, 19, 20);
// Reveal the spots again
Actions.FogRevealCircle(0, 11, 21, 18);
Actions.FogRevealCircle(0, 19, 34, 12);
Actions.FogRevealCircle(0, 25, 12, 17);
Actions.FogRevealCircle(0, 35, 44, 12);
Actions.FogRevealCircle(0, 41, 21, 16);
Actions.FogRevealCircle(0, 49, 45, 8);
Actions.FogRevealCircle(0, 54, 29, 17);
end;
procedure OnTick;
begin
if States.GameTime = 100 then
Actions.ShowMsg(0, '<$0>');
end;
Re: Dynamic Script Usage Questions
PostPosted: 11 Aug 2015, 19:38
by Strangelove
Nice job!

I like the way you did it better tbh. I made it way too complicated.
Re: Dynamic Script Usage Questions
PostPosted: 11 Aug 2015, 20:23
by thibmo
Well, yours would be less trail and error, though.
My solution works for this map only, whereas yours works for nearly any map.
Re: Dynamic Script Usage Questions
PostPosted: 18 Aug 2015, 17:44
by Strangelove
Is
- Code:
Actions.AIGroupsFormationSet
working? Every Time I use it, i get fallowing error when starting up the map:

Re: Dynamic Script Usage Questions
PostPosted: 19 Aug 2015, 06:07
by thibmo
Is
- Code:
Actions.AIGroupsFormationSet
working? Every Time I use it, i get fallowing error when starting up the map:

Could you provide a code example?
The current format should be
- Code:
Actions.AIGroupsFormationSet(aPlayerId, aGroupType: Byte; aUnitCount, aColumns: Word);
@Forum admins: Could you please include syntax highlighting for Pascal? This would help a lot in readability.
Re: Dynamic Script Usage Questions
PostPosted: 19 Aug 2015, 13:24
by Strangelove
- Code:
procedure OnMissionStart();
begin
//Check Formation of Player1s Melee-Groups
Actions.AIGroupsFormationSet(1, 0, 15, 5);
end;
Re: Dynamic Script Usage Questions
PostPosted: 19 Aug 2015, 13:33
by thibmo
- Code:
procedure OnMissionStart();
begin
//Check Formation of Player1s Melee-Groups
Actions.AIGroupsFormationSet(1, 0, 15, 5);
end;
So you want the melee types to be:
. . . . .
. . . . .
. . . . .
I'll check it in a second.

Re: Dynamic Script Usage Questions
PostPosted: 02 May 2016, 09:50
by sado1
1. There once was a script that copied a map tile by tile using a text file. Does anyone know where to find it? I've seen in on the forums but I can't find it anymore.
2. Is there a way to use the map name in a script?
3. How to detect when there's no peacetime set? edit: "if States.PeaceTime <> 0" works, my bad
edit
4. How to count the number of recruits in the Barracks?
Re: Dynamic Script Usage Questions
PostPosted: 06 May 2016, 13:03
by Esthlos
1. There once was a script that copied a map tile by tile using a text file. Does anyone know where to find it? I've seen in on the forums but I can't find it anymore.
If you're referring to the one I made (
http://www.knightsandmerchants.net/foru ... 089#p42089), it was just a proof of concept... I'm pretty sure I never uploaded the "copying" script anyway (just the "printing" one), and I may not even have it anymore.
What would you need it for?
4. How to count the number of recruits in the Barracks?
As far as I know there isn't a function for that... maybe you could get the units' array, check for type 13 (recruit), then check the housetype of their States.UnitHome (21 is the barracks), and count them?
Or, a little faster but less accurate, you could get the number of units type 13 and subtract the number of towers...
Re: Dynamic Script Usage Questions
PostPosted: 06 May 2016, 14:20
by sado1
I thought you somehow knew how to export data to a file, but seems like I was mistaken... nevermind

I want to be able to export game statistics from script to a (csv?) file somehow. Thanks for the suggestion on recruits.
Re: Dynamic Script Usage Questions
PostPosted: 06 May 2016, 14:25
by Esthlos
I thought you somehow knew how to export data to a file, but seems like I was mistaken... nevermind

I want to be able to export game statistics from script to a (csv?) file somehow.
As far as I know you can only export to the log file... the devs made it this way so that it isn't possible at all to spread malicious code through KaM scripted maps.
Thanks for the suggestion on recruits.
No problem.