Change font size
It is currently Sat Sep 21, 2019 1:15 pm

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 2   [ 18 posts ]
Go to page 1, 2  Next
Author Message
 Post subject: vocabulary "zombie" quiz
PostPosted: Sat Jan 26, 2019 5:58 pm 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Hi!
I'm trying to build a quiz game, in which you walk through a maze.
You have to get through locked doors while being followed by zombies (prims).

Once you approach the doors / zombies, they ask you a question,
which you have to answer correctly.

If you do so, the door opens, respectively the zombie dies.
If you don't kill the zombie and he gets too close, he teleports you out and you have to start over again.

I've adjusted two common quiz-scripts for this purpose, one with a dialog, the other one using the chat:

dialog-quiz-version:
{L_CODE}:
//A Dialog-driven quiz, using text from a notecard -- Rolig Loon -- October 2009
//
// Free for public use -- please don't do something crass like selling my script.
// Modify if you must, but please keep these header lines intact.  Be nice.
//
// Notecard format:
// A line beginning with a "Q" is part of a question
// A line beginning with an "A" is a string of comma-delimited zeros (wrong) and a one (right) to identify the answer
// A line beginning with a "#" is a comment
// Blank lines are ignored
//
// Dialog boxes are limited to 512 characters, so make each question (including choices) short enough to fit.
// There is no limit to the number of questions in a quiz, and you may have up to 12 answer choices per question
//
// =============== sample notecard ===========
//# Lines starting with Q appear verbatim in a dialog box
//# You may have as many Q lines as you want per question, but only one A line
//# Interpreted data begins immediately after the lead character in a line
//QWhat is the capital of Minnesota?
//Q1. St. Paul
//Q2. Minneapolis
//Q3. Iowa City
//Q4. Boston
//A1,0,0,0
//QHow many fingers are on my right hand?
//Q1. One
//Q2. Two
//Q3. Three
//Q4. Four
//Q5. Five
//A0,0,0,0,1
// ================= end of sample =================
//
// Instructor types "results" in channel 24 to get a report of all student scores

string gCard; //Notecard name
integer gLine; //Current line being read
key gQID; //Dataserver key
integer gtouch; //Activates/deactivates touch_start event
list gAvList = []; //Cumulative list of people who have taken this quiz
string gAv; //Name of the current quiz-taker
key gAvKey; //Key of the current quiz-taker
integer CHAN; //Channel for dialog communication
integer Handle; //Listen handle for dialog
integer gScore; //This quiz-taker's score
string gQuestion; //Text for the current question
list gAnswers; //Answer key for the current question
list gAllScores = []; //Cumulative list of scores for quiz-takers
integer Timespan = 10;  // This is the maximum time alloted for the quiz, in minutes. Change here if needed.

integer IsNameOnList(list namelist, string name)  //Verifies whether av has already taken the quiz
{
    integer i;
    integer len = llGetListLength(namelist);
    for (i=0; i<=len-1;++i)
        if(llList2String(namelist,i) == name)
        {
            return TRUE;
        }
    return FALSE;
}

init()  //Resets parameters for the next quiz-taker
{
    //llSetTimerEvent(0);
    gtouch = 0;
    gAv = "";
    gAvKey = NULL_KEY;
    gLine = 0;
    gAllScores += gScore;
    gScore = 0;
    llListenControl(Handle,FALSE);
}

list order_buttons(list buttons)
{
return llList2List(buttons, -3, -1) + llList2List(buttons, -6, -4)
+ llList2List(buttons, -9, -7) + llList2List(buttons, -12, -10);
}

default
{
    state_entry()
    {
        gCard = llGetInventoryName(INVENTORY_NOTECARD,0);
        gAvList = [];
        CHAN = (integer)(llFrand(100000000))* (-1);
        Handle = llListen(CHAN,"","","");
        llListen(24,"",llGetOwner(),"");
        init();
   

    llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, 5.0, PI, 20.0);
    }
    sensor(integer num_detected)
   
    {
        if (gtouch == 0)  // Starting quiz with a new person
        {
            //if(IsNameOnList(gAvList,llDetectedName(0)))
            //{
               // llInstantMessage(llDetectedKey(0),"Sorry, "+ llDetectedName(0) + ". You have already taken the quiz. You cannot take it twice.");
                //return;
           // }
            //else
           // {
                //gAvList += llDetectedName(0); // Add av to the list of people who have attempted this quiz
            //}
            gAv = llDetectedName(0);
            gAvKey = llDetectedKey(0);
            //llInstantMessage(gAvKey,"Hello, "+ gAv+ ". You will have "+(string)Timespan+" minutes to finish this quiz. Respond to questions as they appear in blue dialog boxes on your screen.");
            //llInstantMessage(gAvKey,"Touch this panel again to stop the quiz.");
            //llSetTimerEvent(Timespan*60);
        }
        if (gAv != llDetectedName(0)) //Only accept touches from this av until the quiz is finished
        {
            //llInstantMessage(llDetectedKey(0),"Someone else is taking the quiz now.  Please wait.");
            //return;
        }
        //if (gtouch >=1) // This is the emergency stop. Av wants to stop taking the quiz before the last question
        //{
            //llListenControl(Handle,TRUE);
            //llDialog(gAvKey,"If you stop now, you may not restart later. \nDo you want to QUIT now?", ["YES", "NO"],CHAN);
            //return;
        //}
        // An av should only reach this point if it is the first touch
        gQID = llGetNotecardLine(gCard,gLine); //Read the first line of the notecard
        ++gtouch;
    }

    changed(integer change)
    {
        if(change & CHANGED_INVENTORY)
        {
            llResetScript();
        }
    }

//timer()
//{
    //llInstantMessage(gAvKey,"Your time is up. Thank you for taking the quiz. Your score is "+ (string)gScore);
    //init(); //Restart the quiz for the next person
//}

dataserver(key query_id, string data)
{
    if(query_id == gQID) //If the data request came from this script
    {
        if(data != EOF) //If there is still data to be read from the notecard
        {
            if(llGetSubString(data,0,0) == "#"||llGetSubString(data,0,0) == "") //Ignore comment lines and blank lines
            {
                ++gLine;
                gQID = llGetNotecardLine(gCard,gLine);
            }
            else if (llGetSubString(data,0,0) == "Q") //Read the question and all answer choices
            {
                gQuestion += llGetSubString(data,1,-1) + "\n"; //Format each "Q" line as a new line in the dialog box
                ++gLine;
                gQID = llGetNotecardLine(gCard,gLine);
            }
            else if (llGetSubString(data,0,0) == "A") //Read the answer key
            {
                gAnswers = llParseString2List(llGetSubString(data,1,-1),[","],[]);
                integer len = llGetListLength(gAnswers);
                integer i;
                list buttons = [];
                for (i=1;i<=len;++i) //Create a numbered button for each choice
                {
                    buttons += [(string)i];
                }
                llListenControl(Handle,TRUE);
                llDialog(gAvKey,gQuestion,order_buttons(buttons),CHAN); //Display the question in a dialog box
            }
        }
        else // If there are no more lines on the notecard
        {
            //llInstantMessage(gAvKey,"You have finished the quiz. Congratulations. Your score is "+(string)gScore);
            init(); //Restart the quiz for the next person
        }
    }
}

listen (integer channel, string name, key id, string message)
{
    if (channel == 24) //Teacher said something on channel 24
    {
        if (llToLower(message) == "results") //and the message was "results"
        {
            integer len = llGetListLength(gAvList);
            integer i;
            for (i=0;i<=len-1;++i)
            {
                llOwnerSay(llList2String(gAvList,i) +  "....  Score = " + llList2String(gAllScores,i+1));
            }
        }
    }
    else if (message == "YES") // Av has touched the panel and wants to quit
    {
        llInstantMessage(gAvKey,"You have left the quiz with a score of "+(string)gScore +". Goodbye!");
        init();
    }
    else if(message == "NO") // Av has touched the panel and does NOT want to quit
    {
        return;
    }
    else // A question has been displayed in a dialog box
    {
       
       
       
       
       integer pos = llListFindList(gAnswers,["1"]); //Search the answer key. The correct answer is pos+1
        if(message == (string)(pos+1))
        {
           
            //++gScore;
            //llInstantMessage(gAvKey,"Correct! Your score is now "+ (string)gScore+ ". Next ...");
            llDie();
        }
        else if (pos != -1)
        {
            //llInstantMessage(gAvKey,"Wrong. The correct answer was "+ (string)(pos+1) + ". Next ....");
        }
       
       
       
       
        else if (pos == -1) //The teacher screwed up and didn't code a correct answer
        {
            llInstantMessage(gAvKey,"Ooops! There is no right answer to this question. Let's move on....");
        }
        gQuestion = ""; //Erase the current question
        gAnswers = []; //And its answer key
        ++gLine;
        gQID = llGetNotecardLine(gCard,gLine); // Get the next question
    }
}
}



Chat-quiz-version:

{L_QUOTE}:
// :CATEGORY:Quiz
// :NAME:Simple Quiz
// :AUTHOR:Ferd Frederix
// :KEYWORDS:
// :CREATED:2014-09-24 14:53:12
// :EDITED:2014-09-24
// :ID:1049
// :NUM:1663
// :REV:1
// :WORLD:Second Life
// : DESCRIPTION:
// A simple notecard game.
// :CODE:

//it will ask "How many steps are there leading up to the Elven village from the Queens Castle?";
//If you answer "5", the zombie will die.


//integer COLLISION = TRUE; // if set to TRUE instead of FALSE, anyone who walks thru this prim will get prompted for the secret password.
//integer TOUCH = TRUE; // if set to TRUE instead of FALSE, anyone who touches this prim will get prompted for the secret password.
integer IM = TRUE; // if TRUE, they get an Instant Message privately in chat. if FALSE it speaks Publicly.
//string Prompt = "Enter the password";
//string SecretWord = "password";
string Question = "How many steps are there leading up to the Elven village from the Queens Castle?";
string Answer = "5";

default
{
on_rez(integer N) {
llResetScript();
}

state_entry() {
llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, 5.0, PI, 20.0);
}
sensor(integer num_detected)
{


llSay(0, Question);

llListen(0,"","","");
}

listen(integer channel, string name, key id, string message) {



if (message == Answer)
llSay(0, "Correct.");
llDie();

// }
//touch(integer total_number)
//{
//if (TOUCH && ! IM)
//llSay(0,Prompt);
//if (TOUCH && IM)
//llInstantMessage(llDetectedKey(0),Prompt);
}
}

They seem to work.
The only thing I would like to add is the following:

I would like the zombies / doors to randomly select one question out of a pool of multiple questions,
instead of asking the same one again and again.

This would mean I would only have to prepare one quiz-script using all quiz questions
and I could use that same script for all zombies / doors,
instead of having to prepare a different individual quiz-script for each zombie /door.
This would save a lot of time.

This means the script must have a function by which it randomly selects one of several questions,
respectively question notecards, and reads them to the avatar.

The scripts must not interfere with each other, though.
That means, when one zombie's question is answered,
only this one zombie is supposed to die and not the others.

I'm not quite sure if this is possible.
Do you maybe have an idea?
Thanks!


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sat Jan 26, 2019 6:39 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 235
Location: Belgium / Brussels
You could already change string Question "" into list Questions "", "", "" ... and string Answer "" to list Answers "", "", "" ... :P

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Fri Feb 08, 2019 9:27 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 235
Location: Belgium / Brussels
Maybee somethink like that ...
{L_CODE}:
// Simple Sensor Quizz I v0.1 by djphil (CC-BY-NC-SA 4.0)

integer teleport = FALSE;
vector position = <128.0, 128.0, 25.0>;
float range = 2.0;
float rate = 5.0;

list questions = [
    "\nQuestion #1: ... ?",
    "\nQuestion #2: ... ?",
    "\nQuestion #3: ... ?"
];

list responses = [
    "yes, true, oui, 1",
    "no, false, non, 0",
    "Opensim, OpenSimulator"
];

key avatar;
list avatars;
integer random;
integer counter;
integer handler;

string question()
{
    integer count = llGetListLength(questions);
    random = (integer)llFrand((float)count);
    return llList2String(questions, random);
}

integer response(string response)
{
    string csv = llList2String(responses, random);
    list buffer = llCSV2List(llToLower(csv));
    if (~llListFindList(buffer, [llToLower(response)])) return TRUE;
    return FALSE;
}

default
{
    state_entry()
    {
        llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate);
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
    }

    sensor(integer n)
    {
        if (counter > 5)
        {
            llListenRemove(handler);
            llSetStatus(STATUS_PHANTOM, FALSE);
            llRegionSayTo(avatar, PUBLIC_CHANNEL, "You loze " + llKey2Name(avatar));
            if (teleport == TRUE) llTeleportAgent(avatar, "", position, ZERO_VECTOR);
            llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0);
            llSetText("", <1.0, 1.0, 1.0>, 1.0);
            llSetAlpha(1.0, ALL_SIDES);
            avatars = [];
            counter = 0;
        }

        avatar = llDetectedKey(0);

        if (!~llListFindList(avatars, [avatar]))
        {
            if (llGetListLength(avatars) < 1)
            {
                avatars += avatar;
                llSetAlpha(1.0, ALL_SIDES);
                llSetStatus(STATUS_PHANTOM, FALSE);
                llRegionSayTo(avatar, PUBLIC_CHANNEL, question());
                handler = llListen(PUBLIC_CHANNEL, "", avatar, "");
                llSetText(llKey2Name(avatar), <1.0, 1.0, 1.0>, 1.0);
            }

            else if (!~llListFindList(avatars, [avatar]))
            {
                llRegionSayTo(avatar, PUBLIC_CHANNEL, "Sorry " + llKey2Name(avatar) + ", the game is buzy ..."); 
            }
        }

        ++counter;
    }

    no_sensor()
    {
        avatars = [];
        counter = 0;
        llSetAlpha(1.0, ALL_SIDES);
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (uuid == handler)
        {
            message = llStringTrim(message, STRING_TRIM);

            if (response(message) == TRUE)
            {
                counter = 0;
                avatars = [];
                llListenRemove(handler);
                llRegionSayTo(uuid, PUBLIC_CHANNEL, "You win " + name);
                llSetText("", <1.0, 1.0, 1.0>, 1.0);
                llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0);
                llSetStatus(STATUS_PHANTOM, TRUE);
                llSetAlpha(0.25, ALL_SIDES);
            }
        }
    }
   
    on_rez(integer n) {llResetScript();}
}
Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sat Feb 09, 2019 11:31 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Thanks again, mate.
This is pretty much exactly what I was looking for.
I'll adjust it to my my needs.
Should I run into problems, I'll come back for help.
But it looks very promising so far.
Cheers! :)


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sat Feb 09, 2019 12:43 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 235
Location: Belgium / Brussels
... or this one to works with the Iris Door script :P
{L_CODE}:
// Simple Sensor Quizz II v0.1 by djphil (CC-BY-NC-SA 4.0)

integer canal = -123456789;
integer teleport = FALSE;
vector position = <128.0, 128.0, 25.0>;
float range = 2.0;
float rate = 5.0;

list questions = [
    "\nQuestion #1: ... ?",
    "\nQuestion #2: ... ?",
    "\nQuestion #3: ... ?"
];

list responses = [
    "yes, true, oui, 1",
    "no, false, non, 0",
    "Opensim, OpenSimulator"
];

key avatar;
list avatars;
integer random;
integer counter;
integer handler;

string question()
{
    integer count = llGetListLength(questions);
    random = (integer)llFrand((float)count);
    return llList2String(questions, random);
}

integer response(string response)
{
    string csv = llList2String(responses, random);
    list buffer = llCSV2List(llToLower(csv));
    if (~llListFindList(buffer, [llToLower(response)])) return TRUE;
    return FALSE;
}

default
{
    state_entry()
    {
        llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate);
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
        llSetAlpha(1.0, ALL_SIDES);
        llRegionSay(canal, "close");
    }

    sensor(integer n)
    {
        if (counter > 5)
        {
            llListenRemove(handler);
            llSetStatus(STATUS_PHANTOM, FALSE);
            llRegionSayTo(avatar, PUBLIC_CHANNEL, "You loze " + llKey2Name(avatar));
            if (teleport == TRUE) llTeleportAgent(avatar, "", position, ZERO_VECTOR);
            llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0);
            llSetText("", <1.0, 1.0, 1.0>, 1.0);
            llSetAlpha(1.0, ALL_SIDES);
            llRegionSay(canal, "close");
            avatars = [];
            counter = 0;
        }

        avatar = llDetectedKey(0);

        if (!~llListFindList(avatars, [avatar]))
        {
            if (llGetListLength(avatars) < 1)
            {
                avatars += avatar;
                llSetAlpha(1.0, ALL_SIDES);
                llRegionSay(canal, "close");
                llSetStatus(STATUS_PHANTOM, FALSE);
                llRegionSayTo(avatar, PUBLIC_CHANNEL, question());
                handler = llListen(PUBLIC_CHANNEL, "", avatar, "");
                llSetText(llKey2Name(avatar), <1.0, 1.0, 1.0>, 1.0);
            }

            else if (!~llListFindList(avatars, [avatar]))
            {
                llRegionSayTo(avatar, PUBLIC_CHANNEL, "Sorry " + llKey2Name(avatar) + ", the game is buzy ..."); 
            }
        }

        ++counter;
    }

    no_sensor()
    {
        avatars = [];
        counter = 0;
        llSetAlpha(1.0, ALL_SIDES);
        llRegionSay(canal, "close");
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (uuid == handler)
        {
            message = llStringTrim(message, STRING_TRIM);

            if (response(message) == TRUE)
            {
                counter = 0;
                avatars = [];
                llListenRemove(handler);
                llRegionSay(canal, "open");
                llRegionSayTo(uuid, PUBLIC_CHANNEL, "You win " + name);
                llSetText("", <1.0, 1.0, 1.0>, 1.0);
                llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0);
                llSetStatus(STATUS_PHANTOM, TRUE);
                llSetAlpha(0.1, ALL_SIDES);
            }
        }
    }

    on_rez(integer n) {llResetScript();}
}
Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sat Feb 09, 2019 7:01 pm 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Thanks again, sir! :-)
This one works nicely, too.

In case you're interested,
I tried to implement the script using NPC zombies, too, but couldn't do it.

Below is the zombie npc script.
It rezzes a zombie npc.
The zombie follows the avatar and asks a "question".
When presented the correct "answer", he dies.

Unfortunately, again, this is only possible with one, always the same, question and answer.
So, in case you've got some time left, you're welcome to look at it.

But only if it's not annoying.

Thanks again!

{L_CODE}:
//The next 3 variables determine where you will respawn when you are killed - instead of being TP'd to your home sim.
string Destination; // Destination region is checked by the script on startup
vector LandingPoint = <118,118,22.5>; //Change these coords as you wish - Set to the centre of the region now.
vector LookAt = <1,1,1>; //Direction you will be looking at when you respawn
string NotecardName;
float Range;
list Sayings = ["Chomps","Slurrps","Crunches","Nom Noms","Tastes","Bites","Licks","Gnaws","Chews","Grinds","Sucks","Nibbles"];
list Bits = ["Nose","Hand","Arm","Leg","Ass","Head","Foot","Ear","Chest","Stomach","Thighs"];
integer SayingsNr;
integer BitsNr;
key npc;
key id;
integer n;
vector npcPos;
key Target;
vector toucherPos;
vector TargetPos;
vector Pos;
float Position;
integer Inc = 0;
integer DeathInc = 0;
integer DeathPoints=0;
integer BiteInc = 0;
integer Timer = 300;
string TargetName;
float Health;
integer CHAN;
string DeathAnim = "LB-belly3";
string CrouchAnim = "avatar_crouch";
string ZombieWalk = "Zombie_Walk";
string IdleAnim = "idle_1";
string ObjDes;
integer channel=500;
list Zombie=["Female 1","Female 2","Flame","Ghost","Reaper","Male"];//If you change the NPC notecards, change the name here
list SenseRange=["10","15","20","30","50","96"];//Initial sensor range
list HitPoints=["One","Two","Five","Ten","Twenty","Fifty"];//How many shots it takes to kill a zombie
integer hex2int(string hex)
{
    return(integer)("0x"+hex);
}
DelNPC()
{
    osNpcRemove(npc);
}
default
{
    state_entry()
    {
        Destination = llGetRegionName();
        llSetAlpha(1.0,ALL_SIDES);
        llMessageLinked(LINK_SET, 1,"B","");
        CHAN = 0;
        DeathInc = 0;
        Inc = 0;
        BiteInc = 0;
        DelNPC();
        llSetText("",<0,1,1>,1.0);
        llListen(channel, "", NULL_KEY, "");
    }
    changed(integer change)
    {
        if(change & 1024)
        {
            llResetScript();
        }
    }
    touch_start(integer ok)
    {
        id = llDetectedKey(0) ;
        llDialog(id, "Zombie Type ?", Zombie, channel);
    }
    listen(integer channel, string name, key id, string message)
    {
        if (llListFindList(Zombie+SenseRange+HitPoints, [message]) != -1) 
        {
            if(message == "Female 1")
            {
                NotecardName = "Female 1";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Female 2")
            {
                NotecardName = "Female 2";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Flame")
            {
                NotecardName = "Flame";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Ghost")
            {
                NotecardName = "Ghost";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Reaper")
            {
                NotecardName = "Reaper";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            }
            if(message == "Male")
            {
                NotecardName = "Male";
                llDialog(id, "Sensing Range ?", SenseRange, channel);
            } 
            if(message == "10")
            {
                Range = 10.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "15")
            {
                Range = 15.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "20")
            {
                Range = 20.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "30")
            {
                Range = 30.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "50")
            {
                Range = 50.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "96")
            {
                Range = 96.0;
                llDialog(id, "Zombie Max Hits till Death ?", HitPoints, channel);
            }
            if(message == "One")
            {
                DeathPoints = 1;
                state Sense;
            }
            if(message == "Two")
            {
                DeathPoints = 2;
                state Sense;
            }
            if(message == "Five")
            {
                DeathPoints = 5;
                state Sense;
            }
            if(message == "Ten")
            {
                DeathPoints = 10;
                state Sense;
            }
            if(message == "Twenty")
            {
                DeathPoints = 20;
                state Sense;
            }
            if(message == "Fifty")
            {
                DeathPoints = 50;
                state Sense;
            }
        }
    }
}
state Sense
{
    state_entry()
    {
        llMessageLinked(LINK_SET, 3,"B","");
        llSetText("",<0,1,1>,1.0);
        DeathInc = 0;
        Inc = 0;
        BiteInc = 0;
        llSetAlpha(0.0,ALL_SIDES);
        llSensorRepeat("","",AGENT,Range,PI,1.0);
    }
    touch_start(integer number)
    {
        osNpcStand(npc);
        llSleep(1.0);
        osNpcRemove(npc);
        llOwnerSay("Zombie Rezzer RESET");
        state default;
    }
    sensor(integer num)
    {
        integer i;
        for (i = 0; i < num; i ++)
        {
           
            Target = llDetectedKey(i);
            Health = osGetHealth(Target);
            TargetPos = llDetectedPos(i);
            Pos = llGetPos();
            Position = llVecDist(TargetPos,Pos);
            llSensorRemove();
            npcPos = llGetPos() + <0,0,0>;
            npc = osNpcCreate(NotecardName, "...", npcPos, NotecardName);
            state NPC_SIT;
        }
    }
}
state NPC_SIT
{
    state_entry()
    {
        llSensorRepeat("","",AGENT,96,PI,2.0);
        llSetText("",<1,0,0>,1.0);
        SayingsNr = llGetListLength(Sayings);
        BitsNr = llGetListLength(Bits);
        llPreloadSound("Growl");
        llPreloadSound("Scream2");
        llPreloadSound("scream1");
        llSetTimerEvent(10.0);
       CHAN = hex2int(llGetSubString(npc,0,7));
        if (CHAN < 0)
        {
            CHAN = -CHAN;
        }
        //llOwnerSay("NPC Key is: "+(string)npc+"\nNPC Channel is: "+(string)channel);
        llListen(0, "", "", "");
    }
    listen(integer channel, string name, key OurIDs, string message)
    {
        if(channel == 0 && message == "answer")
   
        {
            osNpcStopMoveToTarget(npc);
            osNpcStand(npc);
            DeathInc = DeathInc +1;
            if(DeathInc<=DeathPoints)
            {
                llPlaySound("Scream2",1.0);
            }
            //osAvatarPlayAnimation(npc,IdleAnim);
            //osAvatarPlayAnimation(npc,CrouchAnim);
            llSleep(1.25);
            if(DeathInc>=DeathPoints)
            {
                llSetTimerEvent(0.0);
                llSensorRemove();
                osNpcStopMoveToTarget(npc);
                osNpcStand(npc);
                //osNpcPlayAnimation(npc,DeathAnim);
                llPlaySound("scream1",1.0);
                llSleep(5.0);
                llRegionSay(111,"Dead_Zombie");
                llRegionSay(112,(string)llKey2Name(Target));
                osNpcRemove(npc);
                state Sense;
                //llResetScript();
            }
            llSleep(0.25);
            osNpcPlayAnimation(npc,ZombieWalk);
        }
    }
    sensor(integer num)
    {
        integer i;
        for (i = 0; i < num; i ++)
        {
            llSleep(0.5);
            Target = llDetectedKey(i);
            Health = osGetHealth(Target);
            TargetName = llDetectedName(i);
            toucherPos   = llDetectedPos(i);
            npcPos = osNpcGetPos(npc);
            Position = llVecDist(toucherPos, npcPos);

            if (Position>1.0)
            {
                osNpcMoveToTarget(npc,toucherPos+<0,0,0>, OS_NPC_NO_FLY);
                  }
                      {
                     
                           if (Position<6)
                           {
                           
                           if (Position>3)
                         osNpcSay(npc, "question"); 
               
            }
            }
            if (Position<3.0)
            {
                osTeleportAgent(Target, Destination, LandingPoint, LookAt);
               
               
                if(Health<=35.0)
                {
                   
                    if(BiteInc >=1 )
                    {
                        llRegionSay(111,"Dead");
                        BiteInc = 0;
                    }
                    osNpcSay(npc,"Hahaha.. You Died !!");
                   
                    osCauseHealing(Target, 50);
                }
                llRegionSay(112,(string)llKey2Name(Target));
                float FSaid = llFrand(SayingsNr);
                integer Said = llCeil(FSaid)-1;
                string Text = llList2String(Sayings,Said);
                float FSaid1 = llFrand(BitsNr);
                integer Said1 = llCeil(FSaid1)-1;
                string Text1 = llList2String(Bits,Said1);
                osNpcSay(npc,(string)Text+" "+(string)llKey2Name(Target)+"'s "+(string)Text1);
                BiteInc = BiteInc + 1;
                osCauseDamage(Target, 10.0);
                llRegionSay(111,"Bite");
                llSleep(2.0);
            }
        }
    }
    touch_start(integer number)
    {
        osNpcStand(npc);
        llSleep(1.0);
        osNpcRemove(npc);
        llOwnerSay("Zombie Rezzer RESET");
        state default;
    }
    timer()
    {
        Inc = Inc +10;
        integer Del = Timer-Inc;
        llSetText("Auto-Delete in "+(string)Del+" seconds",<1,0,0>,1.0);
        float Rand1 = llFrand(2.0);
        if(Rand1>= 1.0)
        {
            llPlaySound("Growl",1.0);
        }
        if(Inc>=Timer)
        {
            osNpcRemove(npc);
            state Sense;
            //llResetScript();
        }
    }
}


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sat Feb 09, 2019 7:04 pm 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
This is one of the npc-notecards for the zombie being rezzed.
It is put into the rezzer, too:

{L_CODE}:
<llsd>

  <map>

    <key>serial</key>

    <integer>1</integer>

    <key>height</key>

    <real>2.27775502204895</real>

    <key>wearables</key>

    <array>

      <array>

        <map>

          <key>item</key>

          <uuid>14a46ca1-ad04-4f87-ba83-a3c47337ea6c</uuid>

          <key>asset</key>

          <uuid>d1b17d04-aa47-b716-0252-2774067df4af</uuid>

        </map>

      </array>

      <array>

        <map>

          <key>item</key>

          <uuid>958ef428-cd38-41ed-8928-d741b9d6f4d5</uuid>

          <key>asset</key>

          <uuid>6e9d03e9-c860-39fd-f5b2-6b9dc8af95ec</uuid>

        </map>

      </array>

      <array>

        <map>

          <key>item</key>

          <uuid>796765f7-0a18-4c46-ac5b-08dd89e7bf30</uuid>

          <key>asset</key>

          <uuid>2837bf97-bf17-2d61-7c23-f1d4727c45d3</uuid>

        </map>

      </array>

      <array>

        <map>

          <key>item</key>

          <uuid>38af9ac9-f61c-4013-bcd1-4030622336ec</uuid>

          <key>asset</key>

          <uuid>5994f6d5-d64f-eea1-d4c4-86fd4ff7f1db</uuid>

        </map>

      </array>

      <array />

      <array>

        <map>

          <key>item</key>

          <uuid>524721bd-d364-49dd-b07f-9c7788987493</uuid>

          <key>asset</key>

          <uuid>440db857-154d-76f9-e703-0b5a6191506f</uuid>

        </map>

      </array>

      <array />

      <array />

      <array />

      <array />

      <array />

      <array />

      <array />

      <array />

      <array />

    </array>

    <key>textures</key>

    <array>

      <uuid>cc7a030f-282f-c165-44d2-b5ee572e72bf</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>4934f1bf-3b1f-cf4f-dbdf-a72550d05bc6</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>4934f1bf-3b1f-cf4f-dbdf-a72550d05bc6</uuid>

      <uuid>4934f1bf-3b1f-cf4f-dbdf-a72550d05bc6</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c348941b-39c4-4e8d-86d4-797be7c122dc</uuid>

      <uuid>466645df-20de-4006-804d-144473cf285a</uuid>

      <uuid>99a00eec-4766-4b4d-af34-5d428052d0c7</uuid>

      <uuid>48a911fa-c1be-4a60-9a93-ced127f8976f</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>c228d1cf-4b5d-4ba8-84f4-899a0796aa97</uuid>

      <uuid>405330b1-1d41-48a2-80da-2c5cbc5ddcb4</uuid>

    </array>

    <key>visualparams</key>

    <binary encoding="base64">voefADp/OHD/KwD/ZiS3/6orEVYo9MJ/P//l0/7R///LNf9oAAB/AAAAAAAAfwAAAAAAAAAAAAAAAACHcAAAAAAAAAAAAAAAAL8AAI4AAIlwUFV/f/+EMGTY1szMzDMZWUzMLwAAWKLUdV7/jAB/EX9/f4QA6Uzl/7ZBAOL//z8AAAAAf38AAAAAfwCfAACyf0kAANt/yZF/AABqEn+CANbMxgAA062Z4v/G////v7+/////SUT//////////////wD//////wB1//8ZZP////9UAKMAAC3///8=</binary>

    <key>attachments</key>

    <array>

      <map>

        <key>point</key>

        <integer>28</integer>

        <key>item</key>

        <uuid>49c218e9-b8df-4842-bd69-7e075a9a4532</uuid>

        <key>asset</key>

        <uuid>0dedb2dd-5df2-4297-9564-94b7a21726c7</uuid>

      </map>

    </array>

  </map>

</llsd>


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sat Feb 09, 2019 7:49 pm 
Site Admin
User avatar

Joined: Sun Jun 27, 2010 10:34 am
Posts: 156
Location: France
thanks for the script :) :geek:

_________________
Paela Argus,
Webmanagement and maintenance servers grid, Osgrid

https://www.osgrid.org


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sun Feb 10, 2019 3:02 am 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 235
Location: Belgium / Brussels
... or this one to works with a NPC :P
{L_CODE}:
// Simple Sensor Quizz III v0.1 by djphil (CC-BY-NC-SA 4.0)

integer teleport = FALSE;
vector position = <128.0, 128.0, 25.0>;
float range = 2.0;
float rate = 5.0;

list questions = [
    "\nQuestion #1: ... ?",
    "\nQuestion #2: ... ?",
    "\nQuestion #3: ... ?"
];

list responses = [
    "yes, true, oui, 1",
    "no, false, non, 0",
    "Opensim, OpenSimulator"
];

key avatar;
list avatars;
integer random;
integer counter;
integer handler;

key zombie;
vector inipos;

string question()
{
    integer count = llGetListLength(questions);
    random = (integer)llFrand((float)count);
    return llList2String(questions, random);
}

integer response(string response)
{
    string csv = llList2String(responses, random);
    list buffer = llCSV2List(llToLower(csv));
    if (~llListFindList(buffer, [llToLower(response)])) return TRUE;
    return FALSE;
}

default
{
    state_entry()
    {
        if (llGetInventoryName(INVENTORY_NOTECARD, 0) != "appearance")
            osOwnerSaveAppearance("appearance");
        inipos = llGetPos() + <0.5, 0.0, 1.0>;
        llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate);
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
    }

    sensor(integer n)
    {
        if (counter > 5)
        {
            llListenRemove(handler);
            llSetStatus(STATUS_PHANTOM, FALSE);
            llRegionSayTo(avatar, PUBLIC_CHANNEL, "You loze " + llKey2Name(avatar));
            if (teleport == TRUE) llTeleportAgent(avatar, "", position, ZERO_VECTOR);
            llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0);
            llSetText("", <1.0, 1.0, 1.0>, 1.0);
            llSetAlpha(1.0, ALL_SIDES);
            osNpcRemove(zombie);
            avatars = [];
            counter = 0;
        }

        avatar = llDetectedKey(0);

        if (!~llListFindList(avatars, [avatar]))
        {
            if (llGetListLength(avatars) < 1)
            {
                avatars += avatar;
                llSetAlpha(1.0, ALL_SIDES);
                llSetStatus(STATUS_PHANTOM, FALSE);
                vector agent_pose = llDetectedPos(0);
                rotation agent_rote = llDetectedRot(0);
                vector offset = <1.0, 0.0, 0.0>;
                offset = offset * agent_rote;
                agent_pose += offset;
                zombie = osNpcCreate("NPC", "Zombie", inipos, "appearance");
                osNpcSetRot(zombie, agent_rote * llEuler2Rot(<0.0, 0.0, 180.0> * DEG_TO_RAD));
                osNpcSayTo(zombie, avatar, PUBLIC_CHANNEL, question());
                handler = llListen(PUBLIC_CHANNEL, "", avatar, "");
                llSetText(llKey2Name(avatar), <1.0, 1.0, 1.0>, 1.0);
            }

            else if (!~llListFindList(avatars, [avatar]))
            {
                osNpcSayTo(zombie, avatar, PUBLIC_CHANNEL, "Sorry " + llKey2Name(avatar) + ", the game is buzy ...");
            }
        }

        ++counter;
    }

    no_sensor()
    {
        avatars = [];
        counter = 0;
        osNpcRemove(zombie);
        llSetAlpha(1.0, ALL_SIDES);
        llSetText("", <1.0, 1.0, 1.0>, 1.0);
    }

    listen(integer channel, string name, key uuid, string message)
    {
        if (uuid == handler)
        {
            message = llStringTrim(message, STRING_TRIM);

            if (response(message) == TRUE)
            {
                counter = 0;
                avatars = [];
                llListenRemove(handler);
                osNpcSayTo(zombie, uuid, PUBLIC_CHANNEL, "You win " + name);
                llSetText("", <1.0, 1.0, 1.0>, 1.0);
                llSensorRepeat("", "", AGENT_BY_LEGACY_NAME, range, PI, rate * 2.0);
                llSetStatus(STATUS_PHANTOM, TRUE);
                llSetAlpha(0.25, ALL_SIDES);
                osNpcRemove(zombie);
            }
        }
    }
   
    on_rez(integer n) {llResetScript();}
}
Enjoy! :)

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


Top
 Profile  
 
 Post subject: Re: vocabulary "zombie" quiz
PostPosted: Sun Feb 10, 2019 11:19 am 
Furious Typer

Joined: Mon Feb 13, 2017 1:53 pm
Posts: 65
Thanks very much for your great work.

Unfortunately, "osNpcSayTo" isn't supported by my OSGrid OpenSim version
(osgrid-opensim-11262018.v0.9.1.dc9f0d3).

"llRegionSayTo" didn't work, either.

I probably have to change some settings in the Opensim.ini, but I don't know how.
I tried the current Opensim-version, but that didn't work, either.

Any ideas will be appreciated.
Thanks.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 2   [ 18 posts ]
Go to page 1, 2  Next


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net