How to script a very basic single player level using Loathing

 

Introduction

It took me a very long time to work out the very basics of script editing in Loathing, and I have found that neither the manual written by Bungie, nor the tutorials found on the internet have given me any good examples to work on. Now that I have a very basic understanding on how to start editing, I have decided to sare my knowledge with the world :) I am be no means an extremely experienced user of loathing, but I have in fact only just got to grips with the very fundimentals, so just consider this tutorial as "Loathing Scripting for Dummies" ! I have slowly worked out the basics with the help of Sonork's Myth II Scripting Tutorial, looking at other Bungie levels and experimenting

In this tutorial you will learn how to simply get a group of Thrall and Souless to attack your army, make them cheer if they win and finish the level.

Getting Started

Start by creating a blank, flat, plain, boring map. A 1024 x 1024 picture filled with green with a path runnning down the centre will do. Import this into Loathing and add 10 beserks, 2 dwarves and 5 archers in a suitable formation in the south. (I am assuming in writting this tutorial that you know the basics at least of map editing.)

All these units have to be team 0. All the enemy units will have to be team 1. To be able to identify groups of units, we need to put them into groups. Although this may not seem like a map action, it is in fact, and it is used all the time. To put the Archers into a goup together, select them and go to the menu "Selection" then "Create Data Container". Name it Archers. Now click on the map actions button in the tool palette (The flag). Notice that at the top of this, in the first box, there is an item named "Archers". Click on it. In the second box there should be two items. The first "name" is simply the name show in the top box. The second item "monster_identifier" is the item which tells the map action which units are in the group. The top box in this palette is for the map actions, the second is for perameters. The perameters are the items which are in the map action. These were the name and identifier for the previous example, but if the map action was attack, for example, the perameters might be "Attackers" or "Targets". The bottom box is for the elements. For the identifier perameter, these are the individual units. If it was for a link to another action (we will cover these later) it will say the action it is linked to. For the monster identifier, the Element would be the monsters in the group. If you didn't understand all that, don't worry ! Hopefully after doing some more of the tutorial and re-reading this paragraph, it should make a bit more sense.

 

Setting up...

Repeat this "Create Data Container" method with the beserks then the dwarves, naming them accordingly. Note as they pop up in the map actions window. Next we need to make the enemy units. Place some thrall a medium distance (so they don't have too far to walk) toward the north of the map in a square formation as you see them in the game. Put them on the path. Now put them in a group as described above. Do the same with a few souless on each side of the group of thrall. Put them in groups and name them "Souless 1" and "Souless 2" or whatever you think is appropriate. Now all we need to do is create containers for all the dark forces and all the light forces. We don't want to make a data containers this time - we can do this another way. In the map actions diolog box, under the map actions list, clik on the "add" button. Change the name to "DARK FORCES", leave the type as "NONE". Now click on the add button below the perameters list box. Select "Link" from the menu. This link perameter will link the groups of dark troops we have created into one large group. Click on the add button below the Elements box and select "Thrall". Do the same with the two groups of souless. Now the map action "Dark Forces" has link to the map actions "Thrall" , "Souless 1" and "Souless 2" to create one large group. See if you can repeat this whole process again now - try putting all the light forces together in one map action called "LIGHT FORCES"

 

Lets move !

Phew. Thats the setting up finished. If you didn't quite understand what was going on there, (although it should be easy :P )try experimenting - try looking through all the map actions to see whats what and where everything went. You could also try re-reading some of the things I said earlier on more slowly. Now we get to the fun part - making the troops attack. Where do we start ? By making a move map action - this will make the Thrall move to a position near our troops. (Because this is just a very simple tutorial, they won't be very clever - so when you play the game, let the Thrall come to you - they might be too stupid to stop and attack if you go forwards ! When you are a more advanced scripter, you will be able to script more advanced AIs.) Click the add button below the map actions box to add a new movement action. Call it something like "Thrall move" and select "movement" from the type menu. Now select "On execution" from the "Expiration Mode" menu. This will tell it that it is finished the map action when it has finished moving to the location. Check the "initially active" and the "No initial delay" boxes to show that the thrall will start moving as soon as the game begins. Now you have created these map actions, you need to tell the map action who is moving and where to. Add a perameter of type "Link". Note that to tell it who is moving, we are not selecting "Monsters" because we already have a defined group as a map action called "Thrall". We do this by selecting "Link" and in the elements add the map action "Thrall". This is simpler, as you do not now need to select each individual unit. Now we need to tell the map action where they are moving to. Add a perameter of type "Waypoints" (you use this even if there is just a single destination) and click on the ground near your troops. Now the Thrall will move to that destination.

Now for the souless. I have deliberately not made all the dark forces move together to a single location, because I thought it would be fun if the souless flanked our troops and came from the side or back. Make another movement map action and repeat like before, but setting the waypoints differently for each group of souless, and using the same "Link" method to tell the map action who is moving. You could even use the "Final facing" perameters and drag on the map to tell the Souless which way to face.

Attack !

Now the dark forces are in position they simply need to be told to attack - and who. Guess what - you need to make an attack map action. Name it "Dark Attack", or whatever you want, and change the Expiration Mode to Never, so that they don't stop attacking, whatever. Now our "DARK FORCES" group comes in useful for the first time. Make a "Link" perameter, and under Elements select "DARK FORCES". Now all you need is a target. Rather than adding a targets perameter, Just select a "Attack Nearest Flag" item, so that they attack the closest enemy. Right now this whole map action will not take effect. You need to link it to another map action to say when it will happen. Under each movement map action shown in the list at the top, add an "Activates on execution" perameter, and in the elements add "ATTA.Dark Attack". Now, when the troops have finished moving, they will attack you !!

Time to celebrate

Wait !! Don't go ! There is one more thing. At the moment, when you kill the enemy, nothing will happen. You need to say that this is the end of the level - when you have killed everyone. (Or they have killed you !!) Add a map action of type "Test Unit" and call it something like "All dead ?", expiration mode on successful execution, and check the box "Initially active". We are going to make sure that all of the enemy are dead. Add a perameter "Unit count less than" and add the element "1". Now add a link perameter and link it to the dark forces. This will check that the number of the dark forces is less then 1 (therefore all dead). Duplicate this map action, and configure it to see if all the light forces are dead. You will want to change the name to something like "All Light Dead ?", and change the link perameter's element to light forces. This map action will check to see if all of our troops are dead.

Now create yet another map action. This time it is "Endgame condition". Call it "Light wins". Add "Light Victory Flag" in the perameters. Now under the "All dead ?" map action create a perameter called "Activates on success" and select the "Light Wins" in the elements. This will make it so that when you eventually win, it will end the game. Do the same for the "All light dead ?", adding the Dark Victory Flag this time and putting the map action in the elements of "All light dead ?"

Throughout the tutorial, I have not told you about a nice layout and commenting. With the longer scripts, (as you may have noticed with Bungie's levels, the map actions are nicely set out with headings. I recommend that if you decide to do a lot of scripting in the future I strongly advise to look at their scripts and copy the way they work.

Well now you should have finished, and when you open the level in Myth 2 (after opening the mesh in Fear to check the "Single Player" and "Is complete" boxes), the thrall and souless should attack in a very er, intelligent way indeed.

Congratulations on creating your first Myth 2 single player level. I hope to see more single player maps in the Myth 2 community now and well scripted maps. Thanks to Sonork to his great tutorial and to Bugie for creating such a great game and the tools to go with it. I hope this tutorial has been a help. :)

Any comments critticisms or anything - just a note to say that you made use of this tutorial would be nice ! Send to the address below...

Cya round at bungie.net !

Phish

Phish@talk21.com