Tuesday, 13 December 2011

Room - Closer Inspection

Well as you can see this is an image of the inside of the building featured in the pit and can you see a fault well there's a random wooden slab covering the wood, Its not mine .. however in this room there is a sneaky target hiding behind sandbags supposedly enjoying some TV.

Name of Object: British Invasion Advert Poster (excluding infoboard external part)
Elements in Object: Unknown
Creator: Diavolo Creations
URL Location: https://marketplace.secondlife.com/stores/40737

Name of Object: Wooden Table
Elements in Object: Four Cylinders,Box
Creator: Althalos Dragovar (Me)
How its Made: Create four equal thin cylinders as legs and space out evenly then create a thin box as a base

Name of Object: Busted Wasteland TV
Elements in Object: Unknown
Creator: Spots Sporg
URL Location: https://marketplace.secondlife.com/p/Busted-wasteland-TV/2379178

Final Product Run

video
this view shows how an agent should use the box and billboard provided at the entrance at "The Pit"
video
This last video shows my run round "The Pit" demonstrating how to use it... Just, In order to get both HUD'S in I put the ScoreHUD as Centre and TimingHUD as Bottom, this allowed me to view both HUD's effectively without much problem.

Billboard (Note Giver) & Box (Item Giver)


this is a billboard that gives agents willing to participate in my game the general instructions and comments.

The Code:

string text="Instructions";
string notecard="Instructions";
//Variables used to give names to needed functions with the scripting
default
{
    state_entry()
    {
     llSetText(text,<1.0,1.0,1.0>,1);
             if(llGetInventoryType(notecard)!=-1)
// Searches for the note card contained within the prim's inventory by the name given
        {
             llOwnerSay("Card Successfully added to inventory.");
// this is added so that once a card has been given to wanted agent they will be messaged 
        }
        else
        {
            string name=llGetInventoryName(INVENTORY_NOTECARD,0);
            if(name)
            {
                notecard=name;
                llOwnerSay("notecard was not found in inventory(or not correct name), setting to first notecard I     see in my inventory("+notecard+").");
// this is added so that if the billboard is click but does not contain anything with in its boundaries a error //message will appear to the agent
            }
            else
            {
                llOwnerSay("no notecard was found in inventory.");
            }
        }
    }
    touch_start(integer total_number)
    {
        llGiveInventory(llDetectedKey(0),notecard);
// gives the specific item to the agent
    }
}



This is the image of the code for the note giver, the message that an agent receives and the items within the billboards inventory.

Message that a agent receives when the note card is given to the agent.

Box (Item Giver)


This image is of the "The Pit" course box, this will give agents all the HUD and their read me's in one click the below is the code.

The Code:


// When any user clicks this object, this script will give a folder containing everything in the objects inventory
// This could be used to give away multiple freebies at once. 
default
{
    touch_start(integer total_number)
    {
        list        inventory;        integer     num = llGetInventoryNumber(INVENTORY_ALL);
        string      script = llGetScriptName();
        integer     i = 0;
        for (; i < num; ++i) {
            string name = llGetInventoryName(INVENTORY_ALL, i);
            //Don't give them the selling script.
            if(name != script)
            {
                if(llGetInventoryPermMask(name, MASK_OWNER) & PERM_COPY)
                {
                    inventory += name;
                }
                else
                {
                    llSay(0, "Don't have permissions to give you \""+name+"\".");
                }
            }
        }
        if (llGetListLength(inventory) < 1)
        {
            llSay(0, "No items to offer.");
        }
        else
        {
            // give folder to agent, use name of object as name of folder we are giving
            llGiveInventoryList(llDetectedKey(0), llGetObjectName(), inventory);
        }
    }
}

From this URL http://wiki.secondlife.com/wiki/LlGiveInventoryList

This image displays the code, the contents of the box and the message that an agent will receive once they click on the box.

Addition Prim Assets

In this post I am going to document the many assets that are located within my course.

Name of Prim: Iron Fence covered boxes
Elements of Prim: Iron fence texture, Stone Texture, Box
Creator: Althalos Dragovar (Me)
How it was created: Created two boxes one medium which was covered with a stone texture, one large box with the texture of the iron fencing I then moved the larger one over the medium box with them both still selected linked them together.


Name of Prim: Wooden Struts
Elements of Prim: 7 Old Wood textured boxes, 4 Metal textured box poles
Creator: Althalos Dragovar (Me)
How it was created: Created by making one horizontally long boxes and copying and pasting 7 times then finally texturing them with the old wood style texture then in the corners imputing 4 vertically large metal textured poles.

Name of Object: Walls
Elements of Object: Box, Brick texture
Creator: Althalos Dragovar (Me)
How it was made: Created vertically long box and textured with brick style



Name of Object: Sandbags
Elements of Object: 2 boxes
Creator: Althalos Dragovar (Me)
How it was made:
Created by making two equal boxes and changed the settings in the object section called taper X value - 0.40 and Y value 0.05 and then change the slice setting to the E value to 1.000 and the path cuts E value to 1.000 and finally used a cloth style texture.


Name of Object: Target Shelter
Elements of Object: 2 triangle prims, 6 box prims
Creator: Althalos Dragovar (Me)
How it was made:
Four boxes made in the formation to have square passage in the middle for viewing then linked together with two triangles to the sides and two finally box prims to the top and bottom and coloured white




Name of Object: Target & Barrels
Elements of Object: 4 Cylinders (Barrel), 2 Spheres (Target), Box (Target)
Creator: Althalos Dragovar
How it was made:
Barrel: One cylinder vertically extended and then one small cylinder which was horizontally larger then the vertically large cylinder which then put in to make the appearance of a ridge and repeat two more times.
Spheres squished horizontally then connected to make a head and shoulder pattern then box vertically large linked to the bottom to make a body.



Name of Object: HK 45 USP Pistol ( Decorative)
Elements of Object: Unknown
Creator: Arsenal Inc.
URL Location: https://marketplace.secondlife.com/p/Arsenal-inc-Hk-45-USP-PISTOL-USER-MANUAL/2832618


 


Name of Object: Grunge City Advertising Set (Decorative)
Elements of Object: Unknown
Creator: Diavolo Creations
URL Location: https://marketplace.secondlife.com/p/DC-Grunge-City-Advertising-Set/1974179




Name of Object: Game Helping Asset Boxes
Elements of Object: 3 boxes
Creator: Althalos Dragovar (Me)
How it was made: Two vertically and horizontally large boxes for the main box one smaller then the other to make a inward partition then one vertically large horizontally small box for the lid and then angled to a 25 degree angle.

Timer HUD

There is also a secondary HUD that can if agents want to implement onto their interface which is the timer HUD, this HUD has been custom made from a script originally made from a agent called Frankwhiteaka Blanco which can be found in its originality at this URL location in the Second life marketplace https://marketplace.secondlife.com/p/Precision-Timer-Script/512534

I did this as I haven't got an extensive knowledge of LSL language however I was able to modify his precision timing script to turn into a stopwatch which would work specifically on my course

The Code:


//  Purpose
//  --------------------------------------------------------------
//  This is a basic example of how you can create a stopwatch.
//  
//  Requirements
//  --------------------------------------------------------------
//  A single prim is all that is necessary for this example.
//  Usage
//  --------------------------------------------------------------
//  Touch the object to toggle the timer off/on
//  I have modified the stopwatch so that once an agent touches a checkpoint located on my course this will //stop or start the timer
//  type "reset" to reset the timer.  Not case-sensitive.
//  GLOBAL VARIABLES
//  --------------------------------------------------------------
integer g_Seconds   = 0;        //  Globaly store the Seconds
integer g_Minutes   = 0;        //  Globaly store the Minutes
integer g_Hours     = 0;        //  Globaly store the Hours
integer g_Ticking   = FALSE;    //  Toggles the timer off/on
vector  g_TextColor = <0,0,1>;  //  Text color for the timer. <1,1,1> = White <0,0,1> = Blue
//  FUNCTIONS
//  --------------------------------------------------------------
//  This is a simple function to zero pad the numbers 2 spaces to make
//  the timer look more authentic.  It takes an integer as an argument
//  and outputs a string.
string zero_pad(integer number)
{
    if(number < 10) return "0" + (string)number;
    return (string)number;
}
//  EVENTS
//  --------------------------------------------------------------
default
{
    state_entry()
    {
        //  ------------------------------------------------------
        //  This is the entry-point of the script.  After a script
        //  has been saved or reset, this event will fire off first
        //  ------------------------------------------------------
        //  We call llSetText() first to reset the text above the object
        //  back to 00:00:00 time.
        llSetText("00:00:00", g_TextColor, TRUE);
        //  Set up a listener so that we can reset the timer by typing
        //  "reset".  This particular listener will listen to any chat
        //  typed by anyone (or any object)
        llListen(0, "", "", "");
        //  Finally, we set up a timer that will repeat itself every
        //  g_Ticking seconds.  Since g_Ticking could only ever possibly
        //  equal 0 or 1, we can use this to our advantage in optimizing.
        //  This particular example is not necessary, but can have a 
        //  dramatic impact on larger scripts.  Note that setting a timer
        //  to 0 (False) will indeed turn off the timer.
        llSetTimerEvent(g_Ticking);
       
        llCollisionFilter("EnterBx","",TRUE);
        // will only accept collisions with the object named EnterBx - this is my part of the coding
       // this simple part of the code means that the stop watch will only operate once an agent
       // has been in contact with a prim name "Enter Bx"
    }
    collision_start(integer num_detected)
    {
        //  If someone touches the object, it will toggle the timer off/on
        //  We can avoid using if/else statements here because of the
        //  nature of our timer.  Using an exclamation in front of the
        //  variable "flips" the bits.  In this case, our variable is either
        //  only ever TRUE (1) or FALSE(0).  Since we need the timer to
        //  tick each second, this becomes a nice optimization method.
        g_Ticking = !g_Ticking;
        llSetTimerEvent(g_Ticking);
    }
    listen(integer channel, string name, key id, string message)
    {
        //  This event is fired off whenever anyone chats around the object
        //  and a proper listener is set up, such as in state_entry()
        //  We take the message and make it all lowercase so that the word
        //  "reset" is not case-sensitive
        message = llToLower(message);
        if(message == "reset")
        {
            //  The filter determined that the word "reset" was typed.  So
            //  we need to reset everything back to 0, and turn the timer off
            g_Ticking = FALSE;
            llSetTimerEvent(0);
            llSetText("00:00:00", g_TextColor, TRUE);
            g_Seconds = 0; g_Minutes = 0; g_Hours;
        }
    }
    timer()
    {
        //  This event fires off each second because the integer 1 is being
        //  passed as the argument for seconds in llSetTimerEvent(float seconds)
        //  Incriment the global Seconds variable by 1
        g_Seconds++;
        //  If seconds are at 60, then we've just made a minute
        if(g_Seconds >= 60)
        {
            //  So we increment the global minutes by 1, and reset the seconds.
            g_Minutes++;
            g_Seconds = 0;
            //  If the minutes are at 60, then we've just made an hour
            if(g_Minutes >= 60)
            {
                //  Increment the global hours by 1, and reset the minutes.
                g_Hours++;
                g_Minutes = 0;
            }
        }
        //  Display everything above the object.  Notice the use of the zero_pad()
        //  function that we created earlier to make the timer look better.
        llSetText(zero_pad(g_Hours) + ":" + zero_pad(g_Minutes) + ":" + zero_pad(g_Seconds), g_TextColor, TRUE);
    }
}


This image show the location of the first designated Checkpoint at the start of the obstacle course

This image displays the timerHUD in the interface of my Agent
This image shows the location of the second and last checkpoint in my game which is located at the end of the course this part of the course will stop the TimerHUD

This image shows of the box that contains the TimerHUD (middle box)

this is an image showing the timingHUD in action

this is an image showing the timingHUD stop

Coding - Scoring HUD and Hit Detection

In this section of the blog I am going to talk about some of the scripting that was implemented into my game, this section of the coding will relate to the Scoring HUD which characters if want to can implement into their interface to develop a "killing" score through the duration of the course.

The Code:


integer listen_handle_headshot
integer listen_handle_score;
integer listen_handle_reset;
integer playerScore =0;


//the games global variables which are the names that will represent a figure that will contribute to the final //HUD's scripting


default
{
state_entry()
{
listen_handle_score = llListen(0, "terror",NULL_KEY,"Target Hit");
// this means that the variable will be initiated once a callback has been announced using a specific channel
// with this once Target Hit has been announced from the prim named terror using the channel 0
//this variable will be made into use
listen_handle_headshot = llListen(0, "terrorhead",NULL_KEY,"Headshot!");
listen_handle_reset = llListen(0, "", NULL_KEY,"reset");
//This one is much like the description above however its role is different which you will see in the below //portion of the code
llSetText("Score:"+(string)playerScore,<0,0,255>,1.0);
}
listen(integer channel, string name, key id, string message)
{
if (message == "Target Hit")
{
playerScore++;
//Once the message Target Hit has been announced in the listening channel of 0 from the prim terror 
//the score of the player will increase by the value of 1
llSetText("Score:"+(string)playerScore,<0,0,255>,1.0);
//llsettext Displays text that hovers over a prim with a designated colour and translucency this has to be //announced after each variable change to make sure the text resets and changes to the desired effect
}
{
playerScore++;

else if (message == "Headshot!")

//Once the message Headshot! has been announced in the listening channel of 0 from the prim terrorhead 
//the score of the player will increase by the value of 1


llSetText("Score:"+(string)playerScore,<0,0,255>,1.0);
}
else if (message == "reset")
{
playerScore =0;

//Once the message reset has been announced in the listening channel of 0 from the agent 
//the score of the player will reset back to the starting value of 0 which is indicated in the above code

llSetText("Score:"+(string)playerScore,<0,0,255>,1.0);
}
}
}

this is the coding in world and from the image you can also see the HUD in the players interface currently showing a score of 10.. this was done to test if the script was actually running.

Hit Detection Code

This scripting is used in the targets that are going to be hit by the agents that play the game, this code is very simplistic and corresponds with the code displayed above.

The Code:

Body Shots:


default
{
state_entry()
{
llSay(0, "Target ready!");
}
collision(integer num_detected)
{
if(llDetectedName(0)=="bullet")
{
// this is written so that this prim once active will follow the listening channel of 0 and once the rezzing prim of //"bullet" hits the target prim it will be detected and do the following action below
llSay(0,"Target Hit");
// once the target prim has detected that it has been hit by the rezzing prim by the name of "bullet" it will now //initiate this action of saying "Target Hit" in the listening channel of 0 which corresponds with the scoring HUD //script
}
}
}

Headshots:

default
{
state_entry()
{
llSay(0, "Target ready!");
}
collision(integer num_detected)
{
if(llDetectedName(0)=="bullet")
// this is written so that this prim once active will follow the listening channel of 0 and once the rezzing prim of //"bullet" hits the target prim it will be detected and do the following action below
{
llSay(0,"Headshot!");
// once the target prim has detected that it has been hit by the rezzing prim by the name of "bullet" it will now //initiate this action of saying "Headshot!" in the listening channel of 0 which corresponds with the scoring HUD //script
}
}
}


this is an image of the code for the body target


and these images display the names of the prims that are associated with the scripted codes to show the correspondent assets