Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help Weeping Angel enemies
lizardrock17 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jun 2013
Reputation: 0
#1
Weeping Angel enemies

Hello peoplez i am fairly new to scripting with amnesia, but i would like to create enemies like the weeping angels from doctor who (weeping angels are enemies that cant move when you see them but move when you dont even if your looking at them in the dark and just roam around if they cant find you like if your behind a door). I figured out what engine scripts to use but dont know how to use the script areas for this reason. I was thinking about putting script areas inside of script areas but i dont know if that would would work. I would appreciate some ideas/solutions on how to accomplish this task.

------------------------------
...........
...................__
............./´¯/'...'/´¯¯`·¸
........../'/.../..../......./¨¯\
........('(...´...´.... ¯~/'...')
.........\.................'...../
..........''...\.......... _.·´
............\..............(
BROFIST ...........
06-19-2013, 04:30 AM
Find
Tomato Cat Offline
Senior Member

Posts: 287
Threads: 2
Joined: Sep 2012
Reputation: 20
#2
RE: Weeping Angel enemies

You might try using this particular function:
PHP Code: (Select All)
void SetEntityPlayerLookAtCallback(stringasNamestringasCallbackbool abRemoveWhenLookedAt); 

The actual implementation might be a bit more complex, but I'll leave that up to you.
06-19-2013, 05:22 AM
Find
lizardrock17 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jun 2013
Reputation: 0
#3
RE: Weeping Angel enemies

(06-19-2013, 05:22 AM)Tomato Cat Wrote: You might try using this particular function:
PHP Code: (Select All)
void SetEntityPlayerLookAtCallback(stringasNamestringasCallbackbool abRemoveWhenLookedAt); 

The actual implementation might be a bit more complex, but I'll leave that up to you.

thanx for the reply but i had that much figured out already
(This post was last modified: 06-19-2013, 05:37 AM by lizardrock17.)
06-19-2013, 05:31 AM
Find
CarnivorousJelly Offline
Posting Freak

Posts: 1,196
Threads: 41
Joined: Dec 2012
Reputation: 80
#4
RE: Weeping Angel enemies

(06-19-2013, 04:30 AM)lizardrock17 Wrote: Hello people; I am fairly new to scripting with Amnesia but I would like to create enemies like the Weeping Angels from Doctor Who (Weeping Angels are enemies that can't move when you see them but move when you don't even if your looking at them in the dark and just roam around if they cant find you like if your behind a door). I figured out what engine scripts to use but don't know how to use the script areas for this reason. I was thinking about putting script areas inside of script areas but i don't know if that would would work. I would appreciate some ideas/solutions on how to accomplish this task.

Weeping Angels were terrifying! Traggey might know how to do this (I believe he was working on a Dr Who CS a looooooong time ago). Also, if you need a TARDIS, check out this one!

There was a custom story a little while ago that did something similar with the Brute, but I think they were referencing Schrodinger's Cat. I'm not sure which custom story it was, but Cry definitely played it a while ago, so if you want to check his videos, find it, download the game, and check the script to figure out what they did, that would probably be the best way to go. I'm not going to do that for you because I'm just really tired and really busy :p

Anyways, the script should look something like this for yours:
PHP Code: (Select All)
void OnStart()
{
SetEntityPlayerLookAtCallback("angel_statue_1""WeepingAngel_1"true);
}

//"angel_statue_1" is the name of the statue in the level editor
//"WeepingAngel" is the name of your script that will be called when the player is looking/not looking
//true means the script won't be called again after the player looks at
//the angel once. I'm using this one because you're probably going to
//have to use multiple statues with angel_statue_1 being your first statue

void WeepingAngel_1(string &in asEntityint alState
{
if(
alState == 1//1 means looking
{
//Your angles don't do anything when you're looking at them, so leave this blank
}
else if(
alState == -1)//-1 means not looking
{
SetEntityActive("angel_statue_1"false); //this gets rid of the original one
SetEntityActive("angel_statue_2"true); //this puts in the new one
SetEntityPlayerLookAtCallback("angel_statue_2""WeepingAngel_2"true);
//This callback makes sure that angles keep showing up
}


You can find the majority of scripts on the Engine Scripts page of the wiki. Of course, they can be a little confusing sometimes, so don't be afraid to ask for help!

I'm not sure how you would ensure that the angels appear closer to the player (unless you're using a hallway) or how you would ensure that the angel actually causes harm to/kills the player. I'm not a strong scripter at all, so you might want verification on this :)

Also, since you seem new to this (please don't hurt me for possibly being incorrect): you might want to download and use either Geany or Notepad++ instead of Notepad for scripting if you haven't already downloaded a decent program.

Once that's done, change the language to C++. In Notepad++, this can be done by going under the languages tab in the top menu bar. This will cause strings to appear grey, floats and integers to appear orange, side-notes to appear green, and bools to appear blue. This is helpful for when you get the annoying "Unexpected End of File" error because you'll see a colour that doesn't match up (usually).

Either way, good luck!

[Image: quote_by_rueppells_fox-d9ciupp.png]
(This post was last modified: 06-19-2013, 06:00 AM by CarnivorousJelly.)
06-19-2013, 05:54 AM
Find
DeAngelo Offline
Senior Member

Posts: 263
Threads: 26
Joined: Feb 2013
Reputation: 11
#5
RE: Weeping Angel enemies

I was planning on doing something like this with the armor statue, but I gave up since I'm trying to finish my CS as soon as possible. My plan was to modify a grunt with the mesh of the statue, use a looping "show player position" callback to make sure he chases you no matter what, then make a lookat callback so that when I'm looking at him a custom entity (which would basically be a box of blockboxes to trap him where he was so he couldn't move) would be created where he was (Dunno if that would have worked since I think you can only create entities at script areas) then destroyed when you looked away.

I decided against it for 2 reasons: 1, Was having trouble getting it to work and I'm trying to finish up my CS, and 2, the whole "statue that chases you only when you're not looking" has been done in a lot of horror games and I want to try to do some unique stuff with my CS.

A Late Night Drink http://www.moddb.com/mods/a-late-night-drink
Check out my LP channel, CatBearGaming, I take all Custom Story requests!
06-19-2013, 10:36 AM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#6
RE: Weeping Angel enemies

Kiandra's method is a good place to start - if you can get that working, you'll notice a few problems.

First and foremost is the detection for looking at something is based on where the center of your view is, not just what you can see. You could therefore get into the situation where the statue moves while you can actually see it. The solution to this problem is going to be pretty damn complex, to the point where it's going to take a lot of experimentation on your part to get it right. Honestly, if you're new to scripting, i'd leave this problem till you've got a little more experience using script areas & callbacks in other ways (ways that are better explained in tutorials & with more examples etc)

But hard problems are fun, so here's some advice I gave to the last guy asking about weeping angels (there's been quite a few)...

Quote: ... you can use the function SetEntityPlayerLookAtCallback to detect when the player is looking at an area.

- So you would need a series of script areas & deactivated statues
- Keep track of where the player is using AddEntityCollideCallback to
set the value of a string when they collide with one of the script areas
- Keep track of which statue is currently active
- Use SetEntityPlayerLookAtCallback to detect when the player is looking at an area away from where the current statue is
- Deactivate the current statue and activate another closer to where the player is
http://www.frictionalgames.com/forum/thread-21670.html

EDIT: I should probably add that the steps above would be important to get a 'dynamic' weeping angel style enemy, meaning it could follow you back & forth & all over the level indefinately. If you want to just include a weeping angel style enemy for a particular moment (i.e. just a scare event) you could cut the problem down significantly, which would also IMO make it significantly less interesting Tongue

(This post was last modified: 06-19-2013, 03:24 PM by Adrianis.)
06-19-2013, 03:08 PM
Find
lizardrock17 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jun 2013
Reputation: 0
#7
RE: Weeping Angel enemies

(06-19-2013, 03:08 PM)Adrianis Wrote: Kiandra's method is a good place to start - if you can get that working, you'll notice a few problems.

First and foremost is the detection for looking at something is based on where the center of your view is, not just what you can see. You could therefore get into the situation where the statue moves while you can actually see it. The solution to this problem is going to be pretty damn complex, to the point where it's going to take a lot of experimentation on your part to get it right. Honestly, if you're new to scripting, i'd leave this problem till you've got a little more experience using script areas & callbacks in other ways (ways that are better explained in tutorials & with more examples etc)

But hard problems are fun, so here's some advice I gave to the last guy asking about weeping angels (there's been quite a few)...

Quote: ... you can use the function SetEntityPlayerLookAtCallback to detect when the player is looking at an area.

- So you would need a series of script areas & deactivated statues
- Keep track of where the player is using AddEntityCollideCallback to
set the value of a string when they collide with one of the script areas
- Keep track of which statue is currently active
- Use SetEntityPlayerLookAtCallback to detect when the player is looking at an area away from where the current statue is
- Deactivate the current statue and activate another closer to where the player is
http://www.frictionalgames.com/forum/thread-21670.html

EDIT: I should probably add that the steps above would be important to get a 'dynamic' weeping angel style enemy, meaning it could follow you back & forth & all over the level indefinately. If you want to just include a weeping angel style enemy for a particular moment (i.e. just a scare event) you could cut the problem down significantly, which would also IMO make it significantly less interesting Tongue

I found those other threads and none of them really helped but thanx for the info about the detection. This would be so much easier if amnesia didnt have script areas and each monster had there own AI.

(06-19-2013, 05:54 AM)Kiandra Wrote:
(06-19-2013, 04:30 AM)lizardrock17 Wrote: Hello people; I am fairly new to scripting with Amnesia but I would like to create enemies like the Weeping Angels from Doctor Who (Weeping Angels are enemies that can't move when you see them but move when you don't even if your looking at them in the dark and just roam around if they cant find you like if your behind a door). I figured out what engine scripts to use but don't know how to use the script areas for this reason. I was thinking about putting script areas inside of script areas but i don't know if that would would work. I would appreciate some ideas/solutions on how to accomplish this task.

Weeping Angels were terrifying! Traggey might know how to do this (I believe he was working on a Dr Who CS a looooooong time ago). Also, if you need a TARDIS, check out this one!

There was a custom story a little while ago that did something similar with the Brute, but I think they were referencing Schrodinger's Cat. I'm not sure which custom story it was, but Cry definitely played it a while ago, so if you want to check his videos, find it, download the game, and check the script to figure out what they did, that would probably be the best way to go. I'm not going to do that for you because I'm just really tired and really busy :p

Anyways, the script should look something like this for yours:
PHP Code: (Select All)
void OnStart()
{
SetEntityPlayerLookAtCallback("angel_statue_1""WeepingAngel_1"true);
}

//"angel_statue_1" is the name of the statue in the level editor
//"WeepingAngel" is the name of your script that will be called when the player is looking/not looking
//true means the script won't be called again after the player looks at
//the angel once. I'm using this one because you're probably going to
//have to use multiple statues with angel_statue_1 being your first statue

void WeepingAngel_1(string &in asEntityint alState
{
if(
alState == 1//1 means looking
{
//Your angles don't do anything when you're looking at them, so leave this blank
}
else if(
alState == -1)//-1 means not looking
{
SetEntityActive("angel_statue_1"false); //this gets rid of the original one
SetEntityActive("angel_statue_2"true); //this puts in the new one
SetEntityPlayerLookAtCallback("angel_statue_2""WeepingAngel_2"true);
//This callback makes sure that angles keep showing up
}


You can find the majority of scripts on the Engine Scripts page of the wiki. Of course, they can be a little confusing sometimes, so don't be afraid to ask for help!

I'm not sure how you would ensure that the angels appear closer to the player (unless you're using a hallway) or how you would ensure that the angel actually causes harm to/kills the player. I'm not a strong scripter at all, so you might want verification on this Smile

Also, since you seem new to this (please don't hurt me for possibly being incorrect): you might want to download and use either Geany or Notepad++ instead of Notepad for scripting if you haven't already downloaded a decent program.

Once that's done, change the language to C++. In Notepad++, this can be done by going under the languages tab in the top menu bar. This will cause strings to appear grey, floats and integers to appear orange, side-notes to appear green, and bools to appear blue. This is helpful for when you get the annoying "Unexpected End of File" error because you'll see a colour that doesn't match up (usually).

Either way, good luck!

Thanx for this it has really helped. Still figuring a few kinks out.
(This post was last modified: 06-19-2013, 05:04 PM by lizardrock17.)
06-19-2013, 05:01 PM
Find
Adrianis Offline
Senior Member

Posts: 620
Threads: 6
Joined: Feb 2012
Reputation: 27
#8
RE: Weeping Angel enemies

Quote: I found those other threads and none of them really helped but thanx for
the info about the detection. This would be so much easier if amnesia
didnt have script areas and each monster had there own AI.
It does have an AI system, it just doesn't suit you're needs particularly well. Script areas aren't tied to enemies either, they have a very broad purpose, and you'll find them in all sorts of engines (albeit under different names). It's a perfectly solvable problem, but like many cool features is difficult to implement Smile

What you're doing in solving this problem is defining AI behavior, it's just being done in a very roundabout way not using the best tools available, but it's still rudimentary AI code. Someone's gotta write it Tongue

(This post was last modified: 06-19-2013, 05:46 PM by Adrianis.)
06-19-2013, 05:41 PM
Find
lizardrock17 Offline
Junior Member

Posts: 20
Threads: 3
Joined: Jun 2013
Reputation: 0
#9
RE: Weeping Angel enemies

From what you guys told me I have compiled this: (I havent tried it yet because if i encounter any problems i dont want to spend hours on the internet trying to find out my script is wrong)


void OnStart()
{
SetEntityPlayerLookAtCallback("angel_statue_1", "WeepingAngel_1", false);
}

//"angel_statue_1" is the name of the statue in the level editor
//"WeepingAngel" is the name of your script that will be called when the player is looking/not looking
//true means the script won't be called again after the player looks at
//the angel once. I'm using this one because you're probably going to
//have to use multiple statues with angel_statue_1 being your first statue

void WeepingAngel_1(string &in asEntity, int alState)
{
if(alState == 1) //1 means looking
{
//Your angles don't do anything when you're looking at them, so leave this blank
}
else if(alState == -1)//-1 means not looking
{
void ShowEnemyPlayerPosition(string& "angel_statue_1);\\Makes angel follows player
}
}

Would this work?
(This post was last modified: 06-19-2013, 05:59 PM by lizardrock17.)
06-19-2013, 05:57 PM
Find
OriginalUsername Offline
Posting Freak

Posts: 896
Threads: 42
Joined: Feb 2013
Reputation: 34
#10
RE: Weeping Angel enemies

You'll have the chase music whenever you don't look at him though. Keep that in mind.
06-19-2013, 06:59 PM
Find




Users browsing this thread: 1 Guest(s)