Author Topic: Hello Bowzer here! Duke? Light? This is pointed at you guys...  (Read 2891 times)

Offline bowzer

  • Posts: 4
    • View Profile
Hey Rx. Nice to see you.  I know a good hand full of you guys from the grid.  I am in here looking for a couple people actually. Light and/or Duke.  I am running an Rx. server called Bowzers Castle.  It's still very new and in the beginning stages.  It's simulation is of Bowser's Castle from the game Mario.

So far the tails shrink when your rubber goes down.  Similar to when mario gets hurt and shrinks and then dies.  Same thing here.  When you have no tail left you are just about dead.  Also there are zombies.  one per player. They imitate the ghosts 'Boo' from Bowsers castle.  And last but not least there is the princess 'The Green Win Zone.' You get to the win zone (known as the Princess' and you win that match.  Right now, it's also if you are last man standing, but I am looking to change that and make it more about the princess and less about the other players... But I'm still undetermined if that will cut any fun out of the game... I am working on getting at least one maze map.  It's square and blah right now.  But everytime I go find maze maps it's not quite what I'm looking for and when it is, they are preset with an end win zone, and not empty so taht I can add that myself the way I want to, which is random and much smaller so it's more difficult.  This is one thing I'm working on.  The other big thing under my belt, and this is where Duke or Light come in to play... I want to do /spells... When mario achives certain things he's allowed to level up and become stronger.  I'd like to do the same for this server.  The more times you save the princess, and/or kill someone you gain /spell privileges.  These privileges/spells could be shooting, speed,  sentry guns (something I was told about but am still confused how they work..., or anything else that could make the game a little more interesting.  So if you can get a glimpse of the extent I want to go with this server, and you'd like to help and jump on board, OR just help me script and build this into something that could be a pretty cool server, let me know.  I think I'm on to something worthwhile here...  And I'm still open to a broad spectrum of ideas.  Come check out my server now and see the potential.  It's slow going right now, but It's only been up for a week.  I think I could really do something that people will get into here.

Offline Kira

  • Administrator
  • *****
  • Posts: 545
    • View Profile
    • Lightron
You sounded like you were doing something new, then you made it sound like the direction you wanted to go was another HFT server.  I hope you keep going on unique ideas.

Spells such as what you're talking about are simply parsing an INVALID_COMMAND line.  Maybe if you showed how you're setting up the script, we could help point you in the right direction.  Until then, my next post here will be a PM I sent to someone on the forums on a very basic script.

To hit your other point about the maze.  It doesn't matter if the winzone already exists in it.  You can remove it or change the type, do whatever you want.  The walls don't have to change for you to change that.

I actually have a public maze generator that will put the win zone in the furthest possible position from the starting point.  There is only one way to get to the end and they're generated on the spot when you load the page.

http://lightron.org/maze/?w=10&h=10

You can change the width and height variables in the URL.  I have it allowed to go up to 30 I believe, which is big enough that is causes a lot of graphical lag for most users, so there's no need to allow it to hog up more resources making larger ones that can't be of any use.

I don't really want to join in on scripting it, but if you need help, feel free to use the Support forum here and I'll try to help where I can.

And the next post is coming ... once I find it.

Offline Kira

  • Administrator
  • *****
  • Posts: 545
    • View Profile
    • Lightron
Found it, though I never double checked that I explained things correctly or even got everything right that I said.  Some of it may not be useful if you're using Rx hosting, but I don't feel like reading through and taking out what you don't need, so you can check it out.

Quote from: Light
My framework isn't public.

To learn scripting for the game, you simply need to be familiar with the in-game commands, and a programming language.  You would want to loop while grabbing stdin to read the lines written to the ladderlog.  What you do with them lines is up to you.

Let's run through real quick to try and get you started.

You need to set up the server to output everything for your script.  Add a few options to your config (probably settings_custom.cfg) and then we're ready to start scripting.

Code: [Select]
WAIT_FOR_EXTERNAL_SCRIPT  1|1
WAIT_FOR_EXTERNAL_SCRIPT_TIMEOUT 3
LADDERLOG_WRITE_NEXT_ROUND 1
LADDERLOG_WRITE_ALL 1|1
LADDERLOG_GAME_TIME_INTERVAL 1

Now, for the actual script.  We start off our script with the basics.  We need a shebang line pointing to PHP, and we wrap out PHP in the appropriate tags.

Code: [Select]
#!/usr/bin/php
<?php



?>

Is that not where your PHP bin file is located?  Simply write the following in a terminal to find out.

Code: [Select]
which php
Output
Code: [Select]
tom@kubuntu:~$ which php
/usr/bin/php

Now, we are going to grab the input and set this to loop.  Remember, we need to exit the script when it hits "end of file".  In our case, we will simply break the while loop and allow it to hit the end of the script.

Code: [Select]
// While we're not at "end of file" of our input.
while (!feof(STDIN))
{
// Trim off the new line at the end and keep the input string.
$line = rtrim( fgets(STDIN) );
}

So, now we're gonna grab the lines written to our ladderlog.  Basically like using tail on a file, and writing to it.  That's actually how the scripts used to be set up.

Sample Log Line
Code: [Select]
INVALID_COMMAND /print rx.kira 192.168.1.1 -1 me
So, what happened there was I wrote a command that didn't exist on the server, therefore logging as invalid and showing the command and parameters I've entered.  Basically, this means I wrote "/print me" without the quotes.

What can we do with this?  Well, lets say we wanted to print your name as a center message when you wrote this.

To make things easier, lets split up the line.  Rather than one line of text, lets make an array where each element is a "word", separated by spaces in the line.

Code: [Select]
// Explode the line into words.
$part = explode(" ", $line);

So, if we output $part with print_r() we will get the following.

Code: [Select]
Array
(
    [0] => INVALID_COMMAND
    [1] => /print
    [2] => rx.kira
    [3] => 192.168.1.1
    [4] => -1
    [5] => me
)

Now the information is much easier to access.  So, lets start checking to see if they wrote what we want.  First, we need to make sure it was an invalid command they entered.  This is shown by the first element of the array, $part[0] which shows INVALID_COMMAND.  If it's not, we'll wait until the line is written that it is.

Code: [Select]
// If it's an invalid command ..
if ($part[0] == "INVALID_COMMAND")
{
// Do Something
}

Now we can check for whatever commands we want inside of here.  We're just going to add one command for now, which is "/print".  So, we see the command is the 2nd element of the array, which would be $part[1] and we need to check that it's the command we want.

Code: [Select]
// Did they enter "/print" ?
if ($part[1] == "/print")
{
}

So, at this point, we're only going to do something if they entered an invalid command, and that invalid command happens to be "/print".  If anything else happened, it will simply be ignored.

Now to make it do what we want.  To make it easier, we will write the username into a variable, and call it $user so we can use it in our output.

Code: [Select]
// Store the username.
$user = $part[2];

Now, all that's left to do is make it a center message.  How you input to the server is simple.  You simply output from the script, and the server will read it.  Think of it as writing straight into the console.  When writing in the console, we always have to hit {ENTER} to send the input.  We will do the same in our script.

Code: [Select]
// Send the center message.
echo "CENTER_MESSAGE My name is {$user}!" . "\n";

So, we are echoing out a string first of all.  Inside, there may be a couple odd things.  First, we have {$user}.  This is simply putting a variable inside of a string.  It will show whatever $part[2] was, because that's what we put into $user.

The second thing is the " . ".  This is the end of the string, the appending another string to it.

Code: [Select]
"My string" . " continues here!".
It's not necessary to separate your new lines of course, but I find it makes it easier to read and keeps things a little cleaner.  You'll end up doing whatever you like most, but maybe it will help you out to see others.

Okay, so the script is done!  We can test it out in a terminal, or upload it straight to the server and check it there.  If we have no errors, it should run.  You just put it into the scripts folder of your server, and using SPAWN_SCRIPT to load it.

Our Finished Script
Code: [Select]
#!/usr/bin/php
<?php

// While we're not at "end of file" of our input.
while (!feof(STDIN))
{
// Trim off the new line at the end and keep the input string.
$line rtrimfgets(STDIN) );

// Explode the line into words.
$part explode(" "$line);

// If it's an invalid command ..
if ($part[0] == "INVALID_COMMAND")
{
// Did they enter "/print" ?
if ($part[1] == "/print")
{
// Store the username.
$user $part[2];

// Send the center message.
echo "CENTER_MESSAGE My name is {$user}!" "\n";
}
}
}

?>

The Output
Code: [Select]
INVALID_COMMAND /print Light # I wrote this into the terminal.
CENTER_MESSAGE My name is Light!

-------------------------------------------

Hopefully it helped enough to get you started.  If you have any questions, feel free to ask.  Maybe I'll post a better tutorial sometime on the forums, or we could just move this reply to the forums if there's not already a tutorial on there.

Good luck. (:

Offline bowzer

  • Posts: 4
    • View Profile
Thanks for the reply!  I will read some of that but I am full of hatred when it comes to coding, which is probably a hurtful area of having a server... lol But I've had luck finding some people to help me along the way.  But I do have a question.  I am having a issue figuring out how to save the map into my server.  I've tried a few different ideas, but each time they fail.  Could you shed some light on the matter? 

Offline pdbq

  • Administrator
  • *****
  • Posts: 342
    • View Profile
If you want custom maps, Durf has a custom map maker that might be useful if you hate coding. Just draw the map and it writes the wall code for you! I haven't extensively tried it out but it's worth taking a look at.

http://durf.bugs3.com/me/index.php

Offline Kira

  • Administrator
  • *****
  • Posts: 545
    • View Profile
    • Lightron
You have to go into your maps folder, create a new file, and save it.  Make sure your map category is "maps" and the file name corresponds with the "mapname-version.type.xml" for example ..

big-1.2.aamap.xml
big is the map name
1.2 is the version
aamap is the type
and of course, the xml extension

Then you use
MAP_FILE YOUR_NAME/maps/big-1.2.aamap.xml

The resource should already be set I believe, so that would be it.

Offline bowzer

  • Posts: 4
    • View Profile
If you want custom maps, Durf has a custom map maker that might be useful if you hate coding. Just draw the map and it writes the wall code for you! I haven't extensively tried it out but it's worth taking a look at.

http://durf.bugs3.com/me/index.php

Thanks!  I've checked it out.  Working on some ideas.

Offline bowzer

  • Posts: 4
    • View Profile
This is weird.  I can't add any maps.... So screwy...

 

* Rx Chat