Goto http://www.stucuk.netGoto http://www.atlanticaonlinewiki.comGoto http://www.game-requirements.com

First Steps in Modding

From Original War Support Wiki

Jump to: navigation, search

Tutorial By: Serpent

This tutorial shows you how to create a mod with one playable mission.

Contents

Create Mod

At the beginning we need to create mod. Go to your Original War main folder and run ow_editor.exe.
Click "Create Mod". Fill ModName and ShortName inputs and select "Extract Campaigns", "Extract data, gallery..".



OWEditor Create Mod Form



Now click on "Create" button to confirm operation.

Copy existing map

We want to use one of the existing map. For example third mission from Russian Campaign.
Go to /Original War/mods/<your_mod>/Missions/__RU and copy 03 folder. Back to Missions directory, go to __AR folder and paste map here.

Next step is renameing map directory from 03 to 01.
Now open 01 folder and delete all of files from list:

  • amici.src
  • amici.src.old
  • amici.src.older
  • arabi.src
  • arabi.src.old
  • arabi.src.older
  • dialogy.src
  • difficulty.src
  • Main.src
  • Omikron AI.src
  • rusi.src
  • uvod.src


Open sources.txt files and delete this lines:

  ENABLED "Omikron AI"
  ENABLED Main
  ENABLED uvod
  ENABLED dificulty
  ENABLED rusi
  ENABLED dialogy
  ENABLED jednotky
  ENABLED amici
  ENABLED arabi


Save operation and close file.

Create first mission

Back to OWEditor and click "Select Mod".
In Setup Wizard choose Load Map, click Next, click two times on __AR and again click two times on 01. Editor should load your map now.

Clean up some mess

Now look on the right panel. There are all areas of the map. We don't need it, so just delete it.
In next step delete all units. Click on Selection -> All or press CTRL + A. Now click Delete Unit (selected hexes) button on the upper panel.



OWEditor Upper Panel



Go to Files -> Map Preferences.


OWEditor Map Preferences



Change player on Side 2 (yellow) and side fog on Side 2 (yellow).


OWEditor Map Preferences Description



Select Description, change Russian Camp. to Arabian Camp and set mission number to 01. Confirm operation by clicking Accept.
Save changes - click on Files -> Save or press CTRL + S.

Mission plan

Main commander "Robert Farmer" with small force try to capture russian base and defend from enemy counterstrike.

ToDo List

  • Create Robert Farmer and small arabian forces.
  • Create russian base with personel and simple AI.
  • Prepare counterattack when player capture base.
  • Display medals and win screen if all enemy units died.
  • Display YouLost message when Robert Farmer dies.
  • Add some dialogs.
  • Add crates spawn.
  • Block some techs and buildings.


ToDo #1 - Create Robert Farmer and small arabian forces

We gonna use SAIL to create every unit in this mission (expect buildings).
Click SAIL and open SAIL Editor.

In SAIL Editor click File -> New module, write "Main" and confirm.

Now it's time for some coding.

Starting
begin
ResetFog; // prepare fog of war, not must be but I recommend to use it

End;

It first block. Executed on the begin, when the mission started. Click Commands -> Compile or press CTRL + F9 to compile and save changes in code.



Time to create Farmer and his friends.
Go to File and create another module named "Farmer".

Paste this code to Farmer module:

Export Farmer;  // prepare global variable - Farmer
Export Function PrepareFarmer;
var i;
begin
uc_side := 2; // set units color to yellow
uc_nation := nation_arabian; // or 2

hc_gallery := 'ru'; // gallery name
hc_face_number := 44; // face number in gallery
hc_name := 'Robert Farmer';
hc_importance := 100; // make farmer hero

PrepareHuman(sex_male, class_soldier, 3); // sex, class, basic_skill_value

Farmer := CreateHuman; // create Farmer

result := result ^ Farmer; // add Farmer to array

hc_importance := 0; // only Farmer is hero here
hc_gallery := ''; // random gallery
hc_name := ''; // random name

for i = 1 to 7 do // for loop
    begin
    PrepareHuman(false, i div 2 + 1, 3);
    result := result ^ CreateHuman; // add new unit to array
    end;

// spawn units
for i in result do
    PlaceUnitXYR(i, 53, 8, 10, false);

// center camera on Farmer
CenterNowOnUnits(Farmer);
End;         

In Main module:

Starting
begin
ResetFog;
PrepareFarmer; // insert this line to use function from Farmer module
End;

Time for the first test. Click Commands -> Run or press F9. The game should create Farmer and his friends.


ToDo #2 - Create Russian base with personel and simple AI

Time for some build. Close SAIL Editor and click button "Create Unit".
Change side to 3, nation to Russian and choose Russian depot from list.
Find some place on the map and press LPM + Left Shift. Building should stand strong :)

Feel free to use all buildings from the list and create Russian base.



Example Base



Back to SAIL Editor and create third module "Russians" and paste this code:

Export Function PrepareRussian;
var i;
begin
uc_side := 3; // red color
uc_nation := nation_russian;

// if there is some bunkers
if FilterAllUnits([[f_side, 3], [f_btype, b_bunker]]) then
   begin
   for i = 1 to 2 do
       begin
       PrepareHuman(false, class_soldier, 2);
       // place soldier in empty bunker
       PlaceHumanInUnit(CreateHuman, FilterAllUnits([[f_side, 3], [f_btype, b_bunker], [f_empty]])[1]);
       end;
   end;

// add some engineers
for i = 1 to 2 do
    begin
    PrepareHuman(false, class_engineer, 2);
    PlaceUnitXYR(CreateHuman, 102, 72, 4, false);
    end;

End;


// AI
// Repair building or back to depot
Every 0$01 trigger FilterAllUnits([[f_side, 3], [f_class, 2]]) do
var i, b, engs, depot;
begin
enable; // repeat and repeat and repeat ...
b := FilterAllUnits([[f_side, 3], [f_type, unit_building], [f_not, [f_lives, 1000]]]); // find every russian buildings without full hp
engs := FilterAllUnits([[f_side, 3], [f_class, 2]]); // find every russian engineers
depot := FilterAllUnits([[f_side, 3], [f_btype, b_depot]])[1]; // get russian depot id

if not b then // everything is fine
   begin
   if UnitFilter(engs, [f_not, [f_inside]]) then
      for i in UnitFilter(engs, [f_not, [f_inside]]) do
          ComEnterUnit(i, depot); // go to depot
   end
    else // there is something to repair
     begin
     for i in engs do
         if IsInUnit(i) then  // eng is in depot
            ComExitBuilding(i) // get out
             else
              if not HasTask(i) then     // if not has any task
                 ComRepairBuilding(i, b[1]); // then go to work
     end;
End;

// Event AI
// if tower is on red hp then solider should run and hide into armoury
On UnitGoesToRed(un) do
var i;
begin
if FilterAllUnits([[f_side, 3], [f_btype, b_armoury]]) then // if there is still place to hide...
   begin 
   if GetBType(un) = b_bunker and GetSide(un) = 3 then
      begin
      i := UnitsInside(un)[1]; // get soldier id

      if i then
         ComEnterUnit(i, FilterAllUnits([[f_side, 3], [f_btype, b_armoury]])[1]);
      end;
   end;
End

In Main module:

Starting
begin
ResetFog;
PrepareFarmer;
PrepareRussian; // insert this line
End;


ToDo #3 - Prepare counterattack when player capture base

Create next new module "Mission" and add code:

// when player capture depot
On BuildingCaptured(building, side, human) Do
begin
if GetBType(building) = b_depot then
   begin
   Wait(5$00); // wait 5 minutes
   SendCounterAttack; // and send attack
   end;
end;

Export attackers, count;
Export Function SendCounterAttack;
var i, un;
begin
attackers := [];
count := 0;

uc_side := 3;
uc_nation := 3;

// prepare 2 tanks and 3 soldiers
for i = 1 to 2 do
    begin
    vc_chassis := ru_medium_tracked;
    vc_engine := engine_combustion;
    vc_control := control_manual;
    vc_weapon :=  ru_heavy_machine_gun;
    un := CreateVehicle;
    PlaceUnitXYR(un, 6, 5, 10, false);

    PrepareHuman(false, class_mechanic, 3);
    PlaceHumanInUnit(CreateHuman, un);

    attackers := attackers ^ un;
    // alternative u can use: attackers := Insert(attackers, attackers+1, un);
    end;

for i = 1 to 3 do
    begin
    PrepareHuman(false, 1, 3);
    un := CreateHuman;
    attackers := Insert(attackers, attackers+1, un);
    PlaceUnitXYR(un, 6, 5, 10, false);
    end;
End;

// AI - Attack if attackers exists
Every 0$01 trigger attackers do
var i;
begin
enable;

for i in attackers do // attack nearest enemy unit
    ComAttackUnit(i, NearestUnitToUnit(FilterAllUnits([f_enemy, 3]), i));
End;

On UnitDestroyed(un) do
begin
if un in attackers then
   begin
   attackers := attackers diff un; // delete unit from attackers
   count := count + 1;
   end;
End;


ToDo #4 - Display medals and win screen if all enemy units died

Stay in Mission module and add this code:

// Win!
Every 0$01 trigger not attackers and count >= 5 do
begin
AddMedal('good_job', 1);
AddMedal('good_job', 1);
AddMedal('good_job', 1);

GiveMedals('MAIN'); // display medals screen

RewardPeople(FilterAllUnits([f_side, your_side])); // reward exp.
YouWin; // end mission
End;


Now compile code, save changes and close OWEditor. Open Original War/mods/<your_mod>/campaigns/Ru and copy Txt01.wri file. Do one step back and create new "Ar" folder in campaigns directory. Paste Txt01.wri file here.
Open file using Windows Notepad (or diffrent text editor), press CTRL+A and delete everything.

Paste this code:

// this is first line

^MAIN

* good_job
+ Good Job!
- Bad Job!
*

Save changes.


ToDo #5 - Display YouLost message when Robert Farmer dies

In Txt01.wri:

// this is first line

| farmer_die
Farmer is dead.


^MAIN

* good_job
+ Good Job!
- Bad Job!
*

In Mission module:

On UnitDestroyed(un) do
begin
if un in attackers then
   begin
   attackers := attackers diff un; // delete unit from attackers
   count := count + 1;
   end;
if un = Farmer then // <--- add this line 
   begin // <--- add this line 
   YouLost('farmer_die'); // <--- add this line 
   end; // <--- add this line 
End;


ToDo #6 - Add some dialogs

We want add some dialogs for Farmer.

Open Txt01.wri:

// this is first line

$ farm-1
- Hello! My name is Robert.

$ farm-2
- We want capture Russian base!

$ farm-3
- Help us!

| farmer_die
Farmer is dead.


^MAIN

* good_job
+ Good Job!
- Bad Job!
*

In Main module:

Starting
begin
ResetFog; 
PrepareFarmer;
PrepareRussian;

Say(Farmer, 'farm-1'); // add this line
Say(Farmer, 'farm-2'); // add this line
Say(Farmer, 'farm-3'); // add this line
End;


ToDo #7 - Add some crates spawn

In Mission module:

// Spawn crates
Every 0$33 do
begin
enable;  
CreateCratesXYR(Rand(1,5), 96, 68, 20, true);
End;


ToDo #8 - Block some techs and buildings

You can manipulate technologies and buildings status. Just click Missions and Technologies/Restrictions.



Summary

On this stage your files should looks like it:
Main module

Starting
begin
ResetFog; 
PrepareFarmer;
PrepareRussian;

Say(Farmer, 'farm-1'); // add this line
Say(Farmer, 'farm-2'); // add this line
Say(Farmer, 'farm-3'); // add this line
End;


Farmer module

Export Farmer;  // prepare global variable - Farmer
Export Function PrepareFarmer;
var i;
begin
uc_side := 2; // set units color to yellow
uc_nation := nation_arabian; // or 2

hc_gallery := 'ru'; // gallery name
hc_face_number := 44; // face number in gallery
hc_name := 'Robert Farmer';
hc_importance := 100; // make farmer hero

PrepareHuman(sex_male, class_soldier, 3); // sex, class, basic_skill_value

Farmer := CreateHuman; // create Farmer

result := result ^ Farmer; // add Farmer to array

hc_importance := 0; // only Farmer is hero here
hc_gallery := ''; // random gallery
hc_name := ''; // random name

for i = 1 to 7 do // for loop
    begin
    PrepareHuman(false, i div 2 + 1, 3);
    result := result ^ CreateHuman; // add new unit to array
    end;

// spawn units
for I in result do
    PlaceUnitXYR(i, 53, 8, 10, false);

// center camera on Farmer
CenterNowOnUnits(Farmer);
End;


Russians module

Export Function PrepareRussian;
var i;
begin
uc_side := 3; // red color
uc_nation := nation_russian;

// if there is some bunkers
if FilterAllUnits([[f_side, 3], [f_btype, b_bunker]]) then
   begin
   for i = 1 to 2 do
       begin
       PrepareHuman(false, class_soldier, 2);
       // place soldier in empty bunker
       PlaceHumanInUnit(CreateHuman, FilterAllUnits([[f_side, 3], [f_btype, b_bunker], [f_empty]])[1]);
       end;
   end;

// add some engineers
for i = 1 to 2 do
    begin
    PrepareHuman(false, class_engineer, 2);
    PlaceUnitXYR(CreateHuman, 102, 72, 4, false);
    end;

End;


// AI
// Repair building or back to depot
Every 0$01 trigger FilterAllUnits([[f_side, 3], [f_class, 2]]) do
var i, b, engs, depot;
begin
enable; // repeat and repeat and repeat ...
b := FilterAllUnits([[f_side, 3], [f_type, unit_building], [f_not, [f_lives, 1000]]]); // find every russian buildings without full hp
engs := FilterAllUnits([[f_side, 3], [f_class, 2]]); // find every russian engineers
depot := FilterAllUnits([[f_side, 3], [f_btype, b_depot]])[1]; // get russian depot id

if not b then // everything is fine
   begin
   if UnitFilter(engs, [f_not, [f_inside]]) then
      for i in UnitFilter(engs, [f_not, [f_inside]]) do
          ComEnterUnit(i, depot); // go to depot
   end
    else // there is something to repair
     begin
     for i in engs do
         if IsInUnit(i) then  // eng is in depot
            ComExitBuilding(i) // get out
             else
              if not HasTask(i) then     // if not has any task
                 ComRepairBuilding(i, b[1]); // then go to work
     end;
End;

// Event AI
// if tower is on red hp then solider should run and hide into armoury
On UnitGoesToRed(un) do
var i;
begin
if FilterAllUnits([[f_side, 3], [f_btype, b_armoury]]) then // if there is still place to hide...
   begin 
   if GetBType(un) = b_bunker and GetSide(un) = 3 then
      begin
      i := UnitsInside(un)[1]; // get soldier id

      if I then
         ComEnterUnit(i, FilterAllUnits([[f_side, 3], [f_btype, b_armoury]])[1]);
      end;
   end;
End;


Mission module

// when player capture depot
On BuildingCaptured(building, side, human) Do
begin
if GetBType(building) = b_depot then
   begin
   Wait(5$00); // wait 5 minutes
   SendCounterAttack; // and send attack
   end;
end;

Export attackers, count;
Export Function SendCounterAttack;
var i, un;
begin
attackers := [];
count := 0;

uc_side := 3;
uc_nation := 3;

// prepare 2 tanks and 3 soldiers
for i = 1 to 2 do
    begin
    vc_chassis := ru_medium_tracked;
    vc_engine := engine_combustion;
    vc_control := control_manual;
    vc_weapon :=  ru_heavy_machine_gun;
    un := CreateVehicle;
    PlaceUnitXYR(un, 6, 5, 10, false);

    PrepareHuman(false, class_mechanic, 3);
    PlaceHumanInUnit(CreateHuman, un);

    attackers := attackers ^ un;
    // alternative u can use: attackers := Insert(attackers, attackers+1, un);
    end;

for i = 1 to 3 do
    begin
    PrepareHuman(false, 1, 3);
    un := CreateHuman;
    attackers := Insert(attackers, attackers+1, un);
    PlaceUnitXYR(un, 6, 5, 10, false);
    end;
End;

// AI - Attack if attackers exists
Every 0$01 trigger attackers do
var i;
begin
enable;

for I in attackers do // attack nearest enemy unit
    ComAttackUnit(i, NearestUnitToUnit(FilterAllUnits([f_enemy, 3]), i));
End;


On UnitDestroyed(un) do
begin
if un in attackers then
   begin
   attackers := attackers diff un; // delete unit from attackers
   count := count + 1;
   end;
if un = Farmer then
   begin
   YouLost('farmer_die');
   end;
End;

// Win!
Every 0$01 trigger not attackers and count >= 5 do
begin
AddMedal('good_job', 1);
AddMedal('good_job', 1);
AddMedal('good_job', 1);

GiveMedals('MAIN'); // display medals screen

RewardPeople(FilterAllUnits([f_side, your_side])); // reward exp.
YouWin; // end mission
End;

// Spawn crates
Every 0$33 do
begin
enable;  
CreateCratesXYR(Rand(1,5), 96, 68, 20, true);
End;


Txt01.wri in Original War/mods/<your_mod>/campaigns/Ar

// this is first line

$ farm-1
- Hello! My name is Robert.

$ farm-2
- We want capture Russian base!

$ farm-3
- Help us!

| farmer_die
Farmer is dead.


^MAIN

* good_job
+ Good Job!
- Bad Job!
*



Campaign Settings

From <your_mod>/campaigns/Ru copy missions.dat file to <your_mod>/campaigns/Ar directory. Of course you can edit this file using notepad (or diffrent text editor).



Arabian Button in Main Menu

If you wanna run your mission ingame you need arabian button in main menu.

You can download button package here.
Last step is paste package into your main mod directory and unpacked archive (use WinRar or 7-Zip).


Personal tools
Clanbase
This is a cached copy of the requested page, and may not be up to date.

Sorry! This site is experiencing technical difficulties.
Try waiting a few minutes and reloading.

(Can't contact the database server: MySQL functions missing, have you compiled PHP with the --with-mysql option? )


You can try searching via Google in the meantime.
Note that their indexes of our content may be out of date.