Frictional Games Forum (read-only)
Some scripting help here please :) - 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: Some scripting help here please :) (/thread-11683.html)



Some scripting help here please :) - Gyldenglad - 12-05-2011

Hello forum

I'm pretty new to the mods and stuff, I find scripting especially hard because of my limited C++ knowledge. I managed to make key work on doors so far Big Grin

However, I have some ideas, and I hope you can help me make a script that will help me making my map good Smile.


I'm currently looking for a script(s) that can do the following:
---
Scenario:
Imagine you walk down a corridor, there's some distant lights, the corridor is very slim so you can only walk in a straight line. You can see something approaching you.. It's a barrel, rolling towards you. You will eventually "meet" with this barrel, but before this happens, the barrel explodes and a naked dead guy jumps out in your face. *scare* (if it works Smile )

I was thinking of making a script working this way:

- Player enters area1, starts the trigger:
* spawn entity barrel at area2
* push barrel in x direction?


- Player and barrel are within distance xy
* destroy barrel (sound etc, wood flying around, maybe some smoke)
* spawn entity naked guy & push him towards the player

---
This is what I made so far:

void OnStart()
{
AddEntityCollideCallback("Player", "barrelarea", "barrelpush", true, 1);
AddEntityCollideCallback("barrel_1", "barrelbangarea", "barrelscare", true, 1);
}


void barrelpush(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates)
{
AddPropForce("barrel_1", 0, 0, 20000, "world");
}

void barrelscare(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates)
{
PlaySoundAtEntity("", "lurker_hit_wood.snt","barrel_1", 0, false);
CreateParticleSystemAtEntity("", "ps_break_wood.ps", "barrel_1", true);
SetEntityActive("barrel_1", false);
SetEntityActive("nakedguy", true);
AddPropForce("nakedguy", 0, 0, 5000, "world");
}


Please help me Big Grin


RE: Some scripting help here please :) - phatdoggi - 06-03-2013

Check dem comments

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "barrelarea", "barrelpush", true, 1);
AddEntityCollideCallback("barrel_1", "barrelbangarea", "barrelscare", true, 1);
}

// Maybe it's just me, but aren't the parameters "string &in asParent, string &in asChild, int alState" for an entity collide callback? for your barrelpush and barrelscare functions

void barrelpush(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates)
{
    //Your barrel is going to move pretty freakin fast. Do you want it to roll or teleport at the speed of light? Make sure your force is directed towards the correct axis just in case
        AddPropForce("barrel_1", 0, 0, 20000, "world");
}

void barrelscare(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates)
{
        PlaySoundAtEntity("", "lurker_hit_wood.snt","barrel_1", 0, false);
        CreateParticleSystemAtEntity("", "ps_break_wood.ps", "barrel_1", true);
        SetEntityActive("barrel_1", false);
        SetEntityActive("nakedguy", true);

        // again, make sure you have the force amount and the direction figured out and you're good :D
        AddPropForce("nakedguy", 0, 0, 5000, "world");

        //Play a screaming sound or something for added effect :)
}



RE: Some scripting help here please :) - PutraenusAlivius - 06-04-2013

(06-03-2013, 09:37 PM)phatdoggi Wrote: Check dem comments

Code:
void OnStart()
{
AddEntityCollideCallback("Player", "barrelarea", "barrelpush", true, 1);
AddEntityCollideCallback("barrel_1", "barrelbangarea", "barrelscare", true, 1);
}

// Maybe it's just me, but aren't the parameters "string &in asParent, string &in asChild, int alState" for an entity collide callback? for your barrelpush and barrelscare functions

void barrelpush(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates)
{
    //Your barrel is going to move pretty freakin fast. Do you want it to roll or teleport at the speed of light? Make sure your force is directed towards the correct axis just in case
        AddPropForce("barrel_1", 0, 0, 20000, "world");
}

void barrelscare(string& asParentName, string& asChildName, string& asFunction, bool abDeleteOnCollide, int alStates)
{
        PlaySoundAtEntity("", "lurker_hit_wood.snt","barrel_1", 0, false);
        CreateParticleSystemAtEntity("", "ps_break_wood.ps", "barrel_1", true);
        SetEntityActive("barrel_1", false);
        SetEntityActive("nakedguy", true);

        // again, make sure you have the force amount and the direction figured out and you're good :D
        AddPropForce("nakedguy", 0, 0, 5000, "world");

        //Play a screaming sound or something for added effect :)
}

u chek pos dat plz