05-23-2012, 11:17 AM
I partly discussed this in another thread, but want to bring more attention to the matter and discuss it properly. I started thinking a few months ago about removing all weapons from the code and defining them into text files (without changing any functionality by default). Although this is not an impossible task, it will be quite difficult to do, and needs some planning first. To begin, there are several reasons why I want this:
________________
- Allowing separate games and single player stories with Xonotic:
As some of you may have read, I have a set of features planned to allow creating single player games with Xonotic. Text weapons would allow each story to use guns that fit it instead of the default ones in Xon. Say you're making an urban-oriented story like I am. You might want weapons like a pistol, but the default Xonotic has no business to include such a thing in its code. Or maybe you wanna go further and make a medieval story with swords and bows. This will allow you to define those weapons without any code changes, by including the text file and the weapon model / sounds in your package.
Even on the arena component (non-single-player) the Xonotic code could be used as a framework for other mods, games, and mini-games. You could create another arena-type game within Xonotic which would not be Xonotic (a separate data folder with different graphics, maps, textures, player models, weapon models, and now weapons). The server list would even allow you to play any of those FPS games. If it actually happens, this ability might be a small revolution in open-source FPS gaming, making Xonotic the only project which is both a standalone game and usable as a Software Development Kit. This is a dream I've had for some months, and really wish to put it in practice.
- Great for modding Xonotic:
This would be a great features for modders and creators, even if they're not making an entirely different game. Anyone who runs a server can remove or add any weapon they want, and admins can easily show off their ideas to the public. Being both open-source and very flexible, Xonotic is a larger attraction to modding than other shooters. And if you think closely about it, hard-coded weapons are actually a limit, and removing this limit might open Xon's boundaries to much more fun stuff.
My code will allow guns to do anything... even crazy stuff beyond the purposes of a weapon. For example, you could make a grenade that spawns other items when it explodes, or even triggers server-side cvar aliases or responds to keys other than just attack and attack2 (which would be secondary and non-priority features). Most importantly, by defining the behavior of each firing type, you could create projectiles that look any way you want and do anything you want, as well as the defining exactly how the weapon shoots them.
One example: Some might have tried Morphed's server ([MoN] Overkill [MOD]). It runs a Xonotic mod with a different set of player models, a different balance, and most of all custom weapons (a shotgun, a machinegun, and a minstanex, but different than ours). For those weapons, he probably needs to maintain a separate code, because their firing modes are different. Text weapons would let modders like him run custom guns without needing any code changes.
- Allow full weapon balancing:
This might calm down both the "balance wars" as well as the weapon refactoring wars (removal / addition of certain weapons). A good example is something that's been happening in the last days. Samual wants to remove the shotgun and merge it with the laser, then remove bullet weapons entirely (replacing the UZI with the lightning gun). It's not decided if this will happen yet, but I went super-sayan when I even heard the possibility. Although old weapons would be kept as a mutator (which sounds like a bad way to me) I want to be able to play with the existing guns normally, in case Samual's changes are approved. If Samual's changes don't get approved instead, he would be able to keep his merged weapons as part of his balance and others could still play with them, anyone easily able to choose which weapon set to use.
________________
Those are the main reasons why I want this feature. I believe it will open Xonotic's horizons to a lot of awesome possibilities, and it's something anyone who's even slightly into modding can benefit from (which by itself might also help an increase in popularity). Rest assured, this change will not modify how weapons work by default once if's finished (at worst just some unnoticeable details), so there should be no worry of negative effects.
Problem is that this will take a lot of work, and I don't know how much I can do by myself. A main purpose of this topic is to present my idea and ask who's feeling up for helping me implement it. Here are the technical details of what I want to do exactly:
________________
At this moment, each weapon and its functionality is wrote in a code file (eg: qcsrc\server\w_electro.qc). The number of total weapons and their definitions are also hard coded. What I want is entirely removing weapons from the code, and all words such as Shotgun, Crylink, Electro, Nex, etc. Instead, the code will only contain a single file for weapon functions, consisting of all projectile types and their possibilities. This code then reads weapons defined in one text file, to understand which weapon can be selected and what it does. The text file would contain information on how the weapon is called and what its firing modes will do.
In other words: I defined a weapon called MyGun. Now, does its primary spawn a hitscan projectile, or a rocket / grenade? What model does that projectile, use, and what sounds and particles does it play / spawn? Also, what pattern are the projectiles spawned in, and how many? Does the weapon charge its shot (like the Nex) and can you hold to load multiple projectiles (like the Hagar's secondary)? And of course, what is the model of this weapon and its firing sounds, and what ammo does it take?
The aim is to allow any weapon to define those characteristics. And best of all, to do it without having them conflict each other whenever possible. For instance, if you enable a spread pattern and also a fast firing rate, you get both the Shotgun primary and UZI primary types. Or if you enable both shot charging and loading of multiple projectiles, your shot will do more damage with charge like the Nex, while you can load multiple shots and release them by holding the fire button (like the Hagar).
The format of the text file is undecided. However, I wrote a quick example just to show the basic idea:
And yes, I also plan to make items part of my code (and as a separate project later on, turrets and vehicles). If I go this way, all items are defined as entries in the text file, and only type "weapon" are weapons, ammo / health / armor being "items". The best approach is to define shot types separately, and only parse the name of a shot to the weapon definition (so crylink primary is a group called plasma_spread, and the Crylink weapon just references that). This allows firing types to be used for other things than just weapons, like the turrets.
Another concern is how weapons will be placed on maps. I'm planning to leave that as it is, since new weapons would require new map entities. The weapon definition will probably specify the entity name... so for the Nex, this property will be wep_nex, which is the classname of the weapon placed by the mapper (spawnfunc_weapon_nex). Only alternative is using numbers (wep_1, wep_2, and so on up to the maximum of 24, with the existing entities kept for compatibility), but I don't see a point in doing this and editing all existing maps.
Anyway, this should give a basic idea of what I'm trying to do. I already spoke with divVerent and Samual so far. Although they didn't wanna hear about it at first (because of the high amount of work), div suggested how I should go about this at a first stage. The first thing will be to remove projectile think functions which relate to the player (eg: What RL rockets use for detonation). The weapon code would have to handle any action by the player, not projectiles directly. Then, once projectiles can be spawned from anywhere inside the code (such as a turret being able to use them) code can be put in place to take the properties from text files. Lastly, the way weapons themselves work will need to change, since they aren't defined in the code any more. For instance, the panel HUD must see the text file as well for the slot of each weapon definition to know what it will print and where.
What's your take on this? Who else that wants this feature wishes to help implement it, or can even provide some code advice and input? Also suggestions on what to do and / or not do would help, so this idea matches what everyone agrees with. I strongly wish to make this happen in some way, and maybe we can get it done in a few months at most if enough developers help.
________________
- Allowing separate games and single player stories with Xonotic:
As some of you may have read, I have a set of features planned to allow creating single player games with Xonotic. Text weapons would allow each story to use guns that fit it instead of the default ones in Xon. Say you're making an urban-oriented story like I am. You might want weapons like a pistol, but the default Xonotic has no business to include such a thing in its code. Or maybe you wanna go further and make a medieval story with swords and bows. This will allow you to define those weapons without any code changes, by including the text file and the weapon model / sounds in your package.
Even on the arena component (non-single-player) the Xonotic code could be used as a framework for other mods, games, and mini-games. You could create another arena-type game within Xonotic which would not be Xonotic (a separate data folder with different graphics, maps, textures, player models, weapon models, and now weapons). The server list would even allow you to play any of those FPS games. If it actually happens, this ability might be a small revolution in open-source FPS gaming, making Xonotic the only project which is both a standalone game and usable as a Software Development Kit. This is a dream I've had for some months, and really wish to put it in practice.
- Great for modding Xonotic:
This would be a great features for modders and creators, even if they're not making an entirely different game. Anyone who runs a server can remove or add any weapon they want, and admins can easily show off their ideas to the public. Being both open-source and very flexible, Xonotic is a larger attraction to modding than other shooters. And if you think closely about it, hard-coded weapons are actually a limit, and removing this limit might open Xon's boundaries to much more fun stuff.
My code will allow guns to do anything... even crazy stuff beyond the purposes of a weapon. For example, you could make a grenade that spawns other items when it explodes, or even triggers server-side cvar aliases or responds to keys other than just attack and attack2 (which would be secondary and non-priority features). Most importantly, by defining the behavior of each firing type, you could create projectiles that look any way you want and do anything you want, as well as the defining exactly how the weapon shoots them.
One example: Some might have tried Morphed's server ([MoN] Overkill [MOD]). It runs a Xonotic mod with a different set of player models, a different balance, and most of all custom weapons (a shotgun, a machinegun, and a minstanex, but different than ours). For those weapons, he probably needs to maintain a separate code, because their firing modes are different. Text weapons would let modders like him run custom guns without needing any code changes.
- Allow full weapon balancing:
This might calm down both the "balance wars" as well as the weapon refactoring wars (removal / addition of certain weapons). A good example is something that's been happening in the last days. Samual wants to remove the shotgun and merge it with the laser, then remove bullet weapons entirely (replacing the UZI with the lightning gun). It's not decided if this will happen yet, but I went super-sayan when I even heard the possibility. Although old weapons would be kept as a mutator (which sounds like a bad way to me) I want to be able to play with the existing guns normally, in case Samual's changes are approved. If Samual's changes don't get approved instead, he would be able to keep his merged weapons as part of his balance and others could still play with them, anyone easily able to choose which weapon set to use.
________________
Those are the main reasons why I want this feature. I believe it will open Xonotic's horizons to a lot of awesome possibilities, and it's something anyone who's even slightly into modding can benefit from (which by itself might also help an increase in popularity). Rest assured, this change will not modify how weapons work by default once if's finished (at worst just some unnoticeable details), so there should be no worry of negative effects.
Problem is that this will take a lot of work, and I don't know how much I can do by myself. A main purpose of this topic is to present my idea and ask who's feeling up for helping me implement it. Here are the technical details of what I want to do exactly:
________________
At this moment, each weapon and its functionality is wrote in a code file (eg: qcsrc\server\w_electro.qc). The number of total weapons and their definitions are also hard coded. What I want is entirely removing weapons from the code, and all words such as Shotgun, Crylink, Electro, Nex, etc. Instead, the code will only contain a single file for weapon functions, consisting of all projectile types and their possibilities. This code then reads weapons defined in one text file, to understand which weapon can be selected and what it does. The text file would contain information on how the weapon is called and what its firing modes will do.
In other words: I defined a weapon called MyGun. Now, does its primary spawn a hitscan projectile, or a rocket / grenade? What model does that projectile, use, and what sounds and particles does it play / spawn? Also, what pattern are the projectiles spawned in, and how many? Does the weapon charge its shot (like the Nex) and can you hold to load multiple projectiles (like the Hagar's secondary)? And of course, what is the model of this weapon and its firing sounds, and what ammo does it take?
The aim is to allow any weapon to define those characteristics. And best of all, to do it without having them conflict each other whenever possible. For instance, if you enable a spread pattern and also a fast firing rate, you get both the Shotgun primary and UZI primary types. Or if you enable both shot charging and loading of multiple projectiles, your shot will do more damage with charge like the Nex, while you can load multiple shots and release them by holding the fire button (like the Hagar).
The format of the text file is undecided. However, I wrote a quick example just to show the basic idea:
Code:
// cvar implementation, weapon example
item_1_name Shotgun // how the item is called
item_1_model models/weapons/shotgun.md3 // model of the item
item_1_sprite gfx/weapons/shotgun_icon.tga // sprite of the item
item_1_type weapon // is this item a weapon, health, or armor?
item_1_dropable 1 // this item can be dropped
item_1_intenvory_size 1 2 // the size of blocks this item takes in the inventory
item_1_held 1 // this item can be held by the player, and is activated with the fire button (otherwise instant on pickup)
//type specific settings for "weapon":
item_1_primary_type bullet // primary fire spawns a bullet, or a splash projectile?
item_1_primary_pattern spread // fire the bullets spread (shotgun), continuous (machinegun), or what pattern?
item_1_primary_ammo_type shells // which ammo definition to use
item_1_primary_ammo_amount 1 // how much a shot costs
item_1_primary_damage 5 // damage dealt
item_1_primary_force 10 // push force
item_1_primary_model models/weapons/bullet.md3 // projectile model to use
item_1_primary_sound_fire sounds/weapons/shotgun_fire.ogg // sound when firing
item_1_primary_sound_impact sounds/weapons/bullet_impact.ogg // projectile impact sound
item_1_primary_particles_impact smoke // particle to play when the bullet hits a surface
... etc ...
// cvar implementation, item example
item_2_name "Health 25" // how the item is called
item_2_model models/items/health_25.md3 // model of the item
item_2_sprite gfx/items/health_25_icon.tga // sprite of the item
item_2_type item // is this item a weapon, health, or armor?
item_2_dropable // this item can be dropped
item_2_intenvory_size 1 2 // the size of blocks this item takes in the inventory
item_2_held 1 // this item can be held by the player, and is activated with the fire button (otherwise instant on pickup)
//type specific settings for "item":
item_2_primary_type health // does this increase health or armor?
item_2_primary_amount 25 // how much to heal / boost the stat
item_2_primary_sound_fire sounds/item/heal.ogg // sound
... etc ...
And yes, I also plan to make items part of my code (and as a separate project later on, turrets and vehicles). If I go this way, all items are defined as entries in the text file, and only type "weapon" are weapons, ammo / health / armor being "items". The best approach is to define shot types separately, and only parse the name of a shot to the weapon definition (so crylink primary is a group called plasma_spread, and the Crylink weapon just references that). This allows firing types to be used for other things than just weapons, like the turrets.
Another concern is how weapons will be placed on maps. I'm planning to leave that as it is, since new weapons would require new map entities. The weapon definition will probably specify the entity name... so for the Nex, this property will be wep_nex, which is the classname of the weapon placed by the mapper (spawnfunc_weapon_nex). Only alternative is using numbers (wep_1, wep_2, and so on up to the maximum of 24, with the existing entities kept for compatibility), but I don't see a point in doing this and editing all existing maps.
Anyway, this should give a basic idea of what I'm trying to do. I already spoke with divVerent and Samual so far. Although they didn't wanna hear about it at first (because of the high amount of work), div suggested how I should go about this at a first stage. The first thing will be to remove projectile think functions which relate to the player (eg: What RL rockets use for detonation). The weapon code would have to handle any action by the player, not projectiles directly. Then, once projectiles can be spawned from anywhere inside the code (such as a turret being able to use them) code can be put in place to take the properties from text files. Lastly, the way weapons themselves work will need to change, since they aren't defined in the code any more. For instance, the panel HUD must see the text file as well for the slot of each weapon definition to know what it will print and where.
What's your take on this? Who else that wants this feature wishes to help implement it, or can even provide some code advice and input? Also suggestions on what to do and / or not do would help, so this idea matches what everyone agrees with. I strongly wish to make this happen in some way, and maybe we can get it done in a few months at most if enough developers help.