rules.js has strange code.

For AI and campaign script related discussions and questions
Post Reply
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

rules.js has strange code.

Post by Duha »

base/../rules.js has strange code.

If multiple HQ will be allowed cause an issue. (hide minimap when HQ down)

it will look better in that way:

Code: Select all

// General rules for the campaign
//
// * Enable unit design and minimap only when an HQ exists

function eventStartLevel()
{
	if (enumStruct(me, HQ).length + enumStructOffWorld(me, HQ).length >0)
	{
		setMiniMap(true);
		setDesign(true);}
	else {
		setMiniMap(false);
		setDesign(false);
	}
}

function eventStructureBuilt(struct)
{
	if (struct.player == selectedPlayer && struct.type == STRUCTURE && struct.stattype == HQ)
	{
		setMiniMap(true);
		setDesign(true);
	}
}

function eventDestroyed(victim)
{
	if (enumStruct(me, HQ).length + enumStructOffWorld(me, HQ).length >0)
	{
		// Disable unit design and minimap when the HQ gets destroyed
		setMiniMap(false);
		setDesign(false);
	}
}
almost same for mp.

PS. I can`t make pull request for technical reason.
Last edited by Duha on 25 Apr 2012, 09:57, edited 1 time in total.
http://addons.wz2100.net/ developer
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: rules.js has strange code.

Post by NoQ »

If multiple HQ will be allowed
Why would anybody want that? :hmm:
enumStructOffWorld
What does it do in skirmish/mp games?
Last edited by NoQ on 25 Apr 2012, 00:07, edited 1 time in total.
User avatar
Iluvalar
Regular
Regular
Posts: 1828
Joined: 02 Oct 2010, 18:44

Re: rules.js has strange code.

Post by Iluvalar »

it's the first time i see this code. Please note that there is 4 HQ in the games stats, testing for the HQ identified "HQ" could cause errors.

If i read correctly, if a player build a collective CC. He will keep the map after it destruction.
Heretic 2.3 improver and proud of it.
User avatar
Shadow Wolf TJC
Regular
Regular
Posts: 1047
Joined: 16 Apr 2011, 05:12
Location: Raleigh, NC

Re: rules.js has strange code.

Post by Shadow Wolf TJC »

NoQ wrote:
If multiple HQ will be allowed
Why would anybody want that? :hmm:
I'd personally like to have a spare HQ on the field in case the one in my main base gets destroyed.
Creator of Warzone 2100: Contingency!
Founder of Wikizone 2100: http://wikizone2100.wikia.com/wiki/Wikizone_2100
User avatar
NoQ
Special
Special
Posts: 6226
Joined: 24 Dec 2009, 11:35
Location: /var/zone

Re: rules.js has strange code.

Post by NoQ »

I misread things again, but i still don't understand why would anybody want to allow multiple HQs in the base game.
If it is done via a mod, then this mod should simply adjust rules.js?...
User avatar
Duha
Trained
Trained
Posts: 287
Joined: 25 Mar 2012, 20:05
Location: SPb, Russia

Re: rules.js has strange code.

Post by Duha »

NoQ wrote:I misread things again, but i still don't understand why would anybody want to allow multiple HQs in the base game.
If it is done via a mod, then this mod should simply adjust rules.js?...
In game start event you iterate other HQs and call HQ build event on each. Is it realy need iteraton?
In building start event you just elie that it only one HQ can be per player.

Two different approches in one piece of code. It is not good. Looks like two different peoples write this.

PS.

Code: Select all

//if (enumStruct(me, HQ).length + enumStructOffWorld(me, HQ) >0)
if (enumStruct(me, HQ).length + enumStructOffWorldf(me, HQ).length >0)
NoQ wrote:
enumStructOffWorld
What does it do in skirmish/mp games?
as I said almost the same is for mp. I wil test that after find out why game crashes.

What rules use chalenges?
http://addons.wz2100.net/ developer
User avatar
aubergine
Professional
Professional
Posts: 3459
Joined: 10 Oct 2010, 00:58
Contact:

Re: rules.js has strange code.

Post by aubergine »

"Dedicated to discovering Warzone artefacts, and sharing them freely for the benefit of the community."
-- https://warzone.atlassian.net/wiki/display/GO
Post Reply