Random quest texts

Okay so what I "want" to do is have quests with different text each time the player picks it, so if they pick a escort npc quest, instead of picking it everytime and getting the same quest I want them to get different text.

I seen in a topic called, squiffy templates.
Of a random number path JS.
Only problem is it won't display the {If p1=1: ect ect}

I'm using this exactly word by word:

 Squiffy.randomPath = function(numPath) {

 var path=Math.ceil(Math.random()*squiffy.get("numPath"));
squiffy.set("path",path);

var p1=Math.ceil(Math.random()*6);
squiffy.set("p1",p1);

var p2=Math.ceil(Math.random()*6);
squiffy.set("p2",p2);

var p3=Math.ceil(Math.random()*6);
squiffy.set("p3",p3);

var p4=Math.ceil(Math.random()*6);
squiffy.set("p4",p4);

var p5=Math.ceil(Math.random()*6);
squiffy.set("p5",p5);

var p6=Math.ceil(Math.random()*6);
squiffy.set("p6",p6);

squiffy.set("f1",false);
squiffy.set("f2",false); 
squiffy.set("f3",false); 
squiffy.set("f4",false); 
squiffy.set("f5",false); 
squiffy.set("f6",false);

if (Math.ceil(Math.random()*2)==1){set("f1",true);}
if (Math.ceil(Math.random()*2)==1){set("f2",true);}
if (Math.ceil(Math.random()*2)==1){set("f3",true);}
if (Math.ceil(Math.random()*2)==1){set("f4",true);}
if (Math.ceil(Math.random()*2)==1){set("f5",true);}
if (Math.ceil(Math.random()*2)==1){set("f6",true);}
} '''

What exactly am I doing wrong? Am I not inputting something right? Or is it that squiffy can't do If: inside of If:


Okay, keeping in mind that this is squiffy, what it does is whenever it is called, it sets the variables P1 to P6 for a value of 1-6. It also makes f1 to f6 into booleans, either true or false. Then, when you write your story, you can use these values to generate up to 36 different tellings of the same script. Note that I've exaggerated the differences in the example. Normally you'd be modifying the mood slightly in each election. The code is as follows:

[[function]]:
    
    //THIS SECTION INCLUDES THIS FUNCTION INTO PLAY
    
    squiffy.randomPath = function(numPath) {

        var path=Math.ceil(Math.random()*squiffy.get("numPath"));
        squiffy.set("path",path);
    
        var p1=Math.ceil(Math.random()*6);
        squiffy.set("p1",p1);
        
        var p2=Math.ceil(Math.random()*6);
        squiffy.set("p2",p2);
    
        var p3=Math.ceil(Math.random()*6);
        squiffy.set("p3",p3);
    
        var p4=Math.ceil(Math.random()*6);
        squiffy.set("p4",p4);
    
        var p5=Math.ceil(Math.random()*6);
        squiffy.set("p5",p5);
        
        var p6=Math.ceil(Math.random()*6);
        squiffy.set("p6",p6);
    
        squiffy.set("f1",false);
        squiffy.set("f2",false); 
        squiffy.set("f3",false); 
        squiffy.set("f4",false); 
        squiffy.set("f5",false); 
        squiffy.set("f6",false);
        
        if (Math.ceil(Math.random()*2)==1){set("f1",true);}
        if (Math.ceil(Math.random()*2)==1){set("f2",true);}
        if (Math.ceil(Math.random()*2)==1){set("f3",true);}
        if (Math.ceil(Math.random()*2)==1){set("f4",true);}
        if (Math.ceil(Math.random()*2)==1){set("f5",true);}
        if (Math.ceil(Math.random()*2)==1){set("f6",true);}
    };
    
    squiffy.story.go("start");

[[start]]:

    //STORYTELLING MODE
    
    squiffy.set("numPath",100); 
    squiffy.randomPath ("numPath"); //randomizes paths

This is an example of randomized storytelling. So our hero,
{if p1=1: a dour}
{if p1=2: an annoying}
{if p1=3: a smelly}
{if p1=4: a burly}
{if p1=5: a skinny}
{if p1=6: a butch}
{if f1: man}
{else: woman}
with a wonderful
{if p2=1: sexual magnetism}
{if p2=2: green cape}
{if p2=3: set of teeth}
{if p2=4: smile}
{if p2=5: resume}
{if p2=6: great broadsword}
{if p3=1: strides into}
{if p3=2: drifts into}
{if p3=3: sneaks into}
{if p3=4: crawls into}
{if p3=5: tap-dances into}
{if p3=6: slides into}
{if p4=1: a great forest of Elvenquat.}
{if p4=2: the bank lobby.}
{if p4=3: the vast cave.}
{if p4=4: the liquor store.}
{if p4=5: the local big box store.}
{if p4=6: the lunar abyss.}

If you cut and paste this into the squiffy editor and run it, what you'll get is something maybe like this (for my one run):

This is an example of randomized storytelling. So our hero, a butch woman with a wonderful sexual magnetism slides into the vast cave.


Here is an example of actual use. In my game "Pathfinder", I use the following code (note, the JS section has been omitted. This is just the squiffy end of the text:

You are Captain {CaptFirst} {CaptSecond}, {CaptAge} years old,
{if p1=1: a by-the-book}
{if p1=2: a fussy}
{if p1=3: a rule-breaking}
{if p1=4: a hot-shot}
{if p1=5: non-descript}
{if p1=6: an often-overlooked}
{CaptNation} officer, recently
{if p2=1: ordered}
{if p2=2: summoned}
{if p2=3: requested}
{if p2=4: instructed}
{if p2=5: commanded}
{if p2=6: communicated}
to report to
{if p3=1: Orbital Command}
{if p3=2: Earth Orbit Spacedocks}
{if p3=3: the Lagrange Shipyard}
{if p3=4: the High Orbit Dockyards}
{if p3=5: the Deepspace Military Shipyards}
{if p3=6: Military Orbital Base}
for your
{if p4=1: classified}
{if p4=2: secret}
{if p4=3: curiously-vague}
{if p4=4: hush-hush}
{if p4=5: covert}
{if p4=6: cold-case}
briefing.

Stepping from your shuttle, you pause before a view port, seeing one of the whispered-about Pathfinder Class ships just clearing the docks. To your experienced eye, she seems
{if p5=1: pleasingly sleek.}
{if p5=2: tidy and shipshape.}
{if p5=3: rushed and ill-conceived.}
{if p5=4: as elegant as a race horse.}
{if p5=5: a thing of iron-clad beauty.}
{if p5=6: a thing of cast-iron ugliness.}
On her flank, in large letters, is her name <I>{shipName}</I>.

<img src="images/Earth.jpg" alt=">Sorry, image not found<" height=300 width=431>

Arriving at the commander's office,
{if p6=1: a timid midshipman}
{if p6=2: a librarian-like spinster}
{if p6=3: a burly ex-marine}
{if p6=4: a quiet officer}
{if p6=5: a smiling PR lieutenant}
{if p6=6: a paper-pushing office drone}
notes your arrival and [[shows you in]](Start game mission)

So, when I run it, I see something like this (it's different each time, but still sticks with the story, simply changing the descriptors)

You are Captain Aasiya al-Hasan, 37 years old, a fussy Arab officer, recently communicated to report to Earth Orbit Spacedocks for your secret briefing.

Stepping from your shuttle, you pause before a view port, seeing one of the whispered-about Pathfinder Class ships just clearing the docks. To your experienced eye, she seems pleasingly sleek. On her flank, in large letters, is her name Omen.

Arriving at the commander's office, a burly ex-marine notes your arrival and shows you in


Thank you so much! It worked! I mistyped a JS line and it didn't recognize it lmao your a life saver, also sorry for the long delay in response was moving.


If I'm understanding what you're doing, I think the whole thing could be condensed quite a bit with mrangel's unofficial Squiffy 5.1.4.


This topic is now closed. Topics are closed after 180 days of inactivity.

Support

Forums