RedFiction12
Junior Member
Posts: 9
Threads: 2
Joined: Jul 2012
Reputation:
0
|
Event: Player seeing monster will stop player moving.
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:
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
<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.
Current project : Bad Dreams - 9%
Hello my name is Jaakko Uusitalo and i am co-leader of TF2 Organization called Trolling Bunnies.
|
|
07-06-2012, 11:40 PM |
|
Cruzore
Senior Member
Posts: 301
Threads: 2
Joined: Jun 2012
Reputation:
37
|
RE: Event: Player seeing monster will stop player moving.
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.
Think, before you speak Google, before you post
(This post was last modified: 07-06-2012, 11:43 PM by Cruzore.)
|
|
07-06-2012, 11:43 PM |
|
Strembitsky
Senior Member
Posts: 254
Threads: 37
Joined: Feb 2012
Reputation:
3
|
RE: Event: Player seeing monster will stop player moving.
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.
The Nightmares v1.0 - Dreadful Fires WIP
(This post was last modified: 07-07-2012, 12:50 AM by Strembitsky.)
|
|
07-07-2012, 12:47 AM |
|
Fearlessagent
Junior Member
Posts: 12
Threads: 2
Joined: Jul 2012
Reputation:
1
|
RE: Event: Player seeing monster will stop player moving.
Use This:
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.
(This post was last modified: 07-07-2012, 05:50 AM by Fearlessagent.)
|
|
07-07-2012, 05:49 AM |
|
RedFiction12
Junior Member
Posts: 9
Threads: 2
Joined: Jul 2012
Reputation:
0
|
RE: Event: Player seeing monster will stop player moving.
It worked when i removed that. Thank you. Now i am little smarter!
Current project : Bad Dreams - 9%
Hello my name is Jaakko Uusitalo and i am co-leader of TF2 Organization called Trolling Bunnies.
|
|
07-07-2012, 08:17 AM |
|
|