Frictional Games Forum (read-only)
Please remove - 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: Please remove (/thread-12271.html)

Pages: 1 2 3


RE: AddEntityCollideCallback - eagledude4 - 01-02-2012

(01-02-2012, 07:08 AM)Statyk Wrote: It makes the screen black instantly. That's actually a good teting idea. see, if a function isn't working, a visual like THAT would easily tell you if something is wrong with a specific function, or if it is working fine but has a typo somewhere, etc. Understand?

Indeed, I do. I tested the map again, but the screen didn't go black when I opened the chest.

Full code:
Code:
bool TriggeredEnemy;

void OnStart() {
    if (ScriptDebugOn()) {
        GiveItemFromFile("lantern", "lantern.ent");
        for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
        /*SetEntityActive("invisWall", false);
        SetEntityActive("blockArea", false);*/
    }
    AddEntityCollideCallback("Player", "EnemyTriggerArea", "EnteredEnemyTriggerArea", true, 1);
    AddEntityCollideCallback("Player", "BlockArea", "EnteredBlockArea", true, 1);
    SetEntityPlayerInteractCallback("chest_small_2", "TriggerSpider", true);
    PlaySoundAtEntity("", "Custom\big_clock_chime.snt", "clock_grandfather_1", 0, false);
    SetDeathHint("Death", "StairScare");
    SetEntityCallbackFunc("key_1", "OnPickup");
}

void OnEnter() {
}

void OnLeave() {
}

void EnteredEnemyTriggerArea(string &in asParent, string &in asChild, int alState) {
    TriggeredEnemy = true;
    SetEntityActive("servant_grunt_1", true);
    ShowEnemyPlayerPosition("servant_grunt_1");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
}

void EnteredBlockArea(string &in asParent, string &in asChild, int alState) {
    if (HasItem("key_1") == false) {
        SetMessage("CustomStory", "Barrier", 6);
    }
}

void OnPickup(string &in asEntity, string &in type) {
    SetEntityActive("invisWall", false);
    SetEntityActive("blockArea", false);
}

void TriggerSpider(string &in asParent, string &in asChild, int alState) {
    SetEntityActive("spider_1", true);
    FadeOut(0);
}

/*int EnemyLooksForPlayer() {
    if (TriggeredEnemy == true) {
        if (SonRoomArea.contains("Player") == true) {
            AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 5, "");
        } else if (DadRoomArea.contains("Player") == true) {
            AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 5, "");
        }
    }
    return 500;
}*/



RE: AddEntityCollideCallback - eagledude4 - 01-03-2012

(01-02-2012, 07:08 AM)Statyk Wrote: It makes the screen black instantly. That's actually a good teting idea. see, if a function isn't working, a visual like THAT would easily tell you if something is wrong with a specific function, or if it is working fine but has a typo somewhere, etc. Understand?

Indeed, I do. I've done similar things in the past with other scripting applications.
I tested the map again, but the screen didn't go black when I opened the chest.

Full code:
Code:
bool TriggeredEnemy;

void OnStart() {
    if (ScriptDebugOn()) {
        GiveItemFromFile("lantern", "lantern.ent");
        for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");
        /*SetEntityActive("invisWall", false);
        SetEntityActive("blockArea", false);*/
    }
    //SetPlayerActive(false);
    AddNote("First", "");
    AddTimer("FadeTimer", 5, "StartGame");
    AddEntityCollideCallback("Player", "EnemyTriggerArea", "EnteredEnemyTriggerArea", true, 1);
    AddEntityCollideCallback("Player", "BlockArea", "EnteredBlockArea", true, 1);
    SetEntityCallbackFunc("chest_small_2", "TriggerSpider");
    PlaySoundAtEntity("big_clock_chime", "Custom\big_clock_chime.snt", "clock_grandfather_1", 0, false);
    SetDeathHint("Death", "StairScare");
    SetEntityCallbackFunc("key_1", "OnPickup");
}

void OnEnter() {
}

void OnLeave() {
}

void StartGame() {
    FadeIn(5);
    SetPlayerActive(true);
}
    
void EnteredEnemyTriggerArea(string &in asParent, string &in asChild, int alState) {
    SetEntityActive("servant_grunt_1", true);
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_1", 0, "");
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_2", 0, "");
    if(GetEntitiesCollide("Player", "SonRoomArea") == true) {
        AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_4", 5, "");
    } else if(GetEntitiesCollide("Player", "DadRoomArea") == true) {
        AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_5", 5, "");
    }
    AddEnemyPatrolNode("servant_grunt_1", "PathNodeArea_3", 0, "");
    
}

void EnteredBlockArea(string &in asParent, string &in asChild, int alState) {
    if (HasItem("key_1") == false) {
        SetMessage("CustomStory", "Barrier", 6);
    }
}

void OnPickup(string &in asEntity, string &in type) {
    SetEntityActive("invisWall", false);
    SetEntityActive("blockArea", false);
}

void TriggerSpider(string &in asParent, string &in asChild, int alState) {
    SetEntityActive("spider_1", true);
    FadeOut(0);
}


Help please?



RE: AddEntityCollideCallback - flamez3 - 01-03-2012

Your using the wrong syntax, use this
(string &in asEntity, string &in type)


You should check http://wiki.frictionalgames.com/hpl2/amnesia/script_functions for help with syntaxes and functions.


RE: AddEntityCollideCallback - eagledude4 - 01-03-2012

(01-03-2012, 12:44 AM)flamez3 Wrote: Your using the wrong syntax, use this
(string &in asEntity, string &in type)


You should check http://wiki.frictionalgames.com/hpl2/amnesia/script_functions for help with syntaxes and functions.

I've been using that. I didn't realize I can't rename the functions. Whats the type for opening a chest? onInteract?





RE: AddEntityCollideCallback - flamez3 - 01-03-2012

SetEntityPlayerInteractCallback(string& asName, string& asCallback, bool abRemoveOnInteraction);
Syntax: (string &in asEntity)


Quote:void OnStart()
{
SetEntityPlayerInteractCallback("chest", "TriggerSpider", true);
}
void TriggerSpider(string &in asEntity)
{
SetEntityActive("spider_1", true);
FadeOut(0);
}



RE: AddEntityCollideCallback - eagledude4 - 01-03-2012

I thought
Code:
void SetEntityCallbackFunc

and

Code:
void SetEntityPlayerInteractCallback

had the same effect? They're both described as "Calls a function when the player interacts with a certain entity."

I replaced my code with what you just quoted, and it isn't working.




RE: AddEntityCollideCallback - Statyk - 01-03-2012

Please make sure there are no typos in the level.... That's usually the highest percentage of the "issue list".


RE: AddEntityCollideCallback - eagledude4 - 01-03-2012

(01-03-2012, 03:42 AM)Statyk Wrote: Please make sure there are no typos in the level.... That's usually the highest percentage of the "issue list".

Yep, typo. Thanks. Spider doesn't want to move though.
Why did "SetEntityPlayerInteractCallback" work while "SetEntityCallbackFunc" did not? The wiki says the serve the same purpose.




RE: AddEntityCollideCallback - flamez3 - 01-03-2012

SetEntityCallbackFunc(string& asName, string& asCallback);
Calls a function when the player interacts with a certain entity.
Callback syntax: void MyFunc(string &in asEntity, string &in type)
Type depends on entity type and includes: “OnPickup”, “Break”, “OnIgnite”, etc
Last line is why I think.



RE: AddEntityCollideCallback - eagledude4 - 01-03-2012

Ah, I see. Any reason why the spider doesn't move though?