Blog Archives

Remote Web Server Mod

Here is a simple example of how you can send information from a Rune mod to a remote web server.

All you really need is web host that supports php. There are many free web hosts that do this. Try using google.

In this example I am sending the current map and the number of players who are currently playing on the server, then the php script at the remote web server save these variables to a text file, which can be viewed in a normal web browser.

The mod is running as a ServerActor and does not need to be downloaded by players.

DOWNLOAD:
WebServerMod.zip | WebServerModSrc.zip

CODE:

The ServerActor:

// WebServerMod.uc
Class WebServerMod extends Info;

var UBrowserHTTPClient WebCon;
var string WebHost, WebFile;
var int WebPort, WebTimeOut;
var string WebVars;

event PostBeginPlay()
{
	local string MapName;
	local int Players;

	MapName = left(level, instr(level, "."));
	Players = Level.Game.NumPlayers;

	// Would look something like this in a browser:
	// www.website.com/folder/WebServerScript.php?map=DM-Coliseum&players=16
	WebVars = "?map="$MapName$"&players="$Players;

	WebCon = Spawn(Class'UBrowserHTTPClient');
	WebCon.Browse(WebHost, WebFile$WebVars, WebPort, WebTimeOut);

	log("Browse:"$WebHost$WebFile$WebVars$":"$WebPort);
}

DefaultProperties
{
	WebHost="www.website.com"
	WebFile="/folder/WebServerScript.php"
	WebPort=80
	WebTimeOut=5
}

The php script:

// WebServerScript.php
<?php

$MapName = $_REQUEST['map'];
$NumberOfPlayers = $_REQUEST['players'];

$LogFileName = "WebServerMod.log";
$LogFile = fopen($LogFileName, 'w') or die("can't open file");

$NewLine = "\n";

fwrite($LogFile, "Map: ");
fwrite($LogFile, $MapName);

fwrite($LogFile, $NewLine);

fwrite($LogFile, "Players: ");
fwrite($LogFile, $NumberOfPlayers);

fclose($LogFile);
?>

You could use this kind of thing for many many many other things too:

– update server stats
– update players stats
– create player chat system
– player rating of maps on download sites
– …much more, use your imagination

Note: I just realized that this mod sends the amount of players at the beginning of the map, and there might not be any players on the server so early. But it doesn’t matter, it’s just an example, you should still see the map name at least in the text file if you try it.

Advertisements

Classic Server Query (1.0X Server Fix)

For some reason you can’t join Rune 1.00, 1.02 or 1.04 servers with Rune Classic even if you can join 1.01. That is a little weird because all those versions are network compatible.

Anyway, if you want Rune Classic players to be able to join your 1.00, 1.02 or 1.04 server you can install this fix.

DOWNLOAD:
ClassicServerQuery.zip

Put the file “ClassicServerQuery.u” in your Rune system folder.
Open Rune.ini and change:

ServerActors=IpServer.UdpServerQuery
to:
ServerActors=ClassicServerQuery.ClassicServerQuery

Server Demo Recorder

Usually you record demos in Rune by typing the command “demorec” as a player, but it is also possible to record demos directly on a server.

The problem with a demo recorded by a player is that you will not see all players, and sounds will go away or be weird. This will not happen when you record the demo on the server, a server recorded demo will play back everything exactly as it happened.

I made this simple ServerActor which will automatically start recording a demo when there is someone playing on the server, and stop the demo when the server is empty. It does not need to be downloaded by players so don’t add it to ServerPackages, only to ServerActors!

DOWNLOAD:
ServerDemoRecorder.zip | ServerDemoRecorderSrc.zip

Put ServerDemoRecorder.u in System folder, then add to Rune.ini:

ServerActors=ServerDemoRecorder.ServerDemoRecorder

under all other ServerActors=.

A Simple Bot

A VERY simple bot. Works with all versions of Rune. It’s actually just a scriptpawn that automatically restarts when it dies.

To use it on your server, put all the files into your game System folder. Then when you make a server, select the ASimpleBot mutator from the list. Also add ServerPackages=ASimpleBot under all the other ServerPackages in Rune.ini.

DOWNLOAD:
ASimpleBot.zip | ASimpleBotSrc.zip

CODE:

//=============================================================================
// ASimpleBot
//=============================================================================
Class ASimpleBot extends LokiGuard;

function InitPlayerReplicationInfo()
{
	if (PlayerReplicationInfo.PlayerName == "")
		PlayerReplicationInfo.PlayerName = "ASimpleBot";
}

state Dying
{

PostDeath:
	if( Level.Game.RestartPlayer(self))
    {
		Enemy = None;
		StowWeapon = None;
		ClientReStart();
    }
    else
		log("ASimpleBot failed to restart!");
}

DefaultProperties
{
	bIsPlayer=True
	Intelligence=BRAINS_HUMAN
	Health=100
	MaxHealth=100
	bCanJump=True
	bCanWalk=True
	bCanSwim=True
	bCanFly=True
	bCanOpenDoors=True
	bCanDoSpecial=True
	bAdvancedTactics=True
	bCanStrafe=True
	bCanGrabEdges=True
	Skill=2.000000
	StartStowWeapon=None
	StartShield=None
	StartWeapon=None
	BlockChance=1.000000
	FightOrDefend=0.500000
}

Changing Font (text) Of Rune

This does not work for versions 1.00-1.02. There are ways to change the fonts there too, I will write more about that later.

To change the fonts of Rune you need to make a new FontInfo class and a new RuneRootWindow class, and then tell Rune to use these new classes. Here is how to do it:

1. New package setup

Make a new folder in your game System folder. Choose a suitable name for your package, I named my folder “FontChange”. Inside this folder make a new folder with the name “Classes”. Inside this folder make two new files, “FontChangeFontInfo.uc” and “FontChangeRootWindow”.

You should now have these two files:

C:\Rune\FontChange\Classes\FontChangeFontInfo.uc
C:\Rune\FontChange\Classes\FontChangeRootWindow.uc

Now we need to add some code to these new classes. Open up FontChangeFontInfo.uc in a text editor and add:

//=========================
// FontChangeFontInfo.uc
//=========================
Class FontChangeFontInfo extends FontInfo;

// Debugging, Scoreboard ping
static function font GetStaticSmallFont()
{
	//return Font'SmallFont';
	return Font(DynamicLoadObject("NewFonts.Font16", class'Font'));
}

// Scoreboard, Pause message
static function font GetStaticMedFont()
{
	//return Font'MedFont';
	return Font(DynamicLoadObject("NewFonts.Font16", class'Font'));
}

// Chat messages
static function font GetStaticBigFont()
{
	//return Font'Haettenschweiler16';
	return Font(DynamicLoadObject("NewFonts.Font26", class'Font'));
}

// Progress messages
static function font GetStaticLargeFont()
{
	return Font'RuneLarge';
	//return Font(DynamicLoadObject("NewFonts.Font24", class'Font'));
}

// Not used
static function font GetStaticRuneMedFont()
{
	return Font'RuneMed';
	//return Font(DynamicLoadObject("NewFonts.Font30", class'Font'));
}

// Not used
static function font GetStaticCreditsFont()
{
	return Font'RuneCred';
	//return Font(DynamicLoadObject("NewFonts.Font30", class'Font'));
}

// Not used
static function font GetStaticButtonFont()
{
	return Font'RuneButton';
	//return Font(DynamicLoadObject("NewFonts.Font30", class'Font'));
}

As you can see we are just telling the game to load our own fonts instead of the default ones. Some of the fonts defined there are not used for anything.

Then open FontChangeRootWindow.uc and add:

//=========================
// FontChangeRootWindow.uc
//=========================
Class FontChangeRootWindow extends RuneRootWindow;

// These are for the GUI menus
function SetupFonts()
{
    // Window text, console text, game version text
    Fonts[F_Normal] = 	  	Font(DynamicLoadObject("NewFonts.Font14", class'Font'));

    // Window titles, selected tabs
    Fonts[F_Bold] = 	  	Font(DynamicLoadObject("NewFonts.Font14", class'Font'));

    // Big menu buttons
    Fonts[F_RuneButton] = 	Font(DynamicLoadObject("NewFonts.Font30", class'Font'));

    // Not used
    Fonts[F_Large] = 	  	Font(DynamicLoadObject("NewFonts.Font10", class'Font'));
    Fonts[F_LargeBold] =  	Font(DynamicLoadObject("NewFonts.Font10", class'Font'));
    Fonts[F_RuneMedium] = 	Font(DynamicLoadObject("NewFonts.Font10", class'Font'));
    Fonts[F_RuneBig] = 	  	Font(DynamicLoadObject("NewFonts.Font10", class'Font'));
    Fonts[F_RuneLarge] =  	Font(DynamicLoadObject("NewFonts.Font10", class'Font'));
}

Save both files.

2. Compiling the code

First open Rune.ini and search find the list with all the “EditPackages=”. At the end of this list, after all other EditPackages add:

EditPackages=FontChange

Save the file and exit.

Next open up a command prompt (Start Menu–>Run–>cmd or something) and navigate to the Rune system folder. Then write this in the command prompt window:

ucc make

This should compile the code from the two new classes into a package called FontChange.u. Close the command prompt.

3. Importing the new font

Now you need to find a font you want to use in the game, for this example I am using some font I downloaded for free from the internet called “BadaBoom BB”. You can use any true type font really, just search with google and find something you like.

If you use a font from the internet you must install it in Windows before you import it to Rune! Go to the control panel or something and and find the place where you install fonts.

After you got your font create a text with the following content:

new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font8 FontName="BadaBoom BB" Height=8 AntiAlias=1 CharactersPerPage=64
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font10 FontName="BadaBoom BB" Height=10 AntiAlias=1 CharactersPerPage=64
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font12 FontName="BadaBoom BB" Height=12 AntiAlias=1 CharactersPerPage=64
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font14 FontName="BadaBoom BB" Height=14 AntiAlias=1 CharactersPerPage=64
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font16 FontName="BadaBoom BB" Height=16 AntiAlias=1 CharactersPerPage=64
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font18 FontName="BadaBoom BB" Height=18 AntiAlias=1 CharactersPerPage=16
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font20 FontName="BadaBoom BB" Height=20 AntiAlias=1 CharactersPerPage=16
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font24 FontName="BadaBoom BB" Height=24 AntiAlias=1 CharactersPerPage=16
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font26 FontName="BadaBoom BB" Height=26 AntiAlias=1 CharactersPerPage=16
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font30 FontName="BadaBoom BB" Height=30 AntiAlias=1 CharactersPerPage=16
new TrueTypeFontFactory PACKAGE="NewFonts" Name=Font36 FontName="BadaBoom BB" Height=36 AntiAlias=1 CharactersPerPage=8
OBJ SAVEPACKAGE PACKAGE="NewFonts" FILE="..\Textures\NewFonts.utx"

Replace BadaBoom BB with the name of your own font. Save the file as “import.txt” in your Rune system folder.

Open up the map editor RuneEd, then from the top menu open the log window (Top Menu->Window->Log). You can write commands in this window, and from here we will import the new fonts with the text file we just created. In the log window write this command:

exec import.txt

Now you will see many messages, and when you see Moving ‘..\Textures\Save.tmp’ to ‘..\Textures\NewFonts.utx’ you can close RuneEd.

You have now created the texture file containing the new font.

4. Changing the ini files

Now you have all the files you need, all that is left to do is to tell Rune to use these new packages and classes.

Open Rune.ini and add at the bottom:

[RuneI.RuneScoreboard]
FontInfoClass=FontChange.FontChangeFontInfo

[RMenu.RuneConsole]
RootWindow=FontChange.FontChangeRootWindow
MouseScale=0.400000
ShowDesktop=False
bShowConsole=False
MenuTranslucency=1.000000
UWindowKey=IK_None

Open User.ini and add at the bottom:

[RuneI.RuneHUD]
FontInfoClass=FontChange.FontChangeFontInfo

That is all. Save both ini files and start up the game. You should now see the new fonts wherever you enabled it.

The new font and the old one in comparison: