Page 1 of 1

how to write mod / mod does nothing

Posted: 07 Feb 2023, 21:27
by Luckyturtledev
hi, I have try to write my first mod for this game. But it looks like the mod is not working. I had create a simple test.js saved at `mods/4.3.3/autoload/test.js` for testing how the mod api works. If I start the a game I get a message "Mod: test.js", which make me assume that the mod was loaded successful.
But the mod does nothing.

Code: Select all

receiveAllEvents(true);

function eventStartLevel() {
  debug("hiiiiiiiiiiiiiiiiiiiii");
  console("hiiiiiiiiiiiiiiiiiii");
  receiveAllEvents(true);
}

funciton eventMenuBuild() {
  debug("hiiiiiiiiiiiiiiiiiiiii");
  console("hiiiiiiiiiiiiiiiiiii");
}
I did neither see a message at terminal nor at the ingame console.
Sadly I do not know what I am doing wrong. The scripting doc give some advice, how to write AIs or challenges, but not how to write scripts which should simple run at the background.

Re: how to write mod / mod does nothing

Posted: 15 Feb 2023, 08:24
by Berserk Cyborg
Mods are loaded as .wz files (really .zip) that point to a directory either inside data/base or data/mp depending on if the game is using a campaign or skirmish/multiplayer setting (this is your base.wz or mp.wz file with the installed game--never modify these directly but feel free to copy and mold them into a new mod). https://github.com/Warzone2100/warzone2 ... aster/data

You then follow the structure of those folders to where you need to mod something and either mod a file or create a new one. You can use my Cobra AI as an example of a non-campaign mod. Typically new files can be loaded inside rules.js found in either base/script or mp/multiplay/script.

I guess this depends on what you want to do with your mod.

Re: how to write mod / mod does nothing

Posted: 02 Apr 2023, 18:13
by b1m2n3
Hi,

@Berserk Cyborg: it seems that mp.wz/multiplay/script do not contain rules.js anymore ; is still remains only in base.wz/script.

I looking for upgrade the NoArty mod for v4.x, but all architecture of directories and files is changed. :augh:
So, first, I tried to overwrite basics values of new files extracted from the actual mp.wz (like you said): the mod looks as loaded but none of my changes have taken effect after many tests... Yet other mod (ARmod_4.0.1.wz) works in the same place: ~AppData\Roaming\Warzone 2100 Project\Warzone 2100\mods\4.3.4\autoload

I don't find updated documentation for this stuff.
An idea?

Thanks :)

Re: how to write mod / mod does nothing

Posted: 02 Apr 2023, 18:35
by Berserk Cyborg
Starting with the 4.0.0 series the rules.js file was split into many files to make maintaining mods easier. https://github.com/Warzone2100/warzone2100/pull/1463

You can find everything at data/mp/multiplay/script for it.

To create a modern No-arty mod you can simply add "designable": 0 to the weapon JSON data and set the default structure limits for all structures to 0 by using (for example):

Code: Select all

"userLimits": [
	0,                 - minimum structure limit
	0,                 - default structure limit
	5                  - maximum structure limit
],
Or plainly ripping out research and rewriting the tech tree which may be a lot more effort. Such old mods are using WzScript so they have no functioning script functionality anymore as we migrated entirely to JavaScript so that may be why you see nothing with that mod. Also all stats are in JSON format and not .txt files as was the case before 3.2.0.

Re: how to write mod / mod does nothing

Posted: 05 Apr 2023, 22:02
by b1m2n3
That's it! I've don't seen userLimits property because it not in all items, and I didn't understand "designable" before.
I already started to reproduce a new modern mod, and I even think to make maybe some variations...

Thank you :)