New scripting ideas for KaM Remake
1. Tower Defence (player repells AI attacks and gets resources after each wave)
2. Castle Fight (two competing players that can only hire troops, but cant control them)
3. Other ideas?
Here's our discussion with TDL about 1st idea:
Comment by TDL
Hi Krom and Lewin, I haven't used any of these events yet so this is all new to me. Fortunately it's not hard to understand so I will be fine, yet it is confusing that events are stored in a .evt file and not in the main script. I'm now thinking of some triggers and actions that I would need. Here are some:
- First of all, I need to start the AI attack wave. I can do this with the TIME trigger. - Then I can use the ATTACK action to start the attack wave. I will need more parameters for this, I need to specify exactly which troops have to attack. We should also discuss the behaviour of the soldiers when they go attack. For example, I want the AI's melee units to walk straight to the target, but archers and crossbowmen should fire at anything in their range. I suggest some different attack types. Last but not least, the ATTACK needs one more parameter to identify the attack. Just a number will do. - Then I need a trigger that triggers an event when the attack is repelled, something like ATTACK_DEFEATED. Now the 'id-number' from ATTACK is required to specify which attack has to be stopped in order to activate the event (GIVE_WARES in this case!). - I migt need AND/OR/THEN, like DEFEATED 1 AND DEFEATED 2 AND DEFEATED 3 THEN VICTORY 0. - Then I would also need specific DEFEAT conditions, in this case the destruction of a watchtower. You could specify this watchtower by the X and Y coordinates of the building, or Remake should scan around those coordinates and assign the closest watchtower to it. Something like DEFEAT_CONDITION (Player number) (Condition number) (optional parameters, in this case building type) (and here the X-coordinate) (and Y-coordinate here) Condition number should refer to a list with all possible defeat conditions, for example: 1: Destroy all important buildings 2: Kill all enemy military units 3: Kill all enemy units 4: Destroy a specific building 5: etc. For example: DEFEAT_CONDITION 0 4 17 20 30. So player 0 loses when the watchtower closest to X=20, Y=30 is destroyed. Winning conditions could work the same way, although you would need an extra parameter to indicate the player of whom this building needs to be destroyed. You would need only either winning conditions or defeat conditions if AND/OR/THEN is implemented though.
That's it for now, I might come up with more later.
For now events are very primitive, there are even no AND/ORs.
The way you outline it it seems we need a full-blown scripting engine to meet listed and possible features. Something like HeroesOfMightAndMagic?, Starctaft1, Warcraft3 had.
I see 2 routes from here: A. we plug-in something that is already out there (Lua?), B. We invent our own clumsy bicycle. And of course we will need to figure out how to rig internal events (how to know attack should occur now, or was repelled, or anything else)
I would also like to be able to visualize most of it, so that you could script in our MapEd? and not care for Ids and Types, just selecting values from dropboxes and pointing houses with a mouse.
Let's try to outline TD game scripting in simplest terms, how would it look within MapEd? point of view: We open map, place towns, add resources, etc. Now we need attack waves setup in global script (cos it cant be tied to any visual marker on map). We can instruct AI to prepare troops (TIME 0 MAKE_ARMY type amount), then AI will need to hire recruits and equip em. Say AI town has 10 schools and unlimited supply, that will take 3-4min? Second command should send them to attack (but we dont have guarantee the army is ready?) ... That sounds like too much micro really. Maybe the command should be TIME 0 ATTACK_WAVE id params and let AI work it out on its own. Then next script line could be ATTACK_WAVE_REPELLED id ADD_WARES params. Yeah, I like it better, it seems current scripting system could handle it that way )
The AI won't require to train troops from a barracks. My plan was to provide all troops from the start, together with a storehouse, inn and serfs to keep everything alive. An event to give the soldiers a full health bar might be useful as well. So we are guaranteed that the AI is ready to attack. Lewin said something about creating armies with a command. Not with a barracks, they would just 'magically appear'. That's fine with me too, it would both work I guess. I'm not sure if 'ATTACK_WAVE' would be a good name, as attack waves are typically used in game types like tower defence. What's wrong with just 'ATTACK'? Or do you intend to make ATTACK_WAVE different from ATTACK? I'm just wondering.
I could work with Lua too, I've used it for Settlers: Heritage of Kings. But I'm not really good with it, I think 'normal' scripts are easier.
I'm not sure what you mean with visualizing everything and how I should take part in that. Could you please explain?
The thing is - I want to envision it before starting to code.
Troop from the start is a weak option because that limits playtime and requires a lot of space on map. We need a more convenient way of having "army on demand". It should be both plausible in KaM universe and reusable in different script ideas. Either spawning (how to make that trigger display in MapEd??) in open field or hiring from Barracks (we can make a command to spawn army at Barracks entrance - player wont be able to check if there really were 144 recruits and armaments). I prefer second way, it's more natural. 3rd option - let units walk in from outside map boundaries.
ATTACK as I see it orders an existing groups of units (1st or 2nd defence line) to attack. Where ATTACK_WAVE does not only that, but also takes care of spawning the troops.
Okay, lets try homebrew scripts idea first, we will still need all the triggers and handlers if we switch to Lua and I plan to keep our scripting engine as simple as possible.
Visualizing means placing scripts onto objects where appropriate to avoid Id usage. E.g. creating an army formation (several groups) and editing its script right there, not in Notepad. Another example - placing a script on ground that is triggered by unit walking on it. The MapEd? will take care of substituting proper group indexes (which is handy if you move armies around and delete/add them).
KaM Remake at: http://www.kamremake.com
Original MBWR/WR2/AFC/FVR tools at: http://krom.reveur.de