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 Inverted Controls
MrBehemoth Offline
Senior Member

Posts: 408
Threads: 19
Joined: Feb 2014
Reputation: 40
#3
RE: Inverted Controls

I think Viper is right.

...But I can't resist a scripting challenge! I'm guessing you're going for a drunk/drugged effect. I have an idea that you could do with the 1.3 patch, although it would be clunky and not quite what you're after, but interesting to experiment with...

Spoiler below!

This is just an idea - not tested, not guaranteeing it will work without tweaks, or work at all.

PHP Code: (Select All)
void DrunkMode_Start()
{
    
SetPlayerLookSpeedMul(-1);
    
FadePlayerFOVMulTo(1.75f5.0f);
    
PlayGuiSound("27_thump"1.0f);
    
AddTimer("DrunkModeTimer"RandFloat(0.5f2.0f), "DrunkMode_Reset");
}

void DrunkMode_Stop()
{
    
FadePlayerFOVMulTo(1.0f2.0f);
    
RemoveTimer("DrunkModeTimer");
}

void DrunkMode_Reset(string &in asTimer)
{
    
SetGlobalVarFloat("PlayerPrevX"GetPlayerPosX());
    
SetGlobalVarFloat("PlayerPrevZ"GetPlayerPosZ());
    
AddTimer("DrunkModeTimer"0.1f"DrunkMode_Detect");
}

void DrunkMode_Detect(string &in asParentstring &in asChildint alState)
{
    if(
GetGlobalVarFloat("PlayerPrevX") > GetPlayerPosX())
    {
        
AddPlayerBodyForce(RandFloat(-10000.0f, -6000.0f), 0.0f0.0ffalse);
    }
    else if(
GetGlobalVarFloat("PlayerPrevX") < GetPlayerPosX())
    {
        
AddPlayerBodyForce(RandFloat(10000.0f6000.0f), 0.0f0.0ffalse);
    }
    
    if(
GetGlobalVarFloat("PlayerPrevZ") > GetPlayerPosZ())
    {
        
AddPlayerBodyForce(0.0f0.0fRandFloat(-10000.0f, -6000.0f), false);
    }
    else if(
GetGlobalVarFloat("PlayerPrevZ") < GetPlayerPosZ())
    {
        
AddPlayerBodyForce(0.0f0.0fRandFloat(10000.0f6000.0f), false);
    }
    
    
AddTimer("DrunkModeTimer"RandFloat(0.5f2.0f), "DrunkMode_Reset");


So, to switch it on you call DrunkMode_Start() and that does your visual effects and whatever, then kicks off DrunkMode_Reset() after a random interval.

DrunkMode_Reset() stores the current player x and z as globals, then calls DrunkMode_Detect() after 0.1s.

DrunkMode_Detect() compares the globals to the new current player x and z to check if the player has moved in the last 0.1s, and then applies a force in the oppposite direction.

DrunkMode_Stop() switches it all off.

In other words, while drunk mode is active, every 0.5 - 2.5s, if the player moves, they will be shoved in the opposite direction. Like I said, I've not tested it, but I think this will give a nice stumbling effect, depending on how you tweak the forces.

Also, did you know that if FOV < 0 then it will flip the screen?


10-07-2014, 01:17 AM
Find


Messages In This Thread
Inverted Controls - by Neelke - 10-06-2014, 09:55 PM
RE: Inverted Controls - by Viper85626 - 10-06-2014, 10:31 PM
RE: Inverted Controls - by MrBehemoth - 10-07-2014, 01:17 AM
RE: Inverted Controls - by Neelke - 10-07-2014, 07:54 AM
RE: Inverted Controls - by Neelke - 10-07-2014, 07:51 PM
RE: Inverted Controls - by Mudbill - 10-07-2014, 10:44 PM
RE: Inverted Controls - by MrBehemoth - 10-08-2014, 07:33 AM
RE: Inverted Controls - by Neelke - 10-08-2014, 07:39 AM
RE: Inverted Controls - by Viper85626 - 10-08-2014, 03:44 PM
RE: Inverted Controls - by Neelke - 10-08-2014, 03:55 PM
RE: Inverted Controls - by FlawlessHappiness - 10-08-2014, 04:31 PM
RE: Inverted Controls - by MrBehemoth - 10-08-2014, 06:53 PM
RE: Inverted Controls - by Neelke - 10-08-2014, 09:12 PM



Users browsing this thread: 3 Guest(s)