Frictional Games Forum (read-only)

Full Version: Is there anything wrong with...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys!

Is there anything wrong with this script?
Code:
void OnStart()
{
    AddEntityCollideCallback("Player", "BooArea", "CollideBoo", true, 1);
    AddEntityCollideCallback("MyNameIsBob_1", "Disappear_1", "CollideDisappear", true, 1);
    AddEntityCollideCallback("Player", "Identify", "CollideIdentify", true, 1);
    AddEntityCollideCallback("Player", "ActVeryShocked_1", "CollideVeryShocked", true, 1);
    AddEntityCollideCallback("Player", "Suspicion_1", "CollideSuspicion", true, 1);
    AddEntityCollideCallback("Player", "LightsOut_1", "CollideOff", true, 1);
    AddEntityCollideCallback("Player", "LeScream", "CollideLeScream", true, 1);
    AddEntityCollideCallback("Player", "HearTheStatues_1", "CollideHearThem", true, 1);
    AddEntityCollideCallback("Player", "SeeTheStatues_1", "CollideSeeThem", true, 1);
    SetEntityPlayerInteractCallback("NoteM02", "NoteScare", true);
    SetEntityPlayerInteractCallback("Note06", "NoteText", true);
    SetEntityPlayerInteractCallback("Thingy_1", "MonsterSpawn", true);
    SetEntityPlayerInteractCallback("BlockingDoorBox_1", "UnblockDoor", true);
    SetEntityPlayerInteractCallback("HammerDoor_1", "Picklock", true);
    SetEntityPlayerInteractCallback("Note09", "Inference", true);
    SetEntityPlayerInteractCallback("Nope_1", "Nope", true);
    AddUseItemCallback("", "KeyToRoom_1", "DoorToAdv_1", "UsedKeyOnAdv", true);
    AddCombineCallback("", "Potion_1", "Potion_2", "CombineChem", true);
    AddUseItemCallback("", "HammerForPadlock_1", "Padlock_1", "SmashedLock", true);
    AddUseItemCallback("", "HammerForPadlock_1", "Blockade_1", "SmashedBlockade", true);
    AddUseItemCallback("", "KeyToArea_1", "AreaDoor_1", "OpenedAreaDoor", true);
    AddUseItemCallback("", "KeyForHatch_1", "HatchOfDestiny_1", "OpenedHatch", true);
    AddUseItemCallback("", "Picklock_1", "HammerDoor_1", "OpenedHammerDoor", true);
}

void OnEnter()
{
}

void OnLeave()
{
}

void NoteScare(string &in asEntity)
{
PlaySoundAtEntity("", "04_scream.snt", "UnknownDoor_1", 0, false);
GiveSanityDamage(10, true);
SetMessage("StorageArea2", "Scared", 0);
StartPlayerLookAt("UnknownDoor_1", 4.0f, 4.0f, "TimerScare");
AddTimer("", 1.0f, "TimerScare");
}

void Nope(string &in asEntity)
{
SetMessage("StorageArea2", "Nope", 0);
}

void Picklock(string &in asEntity)
{
SetMessage("StorageArea2", "Picklock", 0);
}

void Inference(string &in asEntity)
{
SetMessage("StorageArea2", "Inference", 0);
}

void TimerScare(string &in asTimer)
{
StopPlayerLookAt();
}

void CollideOff(string &in asParent, string &in asChild, int alState)
{
SetLampLit("torch_static01_32", false, false);
SetLampLit("torch_static01_33", false, false);
SetLampLit("torch_static01_34", false, false);
SetLampLit("torch_static01_35", false, false);
SetLampLit("torch_static01_36", false, false);
SetLampLit("torch_static01_37", false, false);
SetLampLit("torch_static01_38", false, false);
SetLampLit("torch_static01_39", false, false);
SetLampLit("torch_static01_40", false, false);
SetLampLit("torch_static01_41", false, false);
SetLampLit("torch_static01_42", false, false);
SetLampLit("torch_static01_43", false, false);
SetLampLit("torch_static01_44", false, false);
SetLampLit("torch_static01_45", false, false);
SetLampLit("torch_static01_46", false, false);
SetLampLit("torch_static01_47", false, false);
SetLampLit("torch_static01_48", false, false);
SetLampLit("torch_static01_49", false, false);
SetLampLit("torch_static01_50", false, false);
SetLampLit("torch_static01_51", false, false);
SetLampLit("torch_static01_52", false, false);
SetLampLit("torch_static01_53", false, false);
SetLampLit("torch_static01_54", false, false);
SetLampLit("torch_static01_55", false, false);
SetLampLit("torch_static01_56", false, false);
SetLampLit("torch_static01_57", false, false);
SetLampLit("torch_static01_58", false, false);
SetLampLit("torch_static01_59", false, false);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
}



void CollideBoo(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Hello_1", true);
GiveSanityDamage(30, true);
}

void CollideSuspicion(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("UnspokenWordsReference_1", 3.5f, 3.5f, "TimeReference");
AddTimer("TimeReference", 2.0f, "TimeReference");
SetMessage("StorageArea2", "Suspicion", 0);
}

void CollideVeryShocked(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("" ,"react_scare.snt", "Player", 0, false);
}

void CollideLeScream(string &in asParent, string &in asChild, int alState)
{
AddPropImpulse("LeScreamDoor_1", 0, 0, 2, "World");
PlaySoundAtEntity("", "21_bang_door.snt", "LeScreamDoor_1", 0, false);
PlaySoundAtEntity("", "21_intro_scream.snt", "LeScreamDoor_1", 0, false);
}

void CollideHearThem(string &in asParent, string &in asChild, int alState)
{
SetMessage("StorageArea_2", "Huh", 0);
SetEntityActive("SeeMeNow_1", true);
SetEntityActive("SeeMeNow_2", true);
SetEntityActive("JustHeard_1", false);
SetEntityActive("JustHeard_2", false);
}

void CollideSeeThem(string &in asParent, string &in asChild, int alState)
{
StartPlayerLookAt("LeScream", 4.0f, 4.0f, "TimerRealise2");
AddTimer("", 1.0f, "TimerRealise2");
PlaySoundAtEntity("" ,"react_scare.snt", "Player", 0, false);
}

void TimeRealise2(string &in asTimer)
{
StopPlayerLookAt();
}

void TimeReference(string &in asTimer)
{
StopPlayerLookAt();
AddQuest("quest5", "Quest5");
}

void MonsterSpawn(string &in asEnity)
{
SetEntityActive("MyNameIsBob_1", true);
AddEnemyPatrolNode("MyNameIsBob_1", "PathNodeArea_1", 1, "");
    AddEnemyPatrolNode("MyNameIsBob_1", "PathNodeArea_2", 1, "");
    AddEnemyPatrolNode("MyNameIsBob_1", "PathNodeArea_3", 1, "");
    AddEnemyPatrolNode("MyNameIsBob_1", "PathNodeArea_4", 1, "");
    AddEnemyPatrolNode("MyNameIsBob_1", "PathNodeArea_5", 1, "");
    AddEnemyPatrolNode("MyNameIsBob_1", "PathNodeArea_6", 2, "");
}

void UsedKeyOnAdv(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("DoorToAdv_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "DoorToAdv_1", 0, false);
RemoveItem("KeyToRoom_1");
}


void OpenedAreaDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("AreaDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "AreaDoor_1", 0, false);
RemoveItem("KeyToArea_1");
SetMessage("StorageArea2", "LetsGetOut", 0);
}

void OpenedHatch(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("KeyForHatch_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "HatchOfDestiny_1", 0, false);
RemoveItem("KeyForHatch_1");
}

void OpenedHammerDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("HammerDoor_1", false, true);
PlaySoundAtEntity("", "unlock_door.snt", "HammerDoor_1", 0, false);
RemoveItem("Picklock_1");
}

void SmashedLock(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("PadlockDoor_1", false, true);
PlaySoundAtEntity("", "impact_metal_high.snt", "PadlockDoor_1", 0, false);
SetEntityActive("PadlockBroken_1", true);
SetEntityActive("Padlock_1", false);
SetMessage("StorageArea2", "DoneIt", 0);
CreateParticleSystemAtEntity("", "break_wood_small.ps", "PadlockBroken_1", true);
}


void SmashedBlockade(string &in asItem, string &in asEntity)
{
    PlaySoundAtEntity("", "break_wood.snt", "DoorToTinder_1", 0, false);
        SetEntityActive("Blockade_2", true);
        RemoveItem("HammerForPadlock_1");
        SetEntityActive("Blockade_1", false);
    CreateParticleSystemAtEntity("", "break_wood_small.ps", "Blockade_2", true);
    SetMessage("StorageArea2", "DammitToHell", 0);
}

void LockedText(string &in asEntity)
{
SetMessage("StorageArea2", "LockedText", 0);
}

void UnblockDoor(string &in asEntity)
{
SetSwingDoorLocked("Locked_1", false, true);
}

void CollideIdentify(string &in asParent, string &in asChild, int alState)
{
SetMessage("StorageArea2", "Identify", 0);
StartPlayerLookAt("BlockingDoorBox_1", 3.5f, 3.5f, "TimeRealise");
AddTimer("TimeRealise", 1.0f, "TimeRealise");
}

void TimeRealise(string &in asTimer)
{
StopPlayerLookAt();
}

void CollideDisappear(string &in asEntity)
{
FadeEnemyToSmoke("MyNameIsBob_1", false);
SetEntityActive("MyNameIsBob_1", false);
}

///////////////////////////////////////////////////////
//BEGIN EPOXY SCRIPT//////////////////////////////////
void CombineChem(string &in asItemA, string &in asItemB)
{
PlaySoundAtEntity("", "puzzle_acid.snt", "Player", 0, false);
GiveItem("", "chemical_container_epoxy", "Epoxy_1", "chemical_container_epoxy.tga", 1);
AddUseItemCallback("", "Epoxy_1", "BoomScript_1", "LeBigBoom", true);
}

void LeBigBoom(string &in asItem, string &in asEntity)
{
StartPlayerLookAt("ChemJar_1", 1.5f, 1.5f, "Timer1");
SetEntityActive("ChemJar_1", true);
RemoveItem("Epoxy_1");
AddTimer("Timer1", 0.8f, "TimerLookAt");
AddTimer("Timer2", 3.0f, "TimerExplosion");
PlaySoundAtEntity("", "12_epoxy_blow.snt", "ChemJar_1", 0, false);
PlaySoundAtEntity("", "puzzle_place_jar.snt", "ChemJar_1", 0,false);
SetMessage("StorageArea2", "Panic", 0);
}

void TimerLookAt(string &in asTimer)
{
StopPlayerLookAt();
}

void TimerExplosion(string &in asTimer)
{
PlaySoundAtEntity("", "explosion_rock_large.snt", "cave_in_1", 0, false);
SetEntityActive("cave_in_1", false);
SetEntityActive("ChemJar_1", false);
}
//END EPOXY SCRIPT///////////////////////////////////
////////////////////////////////////////////////////
It's just that, only BlackBox errors are coming up and crashing the game so I don't know what is wrong with it. Also, if you don't mind - Can you add a smooth transition to when the lights go out in the above script? - just turning off looks rather shabby.

Thanks.
Well since your the creator, its easier for you to figure it out since you know what you were working on last. 99.9% of the problem is their, unless you made all the code without testing it till the end. Because your stuff is way to long, sorting through that is going to take awhile...

To fade out lights, use this...

void FadeLightTo(string& asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);


Its under the "Lights" catergory in the HPL2 wiki, not "lamps".

Edit: What were you working on last? I'm in the middle of looking for errors. Try commenting things out in your "void on Start()" section and see if you can just get your map to a working order, and start taking them out to figure out where the problem is...


I used to get black box errors when I set up my inventory.hps wrong. I think the problem might be connected to the epoxy script. Try commenting out that entire section and checking if the game can run.
Have you had that epoxy script work before? or was that the last thing you added to the script before the crash?

Wait, you're getting crash errors (like when the level editor crashes)? Or script file errors (which also crash)?
(04-14-2012, 03:13 PM)Putmalk Wrote: [ -> ]Wait, you're getting crash errors (like when the level editor crashes)? Or script file errors (which also crash)?
I am, yes.



(04-14-2012, 02:15 PM)Rapture Wrote: [ -> ]Well since your the creator, its easier for you to figure it out since you know what you were working on last. 99.9% of the problem is their, unless you made all the code without testing it till the end. Because your stuff is way to long, sorting through that is going to take awhile...

To fade out lights, use this...

void FadeLightTo(string& asLightName, float afR, float afG, float afB, float afA, float afRadius, float afTime);


Its under the "Lights" catergory in the HPL2 wiki, not "lamps".

Edit: What were you working on last? I'm in the middle of looking for errors. Try commenting things out in your "void on Start()" section and see if you can just get your map to a working order, and start taking them out to figure out where the problem is...
To be fair, I reckon it'd be easier to remove that script.


(04-14-2012, 02:59 PM)DRedshot Wrote: [ -> ]I used to get black box errors when I set up my inventory.hps wrong. I think the problem might be connected to the epoxy script. Try commenting out that entire section and checking if the game can run.
Have you had that epoxy script work before? or was that the last thing you added to the script before the crash?
No, good sir. Surprisingly, that script worked fine first time.