![]() |
Force player to follow enemy until it disappear help. - 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: Force player to follow enemy until it disappear help. (/thread-22200.html) |
Force player to follow enemy until it disappear help. - GoreGrinder99 - 07-21-2013 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(); RE: Force player to follow enemy until it disappear help. - ClayPigeon - 07-21-2013 Code: void OnStart() RE: Force player to follow enemy until it disappear help. - Rapture - 07-21-2013 StartPlayerLookAt("Grunt_0", 1, 2.4f, ""); Snip from the wiki... Code: asEntityName - the entity to look at 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. RE: Force player to follow enemy until it disappear help. - GoreGrinder99 - 07-21-2013 (07-21-2013, 05:46 PM)ClayPigeon Wrote: 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"? RE: Force player to follow enemy until it disappear help. - ClayPigeon - 07-21-2013 (07-21-2013, 05:56 PM)goregrinder99 Wrote:(07-21-2013, 05:46 PM)ClayPigeon Wrote: 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. RE: Force player to follow enemy until it disappear help. - GoreGrinder99 - 07-21-2013 (07-21-2013, 06:09 PM)ClayPigeon Wrote:(07-21-2013, 05:56 PM)goregrinder99 Wrote:(07-21-2013, 05:46 PM)ClayPigeon Wrote: 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() { } RE: Force player to follow enemy until it disappear help. - Your Computer - 07-21-2013 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. RE: Force player to follow enemy until it disappear help. - ClayPigeon - 07-21-2013 Here: Code: //////////////////////////// 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); RE: Force player to follow enemy until it disappear help. - GoreGrinder99 - 07-21-2013 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? RE: Force player to follow enemy until it disappear help. - Adrianis - 07-22-2013 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 |