Page 1 of 1

rules.js has strange code.

Posted: 24 Apr 2012, 23:49
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.

Re: rules.js has strange code.

Posted: 25 Apr 2012, 00:03
by NoQ
If multiple HQ will be allowed
Why would anybody want that? :hmm:
enumStructOffWorld
What does it do in skirmish/mp games?

Re: rules.js has strange code.

Posted: 25 Apr 2012, 00:07
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.

Re: rules.js has strange code.

Posted: 25 Apr 2012, 04:17
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.

Re: rules.js has strange code.

Posted: 25 Apr 2012, 05:28
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?...

Re: rules.js has strange code.

Posted: 25 Apr 2012, 09:56
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?

Re: rules.js has strange code.

Posted: 09 May 2012, 22:13
by aubergine