Frictional Games Forum (read-only)
Script/area problem. - 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: Script/area problem. (/thread-19845.html)

Pages: 1 2


RE: Script/area problem. - TheGreatCthulhu - 01-07-2013

Are you sure there isn't a bug in the script itself? The fact that AddPropForce() works only means that OnStart() get's called, it doesn't tell you anything about the other functions. There could be other subtle errors.

For example, here:
PHP Code:
AddEntityCollideCallback("Player""area""cake"false0); 

Are you sure that the first script area is named "area" in the editor?

You can use AddDebugMessage() to check which functions get called when. If a callback should be called but isn't, then it means that it wasn't hooked up correctly. Something along these lines:

PHP Code:
// Debugging using AddDebugMessage()

void OnStart()
{
    
AddDebugMessage("In OnStart()."false);   // The message will be displayed in the lower left corner
   
    
AddPropForce ("rope_beam02_Body_1"50000"world");  
    
PlayMusic("12_amb.ogg"true0.811true);   
    
AddEntityCollideCallback("Player""area""cake"false0);
}

void cake(string &in asParentstring &in asChildint alState)
{
    
AddDebugMessage("In cake()."false);

    
SetEntityActive("suitor"true);   
    
AddEnemyPatrolNode("suitor""PathNode1"0"");   
    
AddEnemyPatrolNode("suitor""PathNode2"0""); 
    
AddEntityCollideCallback("suitor""ScriptArea_1""cake1"false1);
}

void cake1(string &in asParentstring &in asChildint alState)
{
    
AddDebugMessage("In cake1()."false);
    
SetEntityActive("suitor"false);




RE: Script/area problem. - The chaser - 01-07-2013

Delete map_cache if there is.


RE: Script/area problem. - TheGreatCthulhu - 01-07-2013

(01-07-2013, 02:46 PM)Robosprog Wrote: I did not notice a debug message at any rate, when running through the area, so that means that it is being called, yes?

For a function, if the corresponding message was shown (each should be different, so that you can tell which one is it), then yes.

(01-07-2013, 02:46 PM)Robosprog Wrote: Done that, noticed it after second test but it still doesn't work.

Hm... If all checks out, then I'm not sure what's going on. Gotta go now, but I'm going to try and test the code later on, if the issue isn't resolved. For now, when you say it doesn't work, you mean that everything compiles, no errors are shown, but enemy doesn't patrol the area? What exactly happens, and what did you expect to happen?

Also, do you happen to use CreateEntityAtArea() anywhere in the script file (in parts not shown here, if any)? It says in the wiki:
Quote:When creating an enemy [using this function], it cannot chase properly along PathNodes(using for example ShowEnemyPlayerPosition).



RE: Script/area problem. - FlawlessHappiness - 01-07-2013

Have you been to the properties of the area and unchecked "AutoRemoveAtLookAt" or something like that?


RE: Script/area problem. - Adrianis - 01-07-2013

Does the enemy appear, and not walk along the path, or does the enemy just not appear at all?


RE: Script/area problem. - NaxEla - 01-07-2013

Try
PHP Code:
AddEntityCollideCallback("Player""area""cake"true1); 



RE: Script/area problem. - FlawlessHappiness - 01-07-2013

(01-07-2013, 04:08 PM)NaxEla Wrote: Try
PHP Code:
AddEntityCollideCallback("Player""area""cake"true1); 

That shouldn't change anything.
What you change there is that the scripts isn't able to call again, and only calls when the player enters the area.
Though it's a little strange to have it set to "...false, 0);"


RE: Script/area problem. - TheGreatCthulhu - 01-07-2013

Another guess at what could be happening - if you add code to the script file and just hit "Quick Reload", only OnEnter() is called, if it exists, and OnStart() is not. OnStart() is only called when the player enters the map for the first time, or during development, only on full reload.

If the handler assignment code was added to preexisting code after you started the map (which would explain why rope swinging works), but you've only used quick reload, the updated OnStart() function is never called, so the cake() callback is never hooked up.


Edit: Apparently, that's not the case. Both OnStart() and OnEnter() get called on quick reload... God dammit. XD

P.S.
(01-07-2013, 05:03 PM)beecake Wrote: Though it's a little strange to have it set to "...false, 0);"
Nah. It may not be used so often, but it isn't strange if the collision needs to be detected only once.


RE: Script/area problem. - FlawlessHappiness - 01-07-2013

(01-07-2013, 06:35 PM)TheGreatCthulhu Wrote:
(01-07-2013, 05:03 PM)beecake Wrote: Though it's a little strange to have it set to "...false, 0);"
Nah. It may not be used so often, but it isn't strange if the collision needs to be detected only once.

But if the detection should be only once then it should be true, and not false.

If it's false the monster will keep being set active, and be assigned patrol nodes everytime the function calls, and that's at least 2 times since the next value is 0


RE: Script/area problem. - TheGreatCthulhu - 01-07-2013

Oh, sry - you are correct; I completely misread that code snippet. Didn't even notice the value of the last param.