| 
		
	
		| Shadowfied   Senior Member
 
 Posts: 261
 Threads: 34
 Joined: Jul 2010
 Reputation: 
5
 | 
			| Give Prop Damage? 
 
				I want to make a script where you break a door with an axe, not in the inventory but you lift it up and hit the door, so when I got the idea, my thoughts was to make a script when the axe collide with the door, it subtracts for example 20 of the doors health, so after a few hits it would be 0. There is a function called AddPropHealth but there doesn't seem to be one of for the opposite. I tried using AddPropHealth and using -20 for the value but that doesn't work.
 I appreciate any tips on making this script, and even if there are better ways to make a script like this, I would still like to know if there is a way to subtract health from a prop.
 
 Sorry for posting so many questions by the way, but thanks for answering them.
 
 Thanks in advance.
 
 
 |  |  
	| 01-21-2012, 05:33 PM |  |  
	
		| flamez3   Posting Freak
 
 Posts: 1,281
 Threads: 48
 Joined: Apr 2011
 Reputation: 
57
 | 
			| RE: Give Prop Damage? 
 
				void OnStart(){
 AddEntityCollideCallback("axe", "door", "hurtdoor", false, 1);
 }
 
 void hurtdoor(string &in asParent, string &in asChild, int alState)
 {
 SetPropHealth(-30.0f);
 }
 
 Note: I don't know if that works, just putting it out there.
 
 |  |  
	| 01-21-2012, 05:40 PM |  |  
	
		| Shadowfied   Senior Member
 
 Posts: 261
 Threads: 34
 Joined: Jul 2010
 Reputation: 
5
 | 
			| RE: Give Prop Damage? 
 
				I've been thinking about that, but wouldn't that mean that every time it collides, it Sets the props health to -30? Cause then it's not subtracting the health, just setting it.
 Okay it actually does work with "AddPropHealth" and then using a negative value, but I can't get it to work on the door...nothing works on the door, it worked on a wooden barrel though..
 
 
 
				
(This post was last modified: 01-21-2012, 05:46 PM by Shadowfied.)
 |  |  
	| 01-21-2012, 05:42 PM |  |  
	
		| Streetboat   Posting Freak
 
 Posts: 1,099
 Threads: 40
 Joined: Mar 2011
 Reputation: 
56
 | 
			| RE: Give Prop Damage? 
 
				Interesting idea, I hope it works out!
 As it happens, I have a solution for ya, because I did something similar. Hint: use LocalVarInts. Every time the axe collides with the door, check for the LocalVarInt and set the health to a certain level, and at the same time, add 1 to the LocalVarInt. That way, every time the function is called, a different output will be made. For example:
 
 void hurtdoor(string &in asParent, string &in asChild, int alState)
 {
 if(GetLocalVarInt("hit") == 0)
 {
 SetPropHealth(80.0f);
 AddLocalVarInt("hit", 1);
 }
 if(GetLocalVarInt("hit") == 1)
 {
 SetPropHealth(60.0f);
 AddLocalVarInt("hit", 1);
 }
 
 ...and so on. Hope that helps!
 
 
				
(This post was last modified: 01-21-2012, 05:56 PM by Streetboat.)
 |  |  
	| 01-21-2012, 05:53 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Give Prop Damage? 
 
				Try if (GetPropHealth("prop_name") > 0)SetPropHealth("prop_name", GetPropHealth("prop_name")-10);
 
 |  |  
	| 01-21-2012, 05:59 PM |  |  
	
		| Shadowfied   Senior Member
 
 Posts: 261
 Threads: 34
 Joined: Jul 2010
 Reputation: 
5
 | 
			| RE: Give Prop Damage? 
 
				 (01-21-2012, 05:53 PM)Streetboat Wrote:  Interesting idea, I hope it works out!
 As it happens, I have a solution for ya, because I did something similar. Hint: use LocalVarInts. Every time the axe collides with the door, check for the LocalVarInt and set the health to a certain level, and at the same time, add 1 to the LocalVarInt. That way, every time the function is called, a different output will be made. For example:
 
 void hurtdoor(string &in asParent, string &in asChild, int alState)
 {
 if(GetLocalVarInt("hit") == 0)
 {
 SetPropHealth(80.0f);
 AddLocalVarInt("hit", 1);
 }
 if(GetLocalVarInt("hit") == 1)
 {
 SetPropHealth(60.0f);
 AddLocalVarInt("hit", 1);
 }
 
 ...and so on. Hope that helps!
 I think I know how you're thinking, but I need to see more of the script to understand it, I think. 
Edit: Nevermind I'm just stupid. I pasted your script and fixed the names but it didn't work on the door or the barrel. 
Edit2: Oh wait I'm even more stupid. Hold on.. 
Edit3: Ok I got it working the way you were thinking (I guess) and made it all the way down to 0, which should take 4 hits but it breaks instantly (the barrel right now), probably cause there are a lot of tiny collisions. I would need to make it so that it only counts when it collides with a pretty big amount of force..
 
  (01-21-2012, 05:59 PM)Your Computer Wrote:  Try
 if (GetPropHealth("prop_name") > 0)SetPropHealth("prop_name", GetPropHealth("prop_name")-10);
 
 Did not work, at least not with the way I inserted it. Besides, I don't understand that at all, and I hate using scripts which I don't understand how to make, or how they work. I appreciate the tip, though.
			 
 
				
(This post was last modified: 01-21-2012, 06:14 PM by Shadowfied.)
 |  |  
	| 01-21-2012, 06:04 PM |  |  
	
		| Your Computer   SCAN ME!
 
 Posts: 3,456
 Threads: 32
 Joined: Jul 2011
 Reputation: 
235
 | 
			| RE: Give Prop Damage? 
 
				 (01-21-2012, 06:04 PM)Shadowfied Wrote:  Did not work, at least not with the way I inserted it. Besides, I don't understand that at all, and I hate using scripts which I don't understand how to make, or how they work. I appreciate the tip, though. 
First line checks to see if the health of the prop is greater than 0 (there is no point in giving a prop health that is below 0). Second line takes away 10 health points from the prop. That's part of the same script that i used to break open a door. Taking away 10 health points each time requires more banging on the door (possibly over 5 hits) before completely breaking, assuming the door starts off at 100 health points.
			 
 
				
(This post was last modified: 01-21-2012, 06:19 PM by Your Computer.)
 |  |  
	| 01-21-2012, 06:17 PM |  |  
	
		| Streetboat   Posting Freak
 
 Posts: 1,099
 Threads: 40
 Joined: Mar 2011
 Reputation: 
56
 | 
			| RE: Give Prop Damage? 
 
				I didn't know one could break barrels and that they had a damage model. Interesting...
			 
 |  |  
	| 01-21-2012, 07:11 PM |  |  
	
		| Shadowfied   Senior Member
 
 Posts: 261
 Threads: 34
 Joined: Jul 2010
 Reputation: 
5
 | 
			| RE: Give Prop Damage? 
 
				 (01-21-2012, 07:11 PM)Streetboat Wrote:  I didn't know one could break barrels and that they had a damage model. Interesting... I saw that several times during my first playthrough of the Dark Descent when monsters smashed them.
 
I also saw in the super_secret folder in an early alpha build that they threw a barrel / box and it broke. In my upcoming story I have modified all of those crates and barrels to be breakable when you throw them, allowing you to find items inside them.
			 
 |  |  
	| 01-21-2012, 07:15 PM |  |  |