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


Thread Rating:
  • 16 Vote(s) - 4.44 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Scripts Recollection
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#31
RE: Scripts Recollection

The basic structure of a puzzle is having an item the player has to find and an area it is applied on. This could either lead to the solution of the puzzle or changing / improving the puzzle item in some way that leads to the solution.

Some examples:

Lever puzzles. These involve mostly some special combination to enable the player to advance (unlock a door, cut off steam flow). Unless the combination bases on a mathematical formula or the player has an effective hint, these become very boring after a short time. Can also work with candles and other things.

Physics-based puzzles. Most fun and logical for the player. Very difficult to pull off though, as they need custom animation / models / particles etc.
One simple way of making these is making something fall down off something.

Item-based puzzles. Basically cover the whole rest. The player needs an item which has to be improved in some way sometimes, or he has to combine several items to solve the puzzle. Examples include a key and a locked door, the padlock puzzle in Frictional's prison, gathering ingredients for a special mixture (or spare parts for repairing something) and many more.


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
01-03-2011, 04:36 PM
Find
Equil Offline
Member

Posts: 94
Threads: 8
Joined: Sep 2010
Reputation: 0
#32
RE: Scripts Recollection

I see, this is very helpful, thank you. How difficult would the lever puzzles/Item puzzles be to script though? Which functions would I be needing to use? Pardon me if I'm hi-jacking the thread here.
01-03-2011, 04:45 PM
Find
DIGI Byte Offline
Senior Member

Posts: 376
Threads: 20
Joined: Dec 2010
Reputation: 1
#33
RE: Scripts Recollection

I have a request for some code o/

I haven't had a chance to get to the gritty side of coding, anyone know about this in more detail?
SetInsanitySetEnabled(string& asSet, bool abX);

Also, how about random number generators?

what I'm trying to do in my map,
make a random number between 0-100 every 10 seconds
if that number is between 0 and 20
generate another random number between 1-10
reduce the sanity by by that random number (0-10)
(This post was last modified: 01-04-2011, 03:29 PM by DIGI Byte.)
01-04-2011, 03:28 PM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#34
RE: Scripts Recollection

Let me think.. I've never used SetInsanitySetEnabled, so no info on that.

It could work like this (you'd obviously have to call InsanityTimer first):

void InsanityTimer(string &in asTimer)
{
    int Insanity = RandFloat(0.0f, 100.0f);
    if (Insanity < 20)
    {
        int Insanity_2 = RandFloat(0.0f, 10.0f);
        GiveSanityDamage(Insanity_2, false);
    }
    
    AddTimer("loop", 10.0f, "InsanityTimer");
}

I haven't tested it out, but that's how it should work. You may want to add a debug message to that, like this:

AddDebugMessage("Damage: "+Insanity_2, false);


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
(This post was last modified: 01-04-2011, 04:38 PM by Frontcannon.)
01-04-2011, 04:35 PM
Find
DIGI Byte Offline
Senior Member

Posts: 376
Threads: 20
Joined: Dec 2010
Reputation: 1
#35
RE: Scripts Recollection

Cheers, I'll test it out, play around with and and see what I get

I'll post a map and code if it works Big Grin
its looking really.. .really good, just need sanity effects

EDIT: I've tried simplifying the layout of the script, should make it easier now, but I don't think I'm qualified to code 4am in the morning :S
(This post was last modified: 01-04-2011, 06:36 PM by DIGI Byte.)
01-04-2011, 04:58 PM
Find
DIGI Byte Offline
Senior Member

Posts: 376
Threads: 20
Joined: Dec 2010
Reputation: 1
#36
RE: Scripts Recollection

Ok, I got the script working mostly, but giveSanity isnt working as it should

What this script does, Lowers sanity on a random timed event, used for showing sanity props and entities that spawn when then players sanity is low enough
Create a random number on start, Creates timer on start
when timer goes higher then random number, runs script
void OnStart()
    {//"event_delay", Create a number between 30 and 120
    int event_delay = RandFloat(30.0f, 120.0f);

    //"global_timer", timer start/create and run script "sanity_drop_loop"
    AddTimer("global_timer", event_delay, "sanity_drop_loop");
        
    }

the script detects player sanity, if higher then 60%, does 10 sanity damage then loops back
if its lower then 60%, heals 40% sanity damage then loops back (doesn't work yet)
(do NOT place in void OnStart () )
void sanity_drop_loop(string &in asTimer)
     {     if (float (GetPlayerSanity()) > 60) // if sanity is higher then 60%
            {    GiveSanityDamage(10, false); // Give 10 sanity dmg
                int random_event_delay = RandFloat(30.0f, 120.0f); // call new random number
                AddTimer("loop",  random_event_delay, "sanity_drop_loop"); //loop timer
            }
        if (float (GetPlayerSanity()) < 60) // if sanity is lower then 60%
            { // currently doesnt work for unknown reasons
                AddPlayerSanity(40); //heal sanity by 40%
                int random_event_delay = RandFloat(30.0f, 120.0f);
                AddTimer("loop", 1, "sanity_drop_loop"); // loop after 1 second
            }
     }
(This post was last modified: 01-05-2011, 04:05 AM by DIGI Byte.)
01-05-2011, 02:53 AM
Find
DIGI Byte Offline
Senior Member

Posts: 376
Threads: 20
Joined: Dec 2010
Reputation: 1
#37
RE: Scripts Recollection

Now that I'm more awake, and well rested I can think better, the idea of my previous script is ok, but for what I was using it for, there was a simpler solution and that I could have more control over

The problem with sanity activated entities (when your sanity is low enough they spawn) is you have to be facing away from it before it will spawn

I wanted it to spawn in front of me

This script is activated on start by a simple timer that runs the reset function in the events, which loops back to the start, and starts my timed event

Timed Events: activate/fade entities & chaining multiple activate/fade events together and looping them back

What this script does in steps;
on start, create timer called auto_start_scare to run the void script initial_scare_delay after 5 seconds
// This runs when the map first starts
    void OnStart()
    {     //start "sanity scare" - comment out to disable!!!
        AddTimer("auto_start_scare", 5, "initial_scare_delay");
    }

This is the Intro to the script, it's where you will setup the initial start
(NOT to be included into void OnStart() )
    void initial_scare_delay(string &in asTimer)
    {
        int init_loop_delay = RandFloat(2.0f, 5.0f); // Initial delay before looping starts
        AddTimer("initial_scare_timer", init_loop_delay, "start_scare");
    }

activate (fade in) first object, create random number for timer to run next script, This can be repeated several times making quiet an advanced scene, but simple is better Cool
    void start_scare(string &in asTimer)
    {
        SetPropActiveAndFade ("ghost_chair", true, 0.2f);//chair activation
        int ghost_spawn_delay = RandFloat(15.0f, 45.0f);
        AddTimer("ghost_spawn_timer", ghost_spawn_delay, "spawn_ghost");
    }

this one fades out the entity and loops back to the start
    void reset_scare(string &in asTimer)
    {
        //de-activate all and restart scare
        SetPropActiveAndFade("ghost_man", false, 0.1f);
        SetPropActiveAndFade("ghost_chair", false, 0.2f);
        int loop_delay = RandFloat(2.0f, 5.0f);
        AddTimer("reset_scare_timer", loop_delay, "start_scare");
    }
01-05-2011, 06:02 AM
Find
Frontcannon Offline
Senior Member

Posts: 538
Threads: 10
Joined: Jul 2010
Reputation: 2
#38
RE: Scripts Recollection

So this basically makes objects appear and disappear in 'random' time intervalls?

Though I still don't get what initial_scare_delay does. It basically adds a max of 5 seconds before start_scare is called, but reset_scare doesn't use it either so it's basically useless.


╔═════════════════╗
☺ Smoke weed everyday ☺
╚═════════════════╝
01-05-2011, 04:29 PM
Find
DIGI Byte Offline
Senior Member

Posts: 376
Threads: 20
Joined: Dec 2010
Reputation: 1
#39
RE: Scripts Recollection

this is used for my main menu, where I want the scare/prop to appear quickly before looping at a slower time rate

initially i was going to use insanity to make the props appear, however thats quite restrictive on how you use it, so a simple activate/fade is more effective
01-05-2011, 09:30 PM
Find
Tony32 Offline
Junior Member

Posts: 26
Threads: 2
Joined: Jan 2011
Reputation: 0
#40
RE: Scripts Recollection

Hmm. Can anyone explain/tell me which function is used to trigger something when an item is picked up?
ex. When I pickup a bowl, something will happen. (NOT when I use the bowl)

Thanks.
01-10-2011, 11:04 PM
Find




Users browsing this thread: 2 Guest(s)