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
Question for the pros.
Tiero Offline
Member

Posts: 126
Threads: 13
Joined: Mar 2011
Reputation: 11
#1
Question for the pros.

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

[Image: 111.jpg]
(This post was last modified: 11-29-2012, 03:30 PM by Tiero.)
11-29-2012, 03:27 PM
Website Find
The chaser Offline
Posting Freak

Posts: 2,486
Threads: 76
Joined: Jun 2012
Reputation: 113
#2
RE: Question for the pros.

It's not so pro, Tiero Smile

So, in your .hps:

CODE 1 (option 1)
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

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?

THE OTHERWORLD (WIP)
[Image: k6vbdhu]

Aculy iz dolan.
(This post was last modified: 11-29-2012, 04:05 PM by The chaser.)
11-29-2012, 04:05 PM
Find
Tiero Offline
Member

Posts: 126
Threads: 13
Joined: Mar 2011
Reputation: 11
#3
RE: Question for the pros.

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... )

[Image: 111.jpg]
(This post was last modified: 11-29-2012, 05:29 PM by Tiero.)
11-29-2012, 05:23 PM
Website Find
Your Computer Offline
SCAN ME!

Posts: 3,456
Threads: 32
Joined: Jul 2011
Reputation: 235
#4
RE: Question for the pros.

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.

Tutorials: From Noob to Pro
11-29-2012, 07:50 PM
Website Find
Tiero Offline
Member

Posts: 126
Threads: 13
Joined: Mar 2011
Reputation: 11
#5
RE: Question for the pros.

I did it! Big GrinDD

If someone be useful, I post this here!

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! +_+

[Image: 111.jpg]
12-01-2012, 09:44 AM
Website Find




Users browsing this thread: 1 Guest(s)