| 
		
	
		| serbusfish   Member
 
 Posts: 211
 Threads: 75
 Joined: Aug 2012
 Reputation: 
0
 | 
			| RE: How to make a door open ajar? 
 
				You guys have been busy since ive been away    Thanks, i'll see if I can get it to work.
			
 |  |  
	| 02-13-2013, 08:46 PM |  |  
	
		| serbusfish   Member
 
 Posts: 211
 Threads: 75
 Joined: Aug 2012
 Reputation: 
0
 | 
			| RE: How to make a door open ajar? 
 
				I have it sorted, thanks again    
One more thing though, rather than make a new thread can someone tell me how I can activate a script box within the game? I tried the SetEntityActive command but it seems to activate when the map is loaded.
 
EDIT: 
 
I tried this script but it wont work, what am I doing wrong?
 AddEntityCollideCallback("Player", "ScriptArea_slam", "DoorSlam", true, 1);
 void DoorSlam(string &in asParent, string &in asChild, int alState)
 
 {
 if(HasItem("key_tomb_rusty_2") == true)
 {
 SetEntityActive("ScriptArea_slam", true);
 AddLocalVarInt("PushDoorVar", 1);
 AddPropImpulse("castle_arched01_11", 1, 0, 0, "world");
 SetSwingDoorClosed("castle_arched01_11", true, false);
 SetSwingDoorLocked("castle_arched01_11", true, false);
 }
 else
 {
 SetEntityActive("ScriptArea_slam", false);
 
 }
 
 
 }
 
				
(This post was last modified: 02-14-2013, 01:25 AM by serbusfish.)
 |  |  
	| 02-14-2013, 01:01 AM |  |  
	
		| NaxEla   Senior Member
 
 Posts: 415
 Threads: 5
 Joined: Dec 2012
 Reputation: 
28
 | 
			| RE: How to make a door open ajar? 
 
				 (02-14-2013, 01:01 AM)serbusfish Wrote:  I have it sorted, thanks again  
 One more thing though, rather than make a new thread can someone tell me how I can activate a script box within the game? I tried the SetEntityActive command but it seems to activate when the map is loaded.
 
SetEntityActive will work to set a script area active/inactive. If you put SetEntityActive in OnStart or OnEnter, the script area will activate when the map is loaded. If you want it to happen after a certain event, then it would go in a different function. In this example, the script area (ScriptArea_1 ) gets activated when the player steps into a different script area (ScriptArea_2 ) :
 void OnStart(){
 AddEntityCollideCallback("Player", "ScriptArea_2", "ActivateArea", true, 1);
 }
 
 void ActivateArea(string &in asParent, string &in asChild, int alState)
 {
 SetEntityActive("ScriptArea_1", true);
 }
 
Make sure that ScriptArea_1 is set inactive in the level editor.
			 
 |  |  
	| 02-14-2013, 01:36 AM |  |  
	
		| FlawlessHappiness   Posting Freak
 
 Posts: 3,980
 Threads: 145
 Joined: Mar 2012
 Reputation: 
171
 | 
			| RE: How to make a door open ajar? 
 
				 (02-14-2013, 01:01 AM)serbusfish Wrote:  I tried this script but it wont work, what am I doing wrong? 
You put the code i gave you in a collide function, but it's supposed to be a timer. That's why it doesn't work    void OnStart(){
 AddEntityCollideCallback("Player", "ScriptArea_slam", "DoorSlam", true, 1);
 }
 
 void DoorSlam(string &in asParent, string &in asChild, int alState)
 {
 AddTimer("PushDoor", 0.2f, "DoorSlamTimer");
 }
 
 void DoorSlamTimer(string &in asTimer)
 {
 if(GetLocalVarInt("PushDoorVar") == 10)
 {
 return;
 }
 
 AddLocalVarInt("PushDoorVar", 1);
 AddPropImpulse("castle_arched01_11", 1.0f, 0.0f, 0.0f, "World");
 AddTimer("PushDoor", 0.2f, "DoorSlamTimer");
 }
Since you want the door to slam, it should need this: SetSwingDoorClosed("castle_arched01_11", true, false); 
because if it's going to slam it should already be open.
			 
 Trying is the first step to success. |  |  
	| 02-14-2013, 06:54 AM |  |  |