rules.js

For code related discussions and questions
Post Reply
User avatar
andrvaut
Trained
Trained
Posts: 192
Joined: 02 Jan 2016, 12:44

rules.js

Post by andrvaut » 19 Dec 2019, 17:17

Good afternoon.
For the past month, I have been doing a bit of adding some features to the game initialization script.
https://github.com/vaut/wz-spec-mod
From features made:
- adding greetings with the settings.
- hint to players where the oil towers are located
Spoiler:
- extended observer support
Future plans
- winner determination refactor
- output of extended information about the past game
- processing technology output depending on the starting settings. (creating at the beginning of the game a list of technologies sorted by opening time. And replacing magic constants with the time of the game).

I am waiting for more ideas what else can should be changed in the initialization of the game. If there are no comments on the implemented features, I will cut the operating time into patches and send pullrequests.

I would also like to talk a bit about scripting. If my complaints are not substantiated or require a lot of work to eliminate, I ask you to write about this honestly.

And I had some pretty serious problems writing clean code. This is mainly the use of global functions and variables.

Take for example the syntax
queue (function [, milliseconds [, object]])
requires
1) creating a global function so that it can be called.
2) creation of global variables if parameters need to be passed to it.

As a result, for every one we have to create new global objects.

At the same time, if I'm not mistaken, setReticuleButton (id, filename, filenameHigh, tooltip, callback) in callback normally accepts a function.

The interpreter does not support Getters and Setters, which makes the code more cumbersome.

Also, a lot of blood spoiled me due to the lack of clarification of what this or that function expects to see coordinates:
As a result, magical multiplications by 128 appeared:
struct = addStructure ("A0ResourceExtractor", scavengerPlayer, oil.x * 128, oil.y * 128).
(there is a shift in the structure by less than a cell, but no turn)
Or addSpotter () which part of the arguments is waiting in the tile, part in small squares.

I understand that changing the syntax of previously created commands will require a lot of refactoring.
But at the moment, we can assume that 99% js of the code in the master version.
There are almost no third-party mods that break due to syntax changes. They are already broken by changes: 3.1.x -> 3.2.x -> 3.3.0 -> master

I hope that only those who can fool the game without a hint will read it here. I ask the moderators if they consider the further text dangerous to delete it.
Physfs currently in use searches for files in many places.
After searching for the file in base.wz and mp.wz he searches in mod, then the map and there are two more places from where he will read it. These two places make it easy to override any file.
Theoretically, at the beginning of the game, you can check the checksums of all resources and disable the player if there is a modification. And it works with /stats/
But not all files are checked. This makes it very easy for an attacker to execute third-party code.
For example, many well-known overlay for streams with stat display is based on this. The game does not require modification.
This is precisely what prevents the observers from gaining player status. This code can be used for illegal purposes in ordinary games...
Last edited by andrvaut on 19 Dec 2019, 23:47, edited 1 time in total.
vaut ΣΑ [GN], ru streamer.
Tournaments channel: https://www.youtube.com/channel/UCzusNa-54ydodtSz2TdHFww

User avatar
moltengear
Trained
Trained
Posts: 163
Joined: 22 Jul 2017, 15:05

Re: rules.js

Post by moltengear » 19 Dec 2019, 22:58

andrvaut wrote:
19 Dec 2019, 17:17

Physfs currently in use searches for files in many places.
After searching for the file in base.wz and mp.wz he searches in fashion, then the map and there are two more places from where he will read it. These two places make it easy to override any file.
It is very uncomfortable! I came across this when doing dxt texture support. There were crutches! There is no particular need for this library. Easier to add folders specifically for mods.

The hint where the oil is located is superfluous. Mode fog of war.

User avatar
andrvaut
Trained
Trained
Posts: 192
Joined: 02 Jan 2016, 12:44

Re: rules.js

Post by andrvaut » 19 Dec 2019, 23:50

The hint is designed to make it easier for players to master the low-oil mode.
Despite the fact that I made a jungle map and played a lot of games on it, I can still forget about some of the oils. What to say about the players who see the map for the first time ....

This also applies to friend low oil maps.
It doesn’t give me pleasure to win at the expense of a better-learned map.
vaut ΣΑ [GN], ru streamer.
Tournaments channel: https://www.youtube.com/channel/UCzusNa-54ydodtSz2TdHFww

User avatar
moltengear
Trained
Trained
Posts: 163
Joined: 22 Jul 2017, 15:05

Re: rules.js

Post by moltengear » 20 Dec 2019, 08:56

I think it would be better to include it as an option.
1) CheckBox - highlight oil rigs
2) CheckBox - Open map at startup
But it seems to me, as a mod, this is wrong. Since the idea of the fog of war is being violated.

User avatar
andrvaut
Trained
Trained
Posts: 192
Joined: 02 Jan 2016, 12:44

Re: rules.js

Post by andrvaut » 20 Dec 2019, 12:24

The goal of the fog of war is to hide the actions of the enemy, and not to entangle the player in the map. The landscape at the start of the game is immediately visible. Why should the location of the oil towers be a secret?
The player playing the map for the first time will look like a blind kitten. Even with good skills, he will not be able to beat a player who knows the exact location of the oil.

To hide the card itself, there is RevealStatus. It is used in the campaign to completely hide the card from the player. In this mode, the towers will be redundant.

Let me remind you why the oil rigs and scavengers are not loaded onto the map. The player through the fog of war sees the state of all previously seen buildings. Therefore, he could follow the minimap for scavengers and oil seizures. This would be a violation of the principle of the fog of war. My mod does not allow this.

Checkboxes that would be good.
But I don't know C ++ well enough to change the code.
It would be possible to turn on the mode when there are no unexplored areas on the map.
vaut ΣΑ [GN], ru streamer.
Tournaments channel: https://www.youtube.com/channel/UCzusNa-54ydodtSz2TdHFww

User avatar
Iluvalar
Regular
Regular
Posts: 1813
Joined: 02 Oct 2010, 18:44

Re: rules.js

Post by Iluvalar » 27 Dec 2019, 07:04

Interest rate is always the first thing I mod in the rule.
An universal income as well.

It help reducing the click fest feel to the game. If you don't design and produce at the second you end a research, you will make a little bit more power in interest.
Heretic 2.3 improver and proud of it.

Post Reply