NME error – Missing super constructor call

So since my memory sucks and I likely will forget this one, I’m going to put it here. It’s an easy enough fix and a stupid error on my part but it took me a good 30 minutes to figure it out.

On compile after creating an empty project I received this error

Source/Main.hx:15: lines 15-35 : Missing super constructor call

The solution is to add super() to your new function for your class.

Unity development – 3rd party tools I couldn’t live without

For the last few months, I have primarily been doing only Unity work and have come to rely on a few third party tools every day:

RageSpline

http://ragespline.com/

  • Generate 2D vector graphics inside Unity Editor with bézier splines
  • Fully adjustable colors and gradients + emboss styling
  • Multi-texturing with easy texture positioning
  • Automatic physics collider generation with BoxCollider and MeshCollider options
  • Adjustable vertex count for visuals and physics.
  • Grid & snapping gizmo for accurate drawing
  • Good peformance on iOS/Android
  • RageSpline API for run-time code access

2dToolKit

http://www.unikronsoftware.com/2dtoolkit/

2D Toolkit provides an efficient and flexible 2D sprite and text system which integrates seamlessly into the Unity environment. Our key focus with this product is mobile performance and workflow efficiency.

2D Toolkit is designed for rapid prototyping, and is built to take you all the way to a shipping game.

NGUI

http://www.tasharen.com/?page_id=140

NGUI is a powerful UI system and event notification framework for Unity (both Pro and Free) written in C# that closely follows the KISS principle. It features clean code and simple, minimalistic approach to everything. Most classes are kept under 200 lines of code. For a programmer this means a much easier time when it comes to working with the kit — from extending its functionality to tweaking the existing one. For everyone else this means better performance, less frustration, and more fun.

Bonus! Playmaker

http://www.hutonggames.com/

This is possibly the most powerful tool I have used to date in Unity, but I haven’t been able to explore it as fully I would like to. In short, it’s a FSM that can easily hook into all aspects of your application. It allows the developer to quickly and visually create easy light switches to complex AI.

JSONFX and Unity

Hey all. It’s been fucking ages since my last post, but maybe this time I’ll be able to keep this sucker going. But to hell with excuses and whatnot. On to the point!

Recently I have been working with unity to build some games at work and decided to take a crack at a 2d game for myself. One of the first things I’ve decided to do is work on the quest engine for the game. Since this is going to be a single player game I’m storing my quests in a local file. I initially tried to store this data in XML until I discovered how awful XML is in C#. I then moved over to storing my quests in JSON. After some googling I came across JsonFX and went with it since it will also work on mobile.

Looking at the examples it seem pretty straight forward so off I went. And after a little trial and error I got it at least loading and parsing the json into my unity project finally!

using UnityEngine;
using System.Collections;
using System.Xml;
using System.Xml.Serialization;
using System.IO;
using System.Text;
using JsonFx.Json;

public class FetchQuest{
	public string name;
	public int questId;
}

public class StoryQuest{
	public string name;
	public int npcId;
}

public class Quest2{
	public FetchQuest[] fetchquests;
	public StoryQuest[] storyquests;
}

public class QuestManager : MonoBehaviour {
	void Start () {
		StreamReader r = File.OpenText(Application.dataPath+"/quest.json");
	    string _info = r.ReadToEnd();
	    r.Close();
		print(_info);
		var search = JsonReader.Deserialize<Quest2>(_info);
		print(search.fetchquests[0].name);
	}
}

{
"fetchquests":
	[{"name":"test", "questId":1},
	{"name":"test", "questId":1}]
,"storyquests":
	[{"name":"story 1", "npcId":1},
	{"name":"story 2", "npcId":2}]
}

And thats loading and deserializing! This makes me happy. A thing to note and this is what caught me, is that it looks up the class variables by name, so case matters! Remember this!

What is the best way to achieve a Flash/Unity app with shared Nodejs server?

Over the last week or so I have been looking into creating a shared nodejs server that has flash and unity interfaces. I’m still rather new to nodejs so this is a post to ask a question; I’m considering creating a JS file that flash and unity communicate to using external interface calls instead of putting the communication layer inside of the application.

My question is, is this an acceptable approach? One of the reasons I’m considering this is because it seems to be a pain in the ass in Unity to achieve this.

Let me know what you guys think!

I'm an awful blogger yes… But I'm back!?

Hey ya’ll! I know it’s been a long time since I’ve posted, but I’m hoping to get back into the groove. With a recent move from Windows to Ubuntu, I lost a lot of my progress on my personal projects. I’ve also been very busy with work and spending as much time with my fiancee as I could.

But things are settling down and work is getting pretty interesting so I found out what I was allowed to talk about at work online and will hopefully be posting about that soon-ish (hope to get a real post out tonight).

My work keeps me primiarily in Flash/Flex and working closely with Electroserver so I will try to cover some of aspects of virtual world design and develop, multiplayer games and my new project, a Facebook game.

So check back later if any of that sounds interesting to ya and hopefully I’ll have a post or two!

SSH'ing into Ubuntu on Virtualbox from Windows to maintain my sanity

As my work on Lantern begins to leave testing tech and basic tests, my work flow quickly became shit where I was either developing code on windows and then having to move it to a shared folder or a usb, or attempting to develop on my virtual machine, which is far from fun. Luckily for me I work with people much smarter than me and one of them suggested ssh’ing into my virtual machine and using sftp to kept my files synced.

And this actually works really well for me and was fairly simple to set up, so here ya go:

  1. Check out this post I already wrote on how to forward a port on your VM for the host to hit.
  2. Download Cygwin.
  3. Start SSH on your server – Google around that. Will depend on your distro
  4. Open Cygwin and run this : ssh username@ipaddress
  5. Using Filezilla, you can SFTP into your VM using the same username/password you used in Cygwin.

And there ya go. Sanity maintained.

Today on the internet…

Today while sitting in the bbg IRC (freenode.net / #bbg) , an epic(!) battle occurred!

lmaopirate has joined
[11:56]    lmaopirate: ARRR ME HEARTIES
[11:56]    lmaopirate fires a cannon at lolninja.
[11:56]    roflsamurai: ahhhhh!
[11:56]    lmaopirate has disconnected: Client Quit
[11:57]    lolninja: lol wtf

Zork/MUD-like basic item structure

So at work the other day I was explaining Lantern to a buddy (@shamuspeveril) and we somehow got onto the topic of how well nodejs would work for a zork like game or a mud. Well, sure enough, with the idea stuck in my head I sat down today and tried to think through. Luckily I think this concept will apply well to what I hope to do with the Lantern server, so I don’t feel like I deviated too much from my path.

In case you are not sure what a MUD is, this is a brief description grabbed from wiki :

MUDs combine elements of role-playing games, hack and slash, interactive fiction, and online chat. Players can read or view depictions of rooms, objects, other players, non-player characters, and actions performed in the virtual world. Players typically interact with each other and the world by typing commands that resemble a natural language.

And if you don’t know what Zork is… Leave. Just go.

Anyways, making the basic nodejs server to handle limited verbs was pretty simple. Ex:
Server:

var http = require("http");
var url = require("url");
var fs = require("fs");
var sys = require("sys");
var qs = require("querystring");
var send404 = function(res){
    res.writeHead(404);
    res.write('404');
    res.end();
}

var server = http.createServer(function(req,res)
{
    var path = url.parse(req.url).pathname;
    sys.puts(path);
    switch (path)
    {
        case "/":
            fs.readFile('mud/index.html', 'utf8', function(err, data)
            {
                if(err) {
                    res.writeHead(500, {});
                    res.end();
                    throw err;
                }

                res.writeHead(200, {
                    'Content-Length': data.length
                    , 'Content-Type': 'text/html'
                });
                res.write(data);
                res.end();
               });
            break;

        case "/command":
            var commands = qs.parse(url.parse(req.url).query).commands;
            handleCommands(commands);
            break;
        default:
            if (/\.(js|html|swf)$/.test(path)){
                try {
                    var swf = path.substr(-4) == '.swf';
                    res.writeHead(200, {'Content-Type': swf ? 'application/x-shockwave-flash' : ('text/' + (path.substr(-3) == '.js' ? 'javascript' : 'html'))});
                    res.write(fs.readFileSync(__dirname + path, swf ? 'binary' : 'utf8'), swf ? 'binary' : 'utf8');
                    res.end();
                } catch(e){
                    send404(res);
                }
                break;
            }

            send404(res);
            break;
    }
});

server.listen(8000);

function handleCommands(commands)
{
    var commandArr = commands.split(" ");
    verbs(commandArr[0]);
}

function verbs(v)
{
    switch(v)
    {
        case "n":
        case "north":
            sys.puts("Moving north");
            break;
        case "s":
        case "south":
            sys.puts("Moving south");
            break;
    }
}

Client :

$(function(){
                    var commandObj = {
                        commands: document.getElementById('commands').value
                    }

                    $.get("http://localhost:8000/command", commandObj,
                        function(data)
                        {

                        }
                    , "json");
                });

So that just handles north/n and south/s but you can see how it would progress. Which should lead you to the problem I hit when I added the “south” command block – That is going to be one massive switch statement. So instead of continuing forward with my massive switch I decided to think about it yesterday and I think I came up with a solution that I will use also in Lantern for my crafting system.

The system relies on the item know what is can do and containing all the information that would make it able to control itself instead of a large switch/case on my part. And this whole set up is made 100 times easier because I’m going to be using mongodb.  Here’s some pseudo code to give you an idea of what I’m talking about:


{
   type:"Room",
   exits:
   {
      north:{desc:"You see an exit to the north",room:3242},
      south:{desc:"There's a small door that seems to be locked",room:123}
   },
   description: "You're in a big room with two doors.",
   items:"123,63,7456,34,99,4563,215789,45"

   commands:
   {
      look:{desc:"The room you are in is stupidly large with only two tiny doors, one to the north and a seemingly locked one to the south."};
      yell:{desc:"You shout at the top of your lungs and you just hear your voice echoing mockingly off the walls."}
   }
}

{
  type:"Item",
  id:123,
  description: "The rock is small and perfectly circular.",
  commands:
  {
     take:{desc:"You take the rock and put it in your backpack.",callback:"addToInventory"};
  }
}

{
  type:"Item",
  id:99,
  description: "A small glass bottle filled with an unknown liquid."
  commands:
  {
      combine:{desc:"Blah blah", callback:combineWith, ingredients:4345, creates:8456}
  }
}

As you can see with a system like this, each item is responsible for knowing everything about it and the other items it interacts with. While this make be more difficult to create up front, I feel that once the system is in place I could easily use this in Lantern, a MUD or really any game going forward.

Or maybe I’m brutally over thinking the problem. Is there a better way to handle item relations and verbs?  Would a massive switch/case with all the different verbs I want be the way to go?  Even if I got that path, I need a similar structure to above just for the content. And then added a simple onetime use command like “lick” or something would require new code instead of just text.

Let me know what you think. I will be starting on code like this soonish for Lantern and would like to have a method pinned out. Right after I figure out the mapping issues I’m having ^^

Updates to Openbracket

There have been a few changes here and a few more are on the way.  Most notably is that here forward I will attempt to use excerpts to reduce the ‘wall of text’ that my blog was/is. Please let me know in the comments what you think of this change. If people like it I’ll keep it, otherwise I’ll revert. Another change that will be coming soon is a Lantern page where I will keep an updated overview of the game and it’s features.
Hope everyone likes these changes ^^

Lantern's Market

I would like to explore and get some thoughts out of my head on this topic.  But before I get too far into this, I should first explain a little about Lantern’s item system, crafting, questing, rare items and in general how they are collected.

A feature that hasn’t been fully scoped out yet, but roughly exists in my head is the crafting system for lantern (another post later) which will rely heavily on a rather different stat system, but that’s another post as well. The crafting system will be similar to that you find in many other games when it comes to the end result. Players will be able to create items from raw materials to sell. The big difference is if I make a sword and you make a sword, these swords could end up being very different.  The quality of the sword, it’s bonuses and other attributes will depend on the maker. For the market this means that items won’t all be priced the same and players will need to figure out what is attributes are  valued when making and buying certain items.

The next interesting note is there will only be a handful of NPC’s that sell items. Most of the items in the game will end up being player made.

A third factor is that this game will maintain a living universe. This means that rare drops from a certain boss/challenge will likely only happen the once. This means there will actually be items in the game that only one person will ever have.

Fourthly with monsters having limited to no drops a player will almost be forced to play the market to make money. That’s right. No grinding for loot. You can grind for everything else but that 😛

And finally, markets will be localized. What I mean by this is that if you put an item for sale in a town ‘a’, those in town ‘b’ can’t see it. The issue with this, if I want the system to remain logical, is how the player can have an item on sale in town if they aren’t there? A few story idea’s have crossed my mind, but the one I think I’m going to go with is a group who offers you handle sales of items for a small percentage.

With all these different factors, my intention to allow the market to have the freedom to grow as it will (no imits on prices),  all players being able to craft to some extent and the ability to have players run a monopoly, I believe this could be a very interesting system.