Page 1 of 1

addStructure

Posted: 14 Jul 2011, 11:06
by NoQ
Still working on this "spectators" thing, now with new map-mod mechanism. That's what i have for a 4-player map with 2 of them being spectators:

spectate.wrf:

Code: Select all

directory       "multiplay/maps/4c-INSERTMAPNAMEHERE"
file		SCRIPT		"spectate.slo"
file		SCRIPTVAL	"spectate.vlo"
spectate.vlo:

Code: Select all

script "spectate.slo"
run
{
command      STRUCTURESTAT   "A0CommandCentre"
satlink      STRUCTURESTAT   "A0Sat-linkCentre"
}
spectate.slo:

Code: Select all

private      STRUCTURESTAT   command,satlink;

trigger spectateTr(every, 10);
event spectateEv(spectateTr)
{
	if ( getStructure(satlink , 2) == NULLOBJECT ) {
		addStructure(satlink, 2, 5*128, 6*128);
	}
	if ( getStructure(command , 2) == NULLOBJECT ) {
		addStructure(command, 2, 4*128, 8*128);
	}
	if ( getStructure(satlink , 3) == NULLOBJECT ) {
		addStructure(satlink, 3, 58*128, 121*128);
	}
	if ( getStructure(command , 3) == NULLOBJECT ) {
		addStructure(command, 3, 59*128, 119*128);
	}
}
Now here's the problem.

Even though the structures are created, players don't seem to benefit from it. The minimap doesn't appear, and the map doesn't get revealed, and they can't even be demolished by your truck. I'm sure the buildings do belong to the players i intended them to belong to.

Re: addStructure

Posted: 14 Jul 2011, 11:27
by devastator
Ты вроде читос всё открывал, не легче?

Re: addStructure

Posted: 14 Jul 2011, 12:35
by NoQ
:annoyed: how is this related? :hmm: :wink:

Re: addStructure

Posted: 14 Jul 2011, 14:22
by NoQ
http://developer.wz2100.net/wiki/ScriptingManual told me to use enableStructure first:

Code: Select all

...
event spectateEv(spectateTr)
{
        enableStructure(command,2);
        enableStructure(command,3);
        enableStructure(satlink,2);
        enableStructure(satlink,3);
...
but it didn't help, the problem is still the same :(

Re: addStructure

Posted: 14 Jul 2011, 20:30
by milo christiansen
NoQ wrote:private      STRUCTURESTAT   command,satlink;
This is part of your problem. When declaring things from a vlo use public. Not sure if this will fix it, but its still incorrect and so should be changed.

Also use the scripts dir for your scripts instead of the map dir. Something like scripts/spectate would be best. It's not needed but it will help keep things cleaner. The way the map/mod support works you won't have to worry about more than one map using scripts of the same name.

Re: addStructure

Posted: 14 Jul 2011, 20:34
by Mysteryem
Hmm, if I use the debug menu to switch to player 2 or 3 it seems to work fine. In single player skirmish, you don't actually change which player you are when you move start positions.

My only change to what was in the first post was changing the directory line of the wrf file to

Code: Select all

directory       "script"
since I put the files there. So depending on where you put the files, what is in the first post works fine.

Edit: I was thinking, how do the away missions from the campaign handle this?

Re: addStructure

Posted: 15 Jul 2011, 03:13
by Buginator
NoQ wrote:Still working on this "spectators" thing, now with new map-mod mechanism. That's what i have for a 4-player map with 2 of them being spectators:
FYI, that is going to be reverted, since it is broken. (Unless a fix is found...before the next release)

Re: addStructure

Posted: 15 Jul 2011, 20:04
by NoQ
Buginator wrote:
NoQ wrote:Still working on this "spectators" thing, now with new map-mod mechanism. That's what i have for a 4-player map with 2 of them being spectators:
FYI, that is going to be reverted, since it is broken. (Unless a fix is found...before the next release)
Hey that's not fair! :shock: Even if it's broken, reverting it breaks things even more in all situations! :shock: O_o

Re: addStructure

Posted: 16 Jul 2011, 07:40
by NoQ
Hmm, if I use the debug menu to switch to player 2 or 3 it seems to work fine. In single player skirmish, you don't actually change which player you are when you move start positions.
So how are we identify players that should be spectators?
Upd: yeah, i noticed the radar of a wrong color after all; i didn't notice it when tried a deity cheat because i was player 0. Looks like they're created for a wrong player after all.

Re: addStructure

Posted: 16 Jul 2011, 08:30
by NoQ
Anyway, i used objectInRange() to discriminate between the players and it's working now, thanks everybody (: