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 help me!
pewds..fan Offline
Junior Member

Posts: 11
Threads: 4
Joined: May 2013
Reputation: 0
#1
help me!

hi everyone! i have a problem with a script i´d love to create but i have no idea how...
im going to doa script that when you walk in to a specific area all the lights will shut down!1 but how i have done this so far...i used "addentitycollidacallback" and then made a "void lightsoff" but could someone tell me is this correct and what soud should i use" it is a castebased corridor!

SCRIPT
////////////////////////////
// Run first time starting map
void OnStart()
{
SetPlayerLampOil(0);
AddUseItemCallback("", "Crowbar", "Door", "UseCrowbarOnDoor", true);
AddEntityCollideCallback("Joint", "AreaBreak", "BreakDoor", true, 1);
SetEntityCallbackFunc("potion_sanity_2", "PianoShut");
SetEntityCallbackFunc("Awesome_key1", "jump");
AddEntityCollideCallback("Player", "explode_scare", "Explode", true, 1);
SetEntityPlayerInteractCallback("mansion_4", "func_slam", true);
AddEntityCollideCallback("Player", "START_BRUTE", "monster", true, 1);
AddEntityCollideCallback("Player", "LIGHTS_OFF", "LIGHTSOFF", true, 1);
}
void LIGHTSOFF(string &in asParent, string &in asChild, int alState)

SetEntityActive("torch_floor_1");
SetEntityActive("torch_floor_2");
SetEntityActive("torch_floor_3");
SetEntityActive("torch_floor_4");
SetEntityActive("torch_floor_5");
SetEntityActive("torch_floor_6");
SetEntityActive("torch_floor_7");
SetEntityActive("torch_floor_8");
SetEntityActive("torch_floor_9");
SetEntityActive("torch_floor_10");
SetEntityActive("torch_floor_11");
SetEntityActive("torch_floor_12");
SetEntityActive("torch_floor_13");
SetEntityActive("torch_floor_14");

void monster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("BRUTE", true);
AddEnemyPatrolNode("BRUTE", "NODE_1", 0, "");
}

void func_slam(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("mansion_4", 0.0f);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

void Explode(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("pot_explode", 0);
GiveSanityDamage(15.0f, true);
}

void jump(string &in asEntity, string &in type)
{
SetEntityActive("GRUNT_PART_1", true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
PlaySoundAtEntity("", "sanity_damage.snt", "Player", 0, false);
GiveSanityDamage(10.0f, true);
}

void PianoShut(string &in asEntity, string &in OnPickup)
{
SetLeverStuckState("piano_1", 0, true);
AddPropImpulse("piano_1", 0, 0, 50, "world");
SetLeverStuckState("piano_1", -1, true);
PlaySoundAtEntity("PianoShut", "break_wood", "piano_1", 0, false);
CreateParticleSystemAtEntity("", "ps_dust_impact.ps", "impact", false);
GiveSanityDamage(60, true);
}

void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05, false);
AddTimer(asEntity, 0.2, "TimerPlaceCrowbar");
}

void TimerPlaceCrowbar(string &in asTimer)
{
SetEntityActive("Joint", true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}

void BreakDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Joint", false);
SetEntityActive("Broken", true);

SetSwingDoorLocked("Door", false, false);
SetSwingDoorClosed("Door", false, false);
SetSwingDoorDisableAutoClose("Door", true);

AddPropImpulse("Door", 0, 0, 3, "world");

CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);
PlaySoundAtEntity("", "break_wood_metal", "AreaEffect", 0, false);

GiveSanityBoostSmall();

PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);

AddTimer("", 0.1, "TimerPushDoor");
}

void TimerPushDoor(string &in asTimer)
{
AddPropImpulse("Door", -4, 2, 1, "world");
AddTimer("", 1.1, "TimerDoorCanClose");
}

void TimerDoorCanClose(string &in asTimer)
{
SetSwingDoorDisableAutoClose("Door", false);
}

////////////////////////////
// Run when entering map
void OnEnter()
{
AddUseItemCallback("", "Awesome_key1", "Door_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Awesome_key2", "locked_2", "UsedKeyOnLocked", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "Door_1", 0, false);
RemoveItem("Awesome_key1");
}

void UsedKeyOnLocked(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_2", false, true);
PlaySoundAtEntity("", "unlock_door", "locked_2", 0, false);
RemoveItem("Awesome_key2");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{
AutoSave();
}
05-29-2013, 03:37 PM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: help me!

Spoiler below!

////////////////////////////
// Run first time starting map
void OnStart()
{
SetPlayerLampOil(0);
AddUseItemCallback("", "Crowbar", "Door", "UseCrowbarOnDoor", true);
AddEntityCollideCallback("Joint", "AreaBreak", "BreakDoor", true, 1);
SetEntityCallbackFunc("potion_sanity_2", "PianoShut");
SetEntityCallbackFunc("Awesome_key1", "jump");
AddEntityCollideCallback("Player", "explode_scare", "Explode", true, 1);
SetEntityPlayerInteractCallback("mansion_4", "func_slam", true);
AddEntityCollideCallback("Player", "START_BRUTE", "monster", true, 1);
AddEntityCollideCallback("Player", "LIGHTS_OFF", "LIGHTSOFF", true, 1);
}
void LIGHTSOFF(string &in asParent, string &in asChild, int alState)
{
SetLampLit("torch_floor_*", false, true); //This means that any entity that have the word (beginning part) "torch_floor_" will be un-lit. That means it will be made to shut down. You also had the wrong parameter and string signature. You have to made the torch floor lamp to be lit and active for this to work.
} //You forgot to add the curly brackets. I also shortened this script.

void monster(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("BRUTE", true);
AddEnemyPatrolNode("BRUTE", "NODE_1", 0, "");
}

void func_slam(string &in asEntity) //You had the wrong callback syntax. The one you have earlier is for the AECC.
{
SetPropHealth("mansion_4", 0.0f);

PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);

PlaySoundAtEntity("", "react_scare", "Player", 0, false);

PlaySoundAtEntity("", "close_door.snt", "Player", 0, false);

GiveSanityDamage(5.0f, true);
}

void Explode(string &in asParent, string &in asChild, int alState)
{
SetPropHealth("pot_explode", 0);
GiveSanityDamage(15.0f, true);
}

void jump(string &in asEntity, string &in type)
{
SetEntityActive("GRUNT_PART_1", true);
PlaySoundAtEntity("", "react_scare.snt", "Player", 0, false);
PlaySoundAtEntity("", "sanity_damage.snt", "Player", 0, false);
GiveSanityDamage(10.0f, true);
}

void PianoShut(string &in asEntity, string &in type) //You also had the wrong syntax here too. [jump] and this had the same parameter, therefore, had the same syntax.
{
SetLeverStuckState("piano_1", 0, true);
AddPropImpulse("piano_1", 0, 0, 50, "world");
SetLeverStuckState("piano_1", -1, true);
PlaySoundAtEntity("PianoShut", "break_wood", "piano_1", 0, false);
CreateParticleSystemAtEntity("", "ps_dust_impact.ps", "impact", false);
GiveSanityDamage(60, true);
}

void UseCrowbarOnDoor(string &in asItem, string &in asEntity)
{
RemoveItem(asItem);
PlaySoundAtEntity("", "player_crouch.snt", "Player", 0.05f, false); //You forgot to add a f Wink
AddTimer("", 0.2, "TimerPlaceCrowbar");
}

void TimerPlaceCrowbar(string &in asTimer)
{
SetEntityActive("Joint", true);
PlaySoundAtEntity("", "puzzle_place_jar.snt", asTimer, 0, false);
}

void BreakDoor(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("Joint", false);
SetEntityActive("Broken", true);

SetSwingDoorLocked("Door", false, false);
SetSwingDoorClosed("Door", false, false);
SetSwingDoorDisableAutoClose("Door", true);

AddPropImpulse("Door", 0, 0, 3, "world");

CreateParticleSystemAtEntity("", "ps_hit_wood.ps", "AreaEffect", false);
PlaySoundAtEntity("", "break_wood_metal", "AreaEffect", 0, false);

GiveSanityBoostSmall();

PlayMusic("10_puzzle01.ogg", false, 0.7, 0.1, 10, false);

AddTimer("", 0.1, "TimerPushDoor");
}

void TimerPushDoor(string &in asTimer)
{
AddPropImpulse("Door", -4, 2, 1, "world");
AddTimer("", 1.1, "TimerDoorCanClose");
}

void TimerDoorCanClose(string &in asTimer)
{
SetSwingDoorDisableAutoClose("Door", false);
}

////////////////////////////
// Run when entering map
void OnEnter() //You might wanna move this to void OnStart unless you want the door to be locked each time the Player enters the map.
{
AddUseItemCallback("", "Awesome_key1", "Door_1", "UsedKeyOnDoor", true);
AddUseItemCallback("", "Awesome_key2", "locked_2", "UsedKeyOnLocked", true);
}

void UsedKeyOnDoor(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("Door_1", false, true);
PlaySoundAtEntity("", "unlock_door", "Door_1", 0, false);
RemoveItem("Awesome_key1");
}

void UsedKeyOnLocked(string &in asItem, string &in asEntity)
{
SetSwingDoorLocked("locked_2", false, true);
PlaySoundAtEntity("", "unlock_door", "locked_2", 0, false);
RemoveItem("Awesome_key2");
}

////////////////////////////
// Run when leaving map
void OnLeave()
{
AutoSave();
}


It seems like you want to run a crowbar thing, right? Well it's not going to work. The crowbar can't find any area for it to collide so that it wouldn't open.

"Veni, vidi, vici."
"I came, I saw, I conquered."
05-29-2013, 03:49 PM
Find
pewds..fan Offline
Junior Member

Posts: 11
Threads: 4
Joined: May 2013
Reputation: 0
#3
RE: help me!

im not trying to make the crowbar thing its working perfectly... im working with the lights shut down thing up at the script page
05-29-2013, 04:03 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#4
RE: help me!

You've made the same mistake in this script that you did in the previous one you posted.

void LIGHTSOFF(string &in asParent, string &in asChild, int alState)

    SetEntityActive("torch_floor_1");
    SetEntityActive("torch_floor_2");
    SetEntityActive("torch_floor_3");
    SetEntityActive("torch_floor_4");
etc...

Here, there is no { and } surrounding the code in that function. I provided you the solution in your other thread, it's very important that you try to understand why that fix worked

However there is another problem, SetEntityActive requires 2 parameters
SetEntityActive(string& asName, bool abActive);
The name of the entity, which you put in, but also true or false, to say whether the entity
should be activated or deactivated


void LIGHTSOFF(string &in asParent, string &in asChild, int alState)
{
    SetEntityActive("torch_floor_1", false);
    SetEntityActive("torch_floor_2", false);
    SetEntityActive("torch_floor_3", false);
    etc...
}

That will make the torches deactivate, hence the 'false'. If you want them to be activated, then use true instead.

EDIT: woops looks like JAP already fixed that and provided a better solution, sorry about that. I'll leave the post as it explains some other extra stuff anyway

(This post was last modified: 05-29-2013, 06:13 PM by Adrianis.)
05-29-2013, 06:09 PM
Find
pewds..fan Offline
Junior Member

Posts: 11
Threads: 4
Joined: May 2013
Reputation: 0
#5
RE: help me!

i noticed the brackets few min after i posted this..

and im trying to deactivate the lights cause the spot is a "terrifying corridor" and after deactivating the lights and walking a bit forward a brute will spawn behind the player and he must run to the next door and hide......
(This post was last modified: 05-30-2013, 12:08 PM by pewds..fan.)
05-30-2013, 12:07 PM
Find




Users browsing this thread: 1 Guest(s)