+ Reply to Thread
Page 2 of 2
FirstFirst 1 2
Results 16 to 25 of 25

Thread: Doors.

  1. #16
    MD's Servant barak1001 is on a distinguished road barak1001's Avatar
    Join Date
    Apr 2007
    Posts
    533
    One single schedule function won't cause lag anyway. Also notice it's a variable so you can change the distance and frequency of the checks simply by changing the number. Best to install it and experiment with it.

    The nice part of this script is that it only runs once per x amount of seconds, even though it controls every door on the map. It should scale up nicely and be able to control however many doors you need.

    As I stated before though, I'm not sure if the script actually functions or not, since I've never tried it in game. In theory it should work, but there might be syntax errors I've missed or problems with the logic that I haven't foreseen.

    Try it on a map and let me know if it works, if it doesn't I may have to load it up and fix the syntax errors.

  2. #17
    MD's Servant barak1001 is on a distinguished road barak1001's Avatar
    Join Date
    Apr 2007
    Posts
    533
    I finally got around to testing out my script.

    Here's the revised version.

    Code:
    $doorDistance = 40;
    //Distance from door to herc, should be meters.
    
    $doorTiming = 2;
    //Amount of time to run the door checks
    
    $DoorPath = "MissionGroup/Doors";
    //SimGroup where doors are stored in the map
    
    function countDoors()
    
    //This function counts through the doors and then fires the distanceCheck function on each one
    
    {
    	//The next section finds the ID number of the first door in the Doors group of the map
    	//It then fires the distanceCheck function on that door, then it goes to the next door
    	//and repeats
    
    	%doorPath = $DoorPath;
    	%door = getNextObject(%doorPath, 0);
    
    	while(%door != 0)
    	{
    		distanceCheck(%door);
    		%door = getNextObject(%doorPath,%door);
    	}
    	schedule("countDoors();",$doorTiming);
    }
    
    function distanceCheck(%this)
    {
    	//The next section will find the total number of players in the server, then go through
    	//them one by one to see if they are in a vehicle or not.
    	
    	%vehicleCount = 0;
    	%count = playerManager::getPlayerCount();
    	for(%i = 0; %i < %count; %i++)
      	{
    		%player = playerManager::getPlayerNum(%i);
    		%vehicle = playerManager::playerNumtoVehicleId(%player);
    		if(%vehicle != "")			//If a player has a vehicle continue to run.
    		{
    			%playerTeam = getTeam(%vehicle);
    			%doorTeam = getTeam(%this);
    			//The next section gets the x,y,z coordinates of the door and the herc.
    
    			%doorX = getPosition(%this, x);
    			%doorY = getPosition(%this, y);
    			%doorZ = getPosition(%this, z);
    			%vehicleX = getPosition(%vehicle, x);
    			%vehicley = getPosition(%vehicle, y);
    			%vehiclez = getPosition(%vehicle, z);
    			%x = %doorX - %vehicleX;
    			%y = %doorY - %vehicleY;
    			%z = %doorZ - %vehicleZ;
    			//The next section checks to see if the numbers are negative numbers.
    			//If they are it multiplies them by -1 to make them a positive number.
    			//This will be needed to do our math for the distance check.
    
    			if(%x < 0)
    			{
    				%x = %x * -1;
    			}
    			if(%y < 0)
    			{
    				%y = %y * -1;
    			}
    			if(%z < 0)
    			{
    				%z = %z * -1;
    			}
    
    			//The next section checks to see if there is a herc within the trigger distance.
    			//If there is it adds 1 to the vehicleCount variable.
    
    			if(%x <= $doorDistance && %y <= $doorDistance && %z <= $doorDistance)
    			{
    				if(%playerTeam == %doorTeam)
    				{
    					%vehicleCount++;
    					if(%this.open != "true")
    					{
    						say(%player,0,"Access Granted");
    					}
    				
    				}
    			}
    		}
    	}
    	//The next section checks to see if the door is closed and if a vehicle is within range.
    	//If so it sets the variable for the door to open and opens the door.
    
    	if(%this.open != "true" && %vehicleCount > 0)
    	{
    		%this.open = "true";
    		playAnimSequence(%this, 0, true);
    	}
    
    	//The next section checks to see if the door is open and all vehicles are out of range.
    	//If so it sets the variable for the door to closed and closes the door.
    
    	else if (%this.open == "true" && %vehicleCount == 0)
    	{
    		%this.open = "false";
    		playAnimSequence(%this, 0, false);
    	}
    	
    }
    
    countDoors();
    I have tested it and it works. All you do is make a sim group called "Doors" and then drop the doors into it. I tested it with two doors in server and they worked perfectly, though the settings probably do need to be tweaked a bit.

    Edit:

    Added in functionality so that it tests the person's team and only opens for the proper team colors. Just set the door's team to whatever color you want it to open for.
    Last edited by barak1001; 03-23-2010 at 02:35 AM.

  3. #18
    Veteran2 Feret is on a distinguished road Feret's Avatar
    Join Date
    Jan 2001
    Location
    Hinton, WV, USA
    Posts
    2,417
    That would make spawn camping more difficult wouldn't it? hrms.
    Founder/Member of Ultra Force
    Game Master of the Hellstorm Hussars Battletech Mercenary Unit

  4. #19
    MD's Servant barak1001 is on a distinguished road barak1001's Avatar
    Join Date
    Apr 2007
    Posts
    533
    You can use it to setup all manner of bases in TDM. Most practical setup would be a walled city with doors on either side.

    It even works with the "cryo door" which is too small for a herc, but a tank can fit through pretty easily.

    Code revised again. Now it allows for you to turn the team checking on and off by variable, and automatically turns it off in DM.

    Code:
    $doorDistance = 40;
    //Distance from door to herc, should be meters.
    
    $doorTiming = 1.5;
    //Amount of time to run the door checks
    
    $DoorPath = "MissionGroup/Doors";
    //SimGroup where doors are stored in the map
    
    $doorTeam = "false";
    //Door will only open if door team and player team color match if set to true.
    
    if($server::TeamPlay == "false")
    {
    $doorTeam = "false";
    }
    //Sets doors to open for any team color in Death Match.
    
    
    function countDoors()
    
    //This function counts through the doors and then fires the distanceCheck function on each one
    
    {
    	//The next section finds the ID number of the first door in the Doors group of the map
    	//It then fires the distanceCheck function on that door, then it goes to the next door
    	//and repeats
    
    	%doorPath = $DoorPath;
    	%door = getNextObject(%doorPath, 0);
    
    	while(%door != 0)
    	{
    		distanceCheck(%door);
    		%door = getNextObject(%doorPath,%door);
    	}
    	schedule("countDoors();",$doorTiming);
    }
    
    function distanceCheck(%this)
    {
    	//The next section will find the total number of players in the server, then go through
    	//them one by one to see if they are in a vehicle or not.
    	
    	%vehicleCount = 0;
    	%count = playerManager::getPlayerCount();
    	for(%i = 0; %i < %count; %i++)
      	{
    		%player = playerManager::getPlayerNum(%i);
    		%vehicle = playerManager::playerNumtoVehicleId(%player);
    		if(%vehicle != "")			//If a player has a vehicle continue to run.
    		{
    			%playerTeam = getTeam(%vehicle);
    			%doorTeam = getTeam(%this);
    			//The next section gets the x,y,z coordinates of the door and the herc.
    
    			%doorX = getPosition(%this, x);
    			%doorY = getPosition(%this, y);
    			%doorZ = getPosition(%this, z);
    			%vehicleX = getPosition(%vehicle, x);
    			%vehicley = getPosition(%vehicle, y);
    			%vehiclez = getPosition(%vehicle, z);
    			%x = %doorX - %vehicleX;
    			%y = %doorY - %vehicleY;
    			%z = %doorZ - %vehicleZ;
    			//The next section checks to see if the numbers are negative numbers.
    			//If they are it multiplies them by -1 to make them a positive number.
    			//This will be needed to do our math for the distance check.
    
    			if(%x < 0)
    			{
    				%x = %x * -1;
    			}
    			if(%y < 0)
    			{
    				%y = %y * -1;
    			}
    			if(%z < 0)
    			{
    				%z = %z * -1;
    			}
    
    			//The next section checks to see if there is a herc within the trigger distance.
    			//If there is it adds 1 to the vehicleCount variable.
    
    			if(%x <= $doorDistance && %y <= $doorDistance && %z <= $doorDistance)
    			{
    				if($doorTeam == "true")
    				{
    					if(%playerTeam == %doorTeam)
    					{
    						%vehicleCount++;
    						if(%this.open != "true")
    						{
    							say(%player,0,"Access Granted");
    						}
    				
    					}
    				}
    				else
    				{
    					%vehicleCount++;
    					if(%this.open != "true")
    					{
    						say(%player,0,"Access Granted");
    					}
    				}
    			}
    		}
    	}
    	//The next section checks to see if the door is closed and if a vehicle is within range.
    	//If so it sets the variable for the door to open and opens the door.
    
    	if(%this.open != "true" && %vehicleCount > 0)
    	{
    		%this.open = "true";
    		playAnimSequence(%this, 0, true);
    	}
    
    	//The next section checks to see if the door is open and all vehicles are out of range.
    	//If so it sets the variable for the door to closed and closes the door.
    
    	else if (%this.open == "true" && %vehicleCount == 0)
    	{
    		%this.open = "false";
    		playAnimSequence(%this, 0, false);
    	}
    	
    }
    
    countDoors();
    Last edited by barak1001; 03-23-2010 at 09:25 AM.

  5. #20
    Junky Enamel_32 is on a distinguished road
    Join Date
    Apr 2007
    Posts
    126
    Very fancy, Barak. I might actually have a map that could use this, too.
    (A.K.A. Stormtrooper MIB)
    Starsiege Stuff

  6. #21
    MD's Servant barak1001 is on a distinguished road barak1001's Avatar
    Join Date
    Apr 2007
    Posts
    533
    I was never really sure if it worked or not since no one reported back on it. So I decided to see for myself.

    As much as I hate map making I'm working on a TDM now that has one team as "rebels" at one end of the city attacking another team in a fortified position. Should be interesting.

  7. #22
    Junky Enamel_32 is on a distinguished road
    Join Date
    Apr 2007
    Posts
    126
    It's the objects drifting when you hit apply that bothers you, right? Try snapping to the grid by a size of 1, use planar movement, and avoid moving multiple things at once. That should take care of almost all of the cases where it happens.
    (A.K.A. Stormtrooper MIB)
    Starsiege Stuff

  8. #23
    MD's Servant barak1001 is on a distinguished road barak1001's Avatar
    Join Date
    Apr 2007
    Posts
    533
    I wasn't aware you could snap to grid.

    As far as the doors go team checking was off in the global, thus the reason they opened for anyone, so the team check does function.

  9. #24
    Junky Enamel_32 is on a distinguished road
    Join Date
    Apr 2007
    Posts
    126
    It's in the options menu, mid-left. Very useful for spacing things.
    (A.K.A. Stormtrooper MIB)
    Starsiege Stuff

  10. #25
    MD's Servant barak1001 is on a distinguished road barak1001's Avatar
    Join Date
    Apr 2007
    Posts
    533
    Or just press the O key. I found it after reading your post. Makes placing walls much easier.

+ Reply to Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts