Page 1 of 3

(SOLVED) Restricting Spectators

Posted: Thu Dec 18, 2008 4:37 am
by Broadus
I am working on a co-op mod, and I don't have to do much to make it work, but I have problems anyway. Just one, so far, that is really, really important.

The AI target spectators. So a spectator flies around, and the AI take shots at him, even though, being a spectator, he can't be hit.
It's not just that, but the spectators trigger events that only players should trigger. When the player walks through an invisible wall, it triggers something to happen in the level. A spectator can do the same thing: He can just float through that invisible wall and trigger something to happen. So a spectator could fly through the whole level and trigger things he shouldn't be able to.
Is there a way to make it so spectators can only spectate players? Or, make it so the spectators can't move at all?

Posted: Thu Dec 18, 2008 5:54 am
by Aprop
Co-op? I working on the similiar mod, you can make spectaros unmoveabkle by script, or try something like "threatbias ignoreme" but i didnt already tested it.....

Posted: Thu Dec 18, 2008 5:58 am
by Broadus
Well, yeah, that's what I'm trying to do, but that's not how to do it. How do I make them unmoveable by script? What script do I use?
I also don't know how to target a spectator to set the threatbias (??????.threatbias = ignoreme).

Posted: Thu Dec 18, 2008 6:46 am
by Aprop

Code: Select all

	$santa threatbias ignoreme
It works for AI, for players - dont know... its similiar to notarget cheat.
To turn it off:

Code: Select all

	$santa threatbias 50000

Posted: Thu Dec 18, 2008 6:56 am
by Broadus
I put "??????" to represent the fact that I don't know what a spectator is called. The player is called $player, an enemy AI might be called $nazi, but what's the spectator called?

Also, knowing how to prevent the spectators from moving is a lot more important than making the AI ignore them. If they can't move, chances are the AI can't even see them. How do I prevent the spectators from moving?
Like, literally, exactly, how? What scripts do I use?

Posted: Thu Dec 18, 2008 9:00 am
by Aprop

Code: Select all

		for (local.p=1;local.p<=$player.size;local.p++)
		{
			local.player = $player[local.p]
		
			if (local.player.dmteam == "spectator")
			{
				local.player thread lock
			}
		}
end

lock:
while (self.dmteam == "spectator")
{
waitframe
self.origin = ( 0 0 0 )
waitframe
}
This should work, waitframe protect script from infinite loop and cpu usage

Posted: Thu Dec 18, 2008 9:04 am
by $oldier Of Ra
There is a perfectly working and fun co-op mod(s) out there by jcb:

http://www.discoverthat.co.uk/games/mohaamods.htm

And threatbias works for AI and Players ;) 'cause it is a command of the Sentient class.
Use <player_alias> threatbias ignoreme

AI will see a spectator if it comes into their screen (even though you're invisible) and if you got any dogs and the spectator was an enemy of those dogs (eg: if dogs are german and player was allied/american or vice versa) then they will sniff out the spectator :P
Spectators weren't meant to be in SP.

Posted: Thu Dec 18, 2008 10:59 am
by Broadus
$oldier Of Ra wrote:There is a perfectly working and fun co-op mod(s) out there by jcb:
http://www.discoverthat.co.uk/games/mohaamods.htm
Uh, that's all fine and good, but those are co-op maps, not a co-op mod. I am making co-op for the original campaign and it won't require any custom files to be downloaded, so people can join a server without downloading anything.
$oldier Of Ra wrote:And threatbias works for AI and Players ;) 'cause it is a command of the Sentient class.
Use <player_alias> threatbias ignoreme
I already talked about this to aprop, I already know how threatbias works. I don't know how to do it for spectators because spectators aren't called "<player_alias>" or anything conveniently named like that.
$oldier Of Ra wrote:AI will see a spectator if it comes into their screen (even though you're invisible) and if you got any dogs and the spectator was an enemy of those dogs (eg: if dogs are german and player was allied/american or vice versa) then they will sniff out the spectator :P
Spectators weren't meant to be in SP.
Yeah, that's why I'm trying to fix the spectator problems with this thread.

Posted: Thu Dec 18, 2008 11:10 am
by $oldier Of Ra
Uh, that's all fine and good, but those are co-op maps, not a co-op mod. I am making co-op for the original campaign and it won't require any custom files to be downloaded, so people can join a server without downloading anything.
No... that would be a SP-to-MP map with the SP stuff still in it. Nothing Co-Op about it.
I don't know how to do it for spectators because spectators aren't called "<player_alias>" or anything conveniently named like that.
Huh :? ?? Yes they are just as convenient to find as that:

Code: Select all

fix_spec:

while(1)
{
for (local.i = 1; local.i <= $player.size; local.i++)
{
if ($player[local.i].dmteam == "spectator")
{
$player[local.i] threatbias ignoreme
}
else
{
$player[local.i] threatbias 5000 //or something like that
}
}
wait 0.5
}
end
I assumed you know how to find players how else could you make a co-op mod?
I hope it helps.

Posted: Thu Dec 18, 2008 11:13 am
by Broadus
Aprop wrote:

Code: Select all

		for (local.p=1;local.p<=$player.size;local.p++)
		{
			local.player = $player[local.p]
		
			if (local.player.dmteam == "spectator")
			{
				local.player thread lock
			}
		}
end

lock:
while (self.dmteam == "spectator")
{
waitframe
self.origin = ( 0 0 0 )
waitframe
}
This should work, waitframe protect script from infinite loop and cpu usage
Thanks! That looks pretty good, but I can't quite get it to work.
I also tried some foolproof variations on it to make sure. Any player that isn't an Axis has a threatbias of ignoreme.

Code: Select all

speclocker:
      for (local.p=1;local.p<=$player.size;local.p++)
      {
         local.player = $player[local.p]
      
         if (local.player.dmteam != "axis")
         {
            local.player thread lock
         }
      }
end

lock:
	while (self.dmteam != "axis")
	{
		waitframe
		self threatbias ignoreme
		waitframe
	}
end
So what I do is, I just have "thread speclocker" by itself on a line. Theoretically, this should make me ignored by the enemies when I join the Allies, but they don't ignore me at all, so the script isn't working or I'm not threading it properly or something.

Posted: Thu Dec 18, 2008 11:18 am
by $oldier Of Ra
That's because your "thread speclocker" probably isn't activated after level waittill spawn in the main thread of the mapscript. Or another problem in any case: The for statement only runs 1 time, so if it has run and you didn't join allies/spectator by the time it does, you didn't get threaded to the lock thread.

Posted: Thu Dec 18, 2008 11:27 am
by Broadus
$oldier Of Ra wrote:
Uh, that's all fine and good, but those are co-op maps, not a co-op mod. I am making co-op for the original campaign and it won't require any custom files to be downloaded, so people can join a server without downloading anything.
No... that would be a SP-to-MP map with the SP stuff still in it. Nothing Co-Op about it.
What??? Dude, that is the very definition of co-op: A bunch of players on the same team going through the campaign together, fighting AI and completing objectives. That's co-op. That's why when you go to co-op for games like Halo 3, it's the original campaign with more players in it.
$oldier Of Ra wrote:
I don't know how to do it for spectators because spectators aren't called "<player_alias>" or anything conveniently named like that.
Huh :? ?? Yes they are just as convenient to find as that:
...
I assumed you know how to find players how else could you make a co-op mod?
I hope it helps.
Actually, I had no idea how to find players. But thanks to your code, I do! Thanks a lot!

Thanks to both of you, I now have the spectators frozen in place, AND they are completely ignored by AI! It worked out perfectly. Problem solved!
Now that I can locate players through script it will probably be really useful in the future.

Posted: Thu Dec 18, 2008 11:33 am
by $oldier Of Ra
Co-Op is playing singleplayer (= clientside) with more than 1 person.
Anyways, glad we could help and give us the IP when it's done; I want to check it out ;)

Posted: Thu Dec 18, 2008 11:39 am
by Broadus
$oldier Of Ra wrote:Co-Op is playing singleplayer (= clientside) with more than 1 person.
Anyways, glad we could help and give us the IP when it's done; I want to check it out ;)
No it's not. Those co-op levels you linked are just multiplayer with AI, like my mod. Sven Co-op, a mod for Half-Life 1, is multiplayer in the original campaign. They just take the deathmatch mode and make it so players can't hurt eachother. Synergy, a mod for Half-Life 2, does the same thing with the Half-Life 2 single player campaign. It's just Half-Life 2 Deathmatch set in the campaign. That's how co-op always works. Because you can already load the monsters into the deathmatch, it makes it possible.
In a game like Call of Duty, they make it impossible by separating the multiplayer and the single player. You would have to own the source code of the Call of Duty games to put co-op into them. That's why playing co-op on Call of Duty 5 requires you to go to the single player part of the game, instead of the multiplayer part. The single player part loads all the single player stuff and the multiplayer part doesn't.
In Allied Assault, Half-Life 1 and Half-Life 2, the modes are practically put together. You can put stuff from the single player, like AI, into the multiplayer modes of those games, which is what makes co-op mods possible. If they were like Call of Duty, it'd be impossible.

Posted: Thu Dec 18, 2008 11:45 am
by $oldier Of Ra
Ah, but those are mods, not put in the game. ;) In a handful of games (moh is one of them) you can connect to clientside games. Valve does not allow this because Valve&steam wants everyone to play online so these mods can only be done serverside. In any game with stock co-op support, the co-op is always "clientside". (It's basically the same as LAN)