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
Doubt about a puzzle idea (script)
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#1
Doubt about a puzzle idea (script)

Hi

I was thinking in make a puzzle in one of my maps. I dont want a complete script just a few questions about an idea.

I want to make a puzzle of a breaking in a specific order some vases. But not all! just a few in a specific order. If the incorrect vase is broken then restart all over again.

But then raises some concerns.

1. I supose I should start the "game" calling for a breakup function on the level editor on my "first" correct vase...

2. If I want to make a reset in making a error I supouse with a chekpoint before the event? that checkpoint should have an auto save? or the chekpoint is enough to make the vases unbroken again?.

3. And which leads me more doubt is... how to make a specific order. Should consider the if statement? If setprophealth == 0 in my second vase... and keep going?...


Thanks for the attention.
03-07-2016, 12:20 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#2
RE: Doubt about a puzzle idea (script)

Feel free to use CheckPoint() to restart the room, but to call it the player has to die. CheckPoints are only really used upon death if I remember correctly. Unsure if a CheckPoint will reset the vases though, so use ResetProp() for that.

As for the order itself, since breaking the wrong order will force you to restart, it can simply be an incrementing local variable.

PHP Code: (Select All)
int vasesBroken 0;

void BreakVase(string &in asEntitystring &in type)//This can be a standard SetEntityFuncCallback as OnBreak
{
    if(
type != "OnBreak") return;

    if(
vasesBroken == && asEntity == "vase_1") {
        
vasesBroken++;
        return;
    } 
    if(
vasesBroken == && asEntity == "vase_2") {
        
vasesBroken++;
        return;
    }
    if(
vasesBroken == && asEntity == "vase_3") {
        
//Success, you reached the end of the order. Add your success code here, before return;
        
return;
    }

    
//If you get here, it's the wrong order, restart code here, call CheckPoint, ResetProp etc...


This code might do it. I'm sure there are better ways to write it but this is the first that popped into my head. I haven't tested it though.
Change the vase names to the order you need, and add this callback to all your vases.
(If nothing happens, try removing the OnBreak line. I might be remembering it wrong)

(This post was last modified: 03-07-2016, 02:54 AM by Mudbill.)
03-07-2016, 02:48 AM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#3
RE: Doubt about a puzzle idea (script)

Hi. Thanks!! I will try it!
03-07-2016, 07:41 PM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#4
RE: Doubt about a puzzle idea (script)

I agree with Mudbill,
but let's be cute with our code for a second. Tongue

Set the variable to the first vase's suffix. "vase_1" => vasesBroken = 1;
Grab the suffix of currently broken entity by SubString and convert it to an Integer.

Compare those...
(this code prevents you from writing if statements for each vase)

While it's not a problem here, some codes could work with thousands of vases.

PHP Code: (Select All)
int vasesBroken 1;

void BreakVase(string &in asEntitystring &in type)//This can be a standard SetEntityFuncCallback as OnBreak
{
    if(
type != "OnBreak") return;

    if(
vasesBroken == StringToInt(StringSub(asEntity51)))
    {
        if(
vasesBroken == 4// 4 in this case is the last vase
        
{
            
//YAAAY! Player Got it right!
        
}
        
vasesBroken++;
        return;
    }

      
vasesBroken 1// And Mudbill surely wanted to include resetting his variable... right?  

//If you get here, it's the wrong order, restart code here, call CheckPoint, ResetProp etc...

03-07-2016, 11:22 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#5
RE: Doubt about a puzzle idea (script)

Yeah I figured someone would come and clean it up a bit. Personally I wouldn't use an if-statement for each vase if I can help it, I just didn't bother with it since I typed it all by hand in a comment at 3 am xP

Though I guess it slipped me because I expected the vases to not be named in the order they were gonna be broken in. And resetting the value is correct. I just assumed it to be included in the reset lose-code, but always good to point out just in case.

One thing; your vasesBroken++; should be before the win-check, or else they won't actually win upon breaking the last one, but rather the next time the break occurs.

(This post was last modified: 03-07-2016, 11:57 PM by Mudbill.)
03-07-2016, 11:56 PM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#6
RE: Doubt about a puzzle idea (script)

Oh no...
The vasesBroken++; is at a correct spot.
I just have the initial vasesBroken value set to 1.
03-08-2016, 07:06 AM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#7
RE: Doubt about a puzzle idea (script)

My bad. Forgot that the value is incremented before the vase name equivalent, from the previous round. Derp.

(This post was last modified: 03-08-2016, 08:16 AM by Mudbill.)
03-08-2016, 08:16 AM
Find
Spelos Away
Banned

Posts: 231
Threads: 19
Joined: Sep 2014
#8
RE: Doubt about a puzzle idea (script)

Well, I agree with Spelos,
but let's be cute & SMART with our code.

Instead of grabbing the number and converting it to Int.
Let's have "vase_" and combine it with the number we have.

PHP Code: (Select All)
int vasesBroken 1;

void BreakVase(string &in asEntitystring &in type)
{
    if(
type != "OnBreak") return;

    if(
asEntity == "vase_" vasesBroken)
    {
        if(
vasesBroken == 4)
        {
            
//The Player got it right!
            
return;
        }
        
vasesBroken++;
        return;
    }

    
vasesBroken 1;
    
ResetProp("vase_*");

03-08-2016, 12:16 PM
Find
sabrinagsoledad Offline
Junior Member

Posts: 32
Threads: 10
Joined: Feb 2016
Reputation: 0
#9
RE: Doubt about a puzzle idea (script)

Hi.

Sorry for the delay to much stuff at the university.

I try the last code and nothing hapens.

int vasesBroken = 1;

void BreakVase(string &in asEntity, string &in type)
{
if(type != "OnBreak") return;

if(asEntity == "vase_" + vasesBroken)
{
if(vasesBroken == 4)
{
GiveSanityBoost();
SetEntityActive("Coins_5", true);
return;
}
vasesBroken++;
return;
}

vasesBroken = 1;

CheckPoint("Checkpoint", "PlayerStartArea_2","", "DeathCategory", "Deathtext3");
SetPlayerHealth(0.0f);
ResetProp("vase_1");
ResetProp("vase_2");
ResetProp("vase_3");
ResetProp("vase_4");
ResetProp("vase_5");
ResetProp("vase_6");
ResetProp("vase_7");
ResetProp("vase_8");
ResetProp("vase_9");
ResetProp("vase_10");
ResetProp("vase_11");
ResetProp("vase_12");
ResetProp("vase_13");
ResetProp("vase_14");
ResetProp("vase_15");
ResetProp("vase_16");

}

I already chek.. every vase name is vase_1... to the last vase vase_16.
And every vase has the BreakVase callfunction.

If its
03-08-2016, 11:44 PM
Find
Mudbill Offline
Muderator

Posts: 3,881
Threads: 59
Joined: Apr 2013
Reputation: 179
#10
RE: Doubt about a puzzle idea (script)

Can you show a screenshot of the entity tab for the vases?

Add
PHP Code: (Select All)
Print("Running BreakVase function"); 
at the top of the BreakVase() function (before the if-check for OnBreak), and then check the log after shutting down to see if it's written there. If not, then the function is never ran.

(This post was last modified: 03-09-2016, 12:15 AM by Mudbill.)
03-09-2016, 12:15 AM
Find




Users browsing this thread: 2 Guest(s)