Map Database  •  FAQ  •  RSS  •  Login

New Dynamic Script Ideas

<<

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 14 Apr 2013, 15:19

Re: New Dynamic Script Ideas

An idea:

If there is "Actions.UnitKill", is it possible to make "Actions.GroupKill"? I mean not to kill only 1 soldier, but the whole group. I want to be able to do such evil things. Haha (6)
Ta da: :P
  Code:
procedure GroupKill(aGroup: Integer); begin if States.GroupDead(aGroup) then Exit; while States.GroupMemberCount(aGroup) > 0 do Actions.UnitKill(States.GroupMember(aGroup, 0), False); end;
Just include that near the top of your script and you can then use GroupKill (you don't need "Actions." because this is your own procedure, not one that we provide)
<<

Ben

User avatar

Former Site Admin

Posts: 3814

Joined: 08 Jan 2009, 23:00

Location: California - Pacific Time (UTC -8/-7 Summer Time)

Post 14 Apr 2013, 18:18

Re: New Dynamic Script Ideas

Ahhh, I understand now. What you are doing there is making your own procedure to use for later...interesting.
I used to spam this forum so much...
<<

Tef

User avatar

Lance Carrier

Posts: 64

Joined: 15 Apr 2013, 15:12

KaM Skill Level: Skilled

Post 15 Apr 2013, 15:50

Re: New Dynamic Script Ideas

First of all, hello to everybody! Just registered on this forum. I've been playing Kam (Remake) for a while now, but now that we can do some serious scripting I thought I should engage in the forums as well. Scripting is AWESOME by the way (H) even though I don't have a programming background.

Some ideas:
1 - using modular scripts, i.e. several .script files per mission. This would allow users to write independent 'mods' that change the behavior of a mission. For multiplayer, mods could be allowed/disallowed or turned on/off by simple commands, maybe? Just an idea. So what kind of mods do I mean? For example, I have built a (singleplayer) script that automatically trains serfs, laborers, citizens and recruits for the HUMAN player, based on the number of buildings and axes, leather armor and iron amor in your barracks. Basically, this mod means you never have to bother looking at your school again. Yes, I know that makes gameplay boring, but at the same time, it's awesome! :D
2 - in light of the previous remark: a direct way to query the current queue in the school (currently I have to do that in a rather cumbersome manner)
3 - possibility to subtract wares from a storehouse. For example, Actions.GiveWares(ActivePlayer, Timber, -10) will result in 65536 timber. I'd like this function because now I cannot command enemy serfs to rob my storehouse.
4 - command to change the radius in which units, warriors or buildings reveal the fog

EDIT:
5 - a new event: procedure OnUserClick (PlayerThatClicked: integer, ClickPositionX: integer, ClickPositionY: integer) or something like that, to do something when you click your mouse.
6 - a new State: RoadFieldWinefieldAt(PositionX: integer, PositionY: integer) returns: Integer -1 for nothing, 1 for road, 2 for field, 3 for winefield. Because neither HouseAt,UnitAt or GroupAt seem to be able to see whether there is a road, field or winefield somewhere.
7 - a new action: DelayedExecution (any action or function or procedure, DelayInTicks) returns DelayedActionID:integer (???). Because if I want to schedule a lot of time-based actions in a row, I currently need to do that by using a lot of variables to remember the amount of GameTime that has expired and/or check through OnGameTick whether the actions are allowed to be executed.
8 - a new event: OnConsoleInput(PlayerSubmittingTheInput: Integer, InputString: string) to allow simple commands that users can enter in the console during the game, for example to turn on/off modular parts of the script. Just like for example is done in minecraft.

Some of my other ideas I saw already mentioned in other topics, but I'm sure I will think of more the coming weeks :)
<<

Siegfried

User avatar

Knight

Posts: 494

Joined: 24 Jul 2009, 22:00

Post 17 Apr 2013, 12:13

Re: New Dynamic Script Ideas

Some ideas:
1 - using modular scripts, i.e. several .script files per mission. This would allow users to write independent 'mods' that change the behavior of a mission. For multiplayer, mods could be allowed/disallowed or turned on/off by simple commands, maybe? Just an idea. So what kind of mods do I mean? For example, I have built a (singleplayer) script that automatically trains serfs, laborers, citizens and recruits for the HUMAN player, based on the number of buildings and axes, leather armor and iron amor in your barracks. Basically, this mod means you never have to bother looking at your school again. Yes, I know that makes gameplay boring, but at the same time, it's awesome! :D
A slightly modified version of this idea:
-how about an include-command that adds the text of another file here. Is that possible? That would allow the idea above; based on some condition - like player count - different script files could be loaded. But it's mainly meant for easier debugging if the codebase gets too large.
It would also allow for "libraries", where for example of all the ideas here are collected and put into thoroughly debugged procedures.
<<

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 17 Apr 2013, 16:33

Re: New Dynamic Script Ideas

- Include external scripts: We need to hash .script files for consistency, that's much harder if we have to look for include files. It's also neater to have all the files for a map start with the map's name.
- We'll add a command to query the school queue.
- User input commands (clicks and console input) are a bit of an issue because they make it very easy to break the deterministic nature of the game. If you do ANYTHING on those events which affects the game, it will cause multiplayer to go out of sync and replays to fail (since those events won't happen on other clients or during the replay). Scripts are designed to interface with game assets only. If we want to make scripts that can interface with the user more directly, then it needs to not be able to affect the game assets except through normal user input (which gets synced to other MP clients and saved for the replay).
- RoadFieldWinefieldAt: Added to suggestions.
- DelayedExecution: I was thinking about that myself, I imagine it would often be useful (e.g. something happens and now you want another thing to happen in +100 ticks). We'll consider doing something like that.
<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2154

Joined: 29 Aug 2007, 22:00

KaM Skill Level: Veteran

Location: In his dark thunderstormy castle

Post 17 Apr 2013, 16:51

Re: New Dynamic Script Ideas

- User input commands (clicks and console input) are a bit of an issue because they make it very easy to break the deterministic nature of the game. If you do ANYTHING on those events which affects the game, it will cause multiplayer to go out of sync and replays to fail (since those events won't happen on other clients or during the replay). Scripts are designed to interface with game assets only. If we want to make scripts that can interface with the user more directly, then it needs to not be able to affect the game assets except through normal user input (which gets synced to other MP clients and saved for the replay).
But what about singleplayer? Imagine the evil king of a country next to yours regrets his horrible deeds and wants to surrender. Accept or decline?
Imo it would be awesome to give players such choices, thereby influencing the outcome of the whole mission. :)
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 17 Apr 2013, 17:02

Re: New Dynamic Script Ideas

@TDL: For now thie same can be achieved by checking if player moves his troops down to one way or another.
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

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 18 Apr 2013, 00:27

Re: New Dynamic Script Ideas

@TDL: But singleplayer still needs consistency/determinism for replays. Maybe eventually we can have something like that where the input (console or clicking) is fed through the GameInputProcess like other user input which affects the game, and therefore does get recorded for MP and replay consistency. But as Krom said you can do something like that now by letting the player move his troops somewhere.
<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2154

Joined: 29 Aug 2007, 22:00

KaM Skill Level: Veteran

Location: In his dark thunderstormy castle

Post 18 Apr 2013, 12:21

Re: New Dynamic Script Ideas

Hmm, I guess that is a possibility... Although not as awesome. ;)

I'm not sure if this was requested somewhere earlier, but what about something like 'Events.OnHouseUnderAttack'?
So I can do stuff when the AI attacks your tower in TD. :P
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 18 Apr 2013, 13:21

Re: New Dynamic Script Ideas

Sounds like a good idea, just one thing: Events.OnHouseUnderAttack will fire a whole lot of times in a row when being under attack by a group of soldiers. Several times a tick perhaps. How do you plan to handle it?
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

The Dark Lord

User avatar

King Karolus Servant

Posts: 2154

Joined: 29 Aug 2007, 22:00

KaM Skill Level: Veteran

Location: In his dark thunderstormy castle

Post 18 Apr 2013, 13:57

Re: New Dynamic Script Ideas

Hmm... Or maybe it should be States.HouseUnderAttack. I was thinking about something like this:
  Code:
function TowerUnderAttack: AnsiString; begin if States.HouseUnderAttack(Tower1) = true then begin Result := (States.TextFormatted(25, [States.PlayerColorText(0), States.PlayerName(0)])) else Result := ''; end; end;
And I can use it in another procedure to actually show the message to every player, e.g.: Dicsoupcan's tower is under attack!
<<

Siegfried

User avatar

Knight

Posts: 494

Joined: 24 Jul 2009, 22:00

Post 18 Apr 2013, 15:26

Re: New Dynamic Script Ideas

  Code:
function TowerUnderAttack: AnsiString; begin if States.HouseUnderAttack(Tower1) = true then begin Result := (States.TextFormatted(25, [States.PlayerColorText(0), States.PlayerName(0)])) else Result := ''; end; end;
  Code:
function TowerUnderAttack: AnsiString; { if (States.HouseUnderAttack(Tower1) = true) { Result := (States.TextFormatted(25, [States.PlayerColorText(0), States.PlayerName(0)])) } else { Result := ''; } }
Having this as a direct comparison, I must say that those brackets really do look better. They don't distract from what's going on in the code.

What exactly does the 'AnsiString' stand for? Is it interchangeable with the string-class? Are the player names AnsiString or String?
<<

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 18 Apr 2013, 15:40

Re: New Dynamic Script Ideas

What exactly does the 'AnsiString' stand for? Is it interchangeable with the string-class? Are the player names AnsiString or String?
It depends which compiler you use. Newer versions of Delphi use Unicode strings. AnsiString forces it to be ANSI no matter what compiler you use. Because we're still compiling with old versions of Delphi they're exactly the same as far as I know.
<<

Krom

User avatar

Knights Province Developer

Posts: 3280

Joined: 09 May 2006, 22:00

KaM Skill Level: Fair

Location: Russia

Post 18 Apr 2013, 16:13

Re: New Dynamic Script Ideas

AnsiString stays for 1byte string of text. Since Delphi XE standard string type was changed to unicode string (each char takes 2byte)

Usual Delphi indent is just 2 spaces. Neatness is a matter of habit ;)
  Code:
function TowerUnderAttack: AnsiString; begin if States.HouseUnderAttack(Tower1) then Result := (States.TextFormatted(25, [States.PlayerColorText(0), States.PlayerName(0)])) else Result := ''; end;
  Code:
function TowerUnderAttack: AnsiString; { if (States.HouseUnderAttack(Tower1) = true) { Result := (States.TextFormatted(25, [States.PlayerColorText(0), States.PlayerName(0)])) } else { Result := ''; } }
Having this as a direct comparison, I must say that those brackets really do look better. They don't distract from what's going on in the code.

What exactly does the 'AnsiString' stand for? Is it interchangeable with the string-class? Are the player names AnsiString or String?
Knights Province at: http://www.knightsprovince.com
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de
<<

sado1

User avatar

Council Member

Posts: 1430

Joined: 21 May 2012, 19:13

KaM Skill Level: Skilled

Post 27 Apr 2013, 01:52

Re: New Dynamic Script Ideas

Could you implement GiveRecruits(Player, Count) ? Similar to GiveWeapons, it should add an amount of recruits to player's first Barracks. I'd make my own procedure for the time being, but I can't rely on GiveUnit since I'd need to carefully manage the space on the map (in other words, I'd need to spawn units in empty spaces, and what if I spawn more than one at once? I could literally make an array on a map, ready to be filed with random recruits, but still, this would not work while they were walking or something...

Also, would it be possible to implement a switch to disable all the "House is not occupied" messages in the game?

Return to “Ideas / Suggestions”

Who is online

Users browsing this forum: No registered users and 11 guests