Frictional Games Forum (read-only)
[CHAOS] Setting up the elevator machine - 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: [CHAOS] Setting up the elevator machine (/thread-21426.html)

Pages: 1 2 3


Setting up the elevator machine - serbusfish - 05-07-2013

Ive attempted looking for a youtube tutorial on this but all I get are walkthoughs for the elevator part in the main game.

My scenario;

The map is filled with water. There is a lever that will open the drainage system and release all the water, however the machine that powers this is currently missing its cogs and coal. You need to replace the cogs, put a piece of coal in the machine, and then you'll be able to pull the lever and drain the water.

Here is all I have so far:

[Image: elevatormachine.jpg]

I know sticky areas need placing on the places where the cogs go, and of course those cogs need to be de-activated and scripted to activate when you place the actual cogs in place, but apart from that im pretty clueless.

Any help on this would be really appreciated, in fact rest assured anyone who can help me with this will get a their own section in the end credits! Smile


RE: Setting up the elevator machine - Tomato Cat - 05-07-2013

What do you have written so far? Post it and I can help guide you through everything. I would much prefer to help someone who is actively trying rather than just asking for a script on the forums.


RE: Setting up the elevator machine - Rapture - 05-07-2013

Do you plan to have a moving elevator or just using one as a "level door"?


RE: Setting up the elevator machine - serbusfish - 05-07-2013

(05-07-2013, 02:42 AM)Tomato Cat Wrote: What do you have written so far? Post it and I can help guide you through everything. I would much prefer to help someone who is actively trying rather than just asking for a script on the forums.

I dont have anything so far as I dont know where to begin.

I'm not asking for anyone to write the entire thing out for me, I simply need to know where to start, what commands are needed, etc. I have only been scripting since January but I know my way around most of the basic commands, but when it comes to something as complex (I think?) as this machine im a little out of my depth.

(05-07-2013, 03:09 AM)Rapture Wrote: Do you plan to have a moving elevator or just using one as a "level door"?

There is no actual elevator in my map, just the machine. What im planning is having the next level door down a flight of stairs, but because of the water you cant get down to it until its been drained.

I'll put a black box in front of the staircase so you cant go down it, then when the water has gone i'll make it deactivate the black box.


RE: Setting up the elevator machine - Tomato Cat - 05-07-2013

(05-07-2013, 03:14 AM)serbusfish Wrote: I dont have anything so far as I dont know where to begin.

I'm not asking for anyone to write the entire thing out for me, I simply need to know where to start, what commands are needed, etc. I have only been scripting since January but I know my way around most of the basic commands, but when it comes to something as complex (I think?) as this machine im a little out of my depth.

Oh, no problem. =)

So, you want the player to replace 3 cogwheels, put some coal in and then pull the lever? Not terribly difficult once you get the hang of it. I'll give you a general idea and you can adjust it to your liking.

Let's start with the coal. I assume you're using the default elevator machine's coal burner.

Spawn in some coal pieces and keep the default names. Next, create a script area. Name it area_coal and place it inside the burner.

Then add a collide callback. The callback function will known as "CoalBurner."

PHP Code:
AddEntityCollideCallback("coal_*","area_coal","CoalBurner",false,1);
//The "*" basically means everything named coal_ and a number 

You'll also need this local variable:

PHP Code:
SetLocalVarInt("CoalCheck",0);
//Place it alongside the collide callback 

Now the function! What it essentially does is increment a variable every time a coal piece is added. If enough coal has already been added, the piece will disappear.

PHP Code:
void CoalBurner(string &in asParentstring &in asChildint alState)
{
        
    if(
GetLocalVarInt("CoalCheck") < 3)
    {
                
//Increments CoalCheck variable and makes the piece disappear
        
AddDebugMessage("Adding coal piece "+asParent,false);
                
AddDebugMessage("Coal check now at "+GetLocalVarInt("CoalCheck"),false);
        
SetPropActiveAndFade(asParentfalse5.0f);
        
AddLocalVarInt("CoalCheck",1);
    }
    
        else
        {
            
//Makes the coal piece disappear
            
SetPropActiveAndFade(asParentfalse3.0f);
            
AddDebugMessage("Too much coal, incinerating!",false);
        }


Let me know how that turns out. Then I can help you with the sticky areas, if you like.


RE: Setting up the elevator machine - PutraenusAlivius - 05-07-2013

PHP Code:
void OnStart()
{
SetLocalVarInt("Cogwheel"0);
SetLocalVarInt("Coal"0);
AddEntityCollideCallback("Coal1""ScriptAreaCoal""AddVar1"false1); //Change Coal1 to coal num 1
AddEntityCollideCallback("Coal2""ScriptAreaCoal""AddVar2"false1); //Change Coal2 to coal num 2
AddEntityCollideCallback("Coal3""ScriptAreaCoal""AddVar3"false1); //Change Coal3 to coal num 3
//You can add more but change the Parent and Function name.
}

void AddVar1(string &in asParentstring &in asChildint alState)
{
AddLocalVarInt("Coal"1);
CheckCoalCount();
}

void AddVar2(string &in asParentstring &in asChildint alState)
{
AddLocalVarInt("Coal"1);
CheckCoalCount();
}

void AddVar3(string &in asParentstring &in asChildint alState)
{
AddLocalVarInt("Coal"1);
CheckCoalCount();
}

void CheckCoalCount()
{
if(
GetLocalVarInt("Coal") == 3//Change 3 to how many coal you want
{
SetMessage("MsgCat""MsgEntry"0); //This is the message that will appear when enough coals are placed.
//Place any other commands here...
}

Coal count script.


RE: Setting up the elevator machine - serbusfish - 05-07-2013

Awesome, thanks a lot guys! Although I will say those 'VarInt' commands are something I havent used before and havent quite got my head around them yet. Im at work today but when I finish tonight I will give this a go Smile


RE: Setting up the elevator machine - serbusfish - 05-08-2013

OK I have tried the script and when I put all 3 pieces of coal into the machine they disappear. Ive also had a mess with the sticky areas and replicated what Frictional did with their machine, and all 3 of the cogs click into place as they should. But that's as far as I have got. I have also put the lever to start the machine in place as well.


RE: Setting up the elevator machine - Tomato Cat - 05-08-2013

Did you not want the coal to disappear?

Use this for the lever:

PHP Code:
SetEntityConnectionStateChangeCallback(stringasNamestringasCallback);

//Callback syntax:
void Function(string &in asEntityint alState



RE: Setting up the elevator machine - serbusfish - 05-08-2013

(05-08-2013, 02:05 AM)Tomato Cat Wrote: Did you not want the coal to disappear?

Use this for the lever:

PHP Code:
SetEntityConnectionStateChangeCallback(stringasNamestringasCallback);

//Callback syntax:
void Function(string &in asEntityint alState

Yes that's fine, I was just updating on what I had done Smile

Ok ive used that command on a previous map so know what to do with it, however I dont know how I actually get the machines cogs and things to start up when the lever is pulled?