Frictional Games Forum (read-only)
Timer Not Working - 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: Timer Not Working (/thread-21848.html)



Timer Not Working - zergling50 - 06-17-2013

I have a scare set up where your locked in a room with a grunt for a short period of time. Once the timer finishes the grunt is supposed to disappear in a flash of light and the door to the room unlocks. The only problem is that the timer is not responding and I have no idea why. Heres the code in question:

void RoomScare(string &in asParent, string &in asChild, int alState)
{
SetPlayerActive(false);
AddPropImpulse("mansion_7", 0, 0, -50, "world");
SetSwingDoorLocked("mansion_7", true, true);
GiveSanityDamage(1, true);
SetPlayerActive(true);
AddTimer("roomscarefinish", 5.0f, "RoomScareFinish");
SetEntityActive("servant_grunt_3", true);
AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_30", 1.0f, "idle");
AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_31", 1.0f, "idle");
AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_32", 1.0f, "idle");
AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_33", 1.0f, "idle");
AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_34", 1.0f, "idle");
AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_35", 1.0f, "idle");
AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_36", 1.0f, "idle");
}

void RoomScareFinish()
{
GiveSanityBoostSmall();
StartEffectFlash(0.3f, 1.0f, 1.0f);
SetSwingDoorLocked("mansion_7", false, true);
SetEntityActive("servant_grunt_3", false);
}


RE: Timer Not Working - PutraenusAlivius - 06-17-2013

Code:
void RoomScare(string &in asParent, string &in asChild, int alState)
{
    SetPlayerActive(false);
    AddPropImpulse("mansion_7", 0, 0, -50, "world");
    SetSwingDoorLocked("mansion_7", true, true);
    GiveSanityDamage(1, true);
    SetPlayerActive(true);
    AddTimer("roomscarefinish", 5.0f, "RoomScareFinish");
    SetEntityActive("servant_grunt_3", true);
    AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_30", 1.0f, "idle");
    AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_31", 1.0f, "idle");
    AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_32", 1.0f, "idle");
    AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_33", 1.0f, "idle");
    AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_34", 1.0f, "idle");
    AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_35", 1.0f, "idle");
    AddEnemyPatrolNode("servant_grunt_3", "PathNodeArea_36", 1.0f, "idle");
}

void RoomScareFinish(string &in asTimer) //Wrong callback syntax. You have () which is not recognizable as the callback syntax for the AddTimer.
{
    GiveSanityBoostSmall();
    StartEffectFlash(0.3f, 1.0f, 1.0f);
    SetSwingDoorLocked("mansion_7", false, true);
    SetEntityActive("servant_grunt_3", false);
}

Fixed it.