Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Swappable game interface

 
Post new topic   Reply to topic Printable version
 View previous topic  Ctf Post :: Post Arena - cnc (asss)  View next topic  
Author Message
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sun Jun 10, 2007 8:20 am    Post subject: Swappable game interface Reply to topic Reply with quote

I've come up with an interface to allow an arenas's gametype to be changed on the fly. This doesn't change the map, just the game. Possible uses include mervbot elim style voting on the game type at the end of each round. Or periodic voting on special side games like what the zone Battlefield had for a short time.

The way it works is one "swappable game manager" (sgm) module (not shown) decides which game to play and starts that game. When the game ends the sgm then picks the next game (this could use a rotation or a vote for example). The StopGame function is so the sgm may end the game early, the game module should stop itself after 1 round and call the GameoverFunc callback.

Code: Show/Hide
/* this is a generic interface for swappable games. a swappable game is a game
* type module that can be loaded/unloaded while an arena is still running, so
* you can rotate through several game types without changing arena. */

#ifndef __SWAPPABLEGAME_H
#define __SWAPPABLEGAME_H

/** the callback function when a game has been won. tgt contains the winners
* or NULL if there were none. */
typedef void (*GameoverFunc)(Arena *arena, const Target *tgt);

/** the fg_ctf interface struct */
typedef struct Iswappablegame
{
   INTERFACE_HEAD_DECL

   void (*StartGame)(Arena *arena, GameoverFunc func);
   void (*StopGame)(Arena *arena);
} Iswappablegame;

#endif

I put a target in the GameoverFunc, it's up to the programmer whether the sgm awards points or the game modules award points. I'm going with the latter since I'm adding swappable functionality to my already existing modules.

Later I will release a sample sgm_vote module that chooses the next game based on player votes and an updated version of my fg_ctf module. The CTF module will have support for the swappable game interface and also remain backwards compatible (read: the game will run automatically as usual unless a Swappable=1 setting is present).

Edit: fixed copy/paste mistake.
_________________
ss news


Last edited by Smong on Sun Jun 10, 2007 3:46 pm, edited 1 time in total
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Animate Dreams
Gotta buy them all!
(Consumer whore)


Age:36
Gender:Gender:Male
Joined: May 01 2004
Posts: 821
Location: Middle Tennessee
Offline

PostPosted: Sun Jun 10, 2007 1:12 pm    Post subject: Reply to topic Reply with quote

Lol, I did something like that, once. I even got it working, but it was one monolithic module, and... well, it didn't work well. But, um... was source supposed to come with your post?

Lol, I think I already found a bug:

#endi

^ Doesn't look right to me. =\
Back to top
View users profile Send private message Add User to Ignore List Send email Visit posters website AIM Address MSN Messenger
Solo Ace
Yeah, I'm in touch with reality...we correspond from time to time.


Age:36
Gender:Gender:Male
Joined: Feb 06 2004
Posts: 2583
Location: The Netherlands
Offline

PostPosted: Sun Jun 10, 2007 1:24 pm    Post subject: Reply to topic Reply with quote

#endTheWhiningAni
Back to top
View users profile Send private message Add User to Ignore List
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Sun Jun 10, 2007 3:50 pm    Post subject: Reply to topic Reply with quote

I'll post source to the game manager and fg_ctf later, I'm currently still tweaking them.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Fri Jun 15, 2007 6:36 am    Post subject: Reply to topic Reply with quote

Here's an example sgm_vote module. It adds the command ?newgame (everything is run automatically, but mods may wish to reset the game). This demo uses the latest fg_ctf (v1.9).

I did consider defining the "game type" modules in the settings, but left them in the code to prevent people screwing up the settings.
Code: Show/Hide
#include "fg_ctf.h"

#define GAME_COUNT 2

local const struct
{
   const char *iid;
   const char *votename;
   const char *helptext;
} game_info[] =
{
   /* edit this and GAME_COUNT to add more games */
   { I_SWAPPABLEGAME_CTF, "CTF", "Bring the enemy flag to your base" },
   { I_SWAPPABLEGAME_CTF, "CTF", "Bring the enemy flag to your base" },
};

The actual game interface is loaded dynamically just before the game is started.




1.4.3 src doc arena

asss-sgm_vote-1.0.zip - 32.85 KB
File downloaded or viewed 34 time(s)
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 642 page(s) served in previous 5 minutes.

phpBB Created this page in 0.510267 seconds : 32 queries executed (81.5%): GZIP compression disabled