Script Difference with Multiplayer

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Wad'a'Holic
Posts: 174
Joined: Tue Mar 01, 2005 8:55 pm
Location: New Zealand
Contact:

Script Difference with Multiplayer

Post by Wad'a'Holic »

Hello everyone,

I have been working on a mod for this great source-port but I have encountered a problem that I can't seem to get my head around.

I made a script that spawns demons (like an invasion based mode). The demons spawn in Single-Player but when I play Deathmatch they won't appear.

Same with the teleporter function. At the start of the match the player will be teleported to a certain area in the level. Again, it works in Single-Player but not in Multiplayer.

Heres some samples of the code that will not work:

Code: Select all

Thing_SpawnFacing(1,4,1,10);
And the teleporter

Code: Select all

// Player setup
Script 102 ENTER
	// Teleport to a certain point
	If(sfProgress==1){Teleport(100);}
	If(sfProgress==2){Teleport(101);}
	If(sfProgress==3){Teleport(102);}
}
It is something that has kinda been bugging me.

Anyways, apart from that, great source port :)
Thanks,
-Wad'a'Holic
User avatar
Bio Hazard
Posts: 4019
Joined: Fri Aug 15, 2003 8:15 pm
Location: ferret ~/C/ZDL $
Contact:

Post by Bio Hazard »

Are the teleport destinations/map spots flagged to appear in multiplayer?

Also, this isin't a bug so I'm moving it into editing.
User avatar
Wills
Posts: 1446
Joined: Mon Jan 10, 2005 7:01 pm
Location: The Well of Wishes

Post by Wills »

Maybe you have monsters turned off for DM, but I'm not sure if that would affect it. And you need to flag everything for Multiplayer.
User avatar
Necromage
Posts: 484
Joined: Thu Feb 10, 2005 3:13 pm
Location: NJ
Contact:

Re: Script Difference with Multiplayer

Post by Necromage »

Definitly make sure that its checked for coop and dm, however, in the script you posted you don't need the '{}' brackets when you only have one statement. This is true for if and else (its also true in for and while but since you have to have a delay in the loop your going to have more then one statement). So the codee above can just be written as:

Code: Select all

// Player setup
Script 102 ENTER
	// Teleport to a certain point
	If(sfProgress==1) Teleport(100);
	If(sfProgress==2) Teleport(101);
	If(sfProgress==3) Teleport(102);
}
While not a big deal it does save a few key strokes. :wink:
User avatar
Jim
Posts: 535
Joined: Mon Aug 11, 2003 10:56 am

Post by Jim »

It's missing a curly brace.

Code: Select all

Script 102 ENTER {
   // ...
User avatar
Zippy
Posts: 3302
Joined: Wed Mar 23, 2005 5:31 pm
Location: New Jersey

Post by Zippy »

Quite frankly most of that is a style issue. I personally use braces even for one line if statements because it more clearly delineates them. Also, it's less error prone. I never write the whole thing on one line either, but at a minimum of three.

Code: Select all

if ( something ) {
   DoStuff;
}
Though with this paticular case, I imagine I'd use a switch statement (especially if sfProgress started getting more than 3 values.)
User avatar
Jim
Posts: 535
Joined: Mon Aug 11, 2003 10:56 am

Post by Jim »

I fully agree, Zippy.
User avatar
Bio Hazard
Posts: 4019
Joined: Fri Aug 15, 2003 8:15 pm
Location: ferret ~/C/ZDL $
Contact:

Re: Script Difference with Multiplayer

Post by Bio Hazard »

And I'd do it like this:

Code: Select all

// Player setup
Script 102 ENTER{
	if(sfProgress){
		Teleport(99+sfProgress);
	}
}
Again, it's all about style.
User avatar
Jim
Posts: 535
Joined: Mon Aug 11, 2003 10:56 am

Post by Jim »

Not completely, actually your code is better Bio. It is smaller (both compiled and uncompiled), just as clear or clearer, and demonstrably faster. Addition is faster than a conditional jump.
User avatar
Bio Hazard
Posts: 4019
Joined: Fri Aug 15, 2003 8:15 pm
Location: ferret ~/C/ZDL $
Contact:

Post by Bio Hazard »

Heh, I was almost positive I'd get an "OM6 ur c0d3 iz Unreadabl3!" form graf or someone.

There are a few problems with the scalability of mine though, all destination tags must be contiguous, although that can be fixed with a small case{} with a default: label and if sfProgress happens to exceed the destinations, something weird can happen. Again, that can be solved with "if(sfProgress&&sfProgress<MAX_PROGRESS){".
Locked

Return to “Editing (Archive)”