11-18-2013, 09:22 PM
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;
}
}
}
//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;
}
}
}