Page 3 of 5

Re: New scripting ideas for KaM Remake

PostPosted: 25 Nov 2012, 05:34
by Krom
Yes, There ain't gonna be much changes since last version I showed. There's only one technical issues left - saving and loading script variables in save/load game commands, but these should be solvable. I'll take a try today. :)

P.S. There's a way to rewrite town tutorial script OnHouseBuilt event. Atm it has a bug - each time house is built it's gonna invoke a message. To fix it it needs an array of flags indicating that certain message has been showed to the player.

Re: New scripting ideas for KaM Remake

PostPosted: 26 Nov 2012, 11:23
by The Dark Lord
Awesome, unfortunately I don't have much time today but I'll start soon. And when (yes: when, not if, because it is inevitable :P) I have questions I'll post them here. :)
Could you send me an executable sooner or later so I can test things as well?

Re: New scripting ideas for KaM Remake

PostPosted: 26 Nov 2012, 13:14
by Krom
@TDL: Yes, of course! Maybe at the end of this week it will be ready.

I have managed to save/load standalone variables (like in examples I have posted), but before finally stopping on PascalScript I want to be able to serialize (thats how it is called properly) more complicated and useful variable types - arrays ("MsgShowed: array [0..30] of Boolean"). Sadly PascalScript sources don't have readymade serialization functions.

Re: New scripting ideas for KaM Remake

PostPosted: 27 Nov 2012, 21:05
by ShowMeState1
You guys should just create a triggers section to the editor. This way we wont have to come up with ideas as much on here but people will develop their own ideas and the tools will be available to a much more diverse and larger group so more things will be developed. To create these game types you're going to have to develop some kind of trigger to create it yourself so why not just create a huge file of triggers to be added into the game and let the map creating be left to the players?

Re: New scripting ideas for KaM Remake

PostPosted: 28 Nov 2012, 05:25
by Krom
We are discussing list of these triggers (events, states, actions) that will be available to map makers. We cant expose whole of the game functions because game keeps on developing, some methods change, some get renames, some removed - we would not be able to provide backwards compatibility if we expose everything. Also, exposing everything without proper documentation (assume that we won't do any changes to structure) is an easy way to ruin the game - some functions depend on others and some methods are expecting different kinds of data than others.

My previous Events handling system didn't worked out - it was not flexible enough for many things (yet enough for tutorials). And I'm glad that we have found its weaknesses sooner than later, cos now we replace it - it's good to be able to replace it before it got dozens of missions using it. Now we use PascalScript and it seems much better cut for the job, TD looks doable.

We could have started with implementing random triggers, but that is not as intense. It would have taken months before someone figured out how to use random existing triggers to make TD game. Instead we take scripts that we need (tutorial missions, campaigns, ask TDL) and implement their triggers - that way we have immediate result.

We do ask you to come up with ideas for what scripting should be able to do, to be able to think it through and implement it in a seamless way. You may saw how TD scripting ideas evolved from "ATTACK_WAVE" to much simpler "GIVE_GROUP" and let AI handle it. If we'd spent time on AttackWave we would spent that for no good and we'd also had to keep supporting it for backwards compatibility - thats not good solution.

Re: New scripting ideas for KaM Remake

PostPosted: 28 Nov 2012, 11:50
by Krom
Here's the sketch of a document describing what is there: http://code.google.com/p/castlesand/wiki/MissionScripts

Re: New scripting ideas for KaM Remake

PostPosted: 04 Dec 2012, 19:19
by The Dark Lord
Just some simple noob-questions: :P

Would this work: if GameTime = 10 then Actions.ShowMsg(0; 1; 2; 3, 1);
Or do I have to write it the long way:
if GameTime = 10 then
Actions.ShowMsg(0, 1);
Actions.ShowMsg(1, 1);
Actions.ShowMsg(2, 1);
Actions.ShowMsg(3, 1);

And if one of the players doesn't exist, will it simply be ignored?

ShowCountdown only has one variable: time. So for which players will it be shown?

Can I use something like if SoldierCount = 0 then ............. to have a player defeat an attack wave (you spoke about UnitCount somewhere but that includes citizens as well. I think this would be more useful)?

Re: New scripting ideas for KaM Remake

PostPosted: 05 Dec 2012, 05:38
by Krom
These are good questions )

1. in current form you will need to list all the players. However, if there are many messages you can write a procedure for that:
  Code:
procedure ShowToHuman(aIndex: Integer); var I: Integer; begin for I := 0 to States.PlayerCount - 1 do if States.PlayerIsHuman(i) then Actions.ShowMsg(i, aIndex); end; begin if States.GameTime = 10 then ShowToHuman(1); end.
Note that players order in MP is not static. Players can take positions in any order, so that position 3 becomes player 6. At the start of the mission all players are within count (irregardless of starting positions taken, these are separate entities). This means that you can't rely on AI always being #7. We plan to make MP AI setup more stable, but for now it is like described. Means you need to check in script that player is indeed an AI and is the one you need.

I can add both States.UnitCount, UnitTypeCount, WarriorsCount and CitizensCount functions, no problem. )

Re: New scripting ideas for KaM Remake

PostPosted: 05 Dec 2012, 15:08
by The Dark Lord
1. in current form you will need to list all the players. However, if there are many messages you can write a procedure for that:
  Code:
procedure ShowToHuman(aIndex: Integer); var I: Integer; begin for I := 0 to States.PlayerCount - 1 do if States.PlayerIsHuman(i) then Actions.ShowMsg(i, aIndex); end; begin if States.GameTime = 10 then ShowToHuman(1); end.
Hmmm... I understand most of this code, except this:
- What is the difference between I and i?
- Why did you write a 1 in ShowToHuman(1)?
- Why is there a '.' behind end? Does it mark the end of the procedure?
Note that players order in MP is not static. Players can take positions in any order, so that position 3 becomes player 6. At the start of the mission all players are within count (irregardless of starting positions taken, these are separate entities). This means that you can't rely on AI always being #7. We plan to make MP AI setup more stable, but for now it is like described. Means you need to check in script that player is indeed an AI and is the one you need.
I didn't think about that, that makes things much more complicated. So I first have to check if players exist somehow and then give them some 'id' that I can use throughout the entire script?

Re: New scripting ideas for KaM Remake

PostPosted: 05 Dec 2012, 15:14
by Krom
- I and i are both the same thing. Pascal is not case sensitive.
- ShowToHuman(1) shows message id=1 to all human players. 1 is a message index in libx file. Could be 2 or 5 or any other number :)
- thats Pascal script rule, last "end" has to be terminated with a .

Yeah, maybe we need to add States.PlayerStartingLoc(aPlayerIndex): Integer; returning which loc does the player has. That could make it simpler.

Re: New scripting ideas for KaM Remake

PostPosted: 05 Dec 2012, 15:22
by The Dark Lord
- I and i are both the same thing. Pascal is not case sensitive.
- ShowToHuman(1) shows message id=1 to all human players. 1 is a message index in libx file. Could be 2 or 5 or any other number :)
- thats Pascal script rule, last "end" has to be terminated with a .
Ok, thanks. :)
Yeah, maybe we need to add States.PlayerStartingLoc(aPlayerIndex): Integer; returning which loc does the player has. That could make it simpler.
How would I use this? It's all very abstract to me, I have to get used to it. ;)

Re: New scripting ideas for KaM Remake

PostPosted: 05 Dec 2012, 16:53
by Krom
Player Index and starting location index match each other only in SP. They are not connected in MP (as any player can pick any location or assign it to AI). That's why we need this "remap" function to convert Player index to starting location index.

EDIT: Good news, I've started removing net players remap on to starting locations. This means player indexed will be tied to starting locations like in SP. Means - easier scripting, you can be sure player1 is always player1 at starting location1 :)

Re: New scripting ideas for KaM Remake

PostPosted: 05 Dec 2012, 19:03
by The Dark Lord
Player Index and starting location index match each other only in SP. They are not connected in MP (as any player can pick any location or assign it to AI). That's why we need this "remap" function to convert Player index to starting location index.
I got that, I was just wondering how to use States.PlayerStartingLoc(aPlayerIndex).
EDIT: Good news, I've started removing net players remap on to starting locations. This means player indexed will be tied to starting locations like in SP. Means - easier scripting, you can be sure player1 is always player1 at starting location1 :)
That's very nice! And if those players don't exist the script will be ignored?

By the way, I think I can now make a complete TD script. Could you send me an executable soon? :)

Re: New scripting ideas for KaM Remake

PostPosted: 06 Dec 2012, 05:04
by Krom
Those player will still exist, albeit disabled. That means they don't have assets, but you could still access their empty States (Alliances, Unitcount=0, etc.). I will see into how disable actions towards disabled players (Actions.GiveGroup etc.)

Please send me your email to kromster80@gmail.com so I could send you a test exe.

Re: New scripting ideas for KaM Remake

PostPosted: 06 Dec 2012, 10:03
by The Dark Lord
Okay, I sent you an email. :)