Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 7 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 Scripting
Scripting and coding with Call of Duty 2.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: Open project - cod2 door script
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Saturday, Jun. 23, 2007 12:23 pm
G'day folks,

Many have wanted a complete door script that will open doors away from a player, so I decided to give it a shot....

[crazy] Man I was optimistic!

There must be something I'm missing, what I wanted was a script that will be usable by all map makers, it was intended to cope with any door placed either E-W or N-S but also rotate the door clockwise or counter clockwise and away from the player depending on what side of the door they are on...

Therein lies the problem, just too many variables to contend with I'm thinking.

So I have posted what I've got so far in here, and I leave it open source for you other script gurus to play with and complete.

I don't have a lot of hair left so I'm leaving the head scratching and hair pulling to others on this one. [lol]

Code:

//
//Filename: _cod2doors.gsc
//Location: maps\mp\_cod2doors.gsc
//Version 2:
//Updated: June 23, 2007
//
//Created By: <|WHC|>Grassy
//
//Description:
//For normal rotating type doors
//This script is for manipulating and playing sounds on multiple doors
//It will also rotate doors away from the user (most of the time :-) )
//
//Usage:
//Place this in the same directory as your map and call this script
//from the main function of your maps .gsc file
//
//Syntax:
//maps\mp\_cod2doors::main();
//
//Other notes:
//For the sounds to work you will need to have the relevant sound
//files and sound cfg files setup correctly
//
//Notes:
//Arghhh I'm going nuts!
//There are just too many variables to deal with!
//For all possible door orientations and players positions to calculate
//this method is too restrictive! or I'm missing something. Grassy
//I will leave this open ended for others to play with.
//


main()
{
  //collect all use triggers for the metal doors
  ent = getentarray("metaldoor", "targetname");
  if(isDefined(ent))
  {
    for(i = 0; i < ent.size; i ++)
      ent[i] thread Metal_Doors();
  }

  //collect all use triggers for the wood doors
  ents = getentarray("wooddoor", "targetname");
  if(isDefined(ents))
  {
    for(i = 0; i < ents.size; i ++)
      ents[i] thread Wood_Doors();
  }
}

Metal_Doors()
{
  door = getent(self.target, "targetname");

  if(isDefined(self.script_delay))
    delay = self.script_delay;
  else
    delay = 3;
    
  door.X = door.origin[0];
  door.Y = door.origin[1];
  
   while(1)
   {
      self waittill ("trigger",other);
      player = other;

      player.X = player.origin[0];
      player.Y = player.origin[1];
      
      //for testing - rem out when done
      iprintln("Door X: ",door.X);
      iprintln("Door Y: ",door.Y);
      iprintln("Player X: ",player.X);
      iprintln("Player Y: ",player.Y);
      
      if((player.X < door.X) && (player.Y < door.Y))
      {
        open = 90;
        close = -90;
      }
      else if((player.X > door.X) && (player.Y > door.Y))
      {
        open = -90;
        close = 90;
      }
      else if((player.X < door.X) && (player.Y > door.Y))
      {
        open = -90;
        close = 90;
      }
      else if((player.X > door.X) && (player.Y < door.Y))
      {
        open = 90;
        close = -90;
      }
      
      
      door rotateYaw(open, 1.5, 0.5, 0.5);
      //sounds disabled for now
      //door playsound ("metal_door_open");
      door waittill("rotatedone");
        wait delay;
      door rotateYaw(close, 1.5, 0.5, 0.5);
      //door playsound ("metal_door_close");
      door waittill("rotatedone");

      player.X = 0;
      player.Y = 0;
      player = undefined;
   }
} 

Wood_Doors()
{
  door = getent(self.target, "targetname");

  if(isDefined(self.script_delay))
    delay = self.script_delay;
  else
    delay = 3;
    
  door.X = door.origin[0];
  door.Y = door.origin[1];
  
   while(1)
   {
      self waittill ("trigger",other);
      player = other;

      player.X = player.origin[0];
      player.Y = player.origin[1];
      
      //for testing - rem out when done
      iprintln("Door X: ",door.X);
      iprintln("Door Y: ",door.Y);
      iprintln("Player X: ",player.X);
      iprintln("Player Y: ",player.Y);
      
      if((player.X < door.X) && (player.Y < door.Y))
      {
        open = 90;
        close = -90;
      }
      else if((player.X > door.X) && (player.Y > door.Y))
      {
        open = -90;
        close = 90;
      }
      else if((player.X < door.X) && (player.Y > door.Y))
      {
        open = -90;
        close = 90;
      }
      else if((player.X > door.X) && (player.Y < door.Y))
      {
        open = 90;
        close = -90;
      }
      
      
      door rotateYaw(open, 1.5, 0.5, 0.5);
      //sounds disabled for now
      //door playsound ("metal_door_open");
      door waittill("rotatedone");
        wait delay;
      door rotateYaw(close, 1.5, 0.5, 0.5);
      //door playsound ("metal_door_close");
      door waittill("rotatedone");

      player.X = 0;
      player.Y = 0;
      player = undefined;
   }
} 


Have fun,
Regards Grassy
Share |
Scharfschuetze
General Member
Since: Dec 23, 2006
Posts: 162
Last: Jul 7, 2011
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Monday, Jun. 25, 2007 09:59 am
I have been developing a massive script for all kinds of doors in my project, "The Doorhaven Project". I have sliding and rotating doors, and single and double doors. I also have a bulkhead door and I am currently working on a garage door. It has all the necessary variables, and yes there are quite a few. However, adding a door can be done quite easily once the basic scripts are there.

I even have a rotating door that opens away from you as you approach, without pressing the use key, then it swings the other way back and forth about three times and closes. This simulates a swinging door like the kind in restaurants into and out of the kitchen. They kind that hits you in the face when someone else is behind the door going the other way.

I am adding lockable doors with keys that you have to find... a whole bunch of stuff. I hope to be finished with it shortly.


[sniper]

Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Tuesday, Jun. 26, 2007 02:25 pm
Hey sounds great mate!

Sorry for the delay, my net has been down for a few days due to a number of problems, cables, Isp's etc.... [banghead]

I am no stranger to all sorts of doors and model manipulation, but what I was trying to do was let the script do all the thinking on standard simple type doors for mappers to make.
I could have used triggers to detect what side of the door the player is on but that would have complicated the mappers life :)

How did you determine the proximity and on what side of the door a player is with your rotating doors? Just curious :)

Anyway the basic script is there for anyone to pull apart or add to.
Feel free to use it however you want people.

Regards Grassy
Share |
Scharfschuetze
General Member
Since: Dec 23, 2006
Posts: 162
Last: Jul 7, 2011
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Wednesday, Jun. 27, 2007 01:52 am
The Doorhaven Project started in March 2007 with the the beginning question: Just how many ways CAN you put a door in a map?

So, I started to think. Yeah, dangerous thing to do....[biggrin] I thought there are sliding and rotating doors. Then I thought of some fancy house with two doors together, ie: double doors. Then, what about the kind of door that swings both ways on a spring like in a restaurant? From here the script began to grow into a massive script that handles all the kinds of doors I can think of.

Here is a zip file of just the scripts

I am in the process of creating it, so this is just a rough draft.

It is based upon the idea of using a switch statement based upon the door type.

The current list of door types and triggers is as follows:

Door Types
1 = Single Rotating. 2 = Single Sliding.
3 = Double Rotating. 4 = Bulkhead Door, Cellar door at an angle.
5 = Double Sliding. 6 = Swinging Door, rotates both ways, without "using".
7 = Gullwing Door. 8 = Garage Door.
9 = Double Trap Door. 10 = Outside Elevator Door.
11 = Inside Elevator Door. 12 = Positional Trigger.
13 = Trap Trigger.


Essentially you go down through a list of triggers and set them up to wait for their own door to activate. This way, if you put one trigger for a door, or two triggers for a door, you can control which way that door opens based upon the trigger that is activated. Hence a simple, not really that simple, way to control the opening of doors. I will also provide the entire map, the bsp AND the source map file when I get to some point where it is playable enough to show the basic uses of doors....

Some of the doors have taken a massive amount of time to figure out, some are simple.

I am looking right now for a way to implement a menu system, but I am having a hard time going through all those script files to figure it out. I hope to be able to allow the player to not only open doors, but also to find a key to unlock and even to lock a door.

There are lots of variables, direction of swing or direction of sliding movement is one of the major ones. Each door can have a specific sound file, each door can have a specific delay, a speed, all kinds of possibilities. All in one script file. Actually three at the moment. I have over twenty triggers working right now.

Then I guess I should do a Window Haven Project?


[sniper]
Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 Scripting
Posted: Wednesday, Jun. 27, 2007 05:12 am
Holey moley! [eek]

There's more arrays in there than I've ever seen in any other script! And multilevel arrays too! [crazy]

You must be a programmer, can tell by the methods used and extensive notes with updates done.

Nice one mate, good stuff.

Grassy
Share |
codmp
General Member
Since: Feb 7, 2006
Posts: 905
Last: Aug 1, 2011
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Monday, Jul. 16, 2007 04:27 am
lol I jus looked at those door scripts and i gotta say THATS A LOT of arrays. It was kind of looking at some of teh .gsc files for the SP maps.
Share |
Reavensito
General Member
Since: Jul 22, 2006
Posts: 74
Last: Nov 21, 2008
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, Jul. 29, 2007 03:18 pm
Scharfschuetze, could you read this topic and help me?

http://www.modsonline.com/index.php?

Is about elevator open door (when elevator arrives, doors open, and, when leave, close)

Thanks.
Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 Scripting

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»