Frictional Games Forum (read-only)
[SCRIPT] Event: Player seeing monster will stop player moving. - Printable Version

+- Frictional Games Forum (read-only) (https://www.frictionalgames.com/forum)
+-- Forum: Amnesia: The Dark Descent (https://www.frictionalgames.com/forum/forum-6.html)
+--- Forum: Custom Stories, TCs & Mods - Development (https://www.frictionalgames.com/forum/forum-38.html)
+---- Forum: Development Support (https://www.frictionalgames.com/forum/forum-39.html)
+---- Thread: [SCRIPT] Event: Player seeing monster will stop player moving. (/thread-16797.html)



Event: Player seeing monster will stop player moving. - RedFiction12 - 07-06-2012

Yo people! Its me again! And i am needing some help right now.

I am planning to do simple "Event" when player collides to certain script area, monster will come out from darkness and player will stop suddenly moving. Monster will come player (while player is looking at it) and hit him ones. After that player fades out into darkness.

I havent done anything big yet, because ive stucked into this one part.

This is my code:

Code:
void OnStart()
    {
        AddEntityCollideCallback("Player", "scary_monster", "MonsterFunction", true, 1);
        AddEntityCollideCallback("Player", "scary_monster", "PlayerLookAtGrunt", true, 1);       
    }

void MonsterFunction(string &in asParent, string &in asChild, int alState)
    {
        SetEntityActive("servant_grunt_1", true);
        AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
    }

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

    {
        StartPlayerLookAt("servant_grunt_1", 6.0, 6.0, "");
        AddTimer("", 3.0f, "StopLook");
        SetPlayerActive(false);
        SetMessage("Messages", "Message4", 4);
    }

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

.lang file


Code:
<CATEGORY Name="Messages">
        <Entry Name ="Message4">"What the hell is that thing?!"</Entry>
   </CATEGORY>

Quick tip:
1. Monster path is working good.
2. Scripted area is working correctly.


Quick tip:
1. Player doesnt stop moving.
2. Player wont look at monster.



RE: Event: Player seeing monster will stop player moving. - Cruzore - 07-06-2012

The callbacks have the same child and parent. If you intended that, you can just forge both callbacks and their functions into 1. That might be the reason it doesn't work.


RE: Event: Player seeing monster will stop player moving. - Strembitsky - 07-07-2012

Do you get errors? If you do, find what's wrong and fix it. If you don't, then try debug messages and find which callback isn't being called.


RE: Event: Player seeing monster will stop player moving. - Fearlessagent - 07-07-2012

Use This:

Code:
void OnStart()
    {
        AddEntityCollideCallback("Player", "scary_monster", "MonsterFunction", true, 1);
    }

void MonsterFunction(string &in asParent, string &in asChild, int alState)
    {
        SetEntityActive("servant_grunt_1", true);
        AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
        StartPlayerLookAt("servant_grunt_1", 6.0, 6.0, "");
        AddTimer("", 3.0f, "StopLook");
        SetPlayerActive(false);
        SetMessage("Messages", "Message4", 4);
    }

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

Both of your original callbacks were of the same interaction, the player colliding with the entity scary_monster. Since you set callback removal when it is triggered:

AddEntityCollideCallback("Player", "scary_monster", "MonsterFunction", true, 1);

it will only call the first, then immediately disable the callback for both. Not sure why it does this, but I had the same issue when I wanted to have a function activate multiple times since I had some conditional statements. The solution for me was setting the option I bolded to false.

You can fix your code easily like I did above by combining the two functions.


RE: Event: Player seeing monster will stop player moving. - RedFiction12 - 07-07-2012

It worked when i removed that. Thank you. Now i am little smarter!