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
Script Help Making it so Slime Damage can Kill, need help!
DaPurpleHippo Offline
Junior Member

Posts: 9
Threads: 2
Joined: Aug 2014
Reputation: 0
#1
Making it so Slime Damage can Kill, need help!

I have an area of my map where poisonous gasses fill the room and kill you if you mess up the puzzle and become trapped. The problem is that the Slime Damage does not seem to be able to kill the player. It just keeps creating more and more damage as time progresses. Is there a script to cause the Slime Damage area type to kill the player?

An alternative method for using the Slime Area I think may work is using a Script Area and coding it so that when the player enters, they take damage. I have a very basic knowledge of scripting though, so I am at a loss and my script does not work (posting the .hps below).

I also tried copying the Slime Damage script directly from the game.cfg file, but that didn't work so I gave up there. If there is some sort of damage or kill area script out there I don't know about, please let me know as well! Smile

Scripts:
Spoiler below!
Level Script

void OnStart()
{
{
AddEntityCollideCallback("Player", "checkpoint_00", "Restart", true, 1);
}
{
AddEntityCollideCallback("Player", "damage_zone01", "GivePlayerDamage", true, 1);
}
}

void Restart(string &in asParent, string &in asChild, int alState)
{
CheckPoint("FirstCheckpoint", "respawn_001", "Happening", "DeathCategory", "Deathtext");
}

void Happening(string &in asName, int alCount)
{
//
}

void move_top_down(string &in asEntity, int alState)
{
if (alState == 1)
{
SetMoveObjectState("top_door", 1.0f);
}
}

GivePlayerDamage("25", "", 0.02, true);
Spoiler below!
game.cfg Script

<Slime
SlimeType0_AttackSound = "slime_attack_normal_hit.snt"
SlimeType0_AttackPS = "ps_slime_attack_normal.ps"
SlimeType0_MinAttackDamage = "5"
SlimeType0_MaxAttackDamage = "8"
SlimeType0_ScreenShakeAmount = "0.03"
/>

Ah! Just remembered that The Cistern Entrance level does have a poisonous gas area with the following script. Going to try and implement it into my map using the same techniques and maybe this can turn into a tutorial :p

Spoiler below!
void CollidePoison_Start(string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("InPosion")==1) return;
SetLocalVarInt("InPosion", 1);

FadeImageTrailTo(0.7, 1);
AddTimer("PoisonCough",0.5, "TimerPoisonCough");
}

void CollidePoison_Stop(string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("InPosion")==0) return;
SetLocalVarInt("InPosion", 0);

StopPoisonEffects();
}

void StopPoisonEffects()
{
FadePlayerFOVMulTo( 1, 1);
FadePlayerAspectMulTo( 1, 1);
FadeImageTrailTo(0, 1);
FadeRadialBlurTo(0.0f, 0.5f);

RemoveTimer("PoisonCough");
}

//----------------------------

void TimerPoisonCough(string &asTimer)
{
PlaySoundAtEntity("cough","player_cough", "Player", 0, false);
GivePlayerDamage(0.5, "BloodSplash", false, false);

if(GetLocalVarInt("PosionOn") == 0){
FadeRadialBlurTo(0.3f, 2.0f);
SetRadialBlurStartDist(0.6f);
SetLocalVarInt("PosionOn", 1);
}else{
FadeRadialBlurTo(0.2f, 2.0f);
SetRadialBlurStartDist(0.8f);
SetLocalVarInt("PosionOn", 0);
}

AddTimer("PoisonCough",RandFloat(1.5, 3.5), "TimerPoisonCough");
}

So simply copypasta didn't work with that script. Viewed the Cistern map and copied the PoisonStart area and Stop area and plopped them in the spot on my map and they did not work with the script. The map loads, but when the player enters the areas, nothing happens.
(This post was last modified: 08-15-2014, 08:03 AM by DaPurpleHippo.)
08-15-2014, 07:36 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#2
RE: Making it so Slime Damage can Kill, need help!

Perhaps try using this line of code:

PHP Code: (Select All)
GivePlayerDamage(float afAmountstringasTypebool abSpinHeadbool abLethal); 
afAmount - amount of damage done to health
asType - plays a certain effect on the screen when the damage is dealt (BloodSplat, Claws or Slash)
abSpinHead - changes the camera view when damage is dealt
abLethal - set to true if player can die from given damage

Edit: I see you have used it, but used it incorrectly.

A float is a decimal number between 0 and 100.
A string is a line of text which is enclosed in quotation marks ( "" )
A bool is a boolean, which means true or false.

If you want it in the correct format, right at the bottom of the code I did in this spoiler, you should find one which works!

Edit 2:
I may have misinterpreted - My one (should) work if the door should NOT open, which would fail the puzzle. If it is incorrect, use First Captain's solution below me Smile

Spoiler below!

Your code is also a bit messy - it almost seems that it would crash when you run it :o
PHP Code: (Select All)
void OnStart()
{
AddEntityCollideCallback("Player""checkpoint_00""Restart"true1);
AddEntityCollideCallback("Player""damage_zone01""GivePlayerDamage"true1);
}

void Restart(string &in asParentstring &in asChildint alState)
{
CheckPoint("FirstCheckpoint""respawn_001""Happening""DeathCategory""Deathtext");
}

void Happening(string &in asNameint alCount)
{
//When you respawn, if anything is supposed to happen, put it here.
}

void move_top_down(string &in asEntityint alState)
{
if(
alState == 1)
{
SetMoveObjectState("top_door"1.0f);
}
else
{
GivePlayerDamage(100.0f"blood"falsetrue); //Will instantly kill the player if they do the wrong thing.



Discord: Romulator#0001
[Image: 3f6f01a904.png]
(This post was last modified: 08-15-2014, 08:40 AM by Romulator.)
08-15-2014, 08:34 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#3
RE: Making it so Slime Damage can Kill, need help!

I'm guessing that what you want is that when you enter the script area you'll take damage periodically yes?

Spoiler below!

void OnStart()
{
AddEntityCollideCallback("Player", "checkpoint_00", "Restart", true, 1);
AddEntityCollideCallback("Player", "damage_zone01", "GivePlayerDamage", true, 1);
}

void Restart(string &in asParent, string &in asChild, int alState)
{
CheckPoint("FirstCheckpoint", "respawn_001", "Happening", "DeathCategory", "Deathtext");
}

void Happening(string &in asName, int alCount)
{
//
}

void move_top_down(string &in asEntity, int alState)
{
if (alState == 1)
{
SetMoveObjectState("top_door", 1.0f);
for (int x; x == 4; x++)
{
GivePlayerDamage("25", "", 0.02, true);
}
}


The script in the spoiler box is made so that the Player's health is taken by 25hu (25 health units) 4 times. 4 times 25 is 100 so the Player dies.

NOTE: I ASSUMED THAT YOU'LL TAKE DAMAGE IF alState IS 1. TELL ME IF THIS IS INCORRECT.

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 08-15-2014, 08:38 AM by PutraenusAlivius.)
08-15-2014, 08:36 AM
Find
DaPurpleHippo Offline
Junior Member

Posts: 9
Threads: 2
Joined: Aug 2014
Reputation: 0
#4
RE: Making it so Slime Damage can Kill, need help!

Thanks for explaining the script Rom. And Captain is right, I want it so that when the player is in the area, they take damage. Think of it as a simple Slime Area, but it can actually kill. I did some experimentation and came up with this code that does not crash the map:
Spoiler below!
void OnStart()
{
AddEntityCollideCallback("Player", "checkpoint_00", "Restart", true, 1);
AddEntityCollideCallback("Player", "damage_zone01", "GivePlayerDamage", true, 1);
}

void Restart(string &in asParent, string &in asChild, int alState)
{
CheckPoint("FirstCheckpoint", "respawn_001", "Happening", "DeathCategory", "Deathtext");
}

void Happening(string &in asName, int alCount)
{
//
}

void move_top_down(string &in asEntity, int alState)
{
if (alState == 1)
{
SetMoveObjectState("top_door", 1.0f);
for (int x; x == 4; x++)
{
GivePlayerDamage(25.0f, "blood", false, true);
}
}
}

but it also does not work :/ if you enter the area where you should be taking damage, nothing happens at all. The issue may be related to the map editor as well, but I'm not sure :/


EDIT: I'm adding a screenshot of the room in the editor mode so the situation is clearer.

Spoiler below!
In the upper right corner is the section where the poison is supposed to be. The player pulls the right lever on the left side and the door will open for a short time. If the rest of the puzzle is not completed by the time the door closes, the player is trapped. That is where the poison comes in and will kill the player. The respawn point is at the entrance to the room.
[Image: ihyZB76.png]
(This post was last modified: 08-15-2014, 09:11 AM by DaPurpleHippo.)
08-15-2014, 08:59 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#5
RE: Making it so Slime Damage can Kill, need help!

I just realized this. In GivePlayerDamage, the second argument is string &in asType. "blood" IS NOT one of them. The Types are: BloodSplat, Claws and Slash.

You need to experiment between the three. Replace the GivePlayerDamage function with one of these. If you don't like it then change into the other two.

BloodSplat Type:
Spoiler below!

PHP Code: (Select All)
GivePlayerDamage(25.0f"BloodSplat"falsetrue); 


Claws Type:
Spoiler below!

PHP Code: (Select All)
GivePlayerDamage(25.0f"Claws"falsetrue); 


Slash type:
Spoiler below!

PHP Code: (Select All)
GivePlayerDamage(25.0f"Slash"falsetrue); 


QUICK EDIT:
If the solution above don't work, make sure the names in the map and the script matches.

"Veni, vidi, vici."
"I came, I saw, I conquered."
(This post was last modified: 08-15-2014, 09:06 AM by PutraenusAlivius.)
08-15-2014, 09:05 AM
Find
DaPurpleHippo Offline
Junior Member

Posts: 9
Threads: 2
Joined: Aug 2014
Reputation: 0
#6
RE: Making it so Slime Damage can Kill, need help!

Huh Still just nothing. Names matchup, changed the Type, script runs fine as there are no crashes and the door is working fine. Even tried messing with true/false values and 1,0,-1 values in different ways to see if there was some magic combo or something. I'm gonna pick this up in the morning but any more suggestions are greatly welcome. I feel like if there was a way to get the script from the Cistern Entrance map working in this scenario, that would work out the best but for now, any way to kill the player in the corner room over time works.

I was thinking of editing the water monster in the model editor so its silent/invisible, but I don't know if it works on land and wouldn't want it to escape the room. I'll sleep on it, and get back to this later. Thanks for the help so far!
08-15-2014, 09:35 AM
Find
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#7
RE: Making it so Slime Damage can Kill, need help!

(08-15-2014, 08:34 AM)Romulat✪r (✿◠‿◠) Wrote: A float is a decimal number between 0 and 100.

That's not quite true, Rom. 0-100 wouldn't be much use.

A float has the range +/- 3.402823466e+38, or in other words between -340,282,346,600,000,000,000,000,000,000,000,000,000 and 340,282,346,600,000,000,000,000,000,000,000,000,000.

The bigger the number is (in either positive or negative direction) the less precise it becomes.

Also, DaPurpleHippo, try this:

void OnStart()
{
    AddEntityCollideCallback("Player", "checkpoint_00", "Restart", true, 1);
    AddEntityCollideCallback("Player", "damage_zone01", "EnterToxicGas", false, 0);
    SetGlobalVarInt("InToxicGas", 0);
}

void Restart(string &in asParent, string &in asChild, int alState)
{
    CheckPoint("FirstCheckpoint", "respawn_001", "Happening", "DeathCategory", "Deathtext");
}

void EnterToxicGas(string &in asParent, string &in asChild, int alState)
{
    if(alState == 1)
    {
        SetGlobalVarInt("InToxicGas", 1);
        AddTimer("ToxicGasTimer", 0.0f, "ToxicGasCheck");
    }
    else
    {
        SetGlobalVarInt("InToxicGas", 0);
    }
}

void ToxicGasCheck(string &in asTimer)
{
    if(GetGlobalVarInt("InToxicGas") == 1)
    {
        GivePlayerDamage(25.0f, "blood", false, true);
        AddTimer("ToxicGasTimer", 2.0f, "ToxicGasCheck");
    }
}

(This post was last modified: 08-15-2014, 09:00 PM by MrBehemoth.)
08-15-2014, 08:46 PM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#8
RE: Making it so Slime Damage can Kill, need help!

(08-15-2014, 08:46 PM)MrBehemoth Wrote:
(08-15-2014, 08:34 AM)Romulat✪r (✿◠‿◠) Wrote: A float is a decimal number between 0 and 100.

That's not quite true, Rom. 0-100 wouldn't be much use.

A float has the range +/- 3.402823466e+38, or in other words between -340,282,346,600,000,000,000,000,000,000,000,000,000 and 340,282,346,600,000,000,000,000,000,000,000,000,000.

The bigger the number is (in either positive or negative direction) the less precise it becomes.

Also, DaPurpleHippo, try this:

void OnStart()
{
    AddEntityCollideCallback("Player", "checkpoint_00", "Restart", true, 1);
    AddEntityCollideCallback("Player", "damage_zone01", "EnterToxicGas", false, 0);
    SetGlobalVarInt("InToxicGas", 0);
}

void Restart(string &in asParent, string &in asChild, int alState)
{
    CheckPoint("FirstCheckpoint", "respawn_001", "Happening", "DeathCategory", "Deathtext");
}

void EnterToxicGas(string &in asParent, string &in asChild, int alState)
{
    if(alState == 1)
    {
        SetGlobalVarInt("InToxicGas", 1);
        AddTimer("ToxicGasTimer", 0.0f, "ToxicGasCheck");
    }
    else
    {
        SetGlobalVarInt("InToxicGas", 0);
    }
}

void ToxicGasCheck(string &in asTimer)
{
    if(GetGlobalVarInt("InToxicGas") == 1)
    {
        GivePlayerDamage(25.0f, "blood", false, true);
        AddTimer("ToxicGasTimer", 2.0f, "ToxicGasCheck");
    }
}

For the sake of the code in this case, I probably should have mentioned that the float should be between 0 and 100 because the health range is 0 <= x <= 100.
Regardless, I stand corrected Smile

Discord: Romulator#0001
[Image: 3f6f01a904.png]
08-15-2014, 11:25 PM
Find
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#9
RE: Making it so Slime Damage can Kill, need help!

(08-15-2014, 11:25 PM)Romulat✪r (✿◠‿◠) Wrote: For the sake of the code in this case, I probably should have mentioned that the float should be between 0 and 100 because the health range is 0 <= x <= 100.
Regardless, I stand corrected Smile

Ahhh, I see your point. Well then, we're both right. Huzzah!

(This post was last modified: 08-15-2014, 11:54 PM by MrBehemoth.)
08-15-2014, 11:53 PM
Find




Users browsing this thread: 2 Guest(s)