Hi
I know this is old but it is always useful to have on a server
I was experimenting around with rotating doors before , and thought i could use some of it to update this mod, so here it is now
Below is a new UPDATED version of the doorblock script by Stranter, it now does not need any other scripts or map specific scripts, it now grabs the coords for every door ( func_rotatingdoor) from the map as it loads, so this can be exec from dmprecache.scr ,
So to summarize updated version
- Only need the ONE script , not the multiple ones like before
- you do NOT need to add custom maps , will find coords automatically.
- executed from dmprecache.scr
Save and load as global/doorblock.scr or similar
Code:
/*
Doorblock Detection
v1 : 22 May 2010
Base function
Original Mod By : Stranter
UPDATED
v2 : 27 April 2014
By : Purple Elephant
Notes on v2:
Now a Global script , can be called from dmpreache, it will find the coords of the doors AUTOMATICALLY!!!! ,
does not require different map specific scripts
REQUIRES : Latest Version of Reborn Patch 1.12 for AA
>> http://www.x-null.net/forums/forumdisplay.php?82-1-12-RC3-Patch <<
for the getentity command
Credits:
Stranter : For original Mod
Purple Elephant : For updating mod for use globally without the need to grab coords from custom maps
Sor: For a little MoveAway script he wrote that i found on xnull
*/
main:
level waittill spawn
local.doorArray = waitthread get_doors
for(local.i = 1; local.i <= local.doorArray.size; local.i++)
{
local.door = spawn trigger_multiple
local.door.origin = ((local.doorArray[local.i][1]) - ( 0 0 40 ))
local.door.angle = local.doorArray[local.i][2]
local.door setsize ( -20 -20 -0 ) ( 20 20 0 )
local.door setthread doorBlock
wait 1
}
end
/// Gets all func_rotatingdoors on the map , made by Purple Elephant
get_doors:
/// Min is sv_maxclients, can be 1 , but this is slightly quicker because lower numbered entities are reserved for players
local.min = int(getcvar(sv_maxclients))
// Max is found by spawning a dummy model and getting its entnum
local.dummy = spawn script_model model "fx/dummy.tik" origin ( 0 0 -1000 )
local.max = int(local.dummy.entnum)
local.j = 0
for(local.i = local.min;local.i <= local.max;local.i++)
{
local.ent = getentity local.i
if(local.ent != NULL)
{
if(local.ent.classname == "RotatingDoor")
{
local.j++
local.array[local.j][1] = local.ent.origin
local.array[local.j][2] = local.ent.angle
}
}
waitframe
}
end local.array
/// This part thanks to Stranter for original , edited by Purple Elephant
doorBlock:
local.player = parm.other
if!(local.player.blockState)
{
local.player.blockState = 1
local.isBlocking = vector_within local.player.origin self.origin 50
local.blockCount = 0
while((isalive local.player) && (local.isBlocking) && (local.player.blockState)&& local.player.dmteam != "spectator")
{
local.isBlocking = vector_within local.player.origin self.origin 50
wait 0.1
local.blockCount++
/// If player pressed use (ie not blocking anymore or not trying to , could be blocked from other side)
// resets counter
if(local.player.useheld)
local.blockCount = 0
///When blockcount reaches 30 , sends away
if(local.blockCount > 30)
{
local.player iprint "You were door blocking"
local.player waitthread MoveAway
local.player.blockState = 0
end
}
}
local.player.blockState = 0
}
end
//// This part thanks to Sor, edited alittle :P
MoveAway:
local.origin = (self gettagposition "eyes bone");
local.rad = 30;
local.move = "back"
if ((sighttrace local.origin (local.origin + (self.forwardvector * local.rad))1) ) {
local.move = "forward";
}
else if ((sighttrace local.origin (local.origin + ((self.forwardvector * -1) * local.rad))1) ) {
local.move = "back";
}
else if ((sighttrace local.origin (local.origin + (self.leftvector * local.rad))1) ) {
local.move = "moveleft";
}
else if ((sighttrace local.origin (local.origin + (self.rightvector * local.rad))1) ) {
local.move = "moveright";
}
self stufftext ("+" + local.move);
wait (randomfloat(0.5) + 0.5); //random [0.5; 1.0] interval to wait;
self stufftext ("-" + local.move);
end;