Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Script Help (Solved) GetPropIsInteractedWith not working?
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#1
(Solved) GetPropIsInteractedWith not working?

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.

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?

Derp.
(This post was last modified: 08-22-2015, 12:11 AM by Neelke.)
08-21-2015, 04:02 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: GetPropIsInteractedWith not working?

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

08-21-2015, 05:26 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#3
RE: GetPropIsInteractedWith not working?

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.

Derp.
08-21-2015, 05:30 PM
Find
Daemian Offline
Posting Freak

Posts: 1,129
Threads: 42
Joined: Dec 2012
Reputation: 49
#4
RE: GetPropIsInteractedWith not working?

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

if ( 
&& ) { playmusic... } 

08-21-2015, 06:18 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#5
RE: GetPropIsInteractedWith not working?

(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: (Select All)
(Speed >= 0.25f && GetPropIsInteractedWith(asParent)) 
Try without those conditions. If it works, try using the conditions separated, like:
PHP Code: (Select All)
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.

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.

Derp.
(This post was last modified: 08-21-2015, 07:06 PM by Neelke.)
08-21-2015, 07:06 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#6
RE: (Kinda Solved) GetPropIsInteractedWith not working?

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.

Derp.
(This post was last modified: 08-21-2015, 08:08 PM by Neelke.)
08-21-2015, 08:07 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#7
RE: (Kinda Solved) GetPropIsInteractedWith not working?

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?

Trying is the first step to success.
08-21-2015, 11:11 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#8
RE: (Kinda Solved) GetPropIsInteractedWith not working?

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.

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

Derp.
(This post was last modified: 08-21-2015, 11:25 PM by Neelke.)
08-21-2015, 11:24 PM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: (Kinda Solved) GetPropIsInteractedWith not working?

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?

Trying is the first step to success.
08-21-2015, 11:53 PM
Find
Neelke Offline
Senior Member

Posts: 668
Threads: 82
Joined: Apr 2013
Reputation: 26
#10
RE: (Kinda Solved) GetPropIsInteractedWith not working?

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.

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.

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

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

Derp.
(This post was last modified: 08-22-2015, 12:10 AM by Neelke.)
08-21-2015, 11:54 PM
Find




Users browsing this thread: 2 Guest(s)