Entity-connected lights and areas (solved) - 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 (https://www.frictionalgames.com/forum/forum-35.html) +--- Thread: Entity-connected lights and areas (solved) (/thread-6445.html) |
Entity-connected lights and areas (solved) - Phoroneus - 02-01-2011 Hello all, I've been using the forum search to answer my questions thus far with great success (and the Script Functions page of the wiki with even greater success) but I've been unable to find a solution to my latest problem, and am wondering if anyone else has managed it or if such a thing is even possible in the HPL2 engine. I'm currently working on a custom story entitled "Whiteout", and a major mechanic in the introductory map is the cold, which will gradually freeze the player to death if (s)he does not find a place of relative warmth*. Towards the end of the map, the player is able to place an ember into a bucket and carry it around as a mobile source of warmth and light (and therefore sanity), allowing them greater freedom of movement and less time spent running between warm spots. My issue is that I have been thus far unable to move the ember's light and warmth area with the ember, which uses the Coal entity and physics to better simulate actually moving a very hot object rather than sticking it in the player's inventory (in fact, touching it with one's hand burns the player). If there were a way to do this with a light (hypothetically "EmberLight"), area ("WarmArea") and entity ("Ember"), how might it be done? And would it utilize primarily the Level Editor, script, or should I modify the entity's properties in the Model Editor (I am comfortable with this, though I have relatively little experience with model editing). Thanks in advance for any help. I can post snippets of code or whatnot as needed. *I realized later just how similar this was to the opening scene in Penumbra: Overture. The scene itself is very different, but the freezing mechanic is apparently not an original concept... which may be why it was so simple to implement. EDIT: I have been able to attach a light using the model editor. The area remains a challenge. Alternately, is there a way to check the player's distance from an object via scripts? For example, Code: if (GetEntityDistance("Player", "Ember") >= 3) Answered my own question. There isn't a script designed to perform such a check. It might come down to filling the entire map with script areas and damaging the player if they're not in the same area as the ember, but GetEntitiesCollide doesn't appear to function in the way I thought it did. :S So I'm rather stuck. Any help or suggestions appreciated. RE: Entity-connected lights and areas (1 of 2 solved) - Frontcannon - 02-01-2011 Not wanting to burst your bubble, but if you can't find anything in the script functions, it'll most likely not work the way you want it, as there is no way of connecting areas to an entity. Maybe use AttachPropToProp (?), but I have no idea how that one works. RE: Entity-connected lights and areas (1 of 2 solved) - Phoroneus - 02-01-2011 (02-01-2011, 10:06 PM)Frontcannon Wrote: Not wanting to burst your bubble, but if you can't find anything in the script functions, it'll most likely not work the way you want it, as there is no way of connecting areas to an entity.Thought of that. AttachPropToProp only appears to work on non-area entities like furniture and such, as it wasn't moving the script areas at all, unfortunately. I also tried adding a non-solid area to the ember (just a modified coal entity) that would collide with the player when they were within a certain range, but that didn't seem to have any effect at all (of course I'm new to modeling outside of ProE and the Model Editor in particular, so that was hardly surprising). I'm currently attempting to get it to work by setting up lots of overlapping 3m by 3m areas throughout the map and assigning each a number, then changing two variables ("EmberLoc" and "PlayerLoc") depending on which area they're in, then comparing the numbers to find out if they're in the same area and determining whether the player is within range of the ember by that method. It's inelegant as all hell, but it appears to be the only option given the limitations. EDIT: And it works, to a degree. It'll require a lot of tweaking and adjusting before it's playable, but at least it's proof of concept. Thanks anyway Frontcannon. RE: Entity-connected lights and areas (1 of 2 solved) - Frontcannon - 02-01-2011 No problem, it's refresing to see a post here that doesn't just say 'Help it doesn't work!! '. Just make sure if the player depends on the ember that he can't lose it somewhere in the map! Because if he could you'd have to spawn a new one, with a new set of areas etc. Or try for-loops. RE: Entity-connected lights and areas (1 of 2 solved) - Phoroneus - 02-02-2011 (02-01-2011, 11:21 PM)Frontcannon Wrote: Or try for-loops. This sounds like a very good idea. And thus far I've been unable to lose the ember, but I know players and if there is a way, they will find it. I'm thinking of creating an ember-spawner as a prophylactic measure. I took a break and I've been messing with the Model Editor, which seems promising. I'll report any findings in case anyone else ends up needing something similar. RE: Entity-connected lights and areas (solved) - jens - 02-02-2011 I think you could make a big body that does not physically collide, but works to use with addcollideentitycallback. So if you set a variable when you have added the ember to the bucket, you could then check the players in/out collision with the big body of the bucket to know if he is in or outside the light (the body would be like an area). At least in Penumbra overture we have one place with a big rock rolling over the player, and to be sure there was no hiccup the entity does not collide physically with the player, but there is an addcollideentitycallback to check if the entity has rolled over the player. Amnesia is a little bit different so could be this idea does not work any longer. RE: Entity-connected lights and areas (solved) - Phoroneus - 02-02-2011 (02-02-2011, 06:49 AM)jens Wrote: I think you could make a big body that does not physically collide, but works to use with addcollideentitycallback. So if you set a variable when you have added the ember to the bucket, you could then check the players in/out collision with the big body of the bucket to know if he is in or outside the light (the body would be like an area). Thanks Jens. I changed my method to an inventory-based one, and actually got it to work just now (was coming back to put [SOLVED] on my other post) but originally considered your idea. I wasn't able to get the big body to register, or anything to register for that matter, using GetEntitiesCollide. No matter what I tried, it always returned false. :/ Even so, I ended up learning more than I originally would have, so all in all I'd say it was more a blessing in disguise than anything else. |