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

Members Online

»
1 Active | 11 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
Page
Next Page
subscribe
Author Topic: rotating doors
SharpHa
General Member
Since: Sep 23, 2005
Posts: 33
Last: Nov 16, 2006
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Friday, Aug. 4, 2006 08:33 pm
I'm sorry to disturb you guy's and gals for this but can someone give me working code for rotating door's. I did try to find that but couldnt find anything [confused][crazy][duh][duh].


SharpHa aka Hannu
Share |
Mystic
General Member
Since: Apr 10, 2004
Posts: 6147
Last: Apr 15, 2018
[view latest posts]
Level 10
Forum Moderator
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Friday, Aug. 4, 2006 08:58 pm
Ill explain so you understand what is happening in this script rather than just giving a bunch of code.

So lets start a new script. Create a new .gsc and lets just call it 'door.gsc'. As with any script we need to start it like so:

main()
{
thread door();
}

As you can see the function we are calling is 'door', so we now need to tell the script what 'door' is. To do this we first need to
grab hold of your door and its trigger. The door should be a script_brushmodel and the trigger a trigger_use.

Code:
door = getent ("door", "targetname");
trig = getent ("doortrigger", "targetname");


As you can see the script is now looking for a script_brushmodel with a targetname of 'door' and a trigger with a targetname of 'doortrigger'. When it finds them we need to tell it what to do with them.

So we want to wait for the door to get triggered. If you remember the trigger is now indentified as 'trig' so we use:

Code:
trig waittill ("trigger");


So somebody has come along a trigggered the trigger, but what happens now? ... Ok being a door we need it to open. So we want it to rotate on the 'Y' axis 90 degrees.

Code:
door rotateyaw (-90,1.5);


So you can see that the door will now open 90 degrees in 1.5 seconds. Either of these can be modified to suit your need. Everything is looking good except no sound will play yet so that is what we need to look at next. We want to play a sound you will need to specify in your .csv (which i wont explain at the moment).

Code:
door playsound("open");


The sound specified is ironically called 'open' as you can see in the code. Now it's a good idea to leave the door open for a while before it closes to allow the player to get through. So lets use:

Code:
wait (3);


Or in other words, 'wait 3 second before you close again'. Lets assume we waited 3 seconds and now we want to close the door back up. Lets play the 'close door sound' (again specified in your .csv as 'close') and rotate the door back 90 degrees.

Code:
door playsound("close");
door rotateyaw (90,2.25);


Lets do a quick check. We got the targetnames, we then waited for the door to be triggered. We opened the door and played the sound. We waited for the player to get through. We closed the door and played the 'close' sound. Only one thing left and that to tell the script that we are all done.
Code:

door waittill ("rotatedone");


Hope this helps.
Share |
SharpHa
General Member
Since: Sep 23, 2005
Posts: 33
Last: Nov 16, 2006
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 04:56 am
Some how it gives me this error:
Script runtime error
(see console for details)
(file 'maps/mp/mp_door1.gsc',line 9)

and when I get back to game door is open but stay's that way.
My hole code is this:

main()
{
thread door();
}
door()
{
door = getent ("door1", "targetname");
trig = getent ("doortrigger1", "targetname");
trig waittill ("trigger");
door rotateyaw ( (0,90,0),2);
door playsound("open");
wait (3);
door playsound("close");
door rotateyaw (90,2.25);
door waittill ("rotatedone");
}


What I did wrong [confused]

[eek][duh]
Share |
ArmorMaster
General Member
Since: Mar 30, 2005
Posts: 371
Last: Oct 3, 2009
[view latest posts]
Level 5
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 05:10 am
I also have problems getting script brushmodels to move. I copy and paste my old .gsc files that used to work fine for COD1 and when I run a COD2 map with those .gsc's, the map crashes with a script compile error. Did they change their scripting methods or something when they made COD2?

Share |
codmp
General Member
Since: Feb 7, 2006
Posts: 905
Last: Aug 1, 2011
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 06:21 am
Quote:
Some how it gives me this error:
Script runtime error
(see console for details)
(file 'maps/mp/mp_door1.gsc',line 9)

and when I get back to game door is open but stay's that way.
My hole code is this:

main()
{
thread door();
}
door()
{
door = getent ("door1", "targetname");
trig = getent ("doortrigger1", "targetname");
trig waittill ("trigger");
door rotateyaw ( (0,90,0),2);
door playsound("open");
wait (3);
door playsound("close");
door rotateyaw (90,2.25);
door waittill ("rotatedone");
}


What I did wrong


Try this:

Code:
main()
{
thread door();
}
door()
{
door = getent ("door1", "targetname");
trig = getent ("doortrigger1", "targetname");
{
trig waittill ("trigger");
door rotateyaw ( (0,90,0),2);
door playsound("open");
wait (3);
door playsound("close");
door rotateyaw (90,2.25);
door waittill ("rotatedone");
}
}
Share |
SharpHa
General Member
Since: Sep 23, 2005
Posts: 33
Last: Nov 16, 2006
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 09:37 am
Somehow it gives error for this:
trig waittill ("trigger");

Dont know why [confused].
Should I do something to that trigger or what's my problem ???


SharpHa aka Hannu

edited on Aug. 8, 2006 05:39 am by SharpHa
Share |
sentchy
General Member
Since: May 6, 2006
Posts: 212
Last: Oct 31, 2006
[view latest posts]
Level 4
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 01:04 pm
In radiant, did you give the door the targetname door1 and the trigger the targetname doortrigger1?

You do this by selecting the door, then pressing N and entering "targetname" as the key and door1 as the value and press Enter. Do the same though with doortrigger1 for the trigger.

The reason you do this is that the COD2 engine needs to know which objects on the map you want to move. You obtain a reference to an map's object by using the getent function to retrieve a single objects and the getentarray to retrieve multiple references to similar objects which in programming is called array.

The line trig = getent("doortrigger1", "targetname"); searches the map for a script_brushmodel that has a key of "targetname" with a value of "doortrigger1").



edited on Aug. 8, 2006 09:11 am by sentchy
Share |
Capt.Com
General Member
Since: Nov 14, 2004
Posts: 879
Last: Oct 6, 2007
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 04:00 pm
SharpHa please check your pm [biggrin]
Share |
SharpHa
General Member
Since: Sep 23, 2005
Posts: 33
Last: Nov 16, 2006
[view latest posts]
Level 2
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 05:56 pm
Thank's Capt.Com it really work [rocking].


SharpHa aka Hannu
Share |
Capt.Com
General Member
Since: Nov 14, 2004
Posts: 879
Last: Oct 6, 2007
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Tuesday, Aug. 8, 2006 06:15 pm
Glad it works [thumbs_up] Always here to help [rocking]
Share |
Restricted Access Topic is Locked
Page
Next Page
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

»