Frictional Games Forum (read-only)
Scripting n00b in need of help. - 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: Scripting n00b in need of help. (/thread-5425.html)

Pages: 1 2 3


RE: Scripting n00b in need of help. - Chilton - 11-13-2010

(11-13-2010, 03:30 PM)Akumasama Wrote: So the function that you create with one of the functions in the list, has a standard syntax?
Code:
(string &in asParent, string &in asChild, int alState)

If so, then I think I'm beginning to understand how this scripting works alot better.

Also, you don't particularly need the onEnter, onStart and onLeave.
You only put those in when you want something to happen at start, enter area or leave area.
Close - You need OnEnter, OnStart and OnLeave for the map to load up in the first place :p
Or OnEnter at least, as its the default initialiser.
Im just going to actually write a hypothetical script using the previously mentioned basis to ensure we're on the same page

void OnStart()
{
AddEntityCollideCallback("Player", "Origin", "scareactivate", true, 1);
}

void scareactivate(string &in asParent, string &in asChild, int alState)
{
void ChangeMap("Map2", "Player_Start_Area_1", "", "");
}

Thats purely an example, and wouldnt work unless you had a map named Map2, and a spawn called Player_Start_Area_1

Best of luck, feel free to post or PM any further questions


RE: Scripting n00b in need of help. - Akumasama - 11-13-2010

Thanks Chilton, Cellrage and Gamekingdude.

I'll post on this topic again should I have another problem.


RE: Scripting n00b in need of help. - anzki - 11-13-2010

And also you don't need to have OnStart, OnEnter and OnLeave!


RE: Scripting n00b in need of help. - Frontcannon - 11-13-2010

You don't even need a .hps to load a map.


RE: Scripting n00b in need of help. - Akumasama - 11-13-2010

Yep, you don't need a .hps file to load a file.
I ran my map quite a few times without the hps.

The only thing you need, is a config file at the root of your story, and a map.
Okay, sorry for double post, but I thought it wouldn't get "bumped" to the top again and get unseen messages Tongue

I can't find a proper Script Function to give a door a small push so it opens a bit.

Code:
void OnStart()
{  
   GiveItemFromFile("lantern", "lantern.ent");

   for(int i=0;i<10;i++) GiveItemFromFile("tinderbox_"+i, "tinderbox.ent");

AddEntityCollideCallback("Player", "scaretrigger", "scareactivate", true, 1);
SetEntityCallbackFunc("lantern", "lanterndooractivate");
}

void scareactivate(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("scaremonster", true);
AddEnemyPatrolNode("scaremonster", "scaremonsterpath1", 0, "");
}

void lanterndooractivate(string &in entity, string &in type)
{
SetSwingDoorLocked("doorlantern", false, false);
HERE MUST GO THE CODE FOR THE PUSH!
}

I've tested if the trigger worked, and the door did unlock.
So it only has to get a little push now.

I tried "RotatePropToSpeed", but it makes the door ummm... well float and unable to be used.


RE: Scripting n00b in need of help. - Frontcannon - 11-13-2010

I'd go with AddPropForce here, and use SetSwingDoorDisableAutoclose so it doesn't 'stick' to being close.


RE: Scripting n00b in need of help. - Akumasama - 11-13-2010

I've seen that one too, but I'm not sure what I would do with asCoordSystem?


RE: Scripting n00b in need of help. - Frontcannon - 11-13-2010

Use either "World" or just "", it's not really important.


RE: Scripting n00b in need of help. - Akumasama - 11-13-2010

(11-13-2010, 10:05 PM)Frontcannon Wrote: Use either "World" or just "", it's not really important.

Okay thanks!


RE: Scripting n00b in need of help. - Akumasama - 11-14-2010

Well that didn't quite work...

Code:
SetSwingDoorLocked("doorlantern", false, false);
AddPropForce("doorlantern", 1, 1, 1, "");
Thats what I have at the moment...
I have also tried "World" instead of "".
Also tried different values at the coordinates.

I have also tried SetSwingDoorClosed("doorlantern", false, false).
It didn't work.
This is used by the Frictional Games, as far as I've seen.

Code:
void OnStart()
{  
AddEntityCollideCallback("Player", "scaretrigger", "scareactivate", true, 1);
SetEntityCallbackFunc("lantern", "lanterndooractivate");
SetSwingDoorDisableAutoClose("doorlantern", true);
}

void scareactivate(string &in asParent, string &in asChild, int alState)
{
SetEntityActive("scaremonster", true);
AddEnemyPatrolNode("scaremonster", "scaremonsterpath1", 0, "");
}

void lanterndooractivate(string &in entity, string &in type)
{
SetSwingDoorLocked("doorlantern", false, false);
AddPropForce("doorlantern", 1, 1, 1, "World");
}

Just posting this too if it helps.

EDIT: I noticed that the door only unlocks, but still auto-closes...
That's kinda vague if you ask me.
Does anyone know what could be it? :/