Page 1 of 2

Y origin calculation?

Posted: Mon Apr 19, 2004 12:11 pm
by Ramah Palmer
Hi everyone, been some time since I posted on here - good to see it's still going strong despite the evil influence that is COD! :D

Ok, I have an idea that I'd like to try and implement in my map - a kind of anti-camping device. I'm not sure if this has been done - can't see anything on the scripting forum.

What I'd like to do is every five or ten seconds or so have the script get every remaining player's origin and compare them with each other. By knowing the origin of the centre of the map it should be possible to tell which player is closest to their spawn shouldn't it? And then whichever player is lagging the most is summarily executed. :lol:
Because my map runs exactly North/South I only need to do a calculation on the Y part of the origin.
So then my first question is: Is what I have described possible?

If so then my second question would be: How? :oops:

Thanks in advance for any help I receive on this subject.

Ramah Palmer.

Posted: Mon Apr 19, 2004 12:46 pm
by Ramah Palmer
Ok, I've been doing a little further digging around the forum and it looks like 'vector_length' could be my best bet - is this correct?
I'm assuming this works out the length of a line drawn between two points? In which case I can ignore just using the 'Y' value of the origin.

Ah, but then the problem could be that a person could be level with the centre of the map but further away on the 'X-axis' and a player could be further back down the map but closer than the first player to the centre. Hmm, am I making any sense? I know what I mean.
Am I talking to myself? :)

silly

Posted: Mon Apr 19, 2004 4:50 pm
by tltrude
It just seems altogether to silly to me. If you want to kill people that don't leave the spawn then just blow them up with a big timed explosion--assuming you know how to spawn explosions that damage players.

Posted: Mon Apr 19, 2004 7:54 pm
by Rindog
vector_within(vector1 vector2 radius)

Returns 1 if vector1 is within radius of vector2. Radius is spherical.

Posted: Tue Apr 20, 2004 1:29 am
by nuggets
lol, good to see you haven't been dragged to CoD,

1stly, yes you do need vector
2ndly, as tltrude said, are you sure you hate campers that much,
they could just as easily make a script that if you've moved too far without being sneaky it'll kill ya

anyway

while ($player.size > 0)
{
for (local.i=1; local.i<=$player.size; local.i++)
{
$player[local.i].oldorigin = $player[local.i].origin
$player[local.i] thread move_check
}
wait 10
}
end

move_check:
wait 10
local.j = vector_length (self.origin - self.oldorigin)
if (local.j < 256) //if player hasn't moved atleast 256 units in 10 seconds
self hurt 10
end

//this will only hurt any stationary player not kill them if they haven't moved atleast the determined number of units within a given time,

//i wouldn't use it to always kill the player who's moved the least, what if everyone is actively running around?

Posted: Tue Apr 20, 2004 5:44 pm
by Ramah Palmer
Thanks for answering guys. I admit, it's a crazy thing to want to do but it's a pretty crazy map that I'm doing. :) Basically it's just a fun map that I am working on to maybe invite a few clans onto our server and have a laugh with.
The anti-camping feature is just one silly little thing I want to add. At the moment I KIND OF have it working with a series of triggers that fire after a while, but it's not a very subtle way fo doing it.

Nuggets, thanks for the script m8, but that isn't quite what I meant. I want to penalizer players for hanging back, not standing still. My map is a series of levels of a building all rectangular in shape with one team starting at one end and the opposing team at the other.
At the moment I have it that there is a 25% chance of the anti-camper device firing and if that happens everyone has to start moving forward pretty quickly as I want to kill whoever is closest to THEIR spawn.

I think I will be able to change the script to suit my needs though m8. Instead of using the centre of the map as an origin to test against I think I will use the far wall facing the team. This will hopefully get rid of the problem I described in my second post above.

I'll see how I get on. :lol:

Posted: Tue Apr 20, 2004 7:51 pm
by Ramah Palmer
Ok, here is the scripting I have for this so far:


anti_camp:

iprintln "Hell's teeth! The gas canisters are leaking! RUN!"

wait 3

local.posit = 0
while ($player.size > 0)
{
for (local.i=1; local.i<=$player.size; local.i++)
{
if($player[local.i].dmteam == axis)
{

local.j = vector_length ($player[local.i].origin - $5_axis_goal.origin)


local.j = local.j * -1 //not sure if this is needed but seemed safe coz not sure if above line would give pos or neg value


if (local.j > local.posit)
{
local.posit = local.j
local.soldier = local.i
}

}

else if($player[local.i].dmteam == allies)
{

local.j = vector_length ($player[local.i].origin - $5_ally_goal.origin)


local.j = local.j * -1 //not sure if this is needed but seemed safe coz not sure if above line would give pos or neg value


if (local.j > local.posit)
{
local.posit = local.j
local.soldier = local.i
}
}
}

$player[local.soldier] stufftext ( " say Eeeuurrghh! Eeeurgh! <choke> EEEEUUURRrgghhh..... ")
$player[local.soldier] stufftext ("kill")
wait 5
}
end



Now, I may have made some mistakes here and made it more long-winded than I have to, but I am still pretty much a novice at this (check out my question on multiple triggers if you need further proof! :D :oops: )
Anyway, this seems like it might work when running around the map on my own (have yet to test it with more people to be sure) but one thing it does wrong is to keep going after I died continually doing the stufftext commands.

I was wondering, does the 'while ($player.size > 0) ' line just check to see how many players there are in the game or how many LIVE players there are?
I think I may need a way to stop the loop when there are no live players left - or have I made some simple mistake?

Thanks.

isalive

Posted: Tue Apr 20, 2004 8:30 pm
by tltrude
$player.size returns the number of players in the game (dead or not). The command for checking if an entity has life or not is, "isalive".

while (isalive local.player[index.i])

Posted: Sat Apr 24, 2004 9:52 am
by Ramah Palmer
Ok thanks. So obviously that line is going to need adding or it will just keep killing the person who is furthest back whether they are already dead or not. :?

But is there a way to rewrite the 'while ($player.size > 0) ' line to mean:

'while (there is at least one person left alive)' ?

allies

Posted: Sat Apr 24, 2004 10:39 am
by tltrude
First, here is a thread that will get the number of allied players in the game.

Code: Select all

getnumberallied:

	local.j = 0
	for(local.i = 1; local.i <= $player.size; local.i++)
	{
	local.player = $player[local.i]
	if(local.player.dmteam == allies)
	local.j++
	}

end local.j
So that thread can be used by another to produce a value for a variable.

local.numallies = waitthread getnumberallied

Now all we need to do is add an extra bit to that "getnumberallied" thread to get the number of "live" allied players.

Code: Select all

getnumberallied:

	local.j = 0
	for(local.i = 1; local.i <= $player.size; local.i++)
	{
	local.player = $player[local.i]
	if ((isalive local.player) && (local.player.dmteam == allies))
	local.j++
	}

end local.j
example -

print_number_allied:

local.numallies = waitthread getnumberallied
iprintln "Living Allied players = " (local.numallies)
wait 2
goto print_number_allied

end


Hope that helps!

Posted: Sat Apr 24, 2004 1:04 pm
by nuggets
hate to put a shadow over this but...

won't the player who's furthest back respawn and always be the player furthest back and therefore always getting killed?

Posted: Sat Apr 24, 2004 1:24 pm
by Ramah Palmer
Respawning map? :shock: Eeeeewwwww!!!!

Posted: Wed Jun 09, 2004 8:23 pm
by oddball
i'm also busy with a nocamp mod, but somehow the game refuses to get the playerstate. i see when the player is dying the isalive value changes but directly after that it goes back to the life status.
so in my case if (isalive($player[local.i])) isn't working :(
That causes big problems, because if a dead player spectates an alive on he also get warned (also warns in my mod) and punished again. Anyone knows a workaround for this ?

Posted: Wed Jun 09, 2004 8:31 pm
by jv_map
Yes spawn a very small trigger_multiple at his origin... if the triggers it (immediately) he's definately not spectating :)

Posted: Wed Jun 09, 2004 8:39 pm
by oddball
hmmm good idea, worth a try
only triggers on alife so when dead, no trigger..
only thing is, can i glue it to the player ? because when spectating i need the trigger to folow the dead player all the time.