The easiest way to allow amazing maps!

For AI and campaign script related discussions and questions
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

The easiest way to allow amazing maps!

Post by NoQ »

Put this into rules.js:

Code: Select all

include("multiplay/maps/"+maxPlayers+"c-"+mapName.slice(0, -3)+"/rules.js");
This will allow making scripted maps without involving map-mods (and including them into the game too!). Works on 3.1.

Unfortunately, throws a LOG_ERROR message if the map doesn't provide any script.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: The easiest way to allow amazing maps!

Post by aubergine »

Neat trick :)

What if the player just wants the map without additional scripting?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The easiest way to allow amazing maps!

Post by NoQ »

Then he does the same thing he does now: plays some other map (:
We could make it adjustable, but it wouldn't be "the easiest" (:
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: The easiest way to allow amazing maps!

Post by Per »

The challenge mode already has .ini files that allow you to add scripts to a map. I am going to look into reusing this functionality for non-challenge maps. Ideally, non-challenge maps should be able to set all the same things that challenge maps do. I may have to modify the challenge .ini file format a bit to generalize this.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: The easiest way to allow amazing maps!

Post by aubergine »

If you alter the challenge ini file, could you change it so that things are zero-indexed like in the rest of WZ? It's über-confusing having 1-referenced values in challenge inis. Same applies to team numbers in <mapname>.ini.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The easiest way to allow amazing maps!

Post by NoQ »

Some maps with challenges do exist already, probably not a good idea to break compatibility; i'd easily fix mine (whenever they are suitable for 3.2+), but there may be some we don't know about.

Also, i'm a bit scared to allow arbitrary file names for scripts. Maps may start to conflict if somebody includes an edited version of the script into his map and doesn't rename it. Even with challenges: we don't have a good naming convention for challenge files anywhere. I believe everything must be forced to stay inside the map's physfs folder.

Maybe deprecate the /challenges/ folder completely and merge its functionality into the map .ini?
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: The easiest way to allow amazing maps!

Post by aubergine »

Currently it's possible to create a challenge for any existing map, and that functionality is useful IMHO. If we force challenges and maps to be bundled together, it will be harder for people who don't make maps to create challenges. There should be some ability for a non-mapmaker to create a challenge (or mini campaign) and a non-scripter to make maps.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: The easiest way to allow amazing maps!

Post by Duha »

NoQ wrote:Put this into rules.js:

Code: Select all

include("multiplay/maps/"+maxPlayers+"c-"+mapName.slice(0, -3)+"/rules.js");
This will allow making scripted maps without involving map-mods (and including them into the game too!). Works on 3.1.
Some questions:

To change rules.js you need create new mod ?

Can you add some event handler in map js with out overriding rules.js. handlers?
http://addons.wz2100.net/ developer
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: The easiest way to allow amazing maps!

Post by aubergine »

If I understand correctly, when a map is selected that adds it's folders to the search paths in the physfs system, couldn't you just override multiplay/skirmish/rules.js by having that path and file in the map?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
Iluvalar
Regular
Regular
Posts: 1828
Joined: 02 Oct 2010, 18:44

Re: The easiest way to allow amazing maps!

Post by Iluvalar »

aubergine wrote:Currently it's possible to create a challenge for any existing map, and that functionality is useful IMHO. If we force challenges and maps to be bundled together, it will be harder for people who don't make maps to create challenges. There should be some ability for a non-mapmaker to create a challenge (or mini campaign) and a non-scripter to make maps.
It's easy to target an existing map in the .addon file
Heretic 2.3 improver and proud of it.
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: The easiest way to allow amazing maps!

Post by aubergine »

.addon file? What are those?
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The easiest way to allow amazing maps!

Post by NoQ »

Duha wrote:To change rules.js you need create new mod ?
I proposed to modify the base game's rules.js. There's not much sense in having this as a mod.
Duha wrote:Can you add some event handler in map js with out overriding rules.js. handlers?
I that think if you mention an event twice, just both functions are called.
aubergine wrote:.addon file? What are those?
addon.lev etc., i think, some really weird logic we're trying to get away from by introducing map.ini (?)
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: The easiest way to allow amazing maps!

Post by aubergine »

If you create two event listeners of same name, the second overwrites the first, unless you do some clever stuff with getter/setter properties.
"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: The easiest way to allow amazing maps!

Post by NoQ »

Uhm, yeah, right, never mind. So we're lacking eventGameInit (we still have eventStartLevel), eventAttacked, eventStructureBuilt and eventDestroyed :(
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: The easiest way to allow amazing maps!

Post by Duha »

aubergine wrote:If you create two event listeners of same name, the second overwrites the first, unless you do some clever stuff with getter/setter properties.
I prefer bind unbind functions style
http://addons.wz2100.net/ developer
Post Reply