Joshua a.k.a sigonasr2's Blog

January 25, 2012

New Laptop (Birthday Gift)

Filed under: Uncategorized — Tags: , , , , , , — sigonasr2 @ 11:42 PM

Well, it has been 4 years (Exactly!) now since my last new laptop, and it was about time for a change!

So what laptop did I end up getting? A pretty darn good one. I was looking with my father at the various laptops we could find at stores. We were on some sort of budget, so looking at some higher end laptops online was not really an option, and buying it locally for my birthday seemed the most sense. We found this at Staples.

An HP Pavilion dv7 laptop. Once I saw this thing I knew that was what I would want to have for perhaps the next 4-8 years of my life.

This thing is pretty darn good. 17.3 inch wide screen, Intel i7 Core processor (Quad-Core, 8 threads @ 2.00 GHz), 750 GB Hard drive, 6GB RAM. 4 USB ports, two per side, full size keyboard, large touchpad, a fingerprint scanner, HD webcam, Blu-Ray drive. This thing is pretty good! It was actually over my father’s budget, but I helped him a little with my money, so it is all good! I do hate the fact that most laptops have their Function (F Keys) only available by holding down the Fn key before hitting one of them. Otherwise they do things like change brightness, music controls, volume, etc. I believe there is a program though that can toggle them.

More details about the processor can be found at http://ark.intel.com/products/52219/Intel-Core-i7-2630QM-Processor-(6M-Cache-2_00-GHz)

I am pleased with its performance and definitely will not mind it. It comes with pretty loud speakers too from Beats Audio. Overall, I would rate the laptop 4.5/5.0. For about $800. Never imagined money could buy this kind of computer power. But we get more and more as time goes on!

750GB? I will Never run out of hard drive space. I think my entire life I have used about 80-100GB worth of data, programs, music, videos, etc. Now I have way too much space!

This is definitely an upgrade, and a wonderful birthday gift! (Birthday’s on January 31st, in case you are curious.)

The Windows Experience Index was very high too. I remember my old laptop having the lowest score at 2.9 and the highest at 3.8.

Funny thing though, we got this laptop at a $75.00 markdown because they sold out, but my father really knew I wanted it. They gave him the one that they used on display, cleaning it up and everything of course. Staples, pretty good store for many things.

As you may know, I was doing a lot with Linux lately. I plan to stick with Windows for now. I have used it before, and I can use it again. You have to admit, Windows is definitely better since Windows 7. Don’t fret though! My server remains on Ubuntu along with my old laptop. I even have my oldest laptop with a dual boot Ubuntu/Windows XP mix.

I will still be doing lots of programming, in fact, by going back to Windows my live streams will be as prevalent as ever! Glad to be on such a powerful computer for once in my life, I can say I am very satisfied for now. I got most of my productivity programs (I did not forget them!) and I am ready to go!

January 10, 2012

January – New Year, More Fun

Filed under: Uncategorized — Tags: , , , , , , , — sigonasr2 @ 4:14 PM

Welcome! Another new year is underway and it feels like a very fresh beginning to what will be a great year for me.

I spent a lot of time thinking of resolutions for me this year, but could not really find anything that I knew I would really keep. But there was one goal I knew I had to accomplish this year:

-Build and Finish a Game

Believe it or not, I spent 8 years learning how to program and develop games and such, and have developed a few small games here and there, but never finished any of them at all! Some got more attention than I expected from others. Well, I always cut off my games in the middle of development. I will not count Free-Like, my roguelike I developed in 7 days because that is not really a full game, and forcing myself to push out the development or it was painful.

What I mean by this resolution is a complete, full-featured, game. And I chose one in the RPG genre for that too, which means it will more than likely be very large! The Weirdest RPG Ever, I mentioned it in my last post, will be what I am developing. I thought of the idea when I was 13 years old and started development, but soon got stuck as I had little experience with programming to develop the concepts I wanted. 5 years later, I am sitting in this chair willing to reach the goal of completing this game, and add even more than I intended!

And so I will! For the next 356 days left of the year (Leap year this year!), I will be developing this RPG until it is done. And note that I have only set one resolution, which means I can focus on just one goal with little distraction!

Also, I updated my site’s page at http://z-gamers.net or http://sigonasr2.servegame.org (They both are the same at the moment.)

If you notice on there at the very bottom, I have a little proposal.

I don’t know if anyone in the world is interested in working with me on The Weirdest RPG Ever, but I am working on it and would like to have a co-programmer to help too. I am looking for someone that is able to: a) Willing to devote a few hours every day working on the game, and b) Willing to learn, communicate, and discuss with me various aspects of the game, its development, the final product, and perhaps even creating the website for it.
What is in it for me? – You may be asking. Well, you need to have a great interest in top-down RPGs, and have to be a little accepting of a game that is not necessarily of high quality in terms of graphics. If you can appreciate the game that way, you already will enjoy making it as much as playing it in the future. However, there may also be money involved for your contributions. I would like to have someone that I could commission and say that you seriously have done a great job with working together on the game that I can pay anywhere from $200-$500 for such a person. But that is a lot of money, but then again, it’s a huge game.
If you think you’re worth it, I would like to ask if you can apply to me. Just email me using one of the following:




So, if you just finished reading that, I am looking for someone who is extremely dedicated to one project. Like I said, this is very hard to do since most people tend to get bored with something. I am hoping someone in the world can step up. If you want to know more of what TWRPGE looks like, you can watch one of my desktop recorded streams of my current work on it at http://www.twitch.tv/sigonasr2/b/304711160. Skip around through various parts of it to see the game in action so far.

That is all for now folks. I also am participating in 7DRL 2012 when they announce a date. That usually happens in February, so stay tuned to hear about that also!

December 31, 2011

Minecraft, TWRPGE, Server, and iPod

Usually I have steady articles being streamed out on my blog, but this time I got quite a bit of catching up to do since November!

The only thing I posted last time was BZStocks, since then quite a bit has been happening.

My brothers and I have started up a Minecraft server for ourselves to play on. I have been reading about Minecraft, hearing about it from friends, and being begged to play it. Unfortunately, I was quite busy during any time I was asked and everyone just said “You have to try it!” No one ever gave me good reason to. But I guess my brothers are a good enough reason because sure enough, after they said it, I immediately agreed. I bought three Minecraft licenses so we can all play simultaneously and we began our wonderful journey of Minecraft.

(Click more to begin reading!)

(more…)

December 2, 2011

BZStocks

Filed under: Uncategorized — Tags: , , , , , — sigonasr2 @ 9:02 AM

Today I will be talking about a fun little PHP project I am working on called BZStocks. I always had a fascination with numbers, stats, and simulations, so I thought it would be nice to give a stock market simulation a try with a little twist.

BZStocks takes servers from the game BZFlag and incorporates them into the simulation. The “economy” of BZFlag is determined by the popularity of a server. Therefore the market is completely influenced by the players in the market.

Simple enough, right? I always wanted a little side game to do apart from BZFlag when time permitted, and this seemed like the perfect thing to do. As far as markets go, progress is fairly slow and it takes much time for money and stocks to grow. While slow-paced may be a little too slow, keep in mind that the game BZFlag is meant to keep you occupied, not this. The goal of this little project is just something fun to do in addition to the game.

Anyways, enough talk. I have captured some screenshots of the alpha development version of the program. Buying and Selling is completely functional. The simulation updates all stocks once every 30 minutes (On the half-hour and hour). Players may then make choices and buy and sell stock. Each player that joins starts with $50,000 to spend on shares.

Want to join in? A description of the game is located at http://sigonasr2.servegame.org/bzstocks. You may register and start playing at http://sigonasr2.servegame.org/bzstocks/main.php. Once the testing phase is over, users that helped test the system may receive additional stock credit or money credit.

And now for some screenshots to explain the rest:

Here we see a page with stocks in the process of being sold and one stock being held back as it continues to build.

A list of all the stocks currently available. These are in the same order that they are in the BZFlag Server List so you can see what's popular right now.

Viewing details about one of the stocks.

A look at the Buy page, and selecting a stock to buy shares from.

Another account showing a user containing 5 different stocks currently purchased and prospering.

Why would I make such a thing? It is just for fun, and to enhance my PHP skills of course. There really is not much else to say about this other than players may either enjoy it or hate it. I highly doubt anyone is going to find it anyways, most of my projects are just little hobby things. (more…)

November 11, 2011

Gnome 3 is Nice

The title says it all. A friend told me about it, so I gave it a spin, and it is amazing to use. Once you get a handle on the very easy to learn keyboard shortcuts, things become even easier. Window management has never been so much fun and streamlined! I am unsure what the big fuss with Gnome 3 is, maybe there are issues for some. But if you get it working the way you want it, there is more to benefit from the Gnome 3 shell than Unity.

Here are some highlights of the visual features you get, in screenshot form (Click to view enlarged images):

Viewing the Gnome 3 "Activities" menu, you get a brief overview of all applications in that current workspace. This is slightly equivalent to WindowsKey+W in Unity, except it only shows the windows in the current workspace. You can access this menu in Gnome 3 either via the Windows key or bringing your cursor to the upper left corner (Which is a really neat and fast gesture!)

 

There were originally two windows in this workspace (Which is why my Youtube window is taking up only half the space). I just finished dragging my Geany window into a new workspace. And just like magic, a new empty workspace also appears!

Dragging a window inside one of the workspace thumbnails or dragging the window seen on-screen directly lets you quickly move windows between workspaces!

In the lower right hand corner, we have our currently running application icons. Their names show up as I hover over them. Right-Clicking them reveals the relevant window and right clicking gives me the options.

Just a quick little instant search I started typing to modify Startup Applications. This is how they appear, very similar to Unity here.

I am really liking Gnome 3, otherwise I wouldn’t have made this post in the first place! Also, if you type in something in search that is not found by your computer, it will be assumed to be a Wikipedia search, though a Google search can also be performed.

The three shortcuts you have to at least know to stay efficient with this environment are: Ctrl+Alt+ArrowKey (Up or Down), Ctrl+Alt+Shift+ArrowKey (Up or Down), and of course, the Windows key for accessing the menu. Though like I mentioned already, moving the mouse to the upper left is really convenient and easy too! When you are done looking at the menu, you can use the Escape key, click one of the workspace thumbnails, click a window, or bring your mouse back to the upper left corner to return to your main desktop.

If you do not like Unity, Gnome 3 is definitely worth trying out. I never hated Unity, but I thought it could be a bit better, especially when organizing windows. I would have to constantly perform Ctrl+Alt+Shift+ArrowKey combinations whenever I wanted a window to move. (Or the more annoying *Right-Click title of window to move* Press W > Number key of workspace to move it to.) The neat thing is, going from Unity to Gnome 3 will still allow you to use these familiar shortcuts! But there are also other ways to interact with windows now that make it even more interesting. (And fun!)

Want a bit more customization with your Gnome 3 interface? Give the package gnome-tweak-tool a try to modify some settings that you may not like that aren’t available to you normally. There are also the gnome-themes-more and gnome-themes-extras packages to give you a few more themes to try out.

Note that I’m not very informed about the complications or problems with Gnome 3. If it works and I find it enjoyable, I post my experiences so that others may try to duplicate such an experience. But I’m always open to comments and criticism!

October 30, 2011

Website, Excitement, Getting Back On Track

Filed under: Uncategorized — Tags: , , , , , , , , , , , , , — sigonasr2 @ 5:32 PM

A lot of things with my life has been happening for me, and things are beginning to look good for me.

To start things off, I am back to working on my website. I have decided during the process of making my website, I will be developing SIGPMS. The goal of SIGPMS is to be a Project Management System where I, or anyone with privileges can login to an administrator panel and create updates for projects, or even create new projects. The idea is simple: Provide a website with live feed updates that can be easily updated and maintained, allowing users to see the updates and interact with the developer(s). It will be written with PHP, MySQL, and AJAX, with underlying support for SVN and BASH.

I will explain it better through application: Let us say I have a Python project I am starting called MiniBytes. The reason I called it that or what its functionality is is irrelevant for this example. I head into the Projects page and click the Add New Project button. I already have created some self-defined categories for my projects, such as PHP, Python, BASH, CSS , C, Perl, and so on. I select that this project will belong in the Python category. I enter in the title MiniBytes for the title. I enter in /home/sigonasr2/minibytes in the SVN Project category. I add in a description in the Description box of what the project is and what I plan to accomplish with it. I also checkmark the boxes for “Announce on new commit”, “Announce on new Release”, and “Allow Project Comments”. My new project is ready to go, and on the front page where my News Feed is located, a new update appears that says “New Project Started: MiniBytes“. Users that click the linked article view the description of the project, the category it is in, and are given a public SVN location that they could check out if they want to stay up to date in development.

In addition, the Projects link now contains MiniBytes under the Python sub heading. My Active Projects link also show MiniBytes as being “New”. Users can find the individual project page and watch it for when I make new commits or if I release a tarball of the project for public release. I enabled the ability to allow project comments. Guests and registered users may comment on the project in general, or in a particular release. Another ability which I did not enable for this project is “Enable Project Forum”, which would split topics for that project into categories which I can define and control. This project is nothing fancy, so I did not worry about having separate discussion forums for it.

Each project has the ability to define new goals / milestones. A goal is a direct need to accomplish something that needs to be addressed for the current version. A milestone is a vision of what the release will end up being. Goals and milestones can be made public or kept private.

I can edit the categories and add new ones whenever I feel like it by clicking the Categories page in the admin panel. Here I can edit previously defined categories or make new ones. Each category can have an optional logo, that is displayed whenever I post an update for that particular type of category. For example, a PHP update would look like this:

  SIGPMS
Commit by sigonasr2 at 07:54:19AM 10/29/11

(SVN Revision 57 “Admin Panel handles MySQL queries correctly after updating categories.”)

I always had a hard time managing my projects, and I wanted a solution that could keep all my projects in one place, and that I did not have to update separately on various websites each time I wanted to get something done. I have decided to use my server as the platform for all my projects in the future. I hope that this project management system ends up being successful and easy for me, because I am getting lost with all my projects. This will take, at least a year to develop. I know it will. Every time I underestimate the date, I never get it done.

What I also want is to have one place where people that actually want to know what I’m doing, don’t have to look at bits and pieces of the web everywhere just to look at all my projects. Everything will be held in one place, nothing will get lost, and using hosted services such as Youtube, Google Code or WordPress will be kept to a bare minimum. If people are interested in my work, they can choose to register on my website, which is just simply choosing a username/nickname, adding a few details about themselves (Gender, Age, Location, if they want, it’s all optional), an email, an avatar to be identified by, and the ability to receive email updates if they choose to opt in on that.

On a less serious note, it will be like my own piece of the web. I highly doubt that many people are interested in my work at this point, because most of what I have done has been, like I mentioned above, unorganized. I am developing this piece of web software so that I can keep myself from focusing on the organization, and more time on the development itself. And people that want to stick around will definitely sign up and stay updated.

Eventually SIGPMS would be redesigned for other web users, and that will be distributed as a public release of this web software. Another goal when I do that is to provide not a strict web template that users do not have much flexibility to change, but only PHP pieces of the software, that have to be put together in a template and displayed. This will allow for the ability for anything in the software to be placed anywhere. The goal of the public release will be to allow for mobility of these modules.

 

So that was a lot of words, and a lot about one project. It is one I am seriously starting on, and I am glad to be doing so. I do not plan on working on other projects until this is done, because I figure that once this is done, I will have projects to do anyways. I have already made a list of future projects I am going to complete with this project management system, listed below:

PHP
- SIGCMS

Python
- Truck Rally

C
- Untitled Project
- Manufactoria DS
- Touhou: Perfect Cherry Blossom DS

BASH
- HTML Viewer
- The Package Master

Java
- BASH Haxorz

C++
- SDL Game (Of some sort)

I haven’t had any other projects come up, so these are the ones I do want to eventually finish. Some of them I have mentioned before, others not so much.

I will probably not be heard much from in the following few months, I’ll probably still manage a monthly blog post, but I think I am all set with a plan. And life is doing well for me, I mentioned that at the beginning, hehe. I rambled on too much, but my plan is laid out.

That is all for now!

October 14, 2011

October is Innovation Month

Filed under: Uncategorized — Tags: , , , , , , , , , , , , — sigonasr2 @ 7:21 AM

Greetings everyone, and here I post yet again for October. Recently, I have been doing quite a number of things, and all at the same time. There are many fun projects I am working on and I have not gotten bored with any of it.

To start with, I would like you to take a peek at http://sigonasr2.servegame.org for a quick moment. You will notice a couple of things. I hope the large header logo got your attention, and I hope that the right sidebar with the large numbers got some attention too. AJAX is a very cool technology and I am glad it has been invented. It allows the updating of text almost magically. Anyways, I plan to develop an AJAX site for grabbing dynamic content.

In other news, I started playing Touhou – Perfect Cherry Blossom (And some of the others, but right now I am mostly into PCB). Here is a game play video of me getting through the first three stages. This is now a week old and I have to admit I am slightly ashamed of this video now. But I will post a new one once I get extremely good.

 I also have spawned another concept for BZFlag in which I create a Touhou simulation, but for the game BZFlag, the goal being to dodge all the bullets. Another video below demonstrates this concept, and I have also created a thread on the BZFlag forums under “Works in Progress”. I highly recommend watching the video in 720p or 1080p to get full HD details, since the video is huge and has two BZFlag games side-by-side. One contains the Normal level run, and the other side contains the Hard level run.

If anyone out there is interested in learning how I made that or wants to help create waves or has wave ideas, do let me know!

Finally, BASH Haxorz, our Java Terminal game continues slowly but surely. (We have been rather busy lately!) I have also taken some time to start teaching a BZFlag player how to write plugins. I may eventually make a guide out of the tutorials I am writing, and hopefully one day it will help someone out since I am fairly knowledgeable in writing BZFlag plugins now.

I probably forgot what else I planned to discuss, but I will hold that off until next month. Until then, Goodbye~!

September 22, 2011

Moved Blog, Java Terminal Game Progressing

Filed under: Uncategorized — Tags: , , , , , , , — sigonasr2 @ 7:18 PM

If you are reading this, you have found the new location of my blog! And the reason why I did this was because I wanted to just have all of what I have done available on my own server, just in case I need direct access to it, I no longer have to download the files or rely on WordPress for it. I did get WordPress software in order to do this, and although I admit the software is a bit bloated, it still is great for content management and blogs.

I know it usually is not a good idea to move a big amount of data completely over to a new domain, but I had my reasons. It will take awhile for Google and other search engines to repopulate data for viewing online, as my old blog’s entries have been removed. There is a link from my old blog to my new one, but other than that all the links to the posts are currently broken.

In other news, my friend and I have begun work on a Java game. This Java game will involve an emulated BASH terminal, and I expect some of the more BASH-inclined users to enjoy this game once we have a final product! I cannot go into too much detail because there is not a whole lot to explain. I uploaded two videos to Youtube demonstrating the emulated features we have so far.

Hope you enjoyed those! Stay tuned for more details!

September 15, 2011

AIM Perl Bot Using Net::Oscar for SVN Updates

Filed under: Uncategorized — Tags: , , , , , , , , — sigonasr2 @ 2:27 AM

A friend and I had to work on a project, and we wanted the ability to receive instant messages whenever a new commit was made, so we could be notified of it. We quickly came up with a plan, to build a bot using Perl. My friend has heard of using Net::OSCAR, a module in Perl that you can use to connect to AIM‘s networks and send or receive and respond to messages using a bot. And I have to admit, it is really simple. There is just one problem. There is very little documentation around the web, and it is scattered everywhere! I will give you some pro tips to follow when building your bot, and hopefully that will help you along the way! Hopefully seeing more Net::OSCAR code available will be able to help others!

Our goal is to create a bot that tells us when an SVN repository is updated and what revision and comments were made along with who committed it. At first our logic was this: The script executes svnlook commands to find out information about the repository. In this case, we needed the revision number, author, and comments about the commit. So we quickly found those commands:

my $svn_revision = `svnlook youngest $pathToSVNRepo`; # Use `` to get the value of a BASH command
my $svn_commit_msg = `svnlook log $pathToSVNRepo`;
my $svn_revision_author = `svnlook author $pathToSVNRepo`;

As you can see, we initialized them in Perl format as we build the rest of our code. If you have not gotten Net::OSCAR do so. (And if you don’t even have Perl, well you will definitely need that!) Installation is simple, you will run the command perl Makefile.PL and then make and sudo make install. Once you do that, Net::OSCAR will be ready for including.

Top of our file we will declare a perl executable file:

#!/usr/bin/perl
use Net::OSCAR qw(:standard);

We also will include Net::OSCAR and use all of the commands available.

my $username = "awesomebot";
my $password = "tehpassword";
my $pathToSVNRepo = "/path/to/svn/repo";
my $pathToLastCommit = "/path/to/a/file";
my $recipient1 = "myaimname";
my $recipient2 = "myaimnamealso";
my $msg = ""; # Send the msg

We initialize some variables we are using in our project. Note that to make a bot, you have to make an AIM bot account believe it or not. The username and password for that bot will be filled appropriately. We need to specify where the svnlook commands will look. We make a file that we will use to store the value of the last commit we announced. This is so we don’t keep saying there’s a new commit and also makes sure we send it out when it does change. Add as many recipients as you want, we’ll get to use them later.

The next step is to initialize Net::OSCAR! Simple!

my $oscar = Net::OSCAR->new(); # Create a variable where we'll call all the 'oscar' functions from
$oscar->signon($username, $password); # Sign on to AIM
my $active=time()+5; #Set time.

At this point, your bot will happily be online and is ready to begin doing things! We set $active 5 seconds in the future because we want to check for commits every 5 seconds.

while (1)
{
    $oscar->do_one_loop();

Alright, now we begin the infinite loop of our program. Our bot will remain online the whole time, and to keep its online presence available, we have to run a socket loop continuously. This functions as a method for also looking at callbacks. Our program does not use callbacks, but I will explain them a bit at the end of this post.

if (time()>$active) {
# SVN info...
my $svn_revision = `svnlook youngest $pathToSVNRepo`; # Use `` to get the value of a BASH command
my $svn_commit_msg = `svnlook log $pathToSVNRepo`;
my $svn_revision_author = `svnlook author $pathToSVNRepo`;
# Get rid of the new lines...
chomp($svn_revision);
chomp($svn_commit_msg);
chomp($svn_revision_author);
$msg = "SVN Revision $svn_revision: "$svn_commit_msg" by $svn_revision_author"; # msg ready for sending

At this point, we see if the current time is past the 5 seconds that we originally gave it. Then we start looking for SVN updates! We also chomp the lines to get rid of excess newline characters that may be hidden. Finally, we prepare the structure of our message!

if (`less $pathToLastCommit` == $svn_revision)
{
    print "No recent commits.n";
}
else
{
    print "New commit. Sending message...n";
    open NEWFILE, ">", "$pathToLastCommit";
    print NEWFILE "$svn_revision";
    # Actually send the message now!
    $oscar->send_im($recipient1,$msg); # Send the message to recipient1
    $oscar->send_im($recipient2,$msg); # Send the message to recipient2
}
$active=time()+5;
    }
}

You may be thinking, “Why is there an if statement? I thought we were sending the message.” Well, remember that random file we had in a variable that we have to have? This will check to see if what our output from $svn_revision was updated or not! If they are not equal, something has changed, and we have to spread it to our recipients! As you can see, we also print to the console what is happening, so we know if we are sending an update out or just chilling without sending anything. The rest is pretty straightforward, and near the bottom, we setup the loop with 5 more seconds into the future before the next call of this while loop.

That is it! It really is! I mean, this bot will now tell us whenever we commit something! What a beautiful little script do you think so? The full script is right below in case you did not want it in pieces:

svnnotify.pl:

#!/usr/bin/perl
use Net::OSCAR qw(:standard);
my $username = "awesomebot";
my $password = "tehpassword";
my $pathToSVNRepo = "/path/to/svn/repo";
my $pathToLastCommit = "/path/to/a/file";
my $recipient1 = "myaimname";
my $recipient2 = "myaimnamealso";
my $msg = ""; # Send the msg
my $oscar = Net::OSCAR->new(); # Create a variable where we'll call all the 'oscar' functions from
$oscar->signon($username, $password); # Sign on to AIM
my $active=time()+5; #Set time.
while (1)
{
$oscar->do_one_loop();
if (time()>$active) {
# SVN info...
my $svn_revision = `svnlook youngest $pathToSVNRepo`; # Use `` to get the value of a BASH command
my $svn_commit_msg = `svnlook log $pathToSVNRepo`;
my $svn_revision_author = `svnlook author $pathToSVNRepo`;
# Get rid of the new lines...
chomp($svn_revision);
chomp($svn_commit_msg);
chomp($svn_revision_author);
$msg = "SVN Revision $svn_revision: "$svn_commit_msg" by $svn_revision_author"; # msg ready for sending
if (`less $pathToLastCommit` == $svn_revision)
{
    print "No recent commits.n";
}
else
{
    print "New commit. Sending message...n";
    open NEWFILE, ">", "$pathToLastCommit";
    print NEWFILE "$svn_revision";
    # Actually send the message now!
    $oscar->send_im($recipient1,$msg); # Send the message to recipient1
    $oscar->send_im($recipient2,$msg); # Send the message to recipient2
}
$active=time()+5;
    }
}

I mentioned earlier that I would explain the callback functionality of Net::OSCAR a bit more, and now I will. For our purposes, we ended up not using the callbacks, because none of our script is trigger-based. However, more people may want to use Net::OSCAR in a more interactive manner. You may have heard or seen those AI chatbots online before? You could potentially build one with this framework too, it requires a lot of time and thinking however. But let me give you a bit of sample code. The very simple echo bot which will say things you said right back at you.

#!/usr/bin/perl
use Net::OSCAR qw(:standard);
my $screenname = "echobot2000"; # My name.
my $password = "secretpassword"; #Password here.
my $recipient1 = "myself"; # Send it to a person.
my $recipient2 = "myvictim"; # Send it to another person.

sub im_in {
    my($oscar, $sender, $message, $is_away) = @_;
    $oscar->send_im($recipient1,$message);
    $oscar->send_im($recipient2,$message);
}

my $oscar = Net::OSCAR->new();
$oscar->set_callback_im_in(&im_in);
$oscar->signon($screenname, $password);
while(1) {
    $oscar->do_one_loop();
}

Now time to go over all this code! As you can see, we specified recipients again. This time, I added a subroutine into the mix. Why did I do that? It is because of the callbacksNet::OSCAR has. If we skip past the subroutine for now and see the $oscar->set_callback_im_in(&im_in); line, we will notice we are creating a reference to im_in as a callback. If we quickly browse to the callback im_in documentation:

im_in (OSCAR, FROM, MESSAGE[, AWAY])
Called when someone sends you an instant message. If the AWAY parameter is non-zero, the message was generated as an automatic reply, perhaps because you sent that person a message and they had an away message set.

As you can tell, the documentation gives the callback name, and returns the Net::OSCAR handle, who a message was received from, the message they sent, and whether they are away or not.

Is this starting to make sense inside that subroutine now? The callbacks give us information to use. We then take that data and do something with it, such as send an instant message back now with their repeated message! Essentially an echo bot!

I should have linked to this earlier, but you probably found it already, the Net::OSCAR documentation can be found at http://search.cpan.org/~toddr/Net-OSCAR-1.928/lib/Net/OSCAR.pm. I was not very helpful when I first took a look at it, but now it’s amazingly handy!

Look through the callbacks, get familiar with them, and let me give you a quick fun little program to try:

#!/usr/bin/perl
use Net::OSCAR qw(:standard);
my $screenname = "stalkerbot400"; # My name.
my $password = "secretpassword"; #Password here.

sub type {
    my($oscar,$name,$status) = @_;
if ($status==$oscar->TYPINGSTATUS_STARTED)
{     $oscar->send_im($name,"I see you... You're trying to say something to me. Carry on.");    }
}

my $oscar = Net::OSCAR->new();
$oscar->set_callback_typing_status(&type);
$oscar->signon($screenname, $password);
while(1) {
    $oscar->do_one_loop();
}

This post was created on September 15th, 2011, which means Net::OSCAR has lived up to its expectations and performing well for all of us! I hope you enjoyed this post, if you have any questions about Net::OSCAR, there is not much documentation out there, and you may need help, do leave a comment and I will try to answer to the best of my ability! And I thank my friend I am working with for teaching me the power of Perl. ;)

By the way, make sure you have all the dependencies of Net::OSCAR, otherwise some features may not work. You may run my script to check if you have all dependencies. If any messages pop up, you are missing it and need to hunt it down! http://sigonasr2.servegame.org/uploader/multi-file-uploader/uploads/net::oscar_check.sh

August 27, 2011

BZFlag Feature – Ratio Tracking

Filed under: Uncategorized — Tags: , , , , , , , , , — sigonasr2 @ 1:24 AM

Greetings all. Today I will be introducing you to the BZFlag feature called Ratio Tracking. If you are a BZFlag player and have seen me online, you may have noticed in my motto something like this: Ratio: 316-247 (1.28) [Commander]. What this is, is my Ratio Tracking feature for BZFlag at work! By adding this feature into BZFlag, you will be able to keep track of your kills to deaths! You will also be able to disable the tracking or displaying of it in your motto at anytime! You get a cool ranking to go with it too! Let us begin:

You will first have to get the source code from the BZFlag SVN trunk. You can do so with the following command:

svn co https://bzflag.svn.sourceforge.net/svnroot/bzflag/trunk/bzflag

The source code will be downloaded to your computer. It is the latest version from trunk that is stable.

You will be modifying four files. These four files will be:

./src/bzflag/LocalPlayer.cxx
./src/bzflag/GUIOptionsMenu.cxx
./src/bzflag/JoinMenu.cxx
./src/bzflag/MainMenu.cxx

LocalPlayer.cxx: We are modifying this file to add in the tracker for a kill or death when it occurs. WARNING! This is a very critical file. DO NOT modify anything else in this file, for you will ruin gameplay.

Search (Ctrl+F) for Player::changeScore(deltaWins, deltaLosses, deltaTks);
Add after that:
if (BZDB.isTrue("killerratio")) {
          FILE*data;
          char temp[75];
          int kills;
          int deaths;
          kills=0;
          deaths=0;
          data=fopen("stats","r");
          if (data) {
              fgets(temp,75,data);
              kills=atoi(temp);
              fgets(temp,75,data);
              deaths=atoi(temp);
              fclose(data);
            }
          data=fopen("stats","w");
          if (data) {
              kills+=deltaWins;
              deaths+=deltaLosses;
              fprintf(data,"%dn%dn",kills,deaths);
              fclose(data);
            }
      }

What we are doing here is adding to the changeScore function. We do it here because when the score changes, so does our kills and deaths. The deltaWins and deltaLosses variables tell us if we gain points from kills or lose points from deaths. You can also include deltaTKs if you want, but I did not since that may not accurately reflect the value. Note that we added a new BZDB variable called “killerratio” which is whether or not this feature is enabled to begin with. Finally we write it to a file. I realize you could easily modify the file later on if you felt like it, but come on, that would not be fun. Better to see how good you are and actually gain points than just rig the darn thing.

Moving on to the next file.

GUIOptionsMenu.cxx:

Search for option->setLabel("Motto Display Length:");
Skip down 5 lines until after the listHUD.push_back(option); part.
Add after that:
  // Ratio Tracking
  option = new HUDuiList;
  option->setFontFace(fontFace);
  option->setLabel("Ratio Tracking:");
  option->setCallback(callback, (void*)"V");
  options = &option->getList();
  options->push_back(std::string("Off"));
  options->push_back(std::string("On"));
  option->update();
  listHUD.push_back(option);

  // Ratio Tracking in Motto
  option = new HUDuiList;
  option->setFontFace(fontFace);
  option->setLabel("Display Ratio in Motto:");
  option->setCallback(callback, (void*)"W");
  options = &option->getList();
  options->push_back(std::string("Off"));
  options->push_back(std::string("On"));
  option->update();
  listHUD.push_back(option);

What we do here is add two options to the GUI Settings of the Options Menu. Those are Ratio Tracking and Display Ratio in Motto. We also give them unique identifiers, V and W. I just chose those since they were not used. Finally, they have two settings, Off and On.

But there is more to do in this file.

Search for ((HUDuiList*)listHUD[i++])->setIndex((int)BZDB.eval("mottoDispLen") / 4); Add after that:
((HUDuiList*)listHUD[i++])->setIndex(BZDB.isTrue("killerratio") ? 1
                 : 0);
  ((HUDuiList*)listHUD[i++])->setIndex(BZDB.isTrue("displayratio") ? 1
                 : 0);

These will setup the link between the menu options and the BZDB variables. We have two variables, killerratio and displayratio. killerratio like we already talking about, can enable or disable the tracking completely. displayratio is whether or not to display it in the motto. As the GUI option we added above states.

Finally, we have to add a few more lines.

Find case 'E': Skip down three lines until after the break; part.
Add after that:
case 'V':
      {
    BZDB.set("killerratio", list->getIndex() ? "1" : "0");
    break;
      }
    case 'W':
          {
        BZDB.set("displayratio", list->getIndex() ? "1" : "0");
        break;
          }

What this does is we are looking at which option identifier we are at, and then setting it, either to 1 or 0 for on or off.

Next file:

JoinMenu.cxx

Find // set fields
Skip 10 lines until you pass the port->setString(buffer); part.
Add after that:
if (BZDB.isTrue("displayratio")) {
            FILE*data;
          char temp[75];
          char finalstring[255];
          char rank[50];
          int kills;
          int deaths;
          kills=0;
          deaths=0;
          data=fopen("stats","r");
          if (data) {
              fgets(temp,75,data);
              kills=atoi(temp);
              fgets(temp,75,data);
              deaths=atoi(temp);
              fclose(data);
            }
        strcpy(finalstring,"");
        if ((double)kills/(double)deaths>=0.005) {strcpy(rank,"Bullet Magnet");} else {strcpy(rank,"Just Sucks");}
        if ((double)kills/(double)deaths>=0.01) {strcpy(rank,"Failure");}
        if ((double)kills/(double)deaths>=0.05) {strcpy(rank,"Nothing");}
        if ((double)kills/(double)deaths>=0.15) {strcpy(rank,"Servant");}
        if ((double)kills/(double)deaths>=0.25) {strcpy(rank,"Recruit");}
        if ((double)kills/(double)deaths>=0.35) {strcpy(rank,"Apprentice");}
        if ((double)kills/(double)deaths>=0.45) {strcpy(rank,"Private");}
        if ((double)kills/(double)deaths>=0.55) {strcpy(rank,"Sergeant");}
        if ((double)kills/(double)deaths>=0.75) {strcpy(rank,"Lieutenant");}
        if ((double)kills/(double)deaths>=1.00) {strcpy(rank,"Captain");}
        if ((double)kills/(double)deaths>=1.10) {strcpy(rank,"Major");}
        if ((double)kills/(double)deaths>=1.20) {strcpy(rank,"Commander");}
        if ((double)kills/(double)deaths>=1.35) {strcpy(rank,"Colonel");}
        if ((double)kills/(double)deaths>=1.50) {strcpy(rank,"Brigadier");}
        if ((double)kills/(double)deaths>=1.65) {strcpy(rank,"General");}
        if ((double)kills/(double)deaths>=1.80) {strcpy(rank,"Semi-Pro");}
        if ((double)kills/(double)deaths>=2.00) {strcpy(rank,"Pro");}
        if ((double)kills/(double)deaths>=2.15) {strcpy(rank,"1337");}
        if ((double)kills/(double)deaths>=2.25) {strcpy(rank,"BZ-Freak");}
        if ((double)kills/(double)deaths>=2.50) {strcpy(rank,"Godly");}
        if ((double)kills/(double)deaths>=2.60) {strcpy(rank,"Master");}
        if ((double)kills/(double)deaths>=2.75) {strcpy(rank,"Grand Master");}
        if ((double)kills/(double)deaths>=3.00) {strcpy(rank,"Unstoppable");}
        if ((double)kills/(double)deaths>=3.50) {strcpy(rank,"Untouchable");}
        if ((double)kills/(double)deaths>=4.00) {strcpy(rank,"Invincible");}
        if ((double)kills/(double)deaths>=15.00) {strcpy(rank,"Asian");}
        if (kills<=150 && deaths<=150) {strcpy(rank,"Pending");}
        sprintf(finalstring,"Ratio: %d-%d (%.2lf) [%s]",kills,deaths,(double)kills/(double)deaths,rank);
        motto->setString(finalstring);
    }

This looks big, but is not too hard to understand. First, we check if we wanted to display our ratio in our motto. If we did, it then reads our file and sets it. Next, we see what our rank is based on our ratio. Note that you can have fun with the names and change them if you really want to. Those just seem fitting. Finally, the ratio is not very accurate until you get a good amount of kills. We check to see if kills or deaths is less than 150. If one of those is less than 150, your rank will be “Pending” until you reach that amount in kills or deaths. This is so that we can get more accurate results on a ranking. The last part displays the string with 2 integers, a float, and a string, respectively. Ratio: Kills-Deaths (Ratio) [Rank]. And finally we set that as our motto.

Our last file.

MainMenu.cxx

Find } else if (_focus == quit) { Add after that:
// save resources
    dumpResources();
    if (alternateConfig == "")
      CFGMGR.write(getCurrentConfigFileName());
    else
      CFGMGR.write(alternateConfig);

This is a simple “lazy” hack for saving our configuration when we exit. Because pressing Quit Game leads to a different function, we would have to modify that itself and a few more things. Doing what Save Settings does here solves this easily. If you look just above, the code is the same for Save Settings.

So that is it! You will now run the following commands:

./autogen.sh
./configure
make
sudo make install

If everything worked out right, you can now type bzflag and start up your client. One note to make: The stats file is created in whichever directory you run the bzflag command. I personally created a launcher on my desktop to run the command bzflag. This starts it up in your home directory by default, since that is where terminal always starts in. This can provide flexibility but be a problem at the same time. One, you could have a multitude of score profiles, based on map style if you really wanted. You can also copy and paste the file around to always have your stats. But it’s up to you. I personally just run it in one place, all the time for consistent stats.

By default, the feature is disabled. Start up BZFlag and go to Options -> GUI Settings. At the bottom you will find two new options. You can enable one, or both. I recommend both are either on or off all the time. If you turn off Display Ratio in Motto then you can delete whatever is there and change it and it will not be forced to change by the game. If it is on, every time you enter the Join Game screen, you will see it updates, so as you change maps or rejoin, it will update!

Enjoy! I make harmless additions to BZFlag for the fun of it. You will at no time at all see any modifications to the client code that can potentially alter or destroy gameplay in an unfair manner. By following the instructions above, you will successfully be adding a feature to the client that I personally like. This code is current as of the trunk on September 27, 2011. This post may be updated or reposted when newer versions and changes to the source code are made. Have fun showing off your ratio and trying to rise up in the ranks! (Or falling.)

Too lazy to update the files manually? You can download the files modified in this tutorial below:

http://sigonasr2.servegame.org/uploader/multi-file-uploader/uploads/LocalPlayer.cxx
http://sigonasr2.servegame.org/uploader/multi-file-uploader/uploads/GUIOptionsMenu.cxx
http://sigonasr2.servegame.org/uploader/multi-file-uploader/uploads/JoinMenu.cxx
http://sigonasr2.servegame.org/uploader/multi-file-uploader/uploads/MainMenu.cxx

Finally, screenshots of it in action (Click to view detail):

Settings in the GUI Options.

Ratio before joining a server.

After a few kills and deaths.

Older Posts »

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.