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 [Solved, sort of] Grunt Not Disappearing
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#1
[Solved, sort of] Grunt Not Disappearing

I have a script set up where the player sees a grunt, or as she describes it, "creature" from down a hall. The thing is scripted to appear, cross through a doorway, and then hits a script box that deactivates it. I felt it was better than making the grunt a hallucination, because you can here the poofing sound and see the dust. I wanted to make it a clean magic trick and have the grunt just plain ol' disappear.

Script is below. My names match and everything, but I feel like I'm missing something. I recently put in some hammer+chipper script, so I don't know if something's messing with it or what. I just need a second, third, and fourth set of eyes to make sure I haven't done anything wrong.

NOTE: The script WORKED ONCE. The FIRST time I tested and before I put in any hammer+chipper stuff, the script actually worked.

PHP Code: (Select All)
int Swings 0;

void OnStart()
{
    
AddEntityCollideCallback("Player""seeShadow""See_Grunt",true1);
    
AddEntityCollideCallback("silent_grunt""silent_grunt_gone""Disable_Grunt",true1);
    
AddEntityCollideCallback("Player""MapChange""ChangeMap"false1);
    
AddUseItemCallback("""stone_hammer_chipper""breakstone_1""Break_Rock"true);
}

void OnEnter()
{

}

void OnLeave()
{

}


//GRUNT//

void See_Grunt(string &in asParentstring &in asChildint alState)
{
    
SetPlayerActive(false);
    
StartPlayerLookAt("silent_grunt"2.0f4.0f"See_Grunt_Walk");
}

void See_Grunt_Walk()
{
    
SetEntityActive("silent_grunt"true);
    
AddTimer("endwalkTimer"8.0f"End_Walk_Timer");
    
SetEnemyDisableTriggers("silent_grunt"true);
    
AddEnemyPatrolNode("silent_grunt""silent_path_3"0.1f"");
    
AddEnemyPatrolNode("silent_grunt""silent_path_5"0.1f"");
    
AddEnemyPatrolNode("silent_grunt""silent_path_7"0.1f"");
    
AddEnemyPatrolNode("silent_grunt""silent_path_8"0.1f"");
}

void Disable_Grunt(string &in asParentstring &in asChildint alState)
{
    
SetEntityActive("silent_grunt"false);
}

void End_Walk_Timer(string &in asTimer)
{
    
SetPlayerActive(true);
    
StopPlayerLookAt();
}

//CHANGE MAP//

void ChangeMap(string &in asParentstring &in asChildint alState)
{
ChangeMap("014_wateroffice.map""PlayerStartArea_1""""");
}


//HAMMER CHIPPER//

void Break_Rock(string &in asItemstring &in asEntity)
{
    
Swings 1;
    
SetEntityActive("move_hammer"true);
    
SetEntityActive("rock_chipper"true);
    
StartPlayerLookAt("move_hammer"22"");
    
AddTimer("hammermove"0.1"MoveHammerTimer");
    
AddTimer("hammersound"0.27"MoveHammerTimer");
    
AddTimer("hammerreset"0.4"MoveHammerTimer");
    
AddTimer("hammerrepeat"0.6"MoveHammerTimer");
}

void MoveHammerTimer(string &in asTimer)
{
    if(
asTimer == "hammermove"SetMoveObjectState("move_hammer"0.4);
    
    else if(
asTimer == "hammersound")
        {
            
StopPlayerLookAt();
            
PlaySoundAtEntity("""impact_rock_high""breakstone_1"0false);
            
PlaySoundAtEntity("""15_hammer""Player"0false);
        }
        
    else if(
asTimer =="hammerreset"SetMoveObjectState("move_hammer"0);
    
    if(
Swings && asTimer =="hammerrepeat")
        {
            
AddTimer("hammermove"0.01"MoveHammerTimer");
            
AddTimer("hammersound"0.17"MoveHammerTimer");
            
AddTimer("hammerreset"0.3"MoveHammerTimer");
            
AddTimer("hammerrepeat"0.5"MoveHammerTimer");
            
Swings Swings 1;
        }
        
    else if(
Swings == && asTimer =="hammerrepeat")
        {
            
AddTimer("hammermove"0.2"MoveHammerTimer");
            
AddTimer("hammersound"0.37"MoveHammerTimer");
            
AddTimer("hammerreset"0.5"MoveHammerTimer");
            
AddTimer("hammerrepeat"0.8"MoveHammerTimer");
            
AddTimer("Break"0.42"MoveHammerTimer");
            
Swings Swings 1;
        }
        
    else if(
Swings == && asTimer =="Break")
        {
            
Break_Rocks_Complete();
            
SetEntityActive("move_hammer"false);
            
SetEntityActive("rock_chipper"false);
        }
}

void Break_Rocks_Complete()
{
    
SetEntityActive("breakstone_1"false);
    
SetEntityActive("breakstone_2"false);
    
SetEntityActive("med_rock_1"true);
    
SetEntityActive("med_rock_2"true);
    
SetEntityActive("med_rock_3"true);
    
SetEntityActive("large_rock_1"true);
    
SetEntityActive("large_rock_2"true);
    
SetEntityActive("large_rock_3"true);
    
SetEntityActive("small_rock_1"true);
    
SetEntityActive("small_rock_2"true);
    
SetEntityActive("small_rock_3"true);
    
SetEntityActive("small_rock_4"true);
    
SetEntityActive("small_rock_5"true);
    
SetEntityActive("small_rock_6"true);
    
SetEntityActive("small_rock_7"true);
    
SetEntityActive("small_rock_8"true);
    
SetEntityActive("small_rock_9"true);
    
SetEntityActive("small_rock_10"true);
    
CreateParticleSystemAtEntity("""ps_hit_wood.ps""breakrock_dust"false);
    
PlaySoundAtEntity("""25_break_rock""Player"0false);


(This post was last modified: 06-19-2014, 03:16 AM by MsHannerBananer.)
06-19-2014, 02:44 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Grunt Not Disappearing

I see no reason for it to not work. If the grunt successfully follows the path, then the script is running fine. The only thing that can maybe be the issue, is the area the grunt collides with. Perhaps it's too small or something wrong with it? Did you modify it?

All I can think of is that the "disable grunt" callback isn't called.

06-19-2014, 02:51 AM
Find
MsHannerBananer Offline
Member

Posts: 218
Threads: 34
Joined: Sep 2013
Reputation: 10
#3
RE: Grunt Not Disappearing

(06-19-2014, 02:51 AM)Mudbill Wrote: I see no reason for it to not work. If the grunt successfully follows the path, then the script is running fine. The only thing that can maybe be the issue, is the area the grunt collides with. Perhaps it's too small or something wrong with it? Did you modify it?

All I can think of is that the "disable grunt" callback isn't called.

For some reason you managed to remind me to exhaust my options completely before I post my problems, which... is something I don't seem capable of doing when it comes to scripting with Amnesia. *Epic Facepalm*

I just set up a timer that disabled the enemy after a certain amount of seconds, and although the first time I put was a little too long, it worked.

For some reason my callback isn't calling for the enemy to be disabled, despite multiple attempts to copy and paste names from the level editor to the .hps file to prevent mismatched names. I've deleted the collide completely, and I'm going to time it so the grunt is disabled via timer.

Normally, I solve mysterious problems like these myself by exhausting my resources completely and going around those problems with other scripts, even though it might be unorthodox and taxing. This is one of the few occasions I didn't at first, but everything worked out in the end.

I feel a little embarrassed with myself that I posted this without even thinking about using other methods.

Now my only problem is finding out why the collide area didn't work...

06-19-2014, 03:15 AM
Find
Romulator Offline
Not Tech Support ;-)

Posts: 3,628
Threads: 63
Joined: Jan 2013
Reputation: 195
#4
RE: [Solved, sort of] Grunt Not Disappearing

The only thing I can think of is if the grunt is in sight. If the player can see the grunt, they won't just vanish at the end of the pathnode allocated. But you seem to compensate with the SetEntityActive script anyway.

I think in the Model Editor, there is an option in the grunt's settings to disable them at the end of their allocated pathnode path, something like AutoRemoveAtEnd. If that's true, then I don't see why it shouldn't vanish unless it is in the Player's vision.

Have you tried setting the grunt collision event alState (in the CollideCallback) to 0? So when it enters or leaves the script_area, it can disable it otherwise?

Till then, the timer is probably a good use to compensate.

Probably not much help, but just within my experiences.

Discord: Romulator#0001
[Image: 3f6f01a904.png]
06-19-2014, 07:23 AM
Find
Acies Offline
Posting Freak

Posts: 1,643
Threads: 60
Joined: Feb 2011
Reputation: 73
#5
RE: [Solved, sort of] Grunt Not Disappearing

Some random guesses:
Does the collision area have a negative scale/size? Has it automatically added a "_1" at the end? Could you have done a 'save and exit' once the grunt was removed once? That might have disabled areas, but the grunt spawns nevertheless due to 'a callback function added in the leveleditor'.

[Image: mZiYnxe.png]


06-19-2014, 02:21 PM
Find




Users browsing this thread: 1 Guest(s)