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
A really annoying script problem
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#1
A really annoying script problem

I've had a very annoying problem with a script I've been working on now for about a week now. Theres just one problem that is ruining everything. Theres a one use item callback that is not working. And since I've ran out of ideas I need your guys help. Heres the script. Sorry for torturing you guys with this very long script, but I'm desperate.

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

///////////////////////////////////////////
// REPAIR COG WHEELS IN MACHINE ROOM
////////////////////////////////////////////

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

float gfCogWheelSpeed = 2.0;
//------------------------------------------

void InitCeilingCogWheels()
{
RotatePropToSpeed("ceiling_machinery_cog_4", 10, gfCogWheelSpeed, 0, 1, 0, true, "");
RotatePropToSpeed("ceiling_machinery_cog_1", 10, gfCogWheelSpeed, 0, -1, 0, true, "");
}

//When player interacts with cog just attach it to the sticky area. (so no movements are needed!)
void CeilingCogWheelInteracted(string &in asEntity)
{
AddDebugMessage("Interacted with cogwheel!", false);

AttachBodyToStickyArea("StickyArea_1", "ceiling_machinery_cog_interact_1_Body_1");

PlaySoundAtEntity("wheel11", "21_cog_slide.snt", "ceiling_machinery_cog_interact_1", 0.0f, true);

AddTimer("CogWheelAttached", 0.5f, "TimerCogWheelAttached");
}

void TimerCogWheelAttached(string &in asTimer)
{
//Remove the interactable cog wheel
SetEntityActive("ceiling_machinery_cog_interact_1", false);

//Make the non-interable wheel visible
SetEntityActive("ceiling_machinery_cog_interact_static_2", true);

PlaySoundAtEntity("wheel13", "21_cog_attach.snt", "ceiling_machinery_cog_interact_static_2", 0.0f, true);
PlaySoundAtEntity("wheel2", "21_cog_wheel_big.snt", "ceiling_machinery_cog_interact_static_2", 1.0f, true);

//Make all remaining wheel rotate
RotatePropToSpeed("ceiling_machinery_cog_interact_static_2", 10, gfCogWheelSpeed, 0, 1, 0, true, "");
RotatePropToSpeed("ceiling_machinery_cog_2", 10, gfCogWheelSpeed, 0, -1, 0, true, "");
RotatePropToSpeed("ceiling_machinery_cog_3", 10, gfCogWheelSpeed, 0, 1, 0, true, "");

//Set a var to notify that the wheel
SetLocalVarInt("CogWheelInPlace", 1);
}

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

///////////////////////////////////////////
// PULL SECURITY DOOR LEVER
////////////////////////////////////////////

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

//Player interacts with a safety door.
void InteractSafetyDoor(string &in asEntity)
{
//Show message
SetMessage("Messages", "LockedSafetyDoors", 0);

//Locked sound
PlayGuiSound("17_attach_crank", 0.5f);

SetMoveObjectState(asEntity, 0.05f);

AddTimer(asEntity, 0.4f, "TimerCloseGate");
AddTimer("sound", 1.0f, "TimerCloseGate");

//Wait 4 seconds and then give a quest.
if(QuestIsAdded("20SafetyDoorClosed")==false)
AddTimer("SafetyDoorQuest", 3.1f, "TimerSafetyDoorQuest");
}

void TimerCloseGate(string &in asTimer)
{
if(asTimer == "sound"){
PlayGuiSound("close_gate.ogg", 0.5f);
} else{
SetMoveObjectState(asTimer, 0.00f);

SetEntityPlayerInteractCallback(asTimer, "InteractSafetyDoor", true);
}
}

void TimerSafetyDoorQuest(string &in asTimer)
{
AddQuest("HeavySafetyDoors", "HeavySafetyDoors");
}

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

void PullSafetyDoorLever(string &in asEntity, int alState)
{
if(alState != -1) return;

/////////////////////////////////
//Cog wheels are in place
if(GetLocalVarInt("CogWheelInPlace")==1)
{
string sDoorName = asEntity=="lever_simple01_1" ? "safety_large_vert_1" : "safety_large_vert_2";

//Open the door
SetMoveObjectState(sDoorName, 1);

//No more interact callbacks on safety doors.
SetEntityPlayerInteractCallback("safety_large_vert_1","",false);
SetEntityPlayerInteractCallback("safety_large_vert_2","",false);

//Lever becomes stuck
SetLeverStuckState(asEntity, alState, true);

PlaySoundAtEntity("workins", "21_ignite.snt", "LeverSounds", 0.2f, false);
PlaySoundAtEntity("working", "21_lever_success", "LeverSounds", 2.0f, false);
PlaySoundAtEntity("working2", "21_loop", "LeverSounds", 2.0f, false);
AddTimer("working", 3.0f, "TimerStopSounds");

StartScreenShake(0.005f, 0.0f, 3.0f, 3.0f);

//Inc lever in position counter
AddLocalVarInt("SafetyDoorCount",1);
if(GetLocalVarInt("SafetyDoorCount")==2)
{
//Complete quest with levers.
CompleteQuest("LeverDoorQuest","LeverDoorQuest");

//Tell agrippa that safety doors are open
SetLocalVarInt("SafetyDoorsOpen", 1);

//activate an area that triggers a voice from Alexander
SetEntityActive("AreaStartAlexanderVoice", true);

//Complete quest!
CompleteQuest("HeavySafetyDoors", "HeavySafetyDoors");

//Sanity boost + nice music!
GiveSanityBoostSmall();
PlayMusic("21_puzzle_door.ogg", false, 0.8f, 0.5f, 9, false);
}

}
///////////////////////////////
//Cog wheels are NOT in place
else
{
//Add quest
AddQuest("LeverDoorQuest","LeverDoorQuest");

//Tell agrippa that we have tried a lever.
SetLocalVarInt("InteractedDoorLever", 1);

SetMessage("Messages", "LeverInteractSafetyDoor", 0);

PlaySoundAtEntity("notworking", "21_lever_fail", "LeverSounds", 0.1f, false);
}
}

void TimerStopSounds(string &in asTimer)
{
StopSound(asTimer, 3.0f);
StopSound(asTimer+2, 3.0f);
PlaySoundAtEntity("workins", "21_ignite.snt", "LeverSounds", 1.0f, false);
}

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

///////////////////////////////////////////
// PLAYER FALLS INTO WELL
////////////////////////////////////////////

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

void CollideWellKillPlayer(string &in asParent, string &in asChild, int alState)
{
CheckPoint("checkFallWell", "PlayerStartArea_1", "CheckPointFallWell", "Hints", "DeathFallSewerWell");

PlaySoundAtEntity("fallaaaaaah", "11_fall", "Player", 0, false);
PlaySoundAtEntity("fallaaaaaah2", "scare_male_terrified5", "Player", 0, false);

FadeOut(0.5);

AddTimer("death1", 0.5f, "TimerFallDeath");
AddTimer("death2", 1, "TimerFallDeath");

AddTimer("meat", 1.6f, "TimerFallDeath");
AddTimer("meatb", 1.8f, "TimerFallDeath");
AddTimer("meatl", 1.9f, "TimerFallDeath");
AddTimer("meat", 1.0f, "TimerFallDeath");
AddTimer("meatb", 1.2f, "TimerFallDeath");
AddTimer("meatl", 1.4f, "TimerFallDeath");
AddTimer("meat", 2.1f, "TimerFallDeath");
AddTimer("meatb", 2.3f, "TimerFallDeath");
AddTimer("meatl", 2.4f, "TimerFallDeath");
}

void TimerFallDeath(string &in asTimer)
{
if(asTimer == "meat"){
PlayGuiSound("21_meat.snt",RandFloat(0.4f,0.9f));
return;
}
if(asTimer == "meatb"){
PlayGuiSound("21_meat_snap.snt",RandFloat(0.4f,0.9f));
return;
}
if(asTimer == "meatl"){
PlayGuiSound("21_meat_long.snt",RandFloat(0.4f,0.9f));;
return;
}

//If first timer, just play a bump
if(asTimer == "death1"){
PlaySoundAtEntity("bump1", "player_bodyfall", "Player", 0, false);
return;
}

//Kill player without making a sound
DisableDeathStartSound();
AddPlayerHealth(-200);

//Lurker attacks player
PlaySoundAtEntity("LurkerScream", "water_lurker_attack_rev.snt", "AreaRopeDown", 0.1f, false);

//Players gets some pain
PlaySoundAtEntity("pain", "player_falldamage_max", "Player", 0, false);
PlaySoundAtEntity("bump2", "player_bodyfall", "Player", 0, false);
}

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

void CheckPointFallWell(string &in asName, int alCount)
{
//Do nothing??
}

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

///////////////////////////////////////////
// PICK UP LAB NOTE
////////////////////////////////////////////

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

void PickupLabNote(string &in asEntity, string &in asType)
{
PlayMusic("01_puzzle_passage.ogg", false, 1.0f, 0, 10, false);

SetLocalVarInt("PickedWeyerNote", 1);
SetGlobalVarInt("WeyerNoteIsPicked", 1);

AddQuest("LabStoneNote", "LabStoneNote");
}

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


///////////////////////////////////////////
// FIRST BROKEN DOOR
////////////////////////////////////////////

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

void InteractJammedDoor(string &in asEntity)
{
SetMessage("Messages", "StuckDoor", 0);

AddTimer(asEntity, 1.0f, "TimerStuckDoor");
}
void TimerJammedDoor(string &in asTimer)
{
SetEntityPlayerInteractCallback(asTimer, "InteractStuckDoor", true);
}
void HammerChipperOnBrokenDoor(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "CollapsedStuckDoor", 0);
}

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

///////////////////////////////////////////
// PLAYER INTERACTS WITH BROKEN LADDER
////////////////////////////////////////////

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

void InteractFirstWellHole(string &in asEntity)
{
SetMessage("Messages", "BrokenSewerLadder", 0);
PlayGuiSound("18_touch_bridge.snt", RandFloat(0.4f, 1.0f));
AddTimer(asEntity, 1.0f, "TimerFirstWellHole");
}
void TimerFirstWellHole(string &in asTimer)
{
SetEntityPlayerInteractCallback(asTimer, "InteractFirstWellHole", true);
}

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

///////////////////////////////////////////
// MAGICAL STONE POTION
////////////////////////////////////////////

//Note: This puzzle is very, very big. So I will make
//one script area for each magical stone.
//I will take each stone in the order according
//to the note in the Lab.

///////////////////////////////////////////
// MAGICAL STONE POTION (EMERALD STONE/EXTRA WITH BLOOD)
////////////////////////////////////////////

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

//Player uses glass jar on heater/extracter/squeezer, but doesn't have the blood
void GlassJarHeaterWithoutBlood(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "GlassJarWithoutBlood", 0);
}
//Player uses glass jar on squeezer/extracter, but blood is not boiled
void JarSqueezerBloodNotBoiled(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "BloodNeedsBoilFirst", -1);
}

//Player uses glass jar on squeezer with blood boiled
void JarSqueezerBloodBoiled(string &in asItem, string &in asEntity)
{
SetEntityActive("glass_container_mix_notdone_static_1", true);
PlaySoundAtEntity("placeglass", "26_place_glass", asEntity, 0.0f, false);

//In case player tries to extract it without container placed below
SetLocalVarInt("ContainerBelow", 1);
}
//Place the emerald stone
void UseEmeraldStoneOnExtractor(string &in asItem, string &in asEntity)
{
int lState = GetLocalVarInt("SqueezerState");

if(GetLocalVarInt("ContainerBelow")==0)
{
//SetMessage("Messages", "NoContainerBelow", -1);
//return;
}

////////////////////
//Squeezer is open
if(lState == -1)
{
PlaySoundAtEntity("placegland","26_place_gland.snt", "squeezer_1", 1, false);
PlaySoundAtEntity("placegland1","26_place_gland.snt", "squeezer_1", 1, false);

RemoveItem(asItem);
SetEntityActive("orbpiece_emerald_1", true);

SetLocalVarInt("EmeraldInSqueezer", 1);
}
////////////////////
//Squeezer is NOT open
else
{
SetMessage("Messages", "NoSpaceMagicStones", -1);
}
}

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


void InteractSqueezer(string &in asEntity)
{
if(GetLocalVarInt("ContainerBelow")==0 && GetLocalVarInt("EmeraldInSqueezer")==1){
SetWheelStuckState(asEntity, -1, false);
SetMessage("Messages", "NoContainerBelow", 0);
return;
}

SetWheelStuckState(asEntity, 0, false);
}

void TurnSqueezer(string &in asEntityName, int alState)
{
SetLocalVarInt("SqueezerState", alState);
AddDebugMessage("Squeezer state: "+alState, false);

//Do nothing if no stone is in squeezer or has already been squeezed.
if(GetLocalVarInt("EmeraldInSqueezer")==0 || GetLocalVarInt("EmeraldIsSqueezed")==1)
{
return;
}

if(alState == 1)
{
PlaySoundAtEntity("splouuutch", "26_squeeze_gland.snt", "AreaSqueezer", 0.0f, false);
PlaySoundAtEntity("liquidsound","26_liquid.snt", "AreaSqueezer", 2, false);

CreateParticleSystemAtEntity("squeezeeffect", "ps_squeeze_gland_effect.ps", "squeezer_1", false);

SetLocalVarInt("EmeraldIsSqueezed", 1);

AddTimer("SqueezeEffectDone", 2, "TimerSqueezeEffectDone");
}
}
void TimerSqueezeEffectDone(string &in asTimer)
{
AddTimer("fadeoutmix", 0.3, "TimerSqueezeEffectFadeOutMix");
StopSound("liquidsound", 1.0f);

SetPropActiveAndFade("glass_container_mix_notdone_3", true, 0.5);
SetPropActiveAndFade("orbpiece_emerald_1", false, 0.5);
}
void TimerSqueezeEffectFadeOutMix(string &in asTimer)
{
SetPropActiveAndFade("glass_container_mix_notdone_static_1", false, 0.5);
SetEntityActive("AreaGlassJarNoBlood", false);
}
//Potion pickup (Emerald added)
void PickEmeraldPotion(string &in asEntity, string &in asType)
{
GiveSanityBoostSmall();
SetEntityActive("squeezer_1", false);
SetEntityActive("squeezer_2", true);
}
//-----------------------------------------

///////////////////////////////////////////
// MAGICAL STONE POTION (OBSIDIAN STONE)
////////////////////////////////////////////

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

//Use 1/6 Potion on squezzer to continue with the potion
void UseOneOnSqueezer(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetEntityActive("TimeForObsidianStone", true);
PlaySoundAtEntity("placeglass", "26_place_glass", asEntity, 0.0f, false);

SetLocalVarInt("ContainerBelowTwo", 1);
}
//Place the obsidian stone
void UseObsidianStoneOnExtractor(string &in asItem, string &in asEntity)
{
int lState = GetLocalVarInt("SqueezerState");

if(GetLocalVarInt("ContainerBelowTwo")==0)
{
//SetMessage("Messages", "NoContainerBelow", -1);
//return;
}

////////////////////
//Squeezer is open
if(lState == -1)
{
PlaySoundAtEntity("placegland","26_place_gland.snt", "squeezer_1", 1, false);
PlaySoundAtEntity("placegland1","26_place_gland.snt", "squeezer_1", 1, false);

RemoveItem(asItem);
SetEntityActive("orbpiece_obsidian_static", true);

SetLocalVarInt("ObsidianInSqueezer", 1);
}
////////////////////
//Squeezer is NOT open
else
{
SetMessage("Messages", "NoSpaceMagicStones", -1);
}
}

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


void InteractSqueezer2(string &in asEntity)
{
if(GetLocalVarInt("ContainerBelowTwo")==0 && GetLocalVarInt("ObsidianInSqueezer")==1){
SetWheelStuckState(asEntity, -1, false);
SetMessage("Messages", "NoContainerBelow", 0);
return;
}

SetWheelStuckState(asEntity, 0, false);
}

void TurnSqueezer2(string &in asEntityName, int alState)
{
SetLocalVarInt("SqueezerState", alState);
AddDebugMessage("Squeezer state: "+alState, false);

//Do nothing if no stone is in squeezer or has already been squeezed.
if(GetLocalVarInt("ObsidianInSqueezer")==0 || GetLocalVarInt("ObsidianIsSqueezed")==1)
{
return;
}

if(alState == 1)
{
PlaySoundAtEntity("splouuutch", "26_squeeze_gland.snt", "AreaSqueezer", 0.0f, false);
PlaySoundAtEntity("liquidsound","26_liquid.snt", "AreaSqueezer", 2, false);

CreateParticleSystemAtEntity("squeezeeffect", "ps_squeeze_gland_effect.ps", "squeezer_1", false);

SetLocalVarInt("ObsidianIsSqueezed", 1);

AddTimer("SqueezeEffectDone", 2, "TimerSqueezeEffectDone2");
}
}
void TimerSqueezeEffectDone2(string &in asTimer)
{
AddTimer("fadeoutmix2", 0.3, "TimerSqueezeEffectFadeOutMix2");
StopSound("liquidsound", 1.0f);

SetPropActiveAndFade("ObsidianEmeraldAdded", true, 0.5);
SetPropActiveAndFade("orbpiece_obsidian_static", false, 0.5);
}
void TimerSqueezeEffectFadeOutMix2(string &in asTimer)
{
SetPropActiveAndFade("TimeForObsidianStone", false, 0.5);
SetEntityActive("AreaGlassJarNoBlood", false);
}
//Picking up Obsidian Potion
void PickObsidianPotion(string &in asEntity, string &in asType)
{
SetEntityActive("squeezer_2", false);
SetEntityActive("squeezer_3", true);
}
//-----------------------------------------

///////////////////////////////////////////
// MAGICAL STONE POTION (INDIGO STONE)
////////////////////////////////////////////

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

//Use blood on extractor, but not boiled (just in case)
void UseBloodOnOvenNotBoiled(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "BloodNotBoiled", 0);
}
//Place 2/6 potion to proceed
void TwoPotionOnExtractor(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetEntityActive("TimeForIndigoStone", true);
PlaySoundAtEntity("placeglass", "26_place_glass", asEntity, 0.0f, false);

SetLocalVarInt("MixPlacedUnderOven", 1);
}

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

void TimerOvenDoorImpulse(string &in asTimer)
{
SetSwingDoorDisableAutoClose("extaction_oven_1", true);
SetSwingDoorClosed("extaction_oven_1", false, true);

AddPropImpulse("extaction_oven_1", -1, 0,0,"World");
AddTimer("push1", 0.1f, "TimerPushAgain");
}
void TimerPushAgain(string &in asTimer)
{
AddPropImpulse("extaction_oven_1", -1, 0,0,"World");
}

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

void InteractOven(string &in asEntity)
{
if(GetLocalVarInt("MixPlacedUnderOven")==0 && GetLocalVarInt("IndigoInOven")==1){
SetLeverStuckState(asEntity, -1, false);
SetMessage("Messages", "InteractOvenTooSoon", 0);
return;
}

SetLeverStuckState(asEntity, 0, false);
}

void UseIndigoOnOven(string &in asItem, string &in asEntity)
{
//Check if oven is running
if(GetLocalVarInt("OvenRunning")==1)
{
SetMessage("Ch03Level26", "OvenIsRunning", -1);
return;
}

//Check so there is a container below
if(GetLocalVarInt("MixPlacedUnderOven")==0)
{
//SetMessage("Ch03Level26", "NoContainerBelowOven", -1);
//return;
}

//Open door and make sure the player looks at it.
StartPlayerLookAt("orbpiece_indigo_1", 2, 5,"");

//Swing open the door, if closed.
if(GetSwingDoorState("extaction_oven_1")<1)
{
SetSwingDoorClosed("extaction_oven_1", false, true);
SetSwingDoorDisableAutoClose("extaction_oven_1", true);

AddTimer("OvenDoorImpulse", 0.1f, "TimerOvenDoorImpulse");
}

AddTimer("PlaceBoneOvenDoorOpen", 0.6f, "TimerPlaceIndigoOvenDoorOpen");

SetLocalVarInt("IndigoInOven", 1);
}

void TimerPlaceIndigoOvenDoorOpen(string &asTimer)
{
StopPlayerLookAt();

SetSwingDoorDisableAutoClose("extaction_oven_1", false);

RemoveItem("orbpiece_indigo_1");
SetEntityActive("orbpiece_indigo_1", true);
}

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

void PullOvenLever(string &in asEntityName, int alState)
{
if(alState != 1) return;

SetLocalVarInt("OvenRunning", 1);

PlaySoundAtEntity("oven_run", "26_oven_run.snt", "extaction_oven_1", 0.5f, false);

SetLeverStuckState("extaction_oven_lever_1", 1, true);
SetSwingDoorLocked("extaction_oven_1", true, true);

//Indigo stone is in oven and uncooked
if(GetLocalVarInt("IndigoInOven")==1 && GetLocalVarInt("IndigoIsCooked")==0)
{
AddTimer("OvenRunningOver", 4, "TimerOvenRunningOver");

//Pour liquid
CreateParticleSystemAtEntity("ovenliquid", "ps_extract_oven_liquid.ps", "AreaOvenNossel", true);

//Pour liquid
PlaySoundAtEntity("ovenliquidsound","26_liquid.snt", "AreaOvenNossel", 3, true);
}
//Oven is empty
else
{
AddTimer("OvenRunningOver", 2, "TimerOvenRunningOver");
}
}

void TimerOvenRunningOver(string &in asTimer)
{
SetLocalVarInt("OvenRunning", 0);
SetLeverStuckState("extaction_oven_lever_1", 0, true);

StopSound("oven_run", 0.5f);

//Turn off the pouring and create the new mixture!
if(GetLocalVarInt("IndigoInOven")==1 && GetLocalVarInt("IndigoIsCooked")==0)
{
SetEntityActive("orbpiece_indigo_1", false);

DestroyParticleSystem("ovenliquid");
StopSound("ovenliquidsound",1);

SetLocalVarInt("IndigoIsCooked",1);

SetPropActiveAndFade("EmeraldObsidianIndigoAdded", true, 0.5);
AddTimer("TimerFadeOutOvenMix", 0.3f, "TimerFadeOutOvenMix");
}

//Smoke comes out from the machine
CreateParticleSystemAtEntity("ovensmoke", "ps_extract_oven_smoke.ps", "AreaInsideOven", false);

//Swing open the door!
SetSwingDoorLocked("extaction_oven_1", false, true);

SetSwingDoorClosed("extaction_oven_1", false, true);
SetSwingDoorDisableAutoClose("extaction_oven_1", true);

AddTimer("OvenDoorImpulse", 0.1f, "TimerOvenDoorImpulse");
AddTimer("OvenDoorImpulse", 0.2f, "TimerOvenDoorImpulse");

AddTimer("RunningDoneOvenDoorOpen", 0.6, "TimerRunningDoneOvenDoorOpen");
}

void TimerFadeOutOvenMix(string &in asTimer)
{
SetPropActiveAndFade("TimeForIndigoStone", false, 0.5);
}

void TimerRunningDoneOvenDoorOpen(string &asTimer)
{
SetSwingDoorDisableAutoClose("extaction_oven_1", false);
}
//-----------------------------------------

///////////////////////////////////////////
// MAGICAL STONE POTION (SCARLET STONE)
////////////////////////////////////////////

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

//Use 3/6 potion to proceed
void UseThirdPotionOnExtractor(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetEntityActive("TimeForIndigoStone", true);
PlaySoundAtEntity("placeglass", "26_place_glass", asEntity, 0.0f, false);

SetLocalVarInt("MixPlacedUnderOven2", 1);
}

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

void TimerOvenDoorImpulse2(string &in asTimer)
{
SetSwingDoorDisableAutoClose("extaction_oven_1", true);
SetSwingDoorClosed("extaction_oven_1", false, true);

AddPropImpulse("extaction_oven_1", -1, 0,0,"World");
AddTimer("push1", 0.1f, "TimerPushAgain1");
}
void TimerPushAgain1(string &in asTimer)
{
AddPropImpulse("extaction_oven_1", -1, 0,0,"World");
}

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

void InteractOven2(string &in asEntity)
{
if(GetLocalVarInt("MixPlacedUnderOven2")==0 && GetLocalVarInt("ScarletInOven")==1){
SetLeverStuckState(asEntity, -1, false);
SetMessage("Messages", "InteractOvenTooSoon", 0);
return;
}

SetLeverStuckState(asEntity, 0, false);
}

void UseScarletOnOven(string &in asItem, string &in asEntity)
{
//Check if oven is running
if(GetLocalVarInt("OvenRunning")==1)
{
SetMessage("Ch03Level26", "OvenIsRunning", -1);
return;
}

//Check so there is a container below
if(GetLocalVarInt("MixPlacedUnderOven")==0)
{
//SetMessage("Ch03Level26", "NoContainerBelowOven", -1);
//return;
}

//Open door and make sure the player looks at it.
StartPlayerLookAt("orbpiece_indigo_1", 2, 5,"");

//Swing open the door, if closed.
if(GetSwingDoorState("extaction_oven_1")<1)
{
SetSwingDoorClosed("extaction_oven_1", false, true);
SetSwingDoorDisableAutoClose("extaction_oven_1", true);

AddTimer("OvenDoorImpulse", 0.1f, "TimerOvenDoorImpulse2");
}

AddTimer("PlaceBoneOvenDoorOpen", 0.6f, "TimerPlaceIndigoOvenDoorOpen2");

SetLocalVarInt("ScarletInOven", 1);
}

void TimerPlaceScarletOvenDoorOpen2(string &asTimer)
{
StopPlayerLookAt();

SetSwingDoorDisableAutoClose("extaction_oven_1", false);

RemoveItem("orbpiece_scarlet_1");
SetEntityActive("orbpiece_scarlet_1", true);
}

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

void PullOvenLever2(string &in asEntityName, int alState)
{
if(alState != 1) return;

SetLocalVarInt("OvenRunning2", 1);

PlaySoundAtEntity("oven_run", "26_oven_run.snt", "extaction_oven_1", 0.5f, false);

SetLeverStuckState("extaction_oven_lever_1", 1, true);
SetSwingDoorLocked("extaction_oven_1", true, true);

//Indigo stone is in oven and uncooked
if(GetLocalVarInt("ScarletInOven")==1 && GetLocalVarInt("ScarletIsCooked")==0)
{
AddTimer("OvenRunningOver", 4, "TimerOvenRunningOver");

//Pour liquid
CreateParticleSystemAtEntity("ovenliquid", "ps_extract_oven_liquid.ps", "AreaOvenNossel", true);

//Pour liquid
PlaySoundAtEntity("ovenliquidsound","26_liquid.snt", "AreaOvenNossel", 3, true);
}
//Oven is empty
else
{
AddTimer("OvenRunningOver", 2, "TimerOvenRunningOver2");
}
}

void TimerOvenRunningOver2(string &in asTimer)
{
SetLocalVarInt("OvenRunning2", 0);
SetLeverStuckState("extaction_oven_lever_1", 0, true);

StopSound("oven_run", 0.5f);

//Turn off the pouring and create the new mixture!
if(GetLocalVarInt("ScarletInOven")==1 && GetLocalVarInt("ScarletIsCooked")==0)
{
SetEntityActive("orbpiece_indigo_1", false);

DestroyParticleSystem("ovenliquid");
StopSound("ovenliquidsound",1);

SetLocalVarInt("IndigoIsCooked",1);

SetPropActiveAndFade("EmeraldObsidianIndigoScarletAdded", true, 0.5);
AddTimer("TimerFadeOutOvenMix2", 0.3f, "TimerFadeOutOvenMix2");
}

//Smoke comes out from the machine
CreateParticleSystemAtEntity("ovensmoke", "ps_extract_oven_smoke.ps", "AreaInsideOven", false);

//Swing open the door!
SetSwingDoorLocked("extaction_oven_1", false, true);

SetSwingDoorClosed("extaction_oven_1", false, true);
SetSwingDoorDisableAutoClose("extaction_oven_1", true);

AddTimer("OvenDoorImpulse2", 0.1f, "TimerOvenDoorImpulse2");
AddTimer("OvenDoorImpulse2", 0.2f, "TimerOvenDoorImpulse2");

AddTimer("RunningDoneOvenDoorOpen2", 0.6, "TimerRunningDoneOvenDoorOpen2");
}

void TimerFadeOutOvenMix2(string &in asTimer)
{
SetPropActiveAndFade("TimeForScarletStone", false, 0.5);
}

void TimerRunningDoneOvenDoorOpen2(string &asTimer)
{
SetSwingDoorDisableAutoClose("extaction_oven_1", false);
}
//-----------------------------------------

///////////////////////////////////////////
// MAGICAL STONE POTION (CRIMSON STONE)
////////////////////////////////////////////

//------------------------------------------
//Use 4/6 potion to proceed
void UseFourthOnSqueezer(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetEntityActive("TimeForCrimsonStone", true);
PlaySoundAtEntity("placeglass", "26_place_glass", asEntity, 0.0f, false);

SetLocalVarInt("ContainerBelowThree", 1);
}
//Place the crimson stone
void UseCrimsonStoneOnSqueezer(string &in asItem, string &in asEntity)
{
int lState = GetLocalVarInt("SqueezerState");

if(GetLocalVarInt("ContainerBelowThree")==0)
{
//SetMessage("Messages", "NoContainerBelow", -1);
//return;
}

////////////////////
//Squeezer is open
if(lState == -1)
{
PlaySoundAtEntity("placegland","26_place_gland.snt", "squeezer_1", 1, false);
PlaySoundAtEntity("placegland1","26_place_gland.snt", "squeezer_1", 1, false);

RemoveItem(asItem);
SetEntityActive("orbpiece_crimson_1", true);

SetLocalVarInt("CrimsonInSqueezer", 1);
}
////////////////////
//Squeezer is NOT open
else
{
SetMessage("Messages", "NoSpaceMagicStones", -1);
}
}

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


void InteractSqueezer3(string &in asEntity)
{
if(GetLocalVarInt("ContainerBelowThree")==0 && GetLocalVarInt("CrimsonInSqueezer")==1){
SetWheelStuckState(asEntity, -1, false);
SetMessage("Messages", "NoContainerBelow", 0);
return;
}

SetWheelStuckState(asEntity, 0, false);
}

void TurnSqueezer3(string &in asEntityName, int alState)
{
SetLocalVarInt("SqueezerState", alState);
AddDebugMessage("Squeezer state: "+alState, false);

//Do nothing if no stone is in squeezer or has already been squeezed.
if(GetLocalVarInt("CrimsonInSqueezer")==0 || GetLocalVarInt("CrimsonIsSqueezed")==1)
{
return;
}

if(alState == 1)
{
PlaySoundAtEntity("splouuutch", "26_squeeze_gland.snt", "AreaSqueezer", 0.0f, false);
PlaySoundAtEntity("liquidsound","26_liquid.snt", "AreaSqueezer", 2, false);

CreateParticleSystemAtEntity("squeezeeffect", "ps_squeeze_gland_effect.ps", "squeezer_1", false);

SetLocalVarInt("CrimsonIsSqueezed", 1);

AddTimer("SqueezeEffectDone", 2, "TimerSqueezeEffectDone3");
}
}
void TimerSqueezeEffectDone3(string &in asTimer)
{
AddTimer("fadeoutmix3", 0.3, "TimerSqueezeEffectFadeOutMix3");
StopSound("liquidsound", 1.0f);

SetPropActiveAndFade("ObsidianEmeraldIndigoScarletCrimsonAdded", true, 0.5);
SetPropActiveAndFade("orbpiece_crimson_1", false, 0.5);
}
void TimerSqueezeEffectFadeOutMix3(string &in asTimer)
{
SetPropActiveAndFade("TimeForCrimsonStone", false, 0.5);
SetEntityActive("AreaGlassJarNoBlood", false);
}
//Pick up Crimson Potion
void PickCrimsonPotion(string &in asEntity, string &in asType)
{
SetEntityActive("squeezer_3", false);
SetEntityActive("squeezer_4", true);
}
//-----------------------------------------

///////////////////////////////////////////
// MAGICAL STONE POTION (TURQUOISE STONE)
////////////////////////////////////////////

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

//Use 5/6 potion to get the last ingredient
void UseFifthPotionOnSqueezer(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
SetEntityActive("TimeForTurquoiseStone", true);
PlaySoundAtEntity("placeglass", "26_place_glass", asEntity, 0.0f, false);

SetLocalVarInt("FinalIngredientJar", 1);
}
//Place the turquoise stone
void UseTurquoiseStoneOnSqueezer(string &in asItem, string &in asEntity)
{
int lState = GetLocalVarInt("SqueezerState");

if(GetLocalVarInt("FinalIngredientJar")==0)
{
//SetMessage("Messages", "NoContainerBelow", -1);
//return;
}

////////////////////
//Squeezer is open
if(lState == -1)
{
PlaySoundAtEntity("placegland","26_place_gland.snt", "squeezer_1", 1, false);
PlaySoundAtEntity("placegland1","26_place_gland.snt", "squeezer_1", 1, false);

RemoveItem(asItem);
SetEntityActive("orbpiece_turquoise_1", true);

SetLocalVarInt("TurquoiseInSqueezer", 1);
}
////////////////////
//Squeezer is NOT open
else
{
SetMessage("Messages", "NoSpaceMagicStones", -1);
}
}


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


void InteractSqueezer4(string &in asEntity)
{
if(GetLocalVarInt("FinalIngredientJar")==0 && GetLocalVarInt("TurquoiseInSqueezer")==1){
SetWheelStuckState(asEntity, -1, false);
SetMessage("Messages", "NoContainerBelow", 0);
return;
}

SetWheelStuckState(asEntity, 0, false);
}

void TurnSqueezer4(string &in asEntityName, int alState)
{
SetLocalVarInt("SqueezerState", alState);
AddDebugMessage("Squeezer state: "+alState, false);

//Do nothing if no stone is in squeezer or has already been squeezed.
if(GetLocalVarInt("TurquoiseInSqueezer")==0 || GetLocalVarInt("TurquoiseIsSqueezed")==1)
{
return;
}

if(alState == 1)
{
PlaySoundAtEntity("splouuutch", "26_squeeze_gland.snt", "AreaSqueezer", 0.0f, false);
PlaySoundAtEntity("liquidsound","26_liquid.snt", "AreaSqueezer", 2, false);

CreateParticleSystemAtEntity("squeezeeffect", "ps_squeeze_gland_effect.ps", "squeezer_1", false);

SetLocalVarInt("TurquoiseIsSqueezed", 1);

AddTimer("SqueezeEffectDone", 2, "TimerSqueezeEffectDoneFinal");
}
}
void TimerSqueezeEffectDoneFinal(string &in asTimer)
{
AddTimer("fadeoutmixfinal", 0.3, "TimerSqueezeEffectFadeOutMixFinal");
StopSound("liquidsound", 1.0f);

SetPropActiveAndFade("CompletedPotion", true, 0.5);
SetPropActiveAndFade("orbpiece_turquoise_1", false, 0.5);
}
void TimerSqueezeEffectFadeOutMixFinal(string &in asTimer)
{
SetPropActiveAndFade("TimeForTurquoiseStone", false, 0.5);
SetEntityActive("AreaGlassJarNoBlood", false);
}
//Final stuff, time to pick up the completed potion
void PickCompletedPotion(string &in asEntity, string &in asType)
{
PlayMusic("26_event_agrippa_head.ogg", false, 1.0f, 1.0f, 10, false);
GiveSanityBoost();
}
//-----------------------------------------

///////////////////////////////////////////
// MAGICAL STONE POTION (EXTRA EDITING)
////////////////////////////////////////////

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

//All wrong ways of making the potion will be tranfered to this script
void WrongCombination(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "NotCorrectLabNote", 0);
}
//Incase the player by some reason wanna boil the blood again
void WannaBoilAgain(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "BloodAlreadyBoiled", 0);
}
//The wrong area to place the magical stones
void WrongStones(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "WrongStonePlaced", 0);
}
//The player wants for some weird reason, boil the stones
void BoilStones(string &in asItem, string &in asEntity)
{
SetMessage("Messages", "BoilTheStones", 0);
}
//-----------------------------------------

///////////////////////////////////////////
// RAMBLING SOUNDS
////////////////////////////////////////////

//Note: In case you don't know what this is, this is basiclly a timer
//that repeats itself over and over, and each timer plays a sound
//that would somehow frighting the player a little extra. Just for the heck of it Smile
//Also to get this working yourself, you have to make sure it is impossible to
//miss this script or this obviously will not have the same effect.

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

void StartRamblingNoices(string &in asParent, string &in asChild, int alState)
{
AddTimer("startsounds", 60.0f, "TimerRamblingNoices");
}
void TimerRamblingNoices(string &in asTimer)
{
if(asTimer == "startsounds")
PlaySoundAtEntity("activate", "man01_whimp.snt", "Player", 0.0f, false);
AddTimer("startsounds1", 60.0f, "TimerRamblingNoices1");
}
void TimerRamblingNoices1(string &in asTimer)
{
if(asTimer == "startsounds1")
PlaySoundAtEntity("activate", "man02_whimp.snt", "Player", 0.0f, false);
AddTimer("startsounds", 60.0f, "TimerRamblingNoices");
}

// Run first time starting map
void OnStart()
{
SetMapDisplayNameEntry("MainHall");

// Clear previously saved maps
ClearSavedMaps();

////////////////////
// Hub start sanity boost
GiveSanityBoost();

////////////////////
// Script test with the magical potion
GiveItemFromFile("glass_container_1", "glass_container.ent");
GiveItemFromFile("lantern_1", "lantern.ent");
GiveItemFromFile("hand_drill", "hand_drill.ent");

//////////////////////
//Load Screen Setup
for(int i=1; i<=4; ++i)
SetupLoadScreen("LoadingText", "MainHallTexts_"+i, 4, "loading_screen_mainhall.jpg");

///////////////////////////
// UseItem - Empty Glass Container
AddUseItemCallback("", "glass_container_1", "extaction_oven_1", "GlassJarHeaterWithoutBlood", false);
AddUseItemCallback("", "glass_container_1", "special_burner_1", "GlassJarHeaterWithoutBlood", false);
AddUseItemCallback("", "glass_container_1", "special_burner_1", "GlassJarHeaterWithoutBlood", false);
AddUseItemCallback("", "glass_container_1", "squeezer_1", "GlassJarHeaterWithoutBlood", false);

//////////////////////
// Blood Container
AddUseItemCallback("", "OldBlood", "squeezer_1", "JarSqueezerBloodBoiled", false);
AddUseItemCallback("", "OldBlood", "extaction_oven_1", "WrongCombination", false);
AddUseItemCallback("", "OldBlood", "AreaExtractJarNoBlood", "WannaBoilAgain", false);

//////////////////////
// 1/6 Potion
AddUseItemCallback("", "glass_container_mix_notdone_3", "squeezer_2", "UseOneOnSqueezer", false);
AddUseItemCallback("", "glass_container_mix_notdone_3", "extaction_oven_1", "WrongCombination", false);
AddUseItemCallback("", "glass_container_mix_notdone_3", "AreaExtractJarNoBlood", "WannaBoilAgain", false);

//////////////////////
// 2/6 Potion
AddUseItemCallback("", "ObsidianEmeraldAdded", "AreaExtractJarNoBlood", "WannaBoilAgain", false);
AddUseItemCallback("", "ObsidianEmeraldAdded", "extaction_oven_1", "TwoPotionOnExtractor", false);
AddUseItemCallback("", "ObsidianEmeraldAdded", "AreaSqueezerNoBlood", "WrongCombination", false);

//////////////////////
// 3/6 Potion
AddUseItemCallback("", "EmeraldObsidianIndigoAdded", "AreaSqueezerNoBlood", "WrongCombination", false);
AddUseItemCallback("", "EmeraldObsidianIndigoAdded", "AreaExtractJarNoBlood", "WannaBoilAgain", false);
AddUseItemCallback("", "EmeraldObsidianIndigoAdded", "extaction_oven_1", "UseThirdPotionOnExtractor", false);

//////////////////////
// 4/6 Potion
AddUseItemCallback("", "EmeraldObsidianIndigoScarletAdded", "extaction_oven_1", "WrongCombination", false);
AddUseItemCallback("", "EmeraldObsidianIndigoScarletAdded", "AreaExtractJarNoBlood", "WannaBoilAgain", false);
AddUseItemCallback("", "EmeraldObsidianIndigoScarletAdded", "squeezer_3", "UseFourthOnSqueezer", false);

//////////////////////
// 5/6 Potion
AddUseItemCallback("", "EmeraldObsidianIndigoScarletCrimsonAdded", "extaction_oven_1", "WrongCombination", false);
AddUseItemCallback("", "EmeraldObsidianIndigoScarletCrimsonAdded", "AreaExtractJarNoBlood", "WannaBoilAgain", false);
AddUseItemCallback("", "EmeraldObsidianIndigoScarletCrimsonAdded", "squeezer_4", "UseFifthPotionOnSqueezer", false);

//////////////////////
// Emerald Stone
AddUseItemCallback("EmeraldSqueezer", "EmeraldStone", "squeezer_1", "UseEmeraldStoneOnExtractor", false);
AddUseItemCallback("EmeraldOven", "EmeraldStone", "extaction_oven_1", "WrongStones", false);
AddUseItemCallback("EmeraldBoil", "EmeraldStone", "AreaExtractJarNoBlood", "BoilStones", false);

//////////////////////
// Obsidian Stone
AddUseItemCallback("ObsidianSqueezer", "ObsidianStone", "squeezer_2", "UseObsidianStoneOnExtractor", false);
AddUseItemCallback("ObsidianBoil", "ObsidianStone", "AreaExtractJarNoBlood", "BoilStones", false);
AddUseItemCallback("ObsidianOven", "ObsidianStone", "extaction_oven_1", "WrongStones", false);

//////////////////////
// Indigo Stone
AddUseItemCallback("IndigoOven", "IndigoStone", "extaction_oven_1", "UseIndigoOnOven", false);
AddUseItemCallback("IndigoBoil", "IndigoStone", "AreaExtractJarNoBlood", "BoilStones", false);
AddUseItemCallback("IndigoSqueezer", "IndigoStone", "squeezer_3", "WrongStones", false);

//////////////////////
// Scarlet Stone
AddUseItemCallback("ScarletSqueezer", "ScarletStone", "squeezer_3", "WrongStones", false);
AddUseItemCallback("ScarletOven", "ScarletStone", "extaction_oven_1", "UseScarletOnOven", false);
AddUseItemCallback("ScarletBoil", "ScarletStone", "AreaExtractJarNoBlood", "BoilStones", false);

//////////////////////
// Crimson Stone
AddUseItemCallback("CrimsonBoil", "CrimsonStone", "AreaExtractJarNoBlood", "BoilStones", false);
AddUseItemCallback("CrimsonSqueezer", "CrimsonStone", "squeezer_3", "UseCrimsonStoneOnSqueezer", false);
AddUseItemCallback("CrimsonOven", "CrimsonStone", "extaction_oven_1", "WrongStones", false);

//////////////////////
// Turquoise Stone
AddUseItemCallback("TurquoiseBoil", "TurquoiseStone", "AreaExtractJarNoBlood", "BoilStones", false);
AddUseItemCallback("TurquoiseOven", "TurquoiseStone", "extaction_oven_1", "WrongStones", false);
AddUseItemCallback("TurquoiseSqueezer", "TurquoiseStone", "squeezer_4", "UseTurquoiseStoneOnSqueezer", false);


//////////////////////
// Collide Callbacks
AddEntityCollideCallback("Player", "AreaRamblingSounds", "StartRamblingNoices", false, 1);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
PlayMusic("21_amb.ogg", true, 0.8f, 5, 0, true);

AutoSave();
}

////////////////////////////
// Run when leaving map
void OnLeave()
{

}
05-23-2013, 07:03 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: A really annoying script problem

How about you include the block that you think is the issue? Because that wall of text is difficult to read.
(This post was last modified: 05-23-2013, 08:10 PM by Tomato Cat.)
05-23-2013, 08:10 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#3
RE: A really annoying script problem

AddUseItemCallback("EmeraldSqueezer", "EmeraldStone", "squeezer_1", "UseEmeraldStoneOnExtractor", false);
05-23-2013, 09:08 PM
Find
OriginalUsername Offline
Posting Freak

Posts: 896
Threads: 42
Joined: Feb 2013
Reputation: 34
#4
RE: A really annoying script problem

Maybe put it in a spoiler?
05-23-2013, 09:10 PM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#5
RE: A really annoying script problem

PHP Code: (Select All)
void UseEmeraldStoneOnExtractor(string &in asItemstring &in asEntity)
{
int lState GetLocalVarInt("SqueezerState");

if(
GetLocalVarInt("ContainerBelow")==0)
{
//SetMessage("Messages", "NoContainerBelow", -1);
//return;


Comment lines and a typo?

Also, I din't think the UseItem callback has an alState parameter.
(This post was last modified: 05-23-2013, 10:36 PM by Tomato Cat.)
05-23-2013, 10:06 PM
Find




Users browsing this thread: 1 Guest(s)