Frictional Games Forum (read-only)
Trigger an event if user has an item - 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: Trigger an event if user has an item (/thread-6577.html)



Trigger an event if user has an item - Linus Ă…gren - 02-13-2011

Okay, I've made an event that is supposed to happen if user has an item. My script looks like:

Code:
void CollideSwingCrown(string &in asParent, string &in asChild, int alState)
{
    if(HasItem("OilContainer")){
        CreateParticleSystemAtEntity("Ghost", "ps_dust_ghost.ps", "candlestick_tri_1", false);
    
        PlaySoundAtEntity("SoundSwirl", "scare_whine_loop", "AreaBeginSwirl", 0.0f, false);
        PlaySoundAtEntity("BeginWindSound", "general_wind_whirl.snt", "Player", 4.0f, false);
        PlaySoundAtEntity("", "scare_male_terrified.snt", "Player", 0.5f, false);
    
        AddPropImpulse("chandelier_large_1", 2.0f, 0.0f, 0.0f, "World");
    
        AddTimer("Swing", 0.5f, "GhostCrown");
        AddTimer("Sanity", 1.0f, "GhostCrown");
        AddTimer("FadeOut", 2.5f, "GhostCrown");
        AddTimer("StopMusic", 15.0f, "GhostCrown");
        AddTimer("StartMusic", 16.0f, "GhostCrown");
    }
}

void GhostCrown(string &in asTimer)
{
    if(asTimer == "Swing"){
        PlayMusic("00_event_gallery.ogg", false, 1.0f, 0.0f, 10, false);
    }
    if(asTimer == "Sanity"){
        GiveSanityDamage(4.0f, true);
        
        FadeRadialBlurTo(0.1f, 0.025f);
        
        SetLampLit("chandelier_large_1", false, true);
        SetLampLit("candlestick_tri_1", false, true);
        SetLampLit("candlestick_tri_3", false, true);
        SetLampLit("candlestick_tri_2", false, true);
        SetLampLit("candlestick_floor_3", false, true);
        SetLampLit("candlestick_floor_2", false, true);
        SetLampLit("candlestick_floor_1", false, true);
        SetLampLit("candlestick_floor_4", false, true);
        SetLampLit("candlestick_wall_1", false, true);
        SetLampLit("candlestick_wall_2", false, true);
    }
    if(asTimer == "FadeOut"){
        FadeRadialBlurTo(0, 0.1f);
    }
    if(asTimer == "StopMusic"){
        StopMusic(10, 0);
    }
    if(asTimer == "StartMusic"){
        PlayMusic("12_amb.ogg", false, 1.0f, 0.0f, 10, false);
    }
}

And the item's name is OilContainer. The problem is that the event won't trigger if you have the item. What's wrong?


RE: Trigger an event if user has an item - Acies - 02-16-2011

I think the IfHasItem is missing a "==true".