Frictional Games Forum (read-only)
[SCRIPT] (Solved) GetPropIsInteractedWith 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: [SCRIPT] (Solved) GetPropIsInteractedWith not working? (/thread-30422.html)

Pages: 1 2


(Solved) GetPropIsInteractedWith not working? - Neelke - 08-21-2015

No matter what I do with this function it cannot properly work at all. It literally doesn't do what I tell it to do.

Code:
float Time = (1.05f - GetTimerTimeLeft("ImpactTime")); // Get's the time taken to impact
float Speed = (Distance / Time); // Gets the speed
    
    if(Speed >= 0.25f && GetPropIsInteractedWith(asParent)) // Minimum necessary speed (don't want this to happen if the rock is hold)
    {
        PlayMusic("17_paper_herbert01.ogg", false, 0.7f, 0, 10, false);
        CompleteQuest("MainVaultDoorsClosed", "MainVaultDoorsClosed");
        SetEntityActive("shovel_joint_1", false); //Prepare new shovel
        SetEntityActive("shovel_joint_2", true);
        ShovelImpulse();
        
        SetMoveObjectStateExt("slide_doo_thick_1", -0.5f, 1.0f, 1.0f, 0.0f, true);
        SetMoveObjectStateExt("slide_doo_thick_2", 0.5f, 1.0f, 1.0f, 0.0f, true);
        
        SetEntityActive("AreaRockOnShovel", false);
        SetEntityActive("AreaRockOnShovel_1", false);
        SetEntityActive("AreaRockTooFarIn", false);
        SetEntityActive("AreaLeftSide", false);
        SetEntityActive("AreaRightSide", false);
        
        SetEntityActive("AreaInteractDoors", false);
    }
    else
    {
        SetMessage("Ch04Level21", "ThrownHarder", 0);
    }

Is this a bug or am I just not using it correctly?


RE: GetPropIsInteractedWith not working? - Mudbill - 08-21-2015

Which item are you using for this? A shovel joint?


RE: GetPropIsInteractedWith not working? - Neelke - 08-21-2015

The entity which represents asParent is the stone_small01.ent simply named "stone". You're normally meant to throw this onto the edge of the shovel joint, but its possible to get the same effect by simply running into the shovel while holding the stone. So I'm trying to get this implemented and working, but it does not work.


RE: GetPropIsInteractedWith not working? - Daemian - 08-21-2015

where's Distance declared?
Debug it all, check each value. I'd start with this:
PHP Code:
(Speed >= 0.25f && GetPropIsInteractedWith(asParent)) 
Try without those conditions. If it works, try using the conditions separated, like:
PHP Code:
boolean a = (Speed >= 0.5f);
boolean b = (GetPropIsInteractedWith(asParent));

if ( 
&& ) { playmusic... } 



RE: GetPropIsInteractedWith not working? - Neelke - 08-21-2015

(08-21-2015, 06:18 PM)Daemian Wrote: where's Distance declared?
Debug it all, check each value. I'd start with this:
PHP Code:
(Speed >= 0.25f && GetPropIsInteractedWith(asParent)) 
Try without those conditions. If it works, try using the conditions separated, like:
PHP Code:
boolean a = (Speed >= 0.5f);
boolean b = (GetPropIsInteractedWith(asParent));

if ( 
&& ) { playmusic... } 

Nope, did not work. The same thing happens. I might as well send the entire script of how it looks like atm.

Code:
float Distance = 0.015f;

void Impact1(string &in asParent , string &in asChild , int alState)
{
    AddTimer("ImpactTime" , 1.0f , "HitTime"); // This doesnt need to call anything
}

void Impact2(string &in asParent, string &in asChild, int alState)
{
    float Time = (1.05f - GetTimerTimeLeft("ImpactTime")); // Get's the time taken to impact
    float Speed = (Distance / Time); // Gets the speed
    
    bool a = (Speed >= 0.25f);
    bool b = (GetPropIsInteractedWith(asParent));
    
    if(a && b) // Minimum necessary speed (don't want this to happen if the rock is hold)
    {
        PlayMusic("17_paper_herbert01.ogg", false, 0.7f, 0, 10, false);
        CompleteQuest("MainVaultDoorsClosed", "MainVaultDoorsClosed");
        SetEntityActive("shovel_joint_1", false); //Prepare new shovel
        SetEntityActive("shovel_joint_2", true);
        ShovelImpulse();
        
        SetMoveObjectStateExt("slide_doo_thick_1", -0.5f, 1.0f, 1.0f, 0.0f, true);
        SetMoveObjectStateExt("slide_doo_thick_2", 0.5f, 1.0f, 1.0f, 0.0f, true);
        
        SetEntityActive("AreaRockOnShovel", false);
        SetEntityActive("AreaRockOnShovel_1", false);
        SetEntityActive("AreaRockTooFarIn", false);
        SetEntityActive("AreaLeftSide", false);
        SetEntityActive("AreaRightSide", false);
        
        SetEntityActive("AreaInteractDoors", false);
    }
    else
    {
        SetMessage("Ch04Level21", "ThrownHarder", 0);
        AddDebugMessage("Stone too lazy thrown or interacted!", false);
    }
}

I think I'm able to change the script so you have to check where the player is located so you cannot stand infront of the shovel and throw it. But I'd rather wanna know if this function is impossible to use or not.


RE: (Kinda Solved) GetPropIsInteractedWith not working? - Neelke - 08-21-2015

So I kinda half fixed it by instead checking where the player is. If player stands too close to the shovel, it's impossible to create the event. If you stand far away it will work. Thanks for the help guys anyway.


RE: (Kinda Solved) GetPropIsInteractedWith not working? - FlawlessHappiness - 08-21-2015

Shouldn't you be checking if it is true/false?

Or is there a default, like if you don't specify it, it's just checking for true?


RE: (Kinda Solved) GetPropIsInteractedWith not working? - Neelke - 08-21-2015

You can modify it for true or false. If you simply leave it like I've done it, it's automatically set to true. You can change it to false by adding a ! at the start.

Code:
if(!GetPropIsInteractedWith(asParent))

But like I've mentioned previously, its pretty much been refusing to function properly. Can't tell if there's something I'm doing wrong or if its simply the function thats just plain broken like AddAttachedPropToProp.

And yes I could add == true and such, but hey this method saves some space Tongue


RE: (Kinda Solved) GetPropIsInteractedWith not working? - FlawlessHappiness - 08-21-2015

Have you tried a simple timer, refiring itself, and adding a debugmessage if a prop is interacted with, just to make sure it actually works?


RE: (Kinda Solved) GetPropIsInteractedWith not working? - Neelke - 08-21-2015

Yeah, good idea. I'll update this comment after I've attempted it.

Ok, that actually did work. The debug message changed when its interacted with now. But I don't understand why the if-statement in the collide function did not work.

I think I solved it, but I had to do it in a method I didn't expect to use. I need to start a timer when entering the map constantly repeating and telling if stone is interacted, setting up an int variable.

Code:
int iInteractStoneIndex = 0;
void TimerUpdateInteraction(string &in asTimer)
{
    if(!GetPropIsInteractedWith("stone")) iInteractStoneIndex = 0;
    else iInteractStoneIndex = 1;
    
    AddTimer("loop", 0.0166f, "TimerUpdateInteraction");
}

And then I just use the variable in the if-statement.

Code:
if(Speed >= 0.2f && iInteractStoneIndex == 0)

Thanks alot Flawless for telling me to experiment with a timer Tongue