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

Members Online

»
0 Active | 111 Guests
Online:

LATEST FORUM THREADS

»
CoD: Battle Royale
CoD+UO Map + Mod Releases
Damaged .pk3's
CoD Mapping
heli to attack ai
CoD4 SP Mapping

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: Advanced (AI) slider doorr
ahoji
General Member
Since: May 16, 2006
Posts: 74
Last: Jun 27, 2008
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 07:54 am
Hi all.
I found this script for some lide doors.

Code:

main()
{
thread slidedoor_slider ();
}

slidedoor_slider()
{
slidedoor=getent("slidedoor","targetname");
trig=getent("slideopen","targetname");
while(1)
{
trig waittill ("trigger");
//wait (4);
slidedoor movey (-64,2,0.5,0.5);
slidedoor waittill ("movedone");
wait (4);
//trig waittill ("trigger");
slidedoor movey(64,2,0.5,0.5);
slidedoor waittill ("movedone");

}
}


But this door is "stupid" and they will trap player if he is standing under them when closing.
So i want to make AI dors which doesn't close while player is nearby.
I prepared this byt I'm not sure if it's right.

Code:

main()
{
thread slidedoor_slider ();
}

slidedoor_slider()
{
slidedoor=getent("slidedoor","targetname");
trig=getent("slideopen","targetname");
 while(1)
 {
 trig waittill ("trigger");
 slidedoor movey (-64,2,0.5,0.5);
 slidedoor waittill ("movedone");
 wait (4);
 player = getentarray( "player", "classname" );
 if(player isnotTouching(trig))
	{
         slidedoor movey(64,2,0.5,0.5);
         slidedoor waittill ("movedone");
         }
 }
}


I don't know if is function 'isnotTouching' or something similar so pls correct me if I'm wrong
Share |
Dibbes65
General Member
Since: Oct 3, 2005
Posts: 89
Last: May 25, 2008
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 08:42 am
I don't think that it is a function, but "istouching" is.
Share |
tomalla
General Member
Since: Jan 16, 2007
Posts: 393
Last: Jun 10, 2012
[view latest posts]
Level 5
Im a fan of MODSonair
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 10:05 am
Try this instead:

if(!player isTouching(trig))

"!" make negative in syntax
Share |
OLD_MAN_WITH_GUN
General Member
Since: May 13, 2006
Posts: 754
Last: Jan 23, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 10:15 am
tomalla writes...
Quote:
Try this instead:

if(!player isTouching(trig))

"!" make negative in syntax
That will be work to block the door.
But then he will run into a further problem.
If the player leave the door, the door won't be close and stays open.
Share |
ahoji
General Member
Since: May 16, 2006
Posts: 74
Last: Jun 27, 2008
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 10:15 am
ok thanks
i know what ! do byt i wasn't sure
Share |
ahoji
General Member
Since: May 16, 2006
Posts: 74
Last: Jun 27, 2008
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 10:27 am
How works 'if' function?
In pascal is there also 'else' or 'elseif' so if 'if' is false then goes 'else'.
And if player isn't touching this trig, what it do?
Because AI door should check if player is touching and if no then close and if yes then wait maybe 1s and then check again if player is touching.

edited on Apr. 29, 2007 06:31 am by ahoji
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 11:03 am
it works just like that

if (...)
{

}
else
{

}

not sure if elseif works, but you can easily try that yourself.
Share |
OLD_MAN_WITH_GUN
General Member
Since: May 13, 2006
Posts: 754
Last: Jan 23, 2010
[view latest posts]
Level 7
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 11:12 am
The_Caretaker writes...
Quote:
not sure if elseif works, but you can easily try that yourself.

Works.

if (...)
{

}
else if (...)
{

}
Share |
ahoji
General Member
Since: May 16, 2006
Posts: 74
Last: Jun 27, 2008
[view latest posts]
Level 3
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 01:47 pm
Can be trigger_use used for function isTouching?
________________________________________
ok so i saw script where is command "return;"
Code:

main()
{
    thread alert_sound();

}

alert_sound()
{
	alerts = getentarray ("enginesound", "targetname");
	while (1)
	{
		
		{
			for (i=1;i<alerts.size;i++)
				alerts[0] playsound("T34engine");

			alerts[0] playsound("T34engine");
			
			wait (3);

     self thread alert_sound();

     return;
		}
		}
	}


I dont know if I'm using 'return;' well but this is what i did.
Code:

main()
{
thread slidedoor_slider ();
}

slidedoor_slider()
{
slidedoor=getent("slidedoor","targetname");
trig=getent("slideopen","targetname");
 while(1)
 {
 trig waittill ("trigger");
 slidedoor movey (-64,2,0.5,0.5);
 slidedoor waittill ("movedone");
 wait (4);
 player = getentarray( "player", "classname" );
 if(!player isTouching(trig))
	{
         slidedoor movey(64,2,0.5,0.5);
         slidedoor waittill ("movedone");
         }
 else if(player isTouching(trig))
	{
         wait(1); //time between returning = rechecking if player is touching
         return; //should return script to if(!player isTouching(trig))
         } 
}
}



or should i use only 'else' instead of 'else if'


edited on Apr. 29, 2007 09:55 am by ahoji
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 Scripting
Posted: Sunday, Apr. 29, 2007 03:10 pm
wouldn't matter... else would only mean less code, because you don't have to use the elseif statement.

Usually else if is only used if there are more than two options..
a = 1, 2 or 3...

if (a ==1)
{

}
else if (a == 2)
{

}
else
{

}

Since in your case the player is either not touching the trigger or he is, the else if doesn't have to be used.
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

»