Frictional Games Forum (read-only)
Question for the pros. - 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: Question for the pros. (/thread-19379.html)



Question for the pros. - Tiero - 11-29-2012

Guys, there are three tools (key, hammer, crowbar). Tell me please, how to make so that the door was opened only with the help of the third instrument, provided that the previous two have already been used? (the crucial instrument can be any one of them)
Very want to realize this point in my story, but the mind is not enough. Smile



RE: Question for the pros. - The chaser - 11-29-2012

It's not so pro, Tiero Smile

So, in your .hps:

CODE 1 (option 1)
Code:
void OnStart()
{
AddUseItemCallback("", "key", "door", "use_key", true);
AddUseItemCallback("", "hammer", "door", "use_hammer", true);
}

void use_key (string &in asItem, string &in asEntity)
{
AddLocalVarInt("Key_variable", 1);
check();
}


void use_hammer (string &in asItem, string &in asEntity)
{
AddLocalVarInt("Key_variable", 1);
check();
}

void check()
{
if (GetLocalVarInt("Key_variable") == 2)
{
AddUseItemCallback("", "crowbar", "door", "crow", true);
}
}


void crow (string &in asItem, string &in asEntity)
{
///Crowbar thing here
}

OPTION 2

Code:
void OnStart()
{
AddUseItemCallback("", "key", "door", "use_key", true);
AddUseItemCallback("", "hammer", "door", "use_hammer", true);
}

void use_key (string &in asItem, string &in asEntity)
{
AddLocalVarInt("Key_variable", 1);
check();
}


void use_hammer (string &in asItem, string &in asEntity)
{
AddLocalVarInt("Key_hammer", 1);
check();
}

void check()
{
if (GetLocalVarInt("Key_variable") == 1)
{
AddUseItemCallback("", "crowbar", "door", "crow", true);
}
if (GetLocalVarInt("Key_hammer") == 1)
{
AddUseItemCallback("", "crowbar", "door", "crow", true);
}
}


void crow (string &in asItem, string &in asEntity)
{
///Crowbar thing here
}

Anyway, could you please specify more?


RE: Question for the pros. - Tiero - 11-29-2012

The chaser, thank you very much ! ! !

A fully event should look like this: in the room hidden the three tools. I need to quickly find them because the time goes by. With time no problems, all timers I've already pre-programmed. The problem is that the player can first find the tool and immediately use it. But player may find all three instruments, in which case I should check the instruments in the world and in the inventory. For all the tools I need to write a two messages: 1 - If the instrument opened the door, 2 - if the instrument is not opened the door. In the room two doors, so the last tool can open both the first and the second door.

tools: key_1 hammer_1 crowbar_1
doors: mansion_6 mansion_7

I beg your pardon, I'm Russian, and I translating text with a program... )


RE: Question for the pros. - Your Computer - 11-29-2012

Just use the same callback for all three items, and if the player used the correct item, then let them pass. Make use of the parameters to see which item was used.


RE: Question for the pros. - Tiero - 12-01-2012

I did it! Big GrinDD

If someone be useful, I post this here!

Code:
void OnStart()
{
    AddEntityCollideCallback("crowbar_joint_1", "crowbar_broke_zone1", "CrowbarFunc", true, 1);     AddEntityCollideCallback("crowbar_joint_2", "crowbar_broke_zone2", "CrowbarFunc2", true, 1);

      AddUseItemCallback("", "key_1", "mansion_6", "KeyFunc", true);
    AddUseItemCallback("", "key_1", "mansion_7", "Key1Func", true);

    AddUseItemCallback("", "hammer_1", "mansion_6", "HammerFunc", true);
    AddUseItemCallback("", "hammer_1", "mansion_7", "Hammer1Func", true);
}

void CrowbarFunc(string &in asParent, string &in asChild, int alState)
{
    if(GetEntityExists("key_1")==false)
    {
        if(GetEntityExists("hammer_1")==false)
        {
            if(HasItem("key_1")==false)
            {
                if(HasItem("hammer_1")==false)
                {
                    SetEntityActive("crowbar_joint_1", false);
                    SetEntityActive("crowbar_joint_1_broke", true);
                    SetSwingDoorLocked("mansion_6", false, true);
                    AddPropImpulse("mansion_6", 0, 0, -10, "World");
                    CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
                    PlaySoundAtEntity("BR", "break_wood_metal", "crowbar_p1_1", 0, false);
                    SetMessage("Things", "S22", 5);
                    RemoveTimer("KillMe");
                }
                else
                {
                    SetEntityActive("crowbar_joint_1", false);
                    SetEntityActive("crowbar_joint_1_broke", true);
                    AddPropImpulse("mansion_6", 0, 0, -10, "World");
                    CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
                    PlaySoundAtEntity("BR", "break_wood_metal", "crowbar_p1_1", 0, false);
                    SetMessage("Things", "S21", 5);
                }
            }
            else
            {
                SetEntityActive("crowbar_joint_1", false);
                SetEntityActive("crowbar_joint_1_broke", true);
                AddPropImpulse("mansion_6", 0, 0, -10, "World");
                CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
                PlaySoundAtEntity("BR", "break_wood_metal", "crowbar_p1_1", 0, false);
                SetMessage("Things", "S21", 5);
            }
        }
        else
        {
            SetEntityActive("crowbar_joint_1", false);
            SetEntityActive("crowbar_joint_1_broke", true);
            AddPropImpulse("mansion_6", 0, 0, -10, "World");
            CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
            PlaySoundAtEntity("BR", "break_wood_metal", "crowbar_p1_1", 0, false);
            SetMessage("Things", "S21", 5);
        }
    }
    else
    {
        SetEntityActive("crowbar_joint_1", false);
        SetEntityActive("crowbar_joint_1_broke", true);
        AddPropImpulse("mansion_6", 0, 0, -10, "World");
        CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
        PlaySoundAtEntity("BR", "break_wood_metal", "crowbar_p1_1", 0, false);
        SetMessage("Things", "S21", 5);
    }
}

void CrowbarFunc2(string &in asParent, string &in asChild, int alState)
{
    if(GetEntityExists("key_1")==false)
    {
        if(GetEntityExists("hammer_1")==false)
        {
            if(HasItem("key_1")==false)
            {
                if(HasItem("hammer_1")==false)
                {
                    SetEntityActive("crowbar_joint_2", false);
                    SetEntityActive("crowbar_joint_2_broke", true);
                    SetSwingDoorLocked("mansion_7", false, true);
                    AddPropImpulse("mansion_7", 0, 0, -10, "World");
                    CreateParticleSystemAtEntity("HW2", "ps_hit_wood.ps", "crowbar_p2", true);
                    PlaySoundAtEntity("BR2", "break_wood_metal", "crowbar_p2_2", 0, false);
                    RemoveTimer("KillMe");
                    SetMessage("Things", "S22", 5);
                    
                }
                else
                {
                    SetEntityActive("crowbar_joint_2", false);
                    SetEntityActive("crowbar_joint_2_broke", true);
                    AddPropImpulse("mansion_7", 0, 0, -10, "World");
                    CreateParticleSystemAtEntity("HW2", "ps_hit_wood.ps", "crowbar_p2", true);
                    PlaySoundAtEntity("BR2", "break_wood_metal", "crowbar_p2_2", 0, false);
                    SetMessage("Things", "S21", 5);
                }
            }
            else
            {
                SetEntityActive("crowbar_joint_2", false);
                SetEntityActive("crowbar_joint_2_broke", true);
                AddPropImpulse("mansion_7", 0, 0, -10, "World");
                CreateParticleSystemAtEntity("HW2", "ps_hit_wood.ps", "crowbar_p2", true);
                PlaySoundAtEntity("BR2", "break_wood_metal", "crowbar_p2_2", 0, false);
                SetMessage("Things", "S21", 5);
            }
        }
        else
        {
            SetEntityActive("crowbar_joint_2", false);
            SetEntityActive("crowbar_joint_2_broke", true);
            AddPropImpulse("mansion_7", 0, 0, -10, "World");
            CreateParticleSystemAtEntity("HW2", "ps_hit_wood.ps", "crowbar_p2", true);
            PlaySoundAtEntity("BR2", "break_wood_metal", "crowbar_p2_2", 0, false);
            SetMessage("Things", "S21", 5);
        }
    }
    else
    {
        SetEntityActive("crowbar_joint_2", false);
        SetEntityActive("crowbar_joint_2_broke", true);
        AddPropImpulse("mansion_7", 0, 0, -10, "World");
        CreateParticleSystemAtEntity("HW2", "ps_hit_wood.ps", "crowbar_p2", true);
        PlaySoundAtEntity("BR2", "break_wood_metal", "crowbar_p2_2", 0, false);
        SetMessage("Things", "S21", 5);
    }
}

void KeyFunc(string &in asItem, string &in asEntity)
{
    if(GetEntityExists("crowbar_1")==false)
    {
        if(GetEntityExists("hammer_1")==false)
        {
            if(HasItem("crowbar_1")==false)
            {
                if(HasItem("hammer_1")==false)
                {
                    SetSwingDoorLocked("mansion_6", false, true);
                    PlaySoundAtEntity("BR", "KeyUnlocke.snt", "crowbar_p1_11", 0, false);
                    SetMessage("Things", "S22", 5);
                    RemoveItem("key_1");
                    RemoveTimer("KillMe");
                }
                else
                {
                    CreateParticleSystemAtEntity("KeyP", "ps_dust_drilling.ps", "KeyP1", true);
                    PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_11", 0, false);
                    SetMessage("Things", "S23", 5);
                    RemoveItem("key_1");
                }
            }
            else
            {
                CreateParticleSystemAtEntity("KeyP", "ps_dust_drilling.ps", "KeyP1", true);
                PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_11", 0, false);
                SetMessage("Things", "S23", 5);
                RemoveItem("key_1");
            }
        }
        else
        {
            CreateParticleSystemAtEntity("KeyP", "ps_dust_drilling.ps", "KeyP1", true);
            PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_11", 0, false);
            SetMessage("Things", "S23", 5);
            RemoveItem("key_1");
        }
    }
    else
    {
        CreateParticleSystemAtEntity("KeyP", "ps_dust_drilling.ps", "KeyP1", true);
        PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_11", 0, false);
        SetMessage("Things", "S23", 5);
        RemoveItem("key_1");
    }
}

void Key1Func(string &in asItem, string &in asEntity)
{
    if(GetEntityExists("crowbar_1")==false)
    {
        if(GetEntityExists("hammer_1")==false)
        {
            if(HasItem("crowbar_1")==false)
            {
                if(HasItem("hammer_1")==false)
                {
                    SetSwingDoorLocked("mansion_7", false, true);
                    PlaySoundAtEntity("BR", "KeyUnlocke.snt", "crowbar_p1_12", 0, false);
                    SetMessage("Things", "S22", 5);
                    RemoveItem("key_1");
                    RemoveTimer("KillMe");
                }
                else
                {
                    CreateParticleSystemAtEntity("KeyP2", "ps_dust_drilling.ps", "KeyP2", true);
                    PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_12", 0, false);
                    SetMessage("Things", "S23", 5);
                    RemoveItem("key_1");
                }
            }
            else
            {
                CreateParticleSystemAtEntity("KeyP2", "ps_dust_drilling.ps", "KeyP2", true);
                PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_12", 0, false);
                SetMessage("Things", "S23", 5);
                RemoveItem("key_1");
            }
        }
        else
        {
            CreateParticleSystemAtEntity("KeyP2", "ps_dust_drilling.ps", "KeyP2", true);
            PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_12", 0, false);
            SetMessage("Things", "S23", 5);
            RemoveItem("key_1");
        }
    }
    else
    {
        CreateParticleSystemAtEntity("KeyP2", "ps_dust_drilling.ps", "KeyP2", true);
        PlaySoundAtEntity("BR", "KeyCrash.snt", "crowbar_p1_12", 0, false);
        SetMessage("Things", "S23", 5);
        RemoveItem("key_1");
    }
}

void HammerFunc(string &in asItem, string &in asEntity)
{
    if(GetEntityExists("key_1")==false)
    {
        if(GetEntityExists("crowbar_1")==false)
        {
            if(HasItem("key_1")==false)
            {
                if(HasItem("crowbar_1")==false)
                {
                    SetSwingDoorLocked("mansion_6", false, true);
                    AddPropImpulse("mansion_6", 0, 0, -100, "World");
                    SetSwingDoorDisableAutoClose("mansion_6", true);
                    SetSwingDoorClosed("mansion_6", false, false);
                    SetMoveObjectState("mansion_6", 1);
                    CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
                    PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p1_1", 0, false);
                    SetMessage("Things", "S22", 5);
                    RemoveItem("hammer_1");
                    RemoveTimer("KillMe");
                }
                else
                {
                    CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
                    PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p1_1", 0, false);
                    SetMessage("Things", "S24", 5);
                    RemoveItem("hammer_1");
                }
            }
            else
            {
                CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
                PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p1_1", 0, false);
                SetMessage("Things", "S24", 5);
                RemoveItem("hammer_1");
            }
        }
        else
        {
            CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
            PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p1_1", 0, false);
            SetMessage("Things", "S24", 5);
            RemoveItem("hammer_1");
        }
    }
    else
    {
        CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p1", true);
        PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p1_1", 0, false);
        SetMessage("Things", "S24", 5);
        RemoveItem("hammer_1");
    }
}

void Hammer1Func(string &in asItem, string &in asEntity)
{
    if(GetEntityExists("key_1")==false)
    {
        if(GetEntityExists("crowbar_1")==false)
        {
            if(HasItem("key_1")==false)
            {
                if(HasItem("crowbar_1")==false)
                {
                    SetSwingDoorLocked("mansion_7", false, true);
                    AddPropImpulse("mansion_7", 0, 0, 100, "World");
                    SetSwingDoorDisableAutoClose("mansion_7", true);
                    SetSwingDoorClosed("mansion_7", false, false);
                    SetMoveObjectState("mansion_7", 1);
                    CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p2", true);
                    PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p2_2", 0, false);
                    SetMessage("Things", "S22", 5);
                    RemoveItem("hammer_1");
                    RemoveTimer("KillMe");
                }
                else
                {
                    CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p2", true);
                    PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p2_2", 0, false);
                    SetMessage("Things", "S24", 5);
                    RemoveItem("hammer_1");
                }
            }
            else
            {
                CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p2", true);
                PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p2_2", 0, false);
                SetMessage("Things", "S24", 5);
                RemoveItem("hammer_1");
            }
        }
        else
        {
            CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p2", true);
            PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p2_2", 0, false);
            SetMessage("Things", "S24", 5);
            RemoveItem("hammer_1");
        }
    }
    else
    {
        CreateParticleSystemAtEntity("HW1", "ps_hit_wood.ps", "crowbar_p2", true);
        PlaySoundAtEntity("BRHammer1", "break_wood_metal", "crowbar_p2_2", 0, false);
        SetMessage("Things", "S24", 5);
        RemoveItem("hammer_1");
    }
}

It was fucking hard! +_+