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 Player Run Into Door, Explosion
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#1
Player Run Into Door, Explosion

Hey forum.

Wondering if this were possible. I have an idea of how to script it, just not sure what to use.

I'm trying to allow Player to ram himself into a locked door which is loose by the hinges to cause it to explode off.

Currently, I am using AddEntityCollideCallback to have the player run into a script box that is close to the door that/for

1) To activate the unlock sequence
2) the explosion sequence
3) If player is running.

Going through the script functions page I found at first look, there is nothing of total use.


Here is what I have thus far::

void OnStart()
{

AddEntityCollideCallback("Player", "script3", "door", true, 1);

}

//then following...

void door(string &in asParent, string &in asChild, int alState)
{
//Add if Player is running here
CreateParticleSystemAtEntity("", "ps_impact_dust_low.ps", "script3", false);
SetPropHealth("prison_1", 0.0f);
SetSwingDoorLocked("prison_1", false, true);

}

This is all fine and dandy, it works, but, I want this to happen IF player is running.

I can't seem to find the right function to call for that if statement.

Can you guys help me out?
03-30-2013, 05:39 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#2
RE: Player Run Into Door, Explosion

You can create a condition.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-30-2013, 06:48 AM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#3
RE: Player Run Into Door, Explosion

There's a function called GetPlayerSpeed() that will return the players' speed.
PHP Code: (Select All)
void door(string &in asParentstring &in asChildint alState
{
    if(
GetPlayerSpeed() > 10.0f) {   // you'll probably need to change 10 to a different number
        
CreateParticleSystemAtEntity("""ps_impact_dust_low.ps""script3"false);
        
SetPropHealth("prison_1"0.0f);
        
SetSwingDoorLocked("prison_1"falsetrue);
    }


I'm not sure if a speed over 10 is running, so you'll need to do some testing to find the right number.

In Ruins [WIP]
03-30-2013, 07:42 AM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#4
RE: Player Run Into Door, Explosion

(03-30-2013, 06:48 AM)JustAnotherPlayer Wrote: You can create a condition.

Right, but could you recommend a function to use?

I understand that a condition needs to be inserted, like

if(insertcondition() = true)

//then

door unlocks.

But I'm not too sure which function to use.

EDIT 1: Thanks NaxEla, I will try that.
(This post was last modified: 03-30-2013, 07:44 AM by TheIcyPickle.)
03-30-2013, 07:43 AM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#5
RE: Player Run Into Door, Explosion

Huh, I'm getting somewhere. If you put in 2.5f in place of the code, it breaks walking. 2.51f, it doent break walking or running. What is the appropriate number?

Do I have to keep doing up by .001 now?

Or is there some other way?

Thanks for the feedback so far btw Smile

EDIT 1: It appears 2.5000000000001f allows walking to work still. Take away a 0 and it doesn't work walking.
This is rather weird.
(This post was last modified: 03-30-2013, 09:12 AM by TheIcyPickle.)
03-30-2013, 09:01 AM
Find
NaxEla Offline
Senior Member

Posts: 415
Threads: 5
Joined: Dec 2012
Reputation: 28
#6
RE: Player Run Into Door, Explosion

I did some testing, and 2.75 works perfectly for me.

In Ruins [WIP]
03-30-2013, 09:19 AM
Find
TheIcyPickle Offline
Member

Posts: 80
Threads: 16
Joined: Feb 2011
Reputation: 0
#7
RE: Player Run Into Door, Explosion

Ah, I think I see the problem. It appears that when I pass it walking, just to test, the if statement is terminated. It did not meet the criteria, and the script box is not of use anymore.

How would one go about re-looping I would guess the void door statement again?

Or was what I said complete garbage? haha

EDIT 1: AH HA!

AddEntityCollideCallback("Player", "script3", "door", false, 1);


Thats it.

Thanks for the help everyone!
(This post was last modified: 03-30-2013, 09:46 AM by TheIcyPickle.)
03-30-2013, 09:32 AM
Find
PutraenusAlivius Offline
Posting Freak

Posts: 4,713
Threads: 75
Joined: Dec 2012
Reputation: 119
#8
RE: Player Run Into Door, Explosion

(03-30-2013, 07:42 AM)NaxEla Wrote: There's a function called GetPlayerSpeed() that will return the players' speed.
PHP Code: (Select All)
void door(string &in asParentstring &in asChildint alState
{
    if(
GetPlayerSpeed() > 10.0f) {   // you'll probably need to change 10 to a different number
        
CreateParticleSystemAtEntity("""ps_impact_dust_low.ps""script3"false);
        
SetPropHealth("prison_1"0.0f);
        
SetSwingDoorLocked("prison_1"falsetrue);
    }


I'm not sure if a speed over 10 is running, so you'll need to do some testing to find the right number.

There is? Where is it? I can't see them in the Script Functions page.

"Veni, vidi, vici."
"I came, I saw, I conquered."
03-30-2013, 11:30 AM
Find
FlawlessHappiness Offline
Posting Freak

Posts: 3,980
Threads: 145
Joined: Mar 2012
Reputation: 171
#9
RE: Player Run Into Door, Explosion

[Image: 2luvy46.png]
Ctrl+F my dear friend

Trying is the first step to success.
03-30-2013, 12:35 PM
Find
WALP Offline
Posting Freak

Posts: 1,221
Threads: 34
Joined: Aug 2012
Reputation: 45
#10
RE: Player Run Into Door, Explosion

(03-30-2013, 12:35 PM)BeeKayK Wrote: [Image: 2luvy46.png]
Ctrl+F my dear friend

wow did not know my browser could do that
03-30-2013, 01:54 PM
Find




Users browsing this thread: 2 Guest(s)