Map Database  •  FAQ  •  RSS  •  Login

Dynamic Script Usage Questions

<<

Vatrix

User avatar

Council Member

Posts: 410

Joined: 19 Apr 2013, 20:30

KaM Skill Level: Veteran

Location: Czech Republic

Post 11 Aug 2015, 18:41

Re: Dynamic Script Usage Questions

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. :P
Thank you very much ;)
I fixed The Shattered Kingdom and The Peasants Rebellion here!
<<

thibmo

User avatar

Council Member

Posts: 124

Joined: 03 Aug 2015, 09:12

KaM Skill Level: Skilled

Website: https://kp-wiki.org/

Location: the Netherlands

Post 11 Aug 2015, 18:41

Re: Dynamic Script Usage Questions

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)
~~ The magic wizard of PascalScriptus. ~~

KP-Wiki :
  • Information about Knights Province scripting ( unofficial )
  • Information about several hosting/server maintenance basics
  • Other random stuff
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 11 Aug 2015, 19:15

Re: Dynamic Script Usage Questions

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;
<<

thibmo

User avatar

Council Member

Posts: 124

Joined: 03 Aug 2015, 09:12

KaM Skill Level: Skilled

Website: https://kp-wiki.org/

Location: the Netherlands

Post 11 Aug 2015, 19:20

Re: Dynamic Script Usage Questions

Darn, you were faster. :P
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;
~~ The magic wizard of PascalScriptus. ~~

KP-Wiki :
  • Information about Knights Province scripting ( unofficial )
  • Information about several hosting/server maintenance basics
  • Other random stuff
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 11 Aug 2015, 19:38

Re: Dynamic Script Usage Questions

Nice job! :P
I like the way you did it better tbh. I made it way too complicated.
<<

thibmo

User avatar

Council Member

Posts: 124

Joined: 03 Aug 2015, 09:12

KaM Skill Level: Skilled

Website: https://kp-wiki.org/

Location: the Netherlands

Post 11 Aug 2015, 20:23

Re: Dynamic Script Usage Questions

Well, yours would be less trail and error, though.
My solution works for this map only, whereas yours works for nearly any map.
~~ The magic wizard of PascalScriptus. ~~

KP-Wiki :
  • Information about Knights Province scripting ( unofficial )
  • Information about several hosting/server maintenance basics
  • Other random stuff
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 18 Aug 2015, 17:44

Re: Dynamic Script Usage Questions

Is
  Code:
Actions.AIGroupsFormationSet
working? Every Time I use it, i get fallowing error when starting up the map:

Image
<<

thibmo

User avatar

Council Member

Posts: 124

Joined: 03 Aug 2015, 09:12

KaM Skill Level: Skilled

Website: https://kp-wiki.org/

Location: the Netherlands

Post 19 Aug 2015, 06:07

Re: Dynamic Script Usage Questions

Is
  Code:
Actions.AIGroupsFormationSet
working? Every Time I use it, i get fallowing error when starting up the map:

Image
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.
~~ The magic wizard of PascalScriptus. ~~

KP-Wiki :
  • Information about Knights Province scripting ( unofficial )
  • Information about several hosting/server maintenance basics
  • Other random stuff
<<

Strangelove

User avatar

Crossbowman

Posts: 230

Joined: 30 Jul 2013, 06:32

KaM Skill Level: Fair

Post 19 Aug 2015, 13:24

Re: Dynamic Script Usage Questions

  Code:
procedure OnMissionStart(); begin //Check Formation of Player1s Melee-Groups Actions.AIGroupsFormationSet(1, 0, 15, 5); end;
<<

thibmo

User avatar

Council Member

Posts: 124

Joined: 03 Aug 2015, 09:12

KaM Skill Level: Skilled

Website: https://kp-wiki.org/

Location: the Netherlands

Post 19 Aug 2015, 13:33

Re: Dynamic Script Usage Questions

  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. :)
~~ The magic wizard of PascalScriptus. ~~

KP-Wiki :
  • Information about Knights Province scripting ( unofficial )
  • Information about several hosting/server maintenance basics
  • Other random stuff
<<

sado1

User avatar

Council Member

Posts: 1430

Joined: 21 May 2012, 19:13

KaM Skill Level: Skilled

Post 02 May 2016, 09:50

Re: Dynamic Script Usage Questions

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?
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 06 May 2016, 13:03

Re: Dynamic Script Usage Questions

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...
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"
<<

sado1

User avatar

Council Member

Posts: 1430

Joined: 21 May 2012, 19:13

KaM Skill Level: Skilled

Post 06 May 2016, 14:20

Re: Dynamic Script Usage Questions

I thought you somehow knew how to export data to a file, but seems like I was mistaken... nevermind :P I want to be able to export game statistics from script to a (csv?) file somehow. Thanks for the suggestion on recruits.
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 06 May 2016, 14:25

Re: Dynamic Script Usage Questions

I thought you somehow knew how to export data to a file, but seems like I was mistaken... nevermind :P 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.
Just when you think you know something, you have to look at it in another way, even though it may seem silly or wrong. You must try! - John Keating, "Dead Poets Society"

Return to “Dynamic Scripting”

Who is online

Users browsing this forum: No registered users and 8 guests