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
keep monster from despawining
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#1
keep monster from despawining

hello all Big Grin i'm wondering if theres any wau to keep a monster from despawning after leaving a map, knowing you'll be going back to it. i dont know of any way to do this. and it's crucial that the monsters dont despawn.
04-14-2014, 02:42 AM
Find
Vale Offline
Member

Posts: 92
Threads: 13
Joined: Mar 2014
Reputation: 7
#2
RE: keep monster from despawining

just an idea. Im no expert in scripting, but when the map loads you could have it check a variable whether the monster is active or not. Just have the variable changed when the monster should spawn or despawn. Use a global variable.
Do you need a code example?

void 0nStart() //the first time the area ever loads
{
SetGlobalVarString("Monster", inactive); //sets a string variable that says the variable monster is inactive. works across all maps so each one may need "Monster" to be replaced with "Monster2", etc
}
void OnEnter() //runs whenever player enters map
{
if(GetGlobalVarString("Monster") == active) //checks when player enters that variable "Monster" is equal to active
{
SetEntityActive("monstername", true);//sets your monster active if previous statement true
}
}

when you first activate your monster, include
SetGlobalVarString("monster_variablename", active);

that code is a mess, and you may need to go over it a couple times. Everything is documented, and it should work. Hope this helps.
(This post was last modified: 04-14-2014, 03:19 AM by Vale.)
04-14-2014, 03:10 AM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#3
RE: keep monster from despawining

that would be helpful ^^ oh and, how is it i go about playing a sound when a player walks into an area ? this is my script so far but the noise won't play.

PHP Code: (Select All)
////////////////////////////
// Run when starting game
void OnStart()
{
/////////////////////////////////////////////////////////////////////////////////////////
//Debug
    
if(ScriptDebugOn())
          {
               
GiveItemFromFile("lantern""lantern.ent");
               
SetPlayerLampOil(100.0f);
 
               for(
int i 0;10;i++)
               {
                    
GiveItemFromFile("tinderbox""tinderbox.ent");
               }
          }
///////////////////////////////////////////////////////////////////////////////////////
//Start Scene
////////////////////////////////////////////////////////////////////////////////////////
    
ShowPlayerCrossHairIcons(false);
    
SetSanityDrainDisabled(true);
    
SetPlayerCrouching(true);
    
SetPlayerActive(false);
    
FadeOut(0);
    
AddTimer("StartGame"6.0f"IntroSequence");
////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////
//General Start Items
////////////////////////////////////////////////////////////////////////////////////////
    
GiveItemFromFile("hollow_needle""hollow_needle.ent");
////////////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////////////
//General Script
////////////////////////////////////////////////////////////////////////////////////////
    
AddEntityCollideCallback("playbreaksound" "Player""doorbreak"true1);
////////////////////////////////////////////////////////////////////////////////////////
}

///////////////////////////////////////////////////////////////////////////////////////
//Start Scene
void IntroSequence(string &in asTimer)
{
    
AddLocalVarInt("iIntroPart"1);
    
float partSpeed 0.5f;
    switch(
GetLocalVarInt("iIntroPart")) {
        case 
1:
            
MovePlayerHeadPos(0, -0.9f010.0f0.1f);
            
PlayGuiSound(""1.0f);
            
StartPlayerLookAt("AreaIntroLook_1"10.0f10.0f"");
            
FadePlayerRollTo(-50200200);
            
partSpeed 0.5f;
        break;
        
        case 
2:
            
StartPlayerLookAt("AreaIntroLook_1"1.0f1.0f"");
            
FadeIn(2.0f);
            
Manpig01();
            
partSpeed 2.6f;  
        break;
        
        case 
3:
            
StartPlayerLookAt("AreaIntroLook_2"2.0f1.0f"");
            
partSpeed 5.0f;
        break;
        
        case 
4:
            
StartPlayerLookAt("AreaIntroLook_3"1.0f1.0f"");
            
PlayGuiSound(""0.7f);
            
FadeOut(3.0f);
            
partSpeed 6.0f;
        break;
        
        case 
5:
            
StopPlayerLookAt();
            
PlayGuiSound("joint_cage_slide_open"10.0f);
            
StartPlayerLookAt("AreaIntroLook_4"20.0f20.0f"");
            
TeleportPlayer("PlayerDrag");
            
FadePlayerRollTo(70200200);
            
partSpeed 1.5f;
        break;
        
        case 
6:
            
StopPlayerLookAt();
            
SetEntityActive("engineer_1"false);
            
SetEntityActive("engineer_2"true);
            
PiggyGo1();
            
SetEntityActive("engineer_3"true);
            
PiggyGo2();
            
partSpeed 0.1f;
        break;
        
        case 
7:
            
FadeIn(2.0f);
            
AddTimer("drag"1.0f"Drag");
            
partSpeed 11.0f;
        break;
        
        case 
8:
            
FadeOut(2.0f);
            
RemoveTimer("drag");
            
partSpeed 2.0f;
        break;
        
        case 
9:
            
TeleportPlayer("PlayerStartArea_2");
            
FadeIn(5.0f);
            
StartPlayerLookAt("AreaIntroLook_5"20.0f20.0f"");
            
PlayGuiSound(""1.0f);
            
partSpeed 6.0f;
        break;
        
        case 
10:
            
FadeOut(2.0f);
            
PlayGuiSound(""1.0f);
            
partSpeed 4.0f;
        break;
        
        case 
11:
            
FadeIn(4.5f);
            
PlayGuiSound(""1.0f);
            
StopPlayerLookAt();
            
FadePlayerRollTo(02018);
            
MovePlayerHeadPos(0.00.00.00.50.1f);
            
partSpeed 5.0f;
        break;
        
        case 
12:
            
ShowPlayerCrossHairIcons(true);
            
SetPlayerCrouching(false);
            
SetPlayerActive(true);
            
partSpeed 0.01f;
        break;
    }
    
    if(
GetLocalVarInt("iIntroPart") < 13)    AddTimer("tmrIntro"partSpeed"IntroSequence");     
}

void Drag(string &in asTimer)
{
  
AddPlayerBodyForce(0010000false);
  
AddTimer(asTimer1.5f"Drag");
  
PlayGuiSound("Drag03.snt"1);
}

void Manpig01()
{
    
AddEnemyPatrolNode("engineer_1""PathNodeArea_1"0.0f"");
    
AddEnemyPatrolNode("engineer_1""PathNodeArea_2"0.0f"");
    
AddEnemyPatrolNode("engineer_1""PathNodeArea_3"0.0f"");


/////////////////////////////////////////////////////////////////////////////////////////////////
//General
/////////////////////////////////////////////////////////////////////////////////////////////////

void PiggyGo1()
{
    
SetEntityActive("engineer_2"true);
    
    
AddEnemyPatrolNode("engineer_2""PathNodeArea_19"0.0f"");
    
AddEnemyPatrolNode("engineer_2""PathNodeArea_78"0.0f"");
    
AddEnemyPatrolNode("engineer_2""PathNodeArea_97"0.0f"");
    
AddEnemyPatrolNode("engineer_2""PathNodeArea_119"0.0f"");
    
AddEnemyPatrolNode("engineer_2""PathNodeArea_19"0.0f"");


void PiggyGo2()
{  
    
SetEntityActive("engineer_3"true);

    
AddEnemyPatrolNode("engineer_3""PathNodeArea_119"0.0f"");
    
AddEnemyPatrolNode("engineer_3""PathNodeArea_19"0.0f"");
    
AddEnemyPatrolNode("engineer_3""PathNodeArea_78"0.0f"");
    
AddEnemyPatrolNode("engineer_3""PathNodeArea_97"0.0f"");
    
AddEnemyPatrolNode("engineer_3""PathNodeArea_119"0.0f"");
}

void breaknoise(stringasParentNamestringasChildNamestringasFunctionbool abDeleteOnCollideint alStates)
{
    
PlaySoundAtEntity("playbreaksound""15_ripp_door.snt""prison_unhinged_hinges_1"1.0ffalse);

04-14-2014, 03:16 AM
Find
Vale Offline
Member

Posts: 92
Threads: 13
Joined: Mar 2014
Reputation: 7
#4
RE: keep monster from despawining

ok, so your entity collide callback is a bit off in order
AddEntityCollideCallback("Player" , "Area Name", "Function", true, 1); //just so ya know, true means it removes callback after. Helpful to know.

void breaknoise(string &in asParent, string &in asChild, int alState)//change this line to this, the callback runs this func if im correct. The name should be the function name (which for yours was doorbreak, i think)

{
PlaySoundAtEntity("playbreaksound", "15_ripp_door.snt", "prison_unhinged_hinges_1", 1.0f, false); //this line looks fine
}

so you named it wrong. You copied it from engine scripts document i presume? That just gave info about how to run the command in code, not necessarily what it needs.

also, first quoted area in PlaySoundAtEntity is for naming the sound, and that may have problems with the fact theres a script area with same name
(This post was last modified: 04-14-2014, 03:28 AM by Vale.)
04-14-2014, 03:24 AM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#5
RE: keep monster from despawining

alrighty thank you Big Grin
04-14-2014, 03:30 AM
Find
Vale Offline
Member

Posts: 92
Threads: 13
Joined: Mar 2014
Reputation: 7
#6
RE: keep monster from despawining

no problem, let me know if all works!
04-14-2014, 03:35 AM
Find
lothabread Offline
Member

Posts: 106
Threads: 11
Joined: Apr 2012
Reputation: 2
#7
RE: keep monster from despawining

okay, well i gave up trying to play it at the entity and decided to go with the gui sound instead but it still wont work and i watched a tutorial video over and over ._. i have never had this much trouble.

PHP Code: (Select All)
////////////////////////////////////////////////////////////////////////////////////////
//General Script
////////////////////////////////////////////////////////////////////////////////////////
    
AddEntityCollideCallback("Player" "playbreaksound""doorbreak"true1);
////////////////////////////////////////////////////////////////////////////////////////


void doorbreak(stringasParentNamestringasChildNamestringasFunctionbool abDeleteOnCollideint alStates)
{
    
PlayGuiSound("15_ripp_door.snt"1);

04-14-2014, 04:28 AM
Find
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#8
RE: keep monster from despawining

I'm sure that calling a function in OnEnter would keep the monster spawned. Every time the player enters a map, the monster respawns.

You could do a function like this for instance:

PHP Code: (Select All)
void OnEnter
{
MonsterRespawn();
}

void MonsterRespawn()
{
SetEntityActive("MonsterName"true);


Not that the above suggestion wouldn't work. Big Grin Just throwing a suggestion out there.

(This post was last modified: 04-14-2014, 04:30 AM by MsHannerBananer.)
04-14-2014, 04:30 AM
Find
Vale Offline
Member

Posts: 92
Threads: 13
Joined: Mar 2014
Reputation: 7
#9
RE: keep monster from despawining

change the part after void to what i said
(string &in asParent, string &in asChild, int alState)

also check the map carefully to make sure that the script area in your map is named playbreaksound
(This post was last modified: 04-14-2014, 04:31 AM by Vale.)
04-14-2014, 04:31 AM
Find
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#10
RE: keep monster from despawining

(04-14-2014, 04:28 AM)lothabread Wrote: okay, well i gave up trying to play it at the entity and decided to go with the gui sound instead but it still wont work and i watched a tutorial video over and over ._. i have never had this much trouble.

PHP Code: (Select All)
////////////////////////////////////////////////////////////////////////////////////////
//General Script
////////////////////////////////////////////////////////////////////////////////////////
    
AddEntityCollideCallback("Player" "playbreaksound""doorbreak"true1);
////////////////////////////////////////////////////////////////////////////////////////


void doorbreak(stringasParentNamestringasChildNamestringasFunctionbool abDeleteOnCollideint alStates)
{
    
PlayGuiSound("15_ripp_door.snt"1);


The PlaySoundAtEntity should work for something like this. I've done it loads of times. Have you checked all your names? Is your sound in the right folder?

(This post was last modified: 04-14-2014, 04:35 AM by MsHannerBananer.)
04-14-2014, 04:34 AM
Find




Users browsing this thread: 1 Guest(s)