Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
Player dies instantly when walking into area 
			 
			
				So, what I've scripted is when enemy (rock worm) and player is in same area I want the player to die. Instead, when player enters one of these areas he dies immediately instead. The script I did is below. Can someone explain what I did wrong? 
 
//The steps for the worm 
void DoWormStep() 
{ 
	int lCurrentWormStep = GetLocalVarInt("WormStep"); 
	 
	AddLocalVarInt("WormStep", 1); 
	int lWormStep = GetLocalVarInt("WormStep"); 
	 
	CheckPlayerWormVariable(); 
	 
	if(lWormStep!=9){ 
		SetLocalVarInt("WormFinished", 3); 
	}else if (lWormStep!=32){ 
		SetLocalVarInt("WormFinished", 4); 
	}else{ 
		SetLocalVarInt("WormFinished", 2); 
	} 
} 
//The steps for the player 
void DoPlayerStep() 
{ 
	int lCurrentPlayerStep = GetLocalVarInt("PlayerStep"); 
	 
	CheckPlayerWormVariable(); 
	 
	AddLocalVarInt("PlayerStep", 1); 
	int lPlayerStep = GetLocalVarInt("PlayerStep"); 
} 
 
//This checks if player and worm is in the same area. If so, kill the player 
void CheckPlayerWormVariable() 
{ 
	string sCurrentPlayerLocation = GetLocalVarString("CurrentPlayerLocation"); 
	string sCurrentEnemyLocation = GetLocalVarString("CurrentEnemyLocation"); 
	 
	if(sCurrentEnemyLocation==sCurrentPlayerLocation) 
	{ 
		FadeOut(0.2f); 
		PlayGuiSound("worm_attack", 1.0f); 
	 
		AddPlayerHealth(-200); 
		CheckPoint("checkpoint","PlayerStartArea_1", "ContinueAgain", "Hints", "DeathByWorm"); 
	} 
	 
	int lRoomIndex = 0; 
	for(int i=0; i<52; ++i) 
	{ 
		if(sCurrentPlayerLocation=="AreaCheckPlayer_" + (i+1)) 
		{ 
			lRoomIndex = i; 
			break; 
		} 
	} 
}
			 
			
			
			
				
(This post was last modified: 11-18-2013, 10:04 PM by Neelke.)
 
				
			 
		 |  
	 
 | 
 
	| 11-18-2013, 09:22 PM  | 
	
		
	 | 
 
 
	
		
		DnALANGE 
 
 
		
			Banned 
			
			
			
 
			
	Posts: 1,549 
	Threads: 73 
	Joined: Jan 2012
	
		
	 | 
	
		
			
RE: Player dies instantly when walking into area 
			 
			
				GivePlayerDamage(100, "bloodsplat", false, true); 
 
Try that in stead of : AddPlayerHealth(-200);
  
			 
			
			
			
		 |  
	 
 | 
 
	| 11-19-2013, 04:14 AM  | 
	
		
	 | 
 
 
	
		
		Daemian 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 1,129 
	Threads: 42 
	Joined: Dec 2012
	
 Reputation: 
49
		
	 | 
	
		
			
RE: Player dies instantly when walking into area 
			 
			
				string sCurrentPlayerLocation = GetLocalVarString("CurrentPlayerLocation"); 
string sCurrentEnemyLocation = GetLocalVarString("CurrentEnemyLocation");
 
These two are getting nothing from that variables cause they don't exist. 
So they are equal and the condition to kill the player is true.
			  
			
			
 
			
		 |  
	 
 | 
 
	| 11-19-2013, 12:44 PM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: Player dies instantly when walking into area 
			 
			
				Since I'm not fully sure how localvarstring works, how do I make them NOT equal? My guess is this? 
 
AddLocalVarString("CurrentPlayerLocation", sCurrentEnemyLocation); 
 
And if this is correct, where do I put it?
			 
			
			
			
				
(This post was last modified: 11-19-2013, 01:21 PM by Neelke.)
 
				
			 
		 |  
	 
 | 
 
	| 11-19-2013, 01:17 PM  | 
	
		
	 | 
 
 
	
		
		Daemian 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 1,129 
	Threads: 42 
	Joined: Dec 2012
	
 Reputation: 
49
		
	 | 
	
		
			
RE: Player dies instantly when walking into area 
			 
			
				I don't think so, you should read some tutorials on scripting and variables first. 
Then you'll see your error. I think there's something in the wiki.
			 
			
			
 
			
		 |  
	 
 | 
 
	| 11-19-2013, 06:51 PM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: Player dies instantly when walking into area 
			 
			
				I can't find any solution to my problem. I just can't. I have tried and I have tried and I have tried. I just don't know how to make them unequal. My best idea was this below. 
 
void TrackPlayerLocation(string &in asParent, string &in asChild, int alState) 
string sEntity = asParent; 
	if(asParent=="Player") 
	{ 
		SetLocalVarString("CurrentPlayerLocation", asChild); 
	} 
	else 
	{ 
		sEntity = "Enemy ("+sEntity+")"; 
		SetLocalVarString("CurrentEnemyLocation", asChild); 
	} 
} 
 
You guys might just want me to keep trying, but to be honest, I really don't feel like it. My rage level is almost level 99 at the moment.
			 
			
			
			
		 |  
	 
 | 
 
	| 11-20-2013, 10:47 PM  | 
	
		
	 | 
 
 
	
		
		Daemian 
 
 
		
			Posting Freak 
			
			
			
 
			
	Posts: 1,129 
	Threads: 42 
	Joined: Dec 2012
	
 Reputation: 
49
		
	 | 
	
		
			
RE: Player dies instantly when walking into area 
			 
			
				Nah, listen, if you just want the worm to kill the player on contact, just declare a collide callback.  
Worm with player.
 AddEntityCollideCallback( "Worm", "Player", "WormPlayerCollide", true, 1 ); 
 
  
function WormPlayerCollide ( string &in p, string &in c, int s ) { SetPlayerHealth( -1 ); } 
 
 
That should work.
			  
			
			
 
			
		 |  
	 
 | 
 
	| 11-21-2013, 04:21 AM  | 
	
		
	 | 
 
 
	
		
		Neelke 
 
 
		
			Senior Member 
			
			
			
 
			
	Posts: 668 
	Threads: 82 
	Joined: Apr 2013
	
 Reputation: 
26
		
	 | 
	
		
			
RE: Player dies instantly when walking into area 
			 
			
				Alright, appearntly, the rock worm that ain't named with an angle, like x,y or z, is impossible to use. I have been using that thing all along. Changed it to a angle worm, worked perfectly. I don't know why, just so weird. But I'm glad it's working finally.
			 
			
			
			
				
(This post was last modified: 11-22-2013, 07:43 PM by Neelke.)
 
				
			 
		 |  
	 
 | 
 
	| 11-21-2013, 04:34 PM  | 
	
		
	 | 
 
 
	 
 |