The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 906 - File: showthread.php PHP 7.2.24-0ubuntu0.18.04.17 (Linux)
File Line Function
/showthread.php 906 errorHandler->error



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
GreyFox Offline
Member

Posts: 162
Threads: 23
Joined: Jul 2011
Reputation: 2
#1
Script Help

Hello, I'm new to this forum so go easy on me. I'm also a total noob when it comes to scripting. Anyways let's get straight to my question

In my custom story Demo thing, I want to have a monster in a room and then when you go to open the door it activates the monster and tries to kill you (Exactly like in the level "Storage" in the main game) Since I had no Idea how to do it I copyed everything from storage (The part i wanted) and then copyed the script (the part I needed). I don't know if this isn't allowed here I just though It was a smart way to figure something out. When I go to run the test of the level it loads and then I go to the correct door/area but nothing happens. No error or anything.

Sorry how long it is this is how long it was in their script (except for the door slamming behind you.) Also if I posted the script wrong I apologize

My Script:

////////////////////////////
// Run first time starting map
void OnStart()
{
AddUseItemCallback("", "LockedDoorKey_1", "LockedDoor_1", "UsedKeyOnDoor", true);
AddEntityCollideCallback("Player", "Scare_1", "CollideScare_1", true, 1);
}

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

void CollideScare_1(string &in asParent, string &in asChild, int alState)
{
SetSwingDoorClosed("ScareDoor_1", true, true);
}

void CollideAreaCloseDoor(string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("GruntInRoomEvent") != 1) return;

//Door opens, make grunt active and normal
if(alState == -1){
AddEnemyPatrolNode("grunt_in_room", "PathNodeArea_4", 0.0f, "");
AddEnemyPatrolNode("grunt_in_room", "PathNodeArea_20", 0.0f, "");
AddEnemyPatrolNode("grunt_in_room", "PathNodeArea_43", 0.0f, "");
SetEntityActive("grunt_in_room", true);

CheckPoint("roomgrunt", "PlayerStartArea_1", "CPCallGruntRoom", "", "");

StopBangDoorEvent();
}

//Door closes, make grunt fictional but not if player is in room too
else{
if(GetLocalVarInt("PlayerInGruntArea") != 1)
StartBangDoorEvent();
}

}

//Check if grunt/player is in the room
void CollideAreaGruntRoom(string &in asParent, string &in asChild, int alState)
{
//If player in room, set var to make sure the grunt will not disable if door is closed.
if(asParent == "Player")
SetLocalVarInt("PlayerInGruntArea", alState);

//Grunt leaves room, so all possible events are shutdown and grunt is just a normal chasing grunt happy with no worries in the world.
if(asParent == "grunt_in_room" && alState == -1){
SetLocalVarInt("GruntInRoomEvent", 2);
SetLocalVarInt("GruntBreakDoor", 3);
StopBangDoorEvent();
AddDebugMessage("Grunt left room", false);
}
}

//Check if player is close to the door outside of the room
void CollideAreaGruntRoomActivate(string &in asParent, string &in asChild, int alState)
{
if(GetLocalVarInt("GruntInRoomEvent") != 1) return;

if(alState == 1)
StartBangDoorEvent();

else
StopBangDoorEvent();
}

//Player comes closer to door, begin the banging
void StartBangDoorEvent()
{
ClearEnemyPatrolNodes("grunt_in_room");

SetEntityActive("grunt_in_room", false);

AddTimer("TimerEBangOnDoor", RandFloat(1.0f, 2.0f), "TimerEBangOnDoor");
}

//Player goes away, remove banging
void StopBangDoorEvent()
{
RemoveTimer("TimerEBangOnDoor");
SetLocalVarInt("TimerEBangOnDoor", 0);

//Event has occured 3 times, remove all, let grunt stay active and do not do event any more
if(GetLocalVarInt("GruntBreakDoor") == 3){
SetEntityActive("AreaGruntRoomActivate", false);
SetEntityActive("AreaGruntRoom", false);
SetEntityActive("AreaCloseDoor", false);

if(GetLocalVarInt("GruntInRoomEvent") != 3){
ClearEnemyPatrolNodes("grunt_in_room");
AddEnemyPatrolNode("grunt_in_room", "PathNodeArea_4", 0.0f, "");
AddEnemyPatrolNode("grunt_in_room", "PathNodeArea_20", 0.0f, "");
AddEnemyPatrolNode("grunt_in_room", "PathNodeArea_43", 0.0f, "");
SetEntityActive("grunt_in_room", true);
}
}
}

//The grunt noise and bang on door
void TimerEBangOnDoor(string &in asTimer)
{
string sEvent = asTimer; //Do not edit, sets timer loop function name.
AddLocalVarInt(sEvent, 1); //Do not edit, steps through timer loop events.
bool bPauseAtStep = false; //Do not edit, to pause or end the timer loop at specified step.

float fEventSpeed = 0.5f; //Set to preferred default time for the timer loop.

switch(GetLocalVarInt(sEvent)){
//////////
//Grunt screams
case 1:
BangOnDoorEffects("grunt", "grunt/notice.snt", false);
break;

//////////
//Grunt bang on door 1
case 2:
BangOnDoorEffects("bang1", "lurker_hit_wood.snt", true);
fEventSpeed = RandFloat(0.2f, 0.8f);
break;

//////////
//Grunt bang on door 2
case 3:
BangOnDoorEffects("bang2", "lurker_hit_wood.snt", true);
fEventSpeed = RandFloat(0.2f, 0.8f);
break;

//////////
//Grunt bang on door 3
case 4:
BangOnDoorEffects("bang3", "lurker_hit_wood.snt", true);
AddLocalVarInt("GruntBreakDoor", 1);

if(GetLocalVarInt("GruntBreakDoor") == 3)
StopBangDoorEvent();
break;


//////////
//End timer when no more steps in the event found.
default:
bPauseAtStep = true;
break;
}

if(!bPauseAtStep) AddTimer(sEvent, fEventSpeed, sEvent);
}

//Effects for each bang
void BangOnDoorEffects(string &in sName, string &in sSound, bool bParticle)
{
PlaySoundAtEntity(sName, sSound, "cellar_wood01_7", 0.0f, false);

if(bParticle)
CreateParticleSystemAtEntity("ps"+sName, "ps_hit_wood.ps", "cellar_wood01_7", false);
}

//Set variable to allow rod grunt to activate.
void EntityCallGruntRoomDisabled(string &in asEntity, string &in type)
{
AddDebugMessage("Grunt from room disabled.", false);

SetLocalVarInt("GruntInRoomEvent", 3);
}

//Checkpoint from room grunt
void CPCallGruntRoom(string &in asName, int alCount)
{
SetLocalVarInt("GruntInRoomEvent", 3);
ResetProp("cellar_wood01_7");

SetEntityActive("AreaGruntBoo", true);

AddEntityCollideCallback("Player", "AreaGruntBoo", "CollideAreaGruntBoo", true, 1);
}
void CollideAreaGruntBoo(string &in asParent, string &in asChild, int alState)
{
PlaySoundAtEntity("boo", "grunt/amb_idle.snt", "AreaGruntBoo_1", 0.0f, false);

AddTimer("scare", 1.0f, "TimerPlayerReactions");
AddTimer("breath", 3.0f, "TimerPlayerReactions");
AddTimer("breathl", 5.0f, "TimerPlayerReactions");
}

////////////////////////////
// Run when entering map
void OnEnter()
{

}

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

}



Current Project
Forgotten
07-12-2011, 05:13 PM
Find


Messages In This Thread
Script Help - by GreyFox - 07-12-2011, 05:13 PM
RE: Script Help - by Zypherzemus - 07-12-2011, 07:17 PM
RE: Script Help - by GreyFox - 07-12-2011, 07:26 PM
RE: Script Help - by Zypherzemus - 07-12-2011, 08:38 PM
RE: Script Help - by GreyFox - 07-12-2011, 09:02 PM
RE: Script Help - by Kyle - 07-12-2011, 09:05 PM
RE: Script Help - by GreyFox - 07-13-2011, 07:05 PM
RE: Script Help - by Zypherzemus - 07-13-2011, 08:02 PM
RE: Script Help - by GreyFox - 07-13-2011, 08:13 PM
RE: Script Help - by ferryadams11 - 07-13-2011, 08:24 PM
RE: Script Help - by GreyFox - 07-13-2011, 09:16 PM



Users browsing this thread: 1 Guest(s)