Archived copy of war3source.com, the War3Source forum (2009–2020), rebuilt from the Internet Archive by wc3mods.net. This page was captured on 2013-01-25 (original capture). Forum · All archived topics · Wiki · Bug tracker · Blog
Chat

War3:Source
January 24, 2013, 10:41:50 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Download: http://war3source.com/index.php?board=9.0
What is War3Source?: http://war3source.com/index.php?topic=200.0
Sample Stats: http://war3source.com/war3stats
Steam Community Group: http://steamcommunity.com/groups/war3source
War3Source SVN Checkout: http://ownageclan.com/svn/war3source/
War3Source servers: http://www.game-monitor.com/search.php?vars=war3_version=
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Race configuration format  (Read 243 times)
Necavi
Sr. Member
****
Posts: 297


View Profile
« on: December 29, 2012, 09:50:51 PM »

I've been doing some thinking and decided that honestly it would be a good idea to switch race configuration from the current (basically) cvar system to a keyvalue based system. Bear with me here, I know that the instant I mention "keyvalue" and "good idea" I'm naturally assumed to be insane, but I realized that there are some decent benefits to doing so:
- MUCH easier for us to automatically create a config for all races every time we startup WITHOUT overwriting custom content
- Much easier for server operators to understand:
Code:
"Races"
{
"undead"
{
"<config key>" "<value>"
}
}
- Easily allow for races to register arbitrary values and defaults
- Probably a lot of other good things (best reason there!)

As the responses have been overwhelmingly positive I'm going to go into a bit more detail about the system I'm designing.

There will be either two or three configs (undecided about whether addons REALLY need their own config section, most of what they do can be done with a SMALL number of cvars, or additions on the race/item configs) one for items and one for races, each race/item will have a section named using their shortname along with a set of keys and values set by plugins.

The idea is to make everything as simple as possible and have almost everything be completely invisible to the plugin developer and easily modifiable by the server operator and to that end the natives I'm proposing are as follows:
Code:
// Easiest method - simply takes a raceID, converts it to a shortname then adds the default to the internal KV
native War3_SetRaceConfigDefault(raceID, String:key[], String:default[]);
// Takes a race shortname and adds the default to the internal KV
native War3_SetRaceConfigDefaultByName(String:shortname[], String:key[], String:default[]);
// Sets a default value for a raceID/key combination
native War3_SetRaceConfigCell(raceID, String:key[], any:default);
// Sets a default value for a shortname/key combination
native War3_SetRaceConfigCell(String:shortname[], String:key[], any:default);
// Takes a key and a value and applies it to all currently loaded races
native War3_SetGlobalRaceConfigDefault(String:key[], String:default[]);

// Gets a value for a raceID/key combination, returning a float/int/bool
native War3_GetRaceConfigCell(raceID, String:key[]);
// Gets a value for a shortname/key combination, returning a float/int/bool
native War3_GetRaceConfigCell(String:shortname[], String:key[]);
// Gets a value for a raceID/key combination, returning a float/int/bool
native War3_GetRaceConfigString(raceID, String:key[], String:value[], maxlen);
// Gets a value for a shortname/key combination, returning a float/int/bool
native War3_GetRaceConfigString(String:shortname[], String:key[], String:value[], maxlen);

Obviously the same thing for items.

The values set here would be kept in one KV (for speed during initial load, likely between OnPluginLoad and OnAllPluginsLoaded this is NOT written to disk, with one write during OnAllPluginsLoaded), whenever loading is finished or during later calls to SetDefault, the values set is then copied into a second keyvalue (the one actually used for lookups), at which point the actual config is loaded up and copied into that keyvalue, and the whole keyvalue is written to the main config (ensuring that all defaults will remain), then any map-specific configs are read and copied into that same keyvalue. This entire process should take just a few milliseconds, but if takes much longer than that I can definitely do a little bit of restructuring to make it faster (albeit harder to read and understand).

The config is also read during any map changes, to ensure that the latest version is always used and any map-specific configs are used

Note: This WILL completely replace the war3 var system.

Example usage:
Code:
/**
* File: War3Source_UndeadScourge.sp
* Description: The Undead Scourge race for War3Source.
* Author(s): Anthony Iacono, Necavi
*/

#pragma semicolon 1

#include <sourcemod>
#include "W3SIncs/War3Source_Interface"
public W3ONLY(){} //unload this?

// War3Source stuff
new thisRaceID;


// Chance/Data Arrays
new Float:SuicideBomberRadius[5]={0.0,250.0,290.0,310.0,333.0};

new Float:SuicideBomberDamage[5]={0.0,166.0,200.0,233.0,266.0};
new Float:SuicideBomberDamageTF[5]={0.0,133.0,175.0,250.0,300.0};

new Float:UnholySpeed[5]={1.0,1.05,1.10,1.15,1.20};
new Float:LevitationGravity[5]={1.0,0.85,0.7,0.6,0.5};
new Float:VampirePercent[5]={0.0,0.08,0.14,0.20,0.25};

new SKILL_LEECH,SKILL_SPEED,SKILL_LOWGRAV,SKILL_SUICIDE;

public Plugin:myinfo =
{
name = "Race - Undead Scourge",
author = "PimpinJuice, Necavi",
description = "The Undead Scourge race for War3Source.",
version = "1.0",
url = "http://war3source.com"
};

// War3Source Functions
public OnPluginStart()
{
LoadTranslations("w3s.race.undead.phrases");
War3_SetRaceConfigDefaultArray(thisRaceID, "SuicideBomberRadius", SuicideBomberRadius);
War3_SetRaceConfigDefaultArray(thisRaceID, "SuicideBomberDamage", SuicideBomberDamage);
War3_SetRaceConfigDefaultArray(thisRaceID, "SuicideBomberDamageTF", SuicideBomberDamageTF);
War3_SetRaceConfigDefaultArray(thisRaceID, "UnholySpeed", UnholySpeed);
War3_SetRaceConfigDefaultArray(thisRaceID, "LevitationGravity", LevitationGravity);
War3_SetRaceConfigDefaultArray(thisRaceID, "VampirePercent", VampirePercent);
}
public OnWar3LoadRaceOrItemOrdered(num)
{
if(num==10)
{
thisRaceID=War3_CreateNewRaceT("undead");
SKILL_LEECH=War3_AddRaceSkillT(thisRaceID,"VampiricAura",false,4,"25%");
SKILL_SPEED=War3_AddRaceSkillT(thisRaceID,"UnholyAura",false,4,"20%");
SKILL_LOWGRAV=War3_AddRaceSkillT(thisRaceID,"Levitation",false,4,"0.5");
SKILL_SUICIDE=War3_AddRaceSkillT(thisRaceID,"SuicideBomber",true,4);

War3_CreateRaceEnd(thisRaceID);
}
}

public OnWar3ConfigLoaded()
{
War3_GetRaceConfigArray(thisRaceID, "SuicideBomberRadius", SuicideBomberRadius, sizeof(SuicideBomberRadius));
War3_GetRaceConfigArray(thisRaceID, "SuicideBomberDamage", SuicideBomberDamage, sizeof(SuicideBomberDamage));
War3_GetRaceConfigArray(thisRaceID, "SuicideBomberDamageTF", SuicideBomberDamageTF, sizeof(SuicideBomberDamageTF));
War3_GetRaceConfigArray(thisRaceID, "UnholySpeed", UnholySpeed, sizeof(UnholySpeed));
War3_GetRaceConfigArray(thisRaceID, "LevitationGravity", LevitationGravity, sizeof(LevitationGravity));
War3_GetRaceConfigArray(thisRaceID, "VampirePercent", VampirePercent, sizeof(VampirePercent));
}

public OnUltimateCommand(client,race,bool:pressed)
{
if(pressed && War3_GetRace(client)==thisRaceID && IsPlayerAlive(client) && !Silenced(client))
{
new ult_level=War3_GetSkillLevel(client,race,SKILL_SUICIDE);
if(ult_level>0)
{
ForcePlayerSuicide(client);
}
else
{
//DP("undad ");
W3MsgUltNotLeveled(client);
}
}
}

public OnSkillLevelChanged(client,race,skill,newskilllevel)
{
InitPassiveSkills(client);
}
public InitPassiveSkills(client){
if(War3_GetRace(client)==thisRaceID)
{
new skilllevel_unholy=War3_GetSkillLevel(client,thisRaceID,SKILL_SPEED);
new Float:speed=UnholySpeed[skilllevel_unholy];
War3_SetBuff(client,fMaxSpeed,thisRaceID,speed);

new skilllevel_levi=War3_GetSkillLevel(client,thisRaceID,SKILL_LOWGRAV);
new Float:gravity=LevitationGravity[skilllevel_levi];
War3_SetBuff(client,fLowGravitySkill,thisRaceID,gravity);

new skilllevel_vampire=War3_GetSkillLevel(client,thisRaceID,SKILL_LEECH);
new Float:percent=VampirePercent[skilllevel_vampire];
War3_SetBuff(client,fVampirePercent,thisRaceID,percent);

}
}

public OnRaceChanged(client,oldrace,newrace)
{
if(newrace!=thisRaceID)
{
War3_SetBuff(client, fMaxSpeed, thisRaceID, 1.0);
War3_SetBuff(client, fLowGravitySkill, thisRaceID, 1.0);
War3_SetBuff(client, fVampirePercent, thisRaceID, 0.0);
}
else
{
if(IsPlayerAlive(client)){
InitPassiveSkills(client);

}
}
}

public OnWar3EventDeath(victim, attacker)
{
new race=W3GetVar(DeathRace);
new skill=War3_GetSkillLevel(victim,thisRaceID,SKILL_SUICIDE);
if(race==thisRaceID && skill>0 && !Hexed(victim))
{
decl Float:location[3];
GetClientAbsOrigin(victim,location);
if(War3_GetGame()==Game_TF)
{
War3_SuicideBomber(victim, location, SuicideBomberDamageTF[skill], SKILL_SUICIDE, SuicideBomberRadius[skill]);
} else {
War3_SuicideBomber(victim, location, SuicideBomberDamage[skill], SKILL_SUICIDE, SuicideBomberRadius[skill]);
}

}
}

public OnWar3EventSpawn(client)
{
new race=War3_GetRace(client);
if(race==thisRaceID)
{
InitPassiveSkills(client); //sets suicide

}
}

Configuration generated by this:
Code:

"Races"
{
"undead"
{
// Standard set of values applied to any race
"minlevel" "0"
"accessflag" "0"
"raceorder" "2200"
"flags" ""
"restrict_items" ""
"team1_limit" "99"
"team2_limit" "99"
"restrictclass" ""
"category" "default"

// Added by the race
"SuicideBomberRadius" "0.0 250.0 290.0 310.0 330.0"
"SuicideBomberDamage" "0.0 166.0 200.0 233.0 266.0"
"SuicideBomberDamageTF" "0.0 133.0 175.0 250.0 300.0"
"UnholySpeed" "1.0 1.05 1.10 1.15 1.20"
"LevitationGravity" "1.0 0.85 0.7 0.6 0.5"
"VampirePercent" "0.0 0.08 0.14 0.20 0.25"
}
}

I believe that during a config reload I will call the OnConfigReloaded function ONLY on plugins that are actually affected, to prevent an absurd amount of array copying.

Note: I will be writing the array parsing from scratch anyway, so the format is maleable at this point, I merely copied the current system used for colors/vectors, but I can switch the arrays to comma separated lists or anything.
« Last Edit: December 30, 2012, 02:33:49 AM by Necavi » Logged

Glider⠠⠵
Global Moderator
Sr. Member
*****
Posts: 454


⠠⠵


View Profile
« Reply #1 on: December 29, 2012, 09:54:34 PM »

- MUCH easier for us to automatically create a config for all races every time we startup WITHOUT overwriting custom content

I'd be in favor for this reason alone  Grin
Logged

Remy Lebeau
Full Member
***
Posts: 172


View Profile
« Reply #2 on: December 29, 2012, 09:56:04 PM »

It sounds like a complete CRAPLOAD of work (esp for servers like ours with 100+ races)...

That being said, as a long term solution I like it.  Last time I did a war3 cvarlist on my server that are a ton of cvars that are never used, not to mention that just recently in fixing up a couple of races I found that they use the same named cvar as a different race :S
Logged
Necavi
Sr. Member
****
Posts: 297


View Profile
« Reply #3 on: December 29, 2012, 10:04:35 PM »

Unfortunately there's nothing we currently can do about having the same shortname, you just have to recompile the race.
Actually this should be less work, basically it'll automatically run war3_cvarlist FOR YOU and then allow you to modify the settings but will never overwrite your existing settings.
« Last Edit: December 29, 2012, 10:19:33 PM by Necavi » Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2169



View Profile WWW
« Reply #4 on: December 29, 2012, 10:31:55 PM »

im assume you will be writing a class for all this KV manipulations
i refuse to touch KV with a 10 foot pooper scooper (and thats why war3 cvarlist was invented).

no objections though, just make it well so i dont ever have to look at the implementation Tongue

are you planning to have each race to have a file? or one giant file?
Logged

DarkEnergy
Necavi
Sr. Member
****
Posts: 297


View Profile
« Reply #5 on: December 29, 2012, 10:37:06 PM »

One giant file, it will also attempt to pull in race-specific configs for overrides

Yes, there will be a nice little plugin to handle them, should have functions like War3_AddKeyDefault(<racename> (possibly race ID?), <value>) and then reading with a similar method.
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2169



View Profile WWW
« Reply #6 on: December 29, 2012, 10:37:58 PM »

raceid is dynamic. you should use shortname
Logged

DarkEnergy
Necavi
Sr. Member
****
Posts: 297


View Profile
« Reply #7 on: December 29, 2012, 10:41:10 PM »

It would be translated by the class, obviously >> There'd be no point to doing it that way otherwise.
I will likely have functions for each, because sometimes you want a specific race name, and sometimes you're looping and adding defaults to everything.
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2169



View Profile WWW
« Reply #8 on: December 29, 2012, 11:01:28 PM »

oh i thought u meant a console command Tongue
Logged

DarkEnergy
Necavi
Sr. Member
****
Posts: 297


View Profile
« Reply #9 on: December 29, 2012, 11:03:55 PM »

There will be console commands too, but those will likely be shortname based.
Logged

Necavi
Sr. Member
****
Posts: 297


View Profile
« Reply #10 on: December 30, 2012, 01:38:47 AM »

Posted a bit more information.
Logged

iceman
Full Member
***
Posts: 177


View Profile
« Reply #11 on: December 30, 2012, 03:03:22 PM »

The option to adjust skill values on each race has been needed for a long time definitely yes on this.
Logged
Remy Lebeau
Full Member
***
Posts: 172


View Profile
« Reply #12 on: December 30, 2012, 04:13:59 PM »

Hm, I'm not convinced by where this is going.

I thought it was going to be a replacement for cvars not as a system to re-write how values are set for each skill.

As a way of setting values that would otherwise require cvars I think it has great potential, however what you are now suggesting is needlessly complicated and would actually make it HARDER to code races.  With that amount of information set through a config file (with 100 or so races), that file would just become stupidly long and unwieldy - not to mention that one mistake would then potentially screw up every race.

Declaring the race ability values within the race file itself works perfectly ok.  These are NOT values that will need to be updated regularly, once you've found the right balance they stay putt.  There is no need to include that level of detail into the config file.
Logged
Necavi
Sr. Member
****
Posts: 297


View Profile
« Reply #13 on: December 30, 2012, 04:35:15 PM »

My main concern in this regard is that, while you are capable of doing so, NOT EVERYONE IS INTELLIGENT ENOUGH TO RECOMPILE RACES Tongue

Not to mention that many of the current values are set by the war3 cvars anyway.
Logged

Glider⠠⠵
Global Moderator
Sr. Member
*****
Posts: 454


⠠⠵


View Profile
« Reply #14 on: December 30, 2012, 07:09:43 PM »

Declaring the race ability values within the race file itself works perfectly ok.  These are NOT values that will need to be updated regularly, once you've found the right balance they stay putt.  There is no need to include that level of detail into the config file.

You do know War3Source runs on CS:S, CS:GO, TF2 and L4D, right? And that people can match War3Source with anything they want? Zombiemod on Counterstrike for example. You can't balance a race for every single situation. For somebody just hosting their own server and coding their own stuff this is not necessary, no. But nobody is forcing you to use the key value interface for your races. If you have no interest in making them configurable, then don't do it. If you're actually writing races for the war3source core then you'll be happy that no longer you will have to hear someone complain about race <x> being OP in game <y> while it's underpowered in game <z>. Server owner doesn't like what the stock races do? He can just change these values himself to tailor the races for his server.

This is really really useful for server hosts that are not sourcepawn coders. And like I said up there: Nobody is forcing you to write your races this way. You can keep your races like you have them right now and they will still work. Only if you want to benefit from this system do you need to use it.
Logged

Ownz
Developer
Administrator
Hero Member
*****
Posts: 2169



View Profile WWW
« Reply #15 on: December 30, 2012, 07:18:48 PM »

you will have people who likes to de-buff the abilities
you will have people who loves OP races

either way, it affects the reputation of war3source, not that reputation matters *cough*. But gives options to the server owners to customize to their liking.

prediction: most wont bother making races using the kv system
Logged

DarkEnergy
Glider⠠⠵
Global Moderator
Sr. Member
*****
Posts: 454


⠠⠵


View Profile
« Reply #16 on: December 30, 2012, 07:25:05 PM »

prediction: most wont bother making races using the kv system

And that is okay. We're not trying to make writing races more complicated, we're just trying to make war3source more accessible/more easily configurable to server hosts Cheesy
Logged

Necavi
Sr. Member
****
Posts: 297


View Profile
« Reply #17 on: December 30, 2012, 07:49:35 PM »

All main war3source races will. They ARE used as a template for most other races, and should (and will) always be models of how to code new races, with maximum configurability, decent speed and respect of all in place buffs/protections/etc.
Logged

Remy Lebeau
Full Member
***
Posts: 172


View Profile
« Reply #18 on: December 30, 2012, 08:17:36 PM »

fair enough then!
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!