GoreGrinder99
Member
Posts: 166
Threads: 47
Joined: Feb 2013
Reputation:
1
|
Force player to follow enemy until it disappear help.
I have a script where when the player interacts with a certain entity it spawns a monster and it heads towards its only patrol node and disappears. What I want is to have the player look directly at the monster when it spawns and follow it until it hits its marker and disappears. I'm assuming this is the script fr it but not sure what to do.
void StartPlayerLookAt(string& asEntityName, float afSpeedMul, float afMaxSpeed, string& asAtTargetCallback);
void StopPlayerLookAt();
-Grind to the Gore-
(This post was last modified: 08-17-2013, 11:36 PM by GoreGrinder99.)
|
|
07-21-2013, 05:23 PM |
|
ClayPigeon
Member
Posts: 214
Threads: 13
Joined: Mar 2012
Reputation:
8
|
RE: Force player to follow enemy until it disappear help.
void OnStart()
{
AddEntityCollideCallback("MonsterEntity", "Area", "StopLook", false, 1);
}
void OnMonsterSpawns // Change this to whenever the enemy spawns
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.5f, "LookedAt");
}
void LookedAt()
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.0f, "LookedAt");
}
void StopLook(string &in par, string &in chi, int state)
{
StopPlayerLookAt();
}
(This post was last modified: 07-21-2013, 05:47 PM by ClayPigeon.)
|
|
07-21-2013, 05:46 PM |
|
Rapture
Posting Freak
Posts: 1,078
Threads: 79
Joined: May 2011
Reputation:
30
|
RE: Force player to follow enemy until it disappear help.
StartPlayerLookAt("Grunt_0", 1, 2.4f, "");
Snip from the wiki...
asEntityName - the entity to look at
afSpeedMul - how fast should the player look at the entity
afMaxSpeed - maximum speed allowed
asAtTargetCallback - function to call when player looks at target
So for " asEntityName", change this to what the enemy's name is, in the Properties on the right side under " General > Name" tab.
For " afSpeedMul", you can use numerical values, but if you want floating points ( e.g. = 1.3), add a " f" to the end, like " 1.3f".
" afMaxSpeed" same as above stated.
" asAtTargetCallback" If you want a function called ( When the entity is in your cross-hairs) like it says. I can't remember what the parameters are needed for the function, for it to work correctly. Anyone else know?
StopPlayerLookAt();
Will just stop any StartPlayerLookAt scripts going (As long as the StartPlayerLookAt it isn't being looped.)
///////////////
If this is gonna be a monster spawn with the player being disabled. Like if you are walking a long a hallway, and you force the player to stare at a grunt walking past. Please don't do that.
If you are on the ground hurt or something, that will be fine.
|
|
07-21-2013, 05:55 PM |
|
GoreGrinder99
Member
Posts: 166
Threads: 47
Joined: Feb 2013
Reputation:
1
|
RE: Force player to follow enemy until it disappear help.
(07-21-2013, 05:46 PM)ClayPigeon Wrote: void OnStart()
{
AddEntityCollideCallback("MonsterEntity", "Area", "StopLook", false, 1);
}
void OnMonsterSpawns // Change this to whenever the enemy spawns
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.5f, "LookedAt");
}
void LookedAt()
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.0f, "LookedAt");
}
void StopLook(string &in par, string &in chi, int state)
{
StopPlayerLookAt();
}
So, where do I put what exactly? I'm assuming "MonsterEntity" is the monster name, what do I put in for "Area", "StopLook, and "LookedAt"?
-Grind to the Gore-
|
|
07-21-2013, 05:56 PM |
|
ClayPigeon
Member
Posts: 214
Threads: 13
Joined: Mar 2012
Reputation:
8
|
RE: Force player to follow enemy until it disappear help.
(07-21-2013, 05:56 PM)goregrinder99 Wrote: (07-21-2013, 05:46 PM)ClayPigeon Wrote: void OnStart()
{
AddEntityCollideCallback("MonsterEntity", "Area", "StopLook", false, 1);
}
void OnMonsterSpawns // Change this to whenever the enemy spawns
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.5f, "LookedAt");
}
void LookedAt()
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.0f, "LookedAt");
}
void StopLook(string &in par, string &in chi, int state)
{
StopPlayerLookAt();
}
So, where do I put what exactly? I'm assuming "MonsterEntity" is the monster name, what do I put in for "Area", "StopLook, and "LookedAt"?
The code that is under OnMonsterSpawns - You said that the monster spawns when the player interacts with a certain entity.
That means, that there is a callback for that interaction. Put the line there.
What's in OnStart - Just paste it in your OnStart callback.
The other ones - Paste them anywhere in your script OUTSIDE any callback.
MonsterEntity is the name of the monster indeed, and the Area is the Script Area the the monster collides with in order to dissapear, which will stop the looking session.
|
|
07-21-2013, 06:09 PM |
|
GoreGrinder99
Member
Posts: 166
Threads: 47
Joined: Feb 2013
Reputation:
1
|
RE: Force player to follow enemy until it disappear help.
(07-21-2013, 06:09 PM)ClayPigeon Wrote: (07-21-2013, 05:56 PM)goregrinder99 Wrote: (07-21-2013, 05:46 PM)ClayPigeon Wrote: void OnStart()
{
AddEntityCollideCallback("MonsterEntity", "Area", "StopLook", false, 1);
}
void OnMonsterSpawns // Change this to whenever the enemy spawns
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.5f, "LookedAt");
}
void LookedAt()
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.0f, "LookedAt");
}
void StopLook(string &in par, string &in chi, int state)
{
StopPlayerLookAt();
}
So, where do I put what exactly? I'm assuming "MonsterEntity" is the monster name, what do I put in for "Area", "StopLook, and "LookedAt"?
The code that is under OnMonsterSpawns - You said that the monster spawns when the player interacts with a certain entity.
That means, that there is a callback for that interaction. Put the line there.
What's in OnStart - Just paste it in your OnStart callback.
The other ones - Paste them anywhere in your script OUTSIDE any callback.
MonsterEntity is the name of the monster indeed, and the Area is the Script Area the the monster collides with in order to dissapear, which will stop the looking session.
I'm sorry, I still don't get it, I'm a little slow. :\ This is my whole hps. Could you put in the follow script as it needs to be for me?
////////////////////////////
// Run first time starting map
void OnStart()
{
PlaySoundAtEntity("", "amb_idle.snt", "Player", 0, false);
SetPlayerActive(false);
SetPlayerCrouching(true);
FadeOut(0);
FadeIn(3);
AddTimer("T1", 3, "Intro");
AddTimer("T2", 6, "Intro");
AddTimer("T3", 8, "Intro");
AddTimer("T4", 10, "Intro");
AddTimer("T5", 12, "Intro");
AddEntityCollideCallback("Player", "MonsterSpawn", "SpawnMonster", true, 1);
AddUseItemCallback("", "key_tower_1", "level_wood_1", "AtticUnlock", true);
}
void Intro(string &in asTimer)
{
string x = asTimer;
if (x == "T1")
{
PlaySoundAtEntity("", "react_breath.snt", "Player", 0, false);
FadeOut(3);
}
else if (x == "T2")
{
FadeIn(3);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
StartPlayerLookAt("ScriptArea_1", 2, 2, "");
}
else if (x == "T3")
{
StopPlayerLookAt();
StartPlayerLookAt("ScriptArea_2", 2, 2, "");
}
else if (x == "T4")
{
PlaySoundAtEntity("", "react_sigh.snt", "Player", 0, false);
StopPlayerLookAt();
}
else if (x == "T5")
{
SetPlayerCrouching(false);
SetPlayerActive(true);
}
}
void SpawnMonster(string &in asParent, string &in asChild, int alState)
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
SetEntityActive("servant_grunt_1", true);
}
void AtticUnlock(string &in asItem, string &in asDoor)
{
SetLevelDoorLocked("level_wood_1", false);
PlayGuiSound("door_sewer_unlock.snt", 100);
RemoveItem("key_tower_1");
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
-Grind to the Gore-
|
|
07-21-2013, 06:35 PM |
|
Your Computer
SCAN ME!
Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation:
235
|
RE: Force player to follow enemy until it disappear help.
FYI: Using StartPlayerLookAt on the monster is impractical if called once. StartPlayerLookAt only cares about the entity position at the time of the call. So, even though the monster has moved away, the player would still be looking at the position the monster was at the time StartPlayerLookAt was called.
(This post was last modified: 07-21-2013, 06:45 PM by Your Computer.)
|
|
07-21-2013, 06:44 PM |
|
ClayPigeon
Member
Posts: 214
Threads: 13
Joined: Mar 2012
Reputation:
8
|
RE: Force player to follow enemy until it disappear help.
Here:
////////////////////////////
// Run first time starting map
void OnStart()
{
PlaySoundAtEntity("", "amb_idle.snt", "Player", 0, false);
SetPlayerActive(false);
SetPlayerCrouching(true);
FadeOut(0);
FadeIn(3);
AddTimer("T1", 3, "Intro");
AddTimer("T2", 6, "Intro");
AddTimer("T3", 8, "Intro");
AddTimer("T4", 10, "Intro");
AddTimer("T5", 12, "Intro");
AddEntityCollideCallback("Player", "MonsterSpawn", "SpawnMonster", true, 1);
AddUseItemCallback("", "key_tower_1", "level_wood_1", "AtticUnlock", true);AddEntityCollideCallback("servant_grunt_1", "Area", "StopLook", false, 1);
}
void Intro(string &in asTimer)
{
string x = asTimer;
if (x == "T1")
{
PlaySoundAtEntity("", "react_breath.snt", "Player", 0, false);
FadeOut(3);
}
else if (x == "T2")
{
FadeIn(3);
PlaySoundAtEntity("", "react_breath_slow.snt", "Player", 0, false);
StartPlayerLookAt("ScriptArea_1", 2, 2, "");
}
else if (x == "T3")
{
StopPlayerLookAt();
StartPlayerLookAt("ScriptArea_2", 2, 2, "");
}
else if (x == "T4")
{
PlaySoundAtEntity("", "react_sigh.snt", "Player", 0, false);
StopPlayerLookAt();
}
else if (x == "T5")
{
SetPlayerCrouching(false);
SetPlayerActive(true);
}
}
void SpawnMonster(string &in asParent, string &in asChild, int alState)
{
AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
SetEntityActive("servant_grunt_1", true);StartPlayerLookAt("MonsterEntity", 1.0f, 1.5f, "LookedAt");
}
void AtticUnlock(string &in asItem, string &in asDoor)
{
SetLevelDoorLocked("level_wood_1", false);
PlayGuiSound("door_sewer_unlock.snt", 100);
RemoveItem("key_tower_1");
}
////////////////////////////
// Run when entering map
void OnEnter()
{
}void LookedAt()
{
StartPlayerLookAt("MonsterEntity", 1.0f, 1.0f, "LookedAt");
}
void StopLook(string &in par, string &in chi, int state)
{
StopPlayerLookAt();
}
////////////////////////////
// Run when leaving map
void OnLeave()
{
}
Just add a script area with which the monster will collide. Copy the area's name and put it instead "Area" in AddEntityCollideCallback("servant_grunt_1", " Area", "StopLook", false, 1);
|
|
07-21-2013, 07:29 PM |
|
GoreGrinder99
Member
Posts: 166
Threads: 47
Joined: Feb 2013
Reputation:
1
|
RE: Force player to follow enemy until it disappear help.
Games loads without crashing but nothing happens. These are all the scripts towards the follow enemy function. -
AddEntityCollideCallback("servant_grunt_1", "StareArea", "StopLook", false, 1);
^The above is in the void OnStart() area.
void LookedAt()
{
StartPlayerLookAt("servant_grunt_1", 1.0f, 1.0f, "LookedAt");
}
void StopLook(string &in par, string &in chi, int state)
{
StopPlayerLookAt();
}
^-The above is not in start, enter or exit area.
I made a script area that the monster will hit after about a second after spawn and renamed the script area in the editor and in the hps.
Am I still missing something?
-Grind to the Gore-
|
|
07-21-2013, 08:28 PM |
|
Adrianis
Senior Member
Posts: 620
Threads: 6
Joined: Feb 2012
Reputation:
27
|
RE: Force player to follow enemy until it disappear help.
Not sure about this, but the callback you set in OnStart, this...
AddEntityCollideCallback("servant_grunt_1", "StareArea", "StopLook", false, 1);
When the grunt hits 'StareArea', you are calling the function StopLook, which calls to StopPlayerLookAt()
If you're intention was to start the LookAt when the grunt hits StareArea, then the line should read
AddEntityCollideCallback("servant_grunt_1", "StareArea", "LookedAt", false, 1);
Because LookedAt is the function that calls to StartPlayerLookAt
|
|
07-22-2013, 03:38 PM |
|
|