Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Player dies instantly when walking into area
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#1
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
Find
DnALANGE Offline
Banned

Posts: 1,549
Threads: 73
Joined: Jan 2012
#2
RE: Player dies instantly when walking into area

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

Try that in stead of : AddPlayerHealth(-200);
Wink
11-19-2013, 04:14 AM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#3
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
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#4
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
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#5
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
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#6
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
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#7
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.

PHP Code: (Select All)
AddEntityCollideCallback"Worm""Player""WormPlayerCollide"true); 

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

That should work.

11-21-2013, 04:21 AM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#8
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
Find




Users browsing this thread: 1 Guest(s)