FlawlessHappiness   
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 3,980 
	Threads: 145 
	Joined: Mar 2012
	
 Reputation: 
171  
		 
	 
	
		
			
[SOLVED] Unlock door with colliding object, Not working 
  
			 
			
				So the idea is that you put a stone chipper inside a padlock (Which works fine).
Then you have to find an object, heavy enough, to throw at the stone chipper, to make the padlock break.
Now there is only one object in my map (so far) which could break it, and that is a brick, called "brick_1".
Here is how it should work with the script:
 
Here is the script:
Spoiler below!   
 
 
void OnStart() 
{ 
 
AddEntityCollideCallback("ScriptArea_4", "Player", "OnCollide_3", false, 1); 
AddEntityCollideCallback("brick_1", "ScriptArea_3", "OnCollide_4", true, 1); 
 
 
AddUseItemCallback("", "stone_chipper_1", "padlock_rusty_1", "UseStoneChipper", true); 
} 
 
///USE ITEMS 
 
void UseStoneChipper(string &in asItem, string &in asEntity) 
{ 
SetEntityActive("stone_chipper_move_1", true); 
PlaySoundAtEntity("", "puzzle_place_jar", "ScriptArea_3", 0, false); 
RemoveItem("stone_chipper_1"); 
} 
 
///COLLIDES 
 
void OnCollide_4(string &in asParent, string &in asChild, int alState) 
{ 
AddPlayerSanity(5); 
PlaySoundAtEntity("", "unlock_door", "prison_section_1", 0, false); 
SetSwingDoorLocked("prison_section_1", false, true); 
SetPropActiveAndFade("padlock_rusty_1", false, 1); 
SetPropActiveAndFade("padlock_rusty_2", true, 1); 
 
SetEntityActive("ScriptArea_4", false); 
SetEntityActive("ScriptArea_3", false); 
} 
 
void OnCollide_3(string &in asParent, string &in asChild, int alState) 
{ 
if(alState == 1) 
{ 
SetEntityActive("ScriptArea_3", false); 
} 
 
if(alState == -1) 
{ 
SetEntityActive("ScriptArea_3", true); 
} 
} 
 
///PICKUP 
 
void chipper_pickup(string &in asEntity) 
{ 
SetEntityActive("ScriptArea_1", true); 
SetEntityActive("block_box_1", true); 
SetEntityActive("block_box_2", true); 
} 
 
///MESSAGES 
 
void DoorLocked_1(string &in asEntity) 
{ 
if(GetSwingDoorLocked("prison_2") == true) 
{ 
SetMessage("Messages", "Locked", 0); 
} 
} 
 
void DoorLocked_2(string &in asEntity) 
{ 
if(GetSwingDoorLocked("prison_section_1") == true) 
{ 
SetMessage("Messages", "PadlockDoorLocked", 0); 
} 
} 
 
void DoorLocked_3(string &in asEntity) 
{ 
if(GetSwingDoorLocked("padlock_rusty_1") == true) 
{ 
SetMessage("Messages", "PadlockLocked", 0); 
} 
} 
 
///INTERACT 
 
void OnStonePickup(string &in asEntity) 
{ 
SetLightVisible("PointLight_3", false); 
} 
 
void OnEnter() 
{ 
 
} 
 
void OnLeave() 
{ 
 
} 
 
 
 
Nothing happens when the brick collides with the script around the padlock... i can't figure out why
			
 
			
			
 
Trying is the first step to success.
			
		  
	
 
 
	06-02-2012, 07:53 PM   
	
		
	 
 
	
		 
		Theforgot3n1   
 
 
		
			Member 
			
			
			
 
			
	Posts: 192 
	Threads: 20 
	Joined: Apr 2012
	
 Reputation: 
6  
		 
	 
	
		
			
RE: Unlock door with colliding object, Not working 
  
			 
			
				Since you don't have a response yet I can attempt to help.
Quote: void OnCollide_3(string &in asParent, string &in asChild, int alState) 
 
{ 
 
if(alState == 1) 
 
{ 
 
SetEntityActive("ScriptArea_3", false); 
 
} 
 
 
 
if(alState == -1) 
 
{ 
 
SetEntityActive("ScriptArea_3", true); 
 
}  
}
When you go out of the "ScriptArea_4", are you sure it makes the entity active? I think collides only trigger when the entity enters the area and not leaves.
Also, when you test, is the "ScriptArea_4" normally inactive from the start?
			
 
			
			
 
			
		  
	
 
 
	06-02-2012, 10:33 PM   
	
		
	 
 
	
		 
		Your Computer   
 
 
		
			SCAN ME! 
			
			
			
 
			
	Posts: 3,456 
	Threads: 32 
	Joined: Jul 2011
	
 Reputation: 
235  
		 
	 
	
		
			
RE: Unlock door with colliding object, Not working 
  
			 
			
				He has 1 instead of 0 for the collision state argument. However, you should be able to avoid requiring a script to do all of this by modifying the padlock to receive damage.
			
			
			
 
			
		  
	
 
 
	06-02-2012, 11:04 PM   
	
		
	 
 
	
		 
		FragdaddyXXL   
 
 
		
			Member 
			
			
			
 
			
	Posts: 136 
	Threads: 20 
	Joined: Apr 2012
	
 Reputation: 
7  
		 
	 
	
		
			
RE: Unlock door with colliding object, Not working 
  
			 
			
				You could check for a collision between the padlock and the brick themselves (without areas) and change the padlock's health to zero when it occurs.
			
			
			
 
			
		  
	
 
 
	06-02-2012, 11:16 PM   
	
		
	 
 
	
		 
		Rapture   
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 1,078 
	Threads: 79 
	Joined: May 2011
	
 Reputation: 
30  
		 
	 
	
		
			
RE: Unlock door with colliding object, Not working 
  
			 
			
				You could use the Distance / Time  formula + Timers  to achieve the same thing. 
 
I know Damascus and his project "The Great Work" has a script already working.
			
			
			
			
		  
	
 
 
	06-02-2012, 11:49 PM   
	
		
	 
 
	
		 
		FlawlessHappiness   
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 3,980 
	Threads: 145 
	Joined: Mar 2012
	
 Reputation: 
171  
		 
	 
	
		
			
RE: Unlock door with colliding object, Not working 
  
			 
			
				Yes both scripts areas are inactive from the start. 
 
Ok i solved it with to scripts. One for Activation of the collide script, and one for the deactivation. 
 
Strange thing is, that some of the stuff that should happen (Like AddPlayerSanity) only started working when i added a debug message to it..
			
			
			
 
Trying is the first step to success.
			
		  
	
 
 
	06-03-2012, 12:23 PM