Frictional Games Forum (read-only)

Full Version: Event: Player seeing monster will stop player moving.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
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.
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.
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.
It worked when i removed that. Thank you. Now i am little smarter!