This tutorial how to make scripts (This is under WIP)

Introduction

This is just an introduction part how script work in your custom campaign & scenario work.

Since it's fairly easy to do it, you can go to in-game map editor & you will see an tab called edit script.

There is bunch of options how do you want to make your scripts to turn out.

Scripts editing

Now let's start with the stuff in-game script editor have.

  • Immediate Start, that will instant start the map
  • Start of turns, that will start certain turns
  • Victory, that will let the player or opponent win
  • Each Days, that will repeat itself per days
  • Unit Destroyed, that will target an either player or opponent unit
  • Building Destroyed, same as unit destroyed but it's only target building e.g mini cannon & ects
  • Terrain Destroyed, same with unit & building that will target terrain only
  • Building Capture, capture certain prop
  • Player defeated, player or opponent defeated
  • Units destroyed, that will count how many unit if the player or opponent defeat
  • Building owned, that will count how many building that the player or opponent owned
  • Player in area, that will make the player reach a certain location
  • Unit in area, same as the player in area but this will target your unit & move toward the certain location
  • Check variable, I dunno what that supposed to do?
  • Is Selected CO, that will check a certain co you play as
  • Gathered Funds, that will check how much funds you hold

Next is the events

  • Dialog
  • Spawn unit
  • Defeat Player
  • Change Buildlist
  • Add funds
  • Change Weather
  • Change CO bar
  • Modify Terrain
  • Modify Unit
  • Animation
  • Victory Info
  • Modify Variable
  • Change unit AI
  • Change building owned
  • Change unit owner
  • Change player team
  • Spawn building
  • Center map
  • Play Sound
  • Volcano Fire
  • Extend Map

Custom NPCs dialogue

The Custom NPCs is pretty easy once you install them in your mod, but they won't appear in-game script editor so you have to do it manually (by using any program that is accepted JS codes e.g VScode)

Here is an example if you made any custom NPC

 var dialog13 = GameAnimationFactory.createGameAnimationDialog(map, qsTr("Tuutturu! here is your grand prize Professor Knightlord!"), "CO_MAYURI_NPC", GameEnums.COMood_Happy, "#ff0000"); dialog9.loadBackground(""); // 1 ScriptEventDialogItem //That how you insert custom NPC in your dialogue also DO NOT COPY IT READER!

If you having trouble putting Custom NPC in your dialogue please visit COW Discord to ask about it.

Custom Music

The Custom music is another feature if you feel like if you want to change the in-game music up with completely new soundtrack up

Here is an example you want to install custom music in

audio.clearPlayList();
audio.addMusic("maps/your map name folder/music/insert your custom music here.mp3");
audio.playMusic(0);
//That allow you play custom music in during your gameplay

But you have to do it manually, can't do it in-game script