Frictional Games Forum (read-only)
HasItem problem [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: HasItem problem [SOLVED] (/thread-7259.html)



HasItem problem [SOLVED] - Linus Ågren - 04-09-2011

What's wrong with this code? I have the key but it doesn't trigger the event.

Code:
void CollideAreaLiving(string &in asParent, string &in asChild, int alState)
{
    if(HasItem("key_storage") == true){
//Slime Fades
        SetPropActiveAndFade("slime_6way_1", true, 1.5f);
        SetPropActiveAndFade("slime_anim_wall_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_2", true, 1.5f);
//Effects
        StartScreenShake(0.115, 2.0f, 0.1f,0.3f);
        FadeSepiaColorTo(100.0f, 4.0f);
        FadeRadialBlurTo(0.15f, 6.0f);
        PlaySoundAtEntity("", "guardian_activated.snt", "Player", 0, false);
//Timer to remove effects
        AddTimer("FadeGone", 3.0f, "GuardianTimer");
    }
}

The code still won't get triggered if I have that key. What's wrong with it?


RE: HasItem problem - Pandemoneus - 04-09-2011

Mind posting the error message?


RE: HasItem problem - Linus Ågren - 04-09-2011

Oh sorry, I forgot to remove that part. Edited post above. The problem is now only that the script won't get activated even if I have the item.


RE: HasItem problem - Dalroc - 04-09-2011

Remove the " == true" from if(HasItem("key_storage") == true), like this
Code:
void CollideAreaLiving(string &in asParent, string &in asChild, int alState)
{
    if(HasItem("key_storage")){
//Slime Fades
        SetPropActiveAndFade("slime_6way_1", true, 1.5f);
        SetPropActiveAndFade("slime_anim_wall_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_1", true, 1.5f);
        SetPropActiveAndFade("slime_pile_2", true, 1.5f);
//Effects
        StartScreenShake(0.115, 2.0f, 0.1f,0.3f);
        FadeSepiaColorTo(100.0f, 4.0f);
        FadeRadialBlurTo(0.15f, 6.0f);
        PlaySoundAtEntity("", "guardian_activated.snt", "Player", 0, false);
//Timer to remove effects
        AddTimer("FadeGone", 3.0f, "GuardianTimer");
    }
}



RE: HasItem problem - Linus Ågren - 04-09-2011

The collidebox STILL won't get triggered o0.


RE: HasItem problem - Dalroc - 04-09-2011

Could you post the EntityCollideCallback that calls CollideAreaLiving?


RE: HasItem problem - Linus Ågren - 04-09-2011

Sure, here you go:
AddEntityCollideCallback("Player", "AreaLiving", "CollideAreaLiving", true, 1);


RE: HasItem problem - Dalroc - 04-10-2011

Spotted the problem (I think). You are destroying the Callback when it's triggered the first time.
Set abDeleteOnCollide to false and it should work.. You will have to find another way to remove the Callback only when you have the item. Example would be to use a variable and add a condition to your if conditional to only execute when the player has the key AND when the variable has the right value.


RE: HasItem problem - Linus Ågren - 04-22-2011

YES! It works! I never realized it would be such an easy answer. Thanks a thousand times. I've been trying to figure out why it didn't work for so long! Big Grin


RE: HasItem problem [SOLVED] - Dalroc - 04-22-2011

Glad I could help! Smile