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
Local varInts
Southlaguna Offline
Member

Posts: 70
Threads: 21
Joined: Jan 2012
Reputation: 0
#1
Local varInts

Hey everybody,

Recently i've had alot of questions about the tools in hpl2, this time i have a more complex question. How do I work Variables, i've seen a few tutorials that just aren't helping me to much and I've attempted studying up on them using the Machine Room.hps because it is very similar to what im trying to do.

Im working on a part where you need to put 5 limbs in a bathtub to clean up one hell of a mess in a hospital room. After the fifth limb is placed the tap starts dripping blood into the water (childsnake blood water) and then I use agrippa's head on the water for the final piece of the body, then my closing sequence start yadda yadda. Below is the script I have been attempting to use to make this work but so far nothing, if someone could help me learn about variables or help me through this process i would be most greatful:

void OnStart()

{
AddEntityCollideCallback("Player", "LightBreak", "LightBreaks", true, 1);
AddEntityCollideCallback("Limb_"i+, "reform", "CollideLimbsInTub", true, 1);

//SetLocalVarInt("LimbOK", 5);
}


//----CHAMBER----//
void CollideLimbsInTub(string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("LimbOK") == 5)
AddUseItemCallback("head", "head", "water", "ChamberComplete", true);
}

void ChamberComplete(string &in asItem, string &in asEntity)
{

DestroyParticleSystem("gas_1");
DestroyParticleSystem("gas_2");
DestroyParticleSystem("gas_3");
DestroyParticleSystem("gas_4");
DestroyParticleSystem("gas_5");

SetLampLit("lamp_1", false, true);
SetLampLit("lamp_2", false, true);
SetLampLit("lamp_3", false, true);

PlaySoundAtEntity("", "02_vent.snt", "ChamberSounds", 2, true);
PlaySoundAtEntity("", "light_off.snt", "ChamberSounds", 0, false);
PlayMusic("eerie09.ogg", true, 1, 0, 0.5, true);
PlayMusic("08_power_out1.ogg", true, 1, 0, 0, true);

SetEntityPlayerLookAtCallback("metal_door", "Bam", true);
}
void Bam(string &in entity, int alState)
{
if(GetSwingDoorClosed("metal_door")) //Checks to see if the door is closed.
{
SetSwingDoorDisableAutoClose("metal_door", true); //This will stop the door from closing as soon as it opens.
SetSwingDoorClosed("metal_door", false, true);

PlaySoundAtEntity("", "scare_slam_door.snt", "metal_door", 0, true);
PlaySoundAtEntity("", "impact_metal_high.snt", "metal_door", 0, true);
AddPropImpulse("metal_door", 0, 0, -30, "World");
}
}

Any advice?

03-30-2012, 12:55 AM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#2
RE: Local varInts


Use this one. WARNING, this is untested, and I do not have access to my regular PC right now and cannot confirm it'll work. But it will give you an idea on basic LocalVarInt.


void OnStart()

{
AddEntityCollideCallback("Player", "LightBreak", "LightBreaks", true, 1);
AddEntityCollideCallback("Limb_1", "reform", "CollideLimbsInTub1", true, 1);
AddEntityCollideCallback("Limb_2", "reform", "CollideLimbsInTub2", true, 1);
AddEntityCollideCallback("Limb_3", "reform", "CollideLimbsInTub3", true, 1);
AddEntityCollideCallback("Limb_4", "reform", "CollideLimbsInTub4", true, 1);
AddEntityCollideCallback("Limb_5", "reform", "CollideLimbsInTub5", true, 1);
SetLocalVarInt("LimbOK", 0);
}


//----CHAMBER----//
void CollideLimbsInTub1(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub2(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub3(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub4(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub5(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void func_on()
{
GetLocalVarInt("LimbOK", 5)
{
AddUseItemCallback("head", "head", "water", "ChamberComplete", true);
}
}

void ChamberComplete(string &in asItem, string &in asEntity)
{

DestroyParticleSystem("gas_1");
DestroyParticleSystem("gas_2");
DestroyParticleSystem("gas_3");
DestroyParticleSystem("gas_4");
DestroyParticleSystem("gas_5");

SetLampLit("lamp_1", false, true);
SetLampLit("lamp_2", false, true);
SetLampLit("lamp_3", false, true);

PlaySoundAtEntity("", "02_vent.snt", "ChamberSounds", 2, true);
PlaySoundAtEntity("", "light_off.snt", "ChamberSounds", 0, false);
PlayMusic("eerie09.ogg", true, 1, 0, 0.5, true);
PlayMusic("08_power_out1.ogg", true, 1, 0, 0, true);

SetEntityPlayerLookAtCallback("metal_door", "Bam", true);
}
void Bam(string &in entity, int alState)
{
if(GetSwingDoorClosed("metal_door")) //Checks to see if the door is closed.
{
SetSwingDoorDisableAutoClose("metal_door", true); //This will stop the door from closing as soon as it opens.
SetSwingDoorClosed("metal_door", false, true);

PlaySoundAtEntity("", "scare_slam_door.snt", "metal_door", 0, true);
PlaySoundAtEntity("", "impact_metal_high.snt", "metal_door", 0, true);
AddPropImpulse("metal_door", 0, 0, -30, "World");
}
}

03-30-2012, 02:48 AM
Find
Southlaguna Offline
Member

Posts: 70
Threads: 21
Joined: Jan 2012
Reputation: 0
#3
RE: Local varInts

(03-30-2012, 02:48 AM)flamez3 Wrote: Use this one. WARNING, this is untested, and I do not have access to my regular PC right now and cannot confirm it'll work. But it will give you an idea on basic LocalVarInt.


void OnStart()

{
AddEntityCollideCallback("Player", "LightBreak", "LightBreaks", true, 1);
AddEntityCollideCallback("Limb_1", "reform", "CollideLimbsInTub1", true, 1);
AddEntityCollideCallback("Limb_2", "reform", "CollideLimbsInTub2", true, 1);
AddEntityCollideCallback("Limb_3", "reform", "CollideLimbsInTub3", true, 1);
AddEntityCollideCallback("Limb_4", "reform", "CollideLimbsInTub4", true, 1);
AddEntityCollideCallback("Limb_5", "reform", "CollideLimbsInTub5", true, 1);
SetLocalVarInt("LimbOK", 0);
}


//----CHAMBER----//
void CollideLimbsInTub1(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub2(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub3(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub4(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub5(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void func_on()
{
GetLocalVarInt("LimbOK", 5)
{
AddUseItemCallback("head", "head", "water", "ChamberComplete", true);
}
}

void ChamberComplete(string &in asItem, string &in asEntity)
{

DestroyParticleSystem("gas_1");
DestroyParticleSystem("gas_2");
DestroyParticleSystem("gas_3");
DestroyParticleSystem("gas_4");
DestroyParticleSystem("gas_5");

SetLampLit("lamp_1", false, true);
SetLampLit("lamp_2", false, true);
SetLampLit("lamp_3", false, true);

PlaySoundAtEntity("", "02_vent.snt", "ChamberSounds", 2, true);
PlaySoundAtEntity("", "light_off.snt", "ChamberSounds", 0, false);
PlayMusic("eerie09.ogg", true, 1, 0, 0.5, true);
PlayMusic("08_power_out1.ogg", true, 1, 0, 0, true);

SetEntityPlayerLookAtCallback("metal_door", "Bam", true);
}
void Bam(string &in entity, int alState)
{
if(GetSwingDoorClosed("metal_door")) //Checks to see if the door is closed.
{
SetSwingDoorDisableAutoClose("metal_door", true); //This will stop the door from closing as soon as it opens.
SetSwingDoorClosed("metal_door", false, true);

PlaySoundAtEntity("", "scare_slam_door.snt", "metal_door", 0, true);
PlaySoundAtEntity("", "impact_metal_high.snt", "metal_door", 0, true);
AddPropImpulse("metal_door", 0, 0, -30, "World");
}
}
Nah man when I use this one I keep getting the "Expected ( ; )" in illogical places of my hps

(This post was last modified: 03-31-2012, 03:57 PM by Southlaguna.)
03-31-2012, 03:27 PM
Find
flamez3 Offline
Posting Freak

Posts: 1,281
Threads: 48
Joined: Apr 2011
Reputation: 57
#4
RE: Local varInts

Sorry, on my regular PC now


void OnStart()

{
AddEntityCollideCallback("Player", "LightBreak", "LightBreaks", true, 1);
AddEntityCollideCallback("Limb_1", "reform", "CollideLimbsInTub1", true, 1);
AddEntityCollideCallback("Limb_2", "reform", "CollideLimbsInTub2", true, 1);
AddEntityCollideCallback("Limb_3", "reform", "CollideLimbsInTub3", true, 1);
AddEntityCollideCallback("Limb_4", "reform", "CollideLimbsInTub4", true, 1);
AddEntityCollideCallback("Limb_5", "reform", "CollideLimbsInTub5", true, 1);
SetLocalVarInt("LimbOK", 0);
}


//----CHAMBER----//
void CollideLimbsInTub1(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub2(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub3(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub4(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void CollideLimbsInTub5(string &in asParent, string &in asChild, int alState)
{
AddLocalVarInt("LimbOK", 1);
func_on();
}

void func_on()
{
if (GetLocalVarInt("LimbOK") == 5)
{
AddUseItemCallback("head", "head", "water", "ChamberComplete", true);
}
}

void ChamberComplete(string &in asItem, string &in asEntity)
{

DestroyParticleSystem("gas_1");
DestroyParticleSystem("gas_2");
DestroyParticleSystem("gas_3");
DestroyParticleSystem("gas_4");
DestroyParticleSystem("gas_5");

SetLampLit("lamp_1", false, true);
SetLampLit("lamp_2", false, true);
SetLampLit("lamp_3", false, true);

PlaySoundAtEntity("", "02_vent.snt", "ChamberSounds", 2, true);
PlaySoundAtEntity("", "light_off.snt", "ChamberSounds", 0, false);
PlayMusic("eerie09.ogg", true, 1, 0, 0.5, true);
PlayMusic("08_power_out1.ogg", true, 1, 0, 0, true);

SetEntityPlayerLookAtCallback("metal_door", "Bam", true);
}
void Bam(string &in entity, int alState)
{
if(GetSwingDoorClosed("metal_door")) //Checks to see if the door is closed.
{
SetSwingDoorDisableAutoClose("metal_door", true); //This will stop the door from closing as soon as it opens.
SetSwingDoorClosed("metal_door", false, true);

PlaySoundAtEntity("", "scare_slam_door.snt", "metal_door", 0, true);
PlaySoundAtEntity("", "impact_metal_high.snt", "metal_door", 0, true);
AddPropImpulse("metal_door", 0, 0, -30, "World");
}
}

03-31-2012, 04:31 PM
Find




Users browsing this thread: 1 Guest(s)