Hello, I'm Paranoic and I'm obsessed with everything that is related to SpellForce universe! Here you can check my mods (custom campaign) for SpellForce 2 game, I'm planning to create a custom campaign for SF3 in a distant future... [Socials]: |ModDB|->|Paranoid_Shaikan| |NexusMods|->|Paranoic1024| |Youtube|->|Rockless| |SoundCloud|->|Paranoic|

Report RSS SpellForce 2 Scripting Tutorial (Spawning units)

Posted by on

Hi, here I'm going to show you to how make a little script, that would spawn any kind of unit from SF2 world editor in your map.

First, create a Coop map in SF2 Editor and choose a Teamsetup in a World section.

Tutorial01SpawnScript

Setup a Coop Team system:

Tutorial02SpawnScript]

World Editor automatically created five different teams: tm_Animal, tm_Creep, tm_Human, tm_Neutral, tm_Enemy. You have also a possibility to create more teams if you want. As you can see, tm_Enemy is highlighted in the picture, because I'm planning to show a script, which would spawn an enemy figure in the map, but you have a complete freedom and can make a script, which could spawn a unit of any team, which are listed above.

After these first steps, we are ready to decorate the map and look for some places, where the unit may be spawned.

Tutorial03SpawnScript03

After planning, which unit will be spawned and where the unit will appear, we need to gather some info about him, which will be used in a script code. As you can see, we will need his Type ID and coordinates.

After gathering the data from a World Editor, delete the unit, which is planned for a spawn event. Now we are finally ready to write a code in a script file. But before doing it, we must create a "script" and "dialog" folders in the "map_name" folder!

Tutorial04SpawnScript

Keep in mind, that even if you're not planning creating dialogs in your map, you still must create the "dialog" folder!

A "dialog" folder must consist of these two files (.lua):

Tutorial05SpawnScript

The code, which is written in these two files, is depicted down below:

Tutorial06SpawnScript

Now we are ready to create a Script in the "script" folder (for example: _map_name.lua)

I'm going to show an example, where the unit is going to be spawned without any conditions (it will be spawned at a very beginning of the game).

Tutorial07SpawnScript

The example of the code shows that you must assign a tagname for the spawned unit, level, ID, coordinates and a team.

A more detailed example:

Tutorial08SpawnScript

Then place a "PortalEndPoint" in your map to spawn your heroes and save the map to test it in your game.

Tutorial09SpawnScript

Run the game and click on a "Freegame" mode, then find your map (might be at the very end of the map list) and load it.

Tutorial10SpawnScript

Ta-da! The script should work and a skeleten must be spawned near the rock. :)


Post comment Comments
Guest
Guest - - 690,231 comments

This comment is currently awaiting admin approval, join now to view.

Guest
Guest - - 690,231 comments

This comment is currently awaiting admin approval, join now to view.

Post a comment

Your comment will be anonymous unless you join the community. Or sign in with your social account: