Map Database  •  FAQ  •  RSS  •  Login

Dynamic Script Usage Questions

<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 09 Sep 2014, 01:15

Re: Dynamic Script Usage

Quick question: do Dynamic Scripts support file writing/reading?
For example, if someone wanted to keep track of a player's army across multiple missions, would it be possible to store and load values in and from an external file?
No ;/ but that could be nice option, for example if u complete quest from mission 1 ull get 10 barbarians in mission 2 or smth like that :>
There's several problems with writing files:
1) It breaks consistency, when you run the replay the file might have different contents so it would crash the replay. Also obviously in multiplayer everyone could have a different file.
2) Scripts might be able to install viruses, extract private data from the HDD, or other unwanted things.

A better way to achieve your goals would be to allowing storing data which is attached to the campaign, and would be included in the save files so replays would still work. There's still other issues which need to be considered, but something like that would be a lot better than allowing the script to read/write files.

I'll add it to our proposals list.
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 09 Sep 2014, 06:29

Re: Dynamic Script Usage

I'll add it to our proposals list.
Thank you.
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"
<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 17 Sep 2014, 18:52

Re: Dynamic Script Usage

Hello,
I plan make Campaign and what wrote Esthlos is very good idea.
By mine scripts what Player did in mission 1, some things will be transfer to mission 2.
Ofc by using scripts is many ways what can be "save".
I thought about some idea how to transfer to next mission.
For example i build in mine village in mission 1 Bakery and Farm.
So by script On house built , check type house and it was Bakery and Farm
so 7 as bakery and 8 as farm will be save.

At the end mission we get message:
"Your builded was remember, to keep it You must on next mission on StoreHouse
block some wares. Do then and block Coal, Stone).
Next by script we get instantly that 2 houses.
if (States.HouseWareBlocked(iStore, 5)) and (States.HouseWareBlocked(iStore, 1)) = true
Its mine simple example :-)
Exacly like code +10 each wares in Store House or Instantly win mission :-)
(By scripts we can add much more thinks)
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 19 Sep 2014, 12:46

Re: Dynamic Script Usage

Yes, I'm planning to add a feature for storing global campaign data that is retained between missions :)
<<

Brolian

User avatar

Recruit

Posts: 36

Joined: 16 Sep 2014, 19:45

KaM Skill Level: Skilled

Location: Poland

Post 19 Sep 2014, 15:48

Re: Dynamic Script Usage

Oh my, really if KaM:Remake can save our actions, in future. That be very good for story line, we added "quest" in mission 1, but player do not made it.
Then in mission 5 player meet that same Unit who able to give quest on mission 1, now can tell to player " i do not wanna talk with You, u did not help me!"
One mouth ago i do not believe that can be able to make missions/campaigns with full story line. Like Warcraft 3.
But its not all! I think, because i know some how editor from Warcraft 3 work, and i must say, KaM:remake now is more interesting then Warcraft 3.
And i as editor mission in K&M i can make much more things then in warcraft 3! After new release possibilities grow up.
My self i do not believe but its true we can meet Campaigns with good story line and even better then in Warcraft 3. :-)
<<

Lewin

User avatar

KaM Remake Developer

Posts: 3822

Joined: 16 Sep 2007, 22:00

KaM Skill Level: Skilled

ICQ: 269127056

Website: http://lewin.hodgman.id.au

Yahoo Messenger: lewinlewinhodgman

Location: Australia

Post 20 Sep 2014, 12:39

Re: Dynamic Script Usage

Oh my, really if KaM:Remake can save our actions, in future. That be very good for story line, we added "quest" in mission 1, but player do not made it.
Then in mission 5 player meet that same Unit who able to give quest on mission 1, now can tell to player " i do not wanna talk with You, u did not help me!"
One mouth ago i do not believe that can be able to make missions/campaigns with full story line. Like Warcraft 3.
But its not all! I think, because i know some how editor from Warcraft 3 work, and i must say, KaM:remake now is more interesting then Warcraft 3.
And i as editor mission in K&M i can make much more things then in warcraft 3! After new release possibilities grow up.
My self i do not believe but its true we can meet Campaigns with good story line and even better then in Warcraft 3. :-)
I agree, it could allow for more interesting campaigns. This feature has been implemented so you can start testing it when RC3 is released :) See description near the top of the wiki for more information.
<<

sado1

User avatar

Council Member

Posts: 1430

Joined: 21 May 2012, 19:13

KaM Skill Level: Skilled

Post 18 Oct 2014, 11:45

Re: Dynamic Script Usage

A bs question to devs: would it be possible to add one of the two heart UTF symbols (heavy black heart hex 2764, black heart suit hex 2665) to the KaM overlay font? I wanted to use the symbol for showing lives count (as in, health - you die once, the script takes away 1 "heart" from the overlay, you lose all the lives - you lose the entire game) in the overlay on one of my maps, but it didn't work - I tried to use #X (where X is decimal symbol of the UTF character) which works for another more common character, so I guess it's a question of availability of the character.
Yeah those characters are not in our fonts. I guess we could add the entire Miscellaneous Symbols block, it probably won't increase texture RAM usage by a noticeable amount (256 extra symbols compared to ~20k that Chinese adds). Anyone else have an opinion or suggestion for unicode symbols we need to add?
Did anything change regarding my idea? Doesn't seem like it works in RC3 so probably not.
<<

Vatrix

User avatar

Council Member

Posts: 410

Joined: 19 Apr 2013, 20:30

KaM Skill Level: Veteran

Location: Czech Republic

Post 20 Nov 2014, 20:09

Re: Dynamic Script Usage

I need some help with script, because I'm total noob in this type of programming. How do I assign group of soldiers which is already put on map at some coordinates to variable (Like AxeGroup or sth like that). I think there's really easy way, can you please write code here?
I fixed The Shattered Kingdom and The Peasants Rebellion here!
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 20 Nov 2014, 21:30

Re: Dynamic Script Usage

I need some help with script, because I'm total noob in this type of programming. How do I assign group of soldiers which is already put on map at some coordinates to variable (Like AxeGroup or sth like that). I think there's really easy way, can you please write code here?
  Code:
AxeGroup := States.GroupAt(X, Y);
Before that, you must declare AxeGroup to be an Integer:
  Code:
var AxeGroup: Integer;
If you declare it at the start of the script it will be a global variable, usable by all of your script.
If you declare it at the start of a procedure, it will exist only within that procedure.

http://code.google.com/p/castlesand/wik ... ptsDynamic

http://code.google.com/p/castlesand/wik ... ptsLookups

https://code.google.com/p/castlesand/wi ... icTutorial
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"
<<

Vatrix

User avatar

Council Member

Posts: 410

Joined: 19 Apr 2013, 20:30

KaM Skill Level: Veteran

Location: Czech Republic

Post 21 Nov 2014, 10:55

Re: Dynamic Script Usage Questions

Yes, but how to assign it to them forever, like I want them to move twice? Then it gives me error, because that group is not at coordinates, from where I was assigning them to variable.

Like:
  Code:
var KnightsTop, KnightsBottom: Integer procedure OnTick; begin KnightsTop:= States.GroupAt (56,25); KnightsBottom:= States.GroupAt (56,35); if States.GameTime = 300 then begin Actions.GroupOrderWalk (KnightsTop, 34. 28, 6); Actions.GroupOrderWalk (KnightsBottom, 34, 34, 6); end; //this part is not working if States.GameTime = 600 then begin Actions.GroupOrderWalk (KnightsTop, 1, 1, 6); end; end;
We are speaking about script for TSK13.
I fixed The Shattered Kingdom and The Peasants Rebellion here!
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 21 Nov 2014, 11:41

Re: Dynamic Script Usage Questions

Try
  Code:
var KnightsTop, KnightsBottom: Integer procedure OnMissionStart; begin KnightsTop:= States.GroupAt (56,25); KnightsBottom:= States.GroupAt (56,35); end; procedure OnTick; begin if States.GameTime = 300 then begin Actions.GroupOrderWalk (KnightsTop, 34. 28, 6); Actions.GroupOrderWalk (KnightsBottom, 34, 34, 6); end; //this part is not working if States.GameTime = 600 then begin Actions.GroupOrderWalk (KnightsTop, 1, 1, 6); end; end;
If you set it OnTick, it will change every 0,1 seconds... and as soon as they start to move, the variable is set to -1 :P

Try to set it once OnMissionStart :wink:
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"
<<

Vatrix

User avatar

Council Member

Posts: 410

Joined: 19 Apr 2013, 20:30

KaM Skill Level: Veteran

Location: Czech Republic

Post 21 Nov 2014, 12:55

Re: Dynamic Script Usage Questions

Nah, I'm so stupid :$

I did it right at the beginning, but then I changed it, so it didn't work. Thanks for help :mrgreen: .
I fixed The Shattered Kingdom and The Peasants Rebellion here!
<<

Vatrix

User avatar

Council Member

Posts: 410

Joined: 19 Apr 2013, 20:30

KaM Skill Level: Veteran

Location: Czech Republic

Post 21 Nov 2014, 20:52

Re: Dynamic Script Usage Questions

  Code:
var iAttack : array[1..4] of Integer; var i: Integer; procedure OnMissionStart; begin iAttack[1] := States.GroupAt(46, 73); iAttack[2] := States.GroupAt(54, 71); iAttack[3] := States.GroupAt(58, 63); iAttack[4] := States.GroupAt(51, 62); end; procedure OnUnitAttacked(aUnitID, aAttackerID: Integer); begin if States.UnitOwner(aUnitID) = 4 then for i := 1 to 4 do begin Actions.GroupOrderHalt(iAttack[i]); end; end;
They're stopping every hit, I just want them to stop once.

*edit: I have fixed it.
I fixed The Shattered Kingdom and The Peasants Rebellion here!
<<

Vatrix

User avatar

Council Member

Posts: 410

Joined: 19 Apr 2013, 20:30

KaM Skill Level: Veteran

Location: Czech Republic

Post 29 Nov 2014, 13:56

Re: Dynamic Script Usage Questions

Hello guys,
I need some help again.

I'm sure this can be written in a better way:
  Code:
var iStorehouseAi1, iStorehouseAi2, iStorehouseAi3: Integer; procedure OnMissionStart; begin iStorehouseAi1:= States.HouseAt(108, 31); iStorehouseAi2:= States.HouseAt(108, 50); iStorehouseAi3:= States.HouseAt(114, 17); Actions.HouseWareBlock(iStorehouseAi1, 0, true); //tree trunks Actions.HouseWareBlock(iStorehouseAi1, 3, true); //iron ore Actions.HouseWareBlock(iStorehouseAi1, 4, true); //gold ore Actions.HouseWareBlock(iStorehouseAi1, 5, true); //coal Actions.HouseWareBlock(iStorehouseAi1, 6, true); //iron Actions.HouseWareBlock(iStorehouseAi1, 9, true); //corn Actions.HouseWareBlock(iStorehouseAi1, 11, true); //flour Actions.HouseWareBlock(iStorehouseAi1, 14, true); //pigs Actions.HouseWareBlock(iStorehouseAi1, 15, true); //skins Actions.HouseWareBlock(iStorehouseAi1, 16, true); //wooden shields Actions.HouseWareBlock(iStorehouseAi1, 17, true); //long shields Actions.HouseWareBlock(iStorehouseAi1, 18, true); //leather armours Actions.HouseWareBlock(iStorehouseAi1, 19, true); //iron armaments Actions.HouseWareBlock(iStorehouseAi1, 20, true); //axes Actions.HouseWareBlock(iStorehouseAi1, 21, true); //swords Actions.HouseWareBlock(iStorehouseAi1, 22, true); //lances Actions.HouseWareBlock(iStorehouseAi1, 23, true); //pikes Actions.HouseWareBlock(iStorehouseAi1, 24, true); //longbows Actions.HouseWareBlock(iStorehouseAi1, 25, true); //crossbows Actions.HouseWareBlock(iStorehouseAi1, 26, true); //horses Actions.HouseWareBlock(iStorehouseAi2, 0, true); //tree trunks Actions.HouseWareBlock(iStorehouseAi2, 3, true); //iron ore Actions.HouseWareBlock(iStorehouseAi2, 4, true); //gold ore Actions.HouseWareBlock(iStorehouseAi2, 5, true); //coal Actions.HouseWareBlock(iStorehouseAi2, 6, true); //iron Actions.HouseWareBlock(iStorehouseAi2, 9, true); //corn Actions.HouseWareBlock(iStorehouseAi2, 11, true); //flour Actions.HouseWareBlock(iStorehouseAi2, 14, true); //pigs Actions.HouseWareBlock(iStorehouseAi2, 15, true); //skins Actions.HouseWareBlock(iStorehouseAi2, 16, true); //wooden shields Actions.HouseWareBlock(iStorehouseAi2, 17, true); //long shields Actions.HouseWareBlock(iStorehouseAi2, 18, true); //leather armours Actions.HouseWareBlock(iStorehouseAi2, 19, true); //iron armaments Actions.HouseWareBlock(iStorehouseAi2, 20, true); //axes Actions.HouseWareBlock(iStorehouseAi2, 21, true); //swords Actions.HouseWareBlock(iStorehouseAi2, 22, true); //lances Actions.HouseWareBlock(iStorehouseAi2, 23, true); //pikes Actions.HouseWareBlock(iStorehouseAi2, 24, true); //longbows Actions.HouseWareBlock(iStorehouseAi2, 25, true); //crossbows Actions.HouseWareBlock(iStorehouseAi2, 26, true); //horses Actions.HouseWareBlock(iStorehouseAi3, 0, true); //tree trunks Actions.HouseWareBlock(iStorehouseAi3, 3, true); //iron ore Actions.HouseWareBlock(iStorehouseAi3, 4, true); //gold ore Actions.HouseWareBlock(iStorehouseAi3, 5, true); //coal Actions.HouseWareBlock(iStorehouseAi3, 6, true); //iron Actions.HouseWareBlock(iStorehouseAi3, 9, true); //corn Actions.HouseWareBlock(iStorehouseAi3, 11, true); //flour Actions.HouseWareBlock(iStorehouseAi3, 14, true); //pigs Actions.HouseWareBlock(iStorehouseAi3, 15, true); //skins Actions.HouseWareBlock(iStorehouseAi3, 16, true); //wooden shields Actions.HouseWareBlock(iStorehouseAi3, 17, true); //long shields Actions.HouseWareBlock(iStorehouseAi3, 18, true); //leather armours Actions.HouseWareBlock(iStorehouseAi3, 19, true); //iron armaments Actions.HouseWareBlock(iStorehouseAi3, 20, true); //axes Actions.HouseWareBlock(iStorehouseAi3, 21, true); //swords Actions.HouseWareBlock(iStorehouseAi3, 22, true); //lances Actions.HouseWareBlock(iStorehouseAi3, 23, true); //pikes Actions.HouseWareBlock(iStorehouseAi3, 24, true); //longbows Actions.HouseWareBlock(iStorehouseAi3, 25, true); //crossbows Actions.HouseWareBlock(iStorehouseAi3, 26, true); //horses end;
I fixed The Shattered Kingdom and The Peasants Rebellion here!
<<

Esthlos

User avatar

Knight

Posts: 676

Joined: 23 Jun 2013, 16:02

KaM Skill Level: Beginner

Post 29 Nov 2014, 14:26

Re: Dynamic Script Usage Questions

Hello guys,
I need some help again.

I'm sure this can be written in a better way:
  Code:
var iStorehouseAi1, iStorehouseAi2, iStorehouseAi3: Integer; procedure OnMissionStart; begin iStorehouseAi1:= States.HouseAt(108, 31); iStorehouseAi2:= States.HouseAt(108, 50); iStorehouseAi3:= States.HouseAt(114, 17); Actions.HouseWareBlock(iStorehouseAi1, 0, true); //tree trunks Actions.HouseWareBlock(iStorehouseAi1, 3, true); //iron ore Actions.HouseWareBlock(iStorehouseAi1, 4, true); //gold ore Actions.HouseWareBlock(iStorehouseAi1, 5, true); //coal Actions.HouseWareBlock(iStorehouseAi1, 6, true); //iron Actions.HouseWareBlock(iStorehouseAi1, 9, true); //corn Actions.HouseWareBlock(iStorehouseAi1, 11, true); //flour Actions.HouseWareBlock(iStorehouseAi1, 14, true); //pigs Actions.HouseWareBlock(iStorehouseAi1, 15, true); //skins Actions.HouseWareBlock(iStorehouseAi1, 16, true); //wooden shields Actions.HouseWareBlock(iStorehouseAi1, 17, true); //long shields Actions.HouseWareBlock(iStorehouseAi1, 18, true); //leather armours Actions.HouseWareBlock(iStorehouseAi1, 19, true); //iron armaments Actions.HouseWareBlock(iStorehouseAi1, 20, true); //axes Actions.HouseWareBlock(iStorehouseAi1, 21, true); //swords Actions.HouseWareBlock(iStorehouseAi1, 22, true); //lances Actions.HouseWareBlock(iStorehouseAi1, 23, true); //pikes Actions.HouseWareBlock(iStorehouseAi1, 24, true); //longbows Actions.HouseWareBlock(iStorehouseAi1, 25, true); //crossbows Actions.HouseWareBlock(iStorehouseAi1, 26, true); //horses Actions.HouseWareBlock(iStorehouseAi2, 0, true); //tree trunks Actions.HouseWareBlock(iStorehouseAi2, 3, true); //iron ore Actions.HouseWareBlock(iStorehouseAi2, 4, true); //gold ore Actions.HouseWareBlock(iStorehouseAi2, 5, true); //coal Actions.HouseWareBlock(iStorehouseAi2, 6, true); //iron Actions.HouseWareBlock(iStorehouseAi2, 9, true); //corn Actions.HouseWareBlock(iStorehouseAi2, 11, true); //flour Actions.HouseWareBlock(iStorehouseAi2, 14, true); //pigs Actions.HouseWareBlock(iStorehouseAi2, 15, true); //skins Actions.HouseWareBlock(iStorehouseAi2, 16, true); //wooden shields Actions.HouseWareBlock(iStorehouseAi2, 17, true); //long shields Actions.HouseWareBlock(iStorehouseAi2, 18, true); //leather armours Actions.HouseWareBlock(iStorehouseAi2, 19, true); //iron armaments Actions.HouseWareBlock(iStorehouseAi2, 20, true); //axes Actions.HouseWareBlock(iStorehouseAi2, 21, true); //swords Actions.HouseWareBlock(iStorehouseAi2, 22, true); //lances Actions.HouseWareBlock(iStorehouseAi2, 23, true); //pikes Actions.HouseWareBlock(iStorehouseAi2, 24, true); //longbows Actions.HouseWareBlock(iStorehouseAi2, 25, true); //crossbows Actions.HouseWareBlock(iStorehouseAi2, 26, true); //horses Actions.HouseWareBlock(iStorehouseAi3, 0, true); //tree trunks Actions.HouseWareBlock(iStorehouseAi3, 3, true); //iron ore Actions.HouseWareBlock(iStorehouseAi3, 4, true); //gold ore Actions.HouseWareBlock(iStorehouseAi3, 5, true); //coal Actions.HouseWareBlock(iStorehouseAi3, 6, true); //iron Actions.HouseWareBlock(iStorehouseAi3, 9, true); //corn Actions.HouseWareBlock(iStorehouseAi3, 11, true); //flour Actions.HouseWareBlock(iStorehouseAi3, 14, true); //pigs Actions.HouseWareBlock(iStorehouseAi3, 15, true); //skins Actions.HouseWareBlock(iStorehouseAi3, 16, true); //wooden shields Actions.HouseWareBlock(iStorehouseAi3, 17, true); //long shields Actions.HouseWareBlock(iStorehouseAi3, 18, true); //leather armours Actions.HouseWareBlock(iStorehouseAi3, 19, true); //iron armaments Actions.HouseWareBlock(iStorehouseAi3, 20, true); //axes Actions.HouseWareBlock(iStorehouseAi3, 21, true); //swords Actions.HouseWareBlock(iStorehouseAi3, 22, true); //lances Actions.HouseWareBlock(iStorehouseAi3, 23, true); //pikes Actions.HouseWareBlock(iStorehouseAi3, 24, true); //longbows Actions.HouseWareBlock(iStorehouseAi3, 25, true); //crossbows Actions.HouseWareBlock(iStorehouseAi3, 26, true); //horses end;
  Code:
var iStorehouseAI: array[0..2] of Integer; procedure OnMissionStart; var i, i2: Integer; begin iStorehouseAI[0] := States.HouseAt(108, 31); iStorehouseAI[1] := States.HouseAt(108, 50); iStorehouseAI[2] := States.HouseAt(114, 17); for i := 0 to 2 do for i2 := 0 to 26 do if ( (i2 <> 1) AND (i2 <> 2) AND (i2 <> 7) AND (i2 <> 8) AND (i2 <> 10) AND (i2 < 12)) OR (i2 >= 14) then Actions.HouseWareBlock(iStorehouseAI[i], i2, true); end;
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 2 guests