Frictional Games Forum (read-only)
Player dies instantly when walking into area - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: Player dies instantly when walking into area (/thread-23890.html)



Player dies instantly when walking into area - Neelke - 11-18-2013

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;
}
}
}


RE: Player dies instantly when walking into area - DnALANGE - 11-19-2013

GivePlayerDamage(100, "bloodsplat", false, true);

Try that in stead of : AddPlayerHealth(-200);
Wink


RE: Player dies instantly when walking into area - Daemian - 11-19-2013

Code:
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.


RE: Player dies instantly when walking into area - Neelke - 11-19-2013

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?


RE: Player dies instantly when walking into area - Daemian - 11-19-2013

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.


RE: Player dies instantly when walking into area - Neelke - 11-20-2013

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.


RE: Player dies instantly when walking into area - Daemian - 11-21-2013

Nah, listen, if you just want the worm to kill the player on contact, just declare a collide callback.
Worm with player.

PHP Code:
AddEntityCollideCallback"Worm""Player""WormPlayerCollide"true); 

PHP Code:
function WormPlayerCollide string &in pstring &in cint s )
SetPlayerHealth( -); } 

That should work.


RE: Player dies instantly when walking into area - Neelke - 11-21-2013

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.