home home

downloads files

forum forum

docs docs

wiki wiki

faq faq

Cube & Cube 2 FORUM


CubeScript Enhancement project

by Q009 on 05/26/2010 09:57, 16 messages, last message: 06/03/2010 02:46, 4668 views, last view: 05/04/2024 14:52

Hey guys!

I'm planning extending CubeScript by adding more functions, read-only vars and menu script stuff.

Before i'll start to work on it i need suggestions.

Tell me: what would you like to see in CubeScript?

Mod will be available in SauerEnhanced and standalone.

   Board Index   

#1: ..

by SheeEttin on 05/26/2010 22:12

Basically go through most of the files and expose just about everything. Damage, physics, rendering tweaks, AI, etc.

Of course, if you do this, you'll probably want to implement some kind of lock (e.g. for playing online). Dunno if that's feasible, which may be the reason eihrul doesn't expose too much to Cubescript...

reply to this message

#2: Re: ..

by Quin on 05/27/2010 07:00, refers to #1

We generally only expose stuff to CubeScript as necessary/requested; exposing everything would be time consuming and maybe pointless in the larger scope of things (we hard code where we can to avoid the extra overhead of scripting and keep the codebase clean).

reply to this message

#3: ..

by Razgriz on 05/27/2010 12:01

I have a list

1) event vars
2) support for direct variable use in (rnd)
@ex: (rnd $variable)
3)support for minimal return value in (rnd)
@ex: (rnd 50 100)
4) use of list of extensions for loopfiles command
@ex: loopfiles f "packages/base" [ogz wpt]
5) ability to compare a range of strings to one string
@)ex: (strcmp [$var1 $var2 $var3] $var4) [all same] [not same]
6) possibly the ability for certain cubescript commands to identify their own extension
@ex: music, guiimage etc

more to come if i remember

reply to this message

#4: Re: ..

by Razgriz on 05/27/2010 12:11, refers to #3

7) support for hex in ^f# color command
@ex: guitext "^fFE0325text here"
8) read-only var for mastermode
9) new 'when' command, which will wait for the conditions to be met and execute only once.
@ex: when (= (loop i (listclients 1) [if (ismaster (at (listclients 1) $i)) [result 1] [result 0]])) [setmaster 1]
10) easy support for modsliders which slide by a specified amount without use of extra, complex code
@ex: guislider var min max range [action]

reply to this message

#5: Re: ..

by Quin on 05/28/2010 01:14, refers to #4

.. and you've posted so much at once it will likely get ignored. Good work hijacking yet another conversation with your suggestions/complaints. We were talking about exposing stuff to Cube Script, not fulfilling your personal wishlist.

reply to this message

#6: ..

by Captain_Ahab on 05/28/2010 03:32

Iwould like to see cubescript be able to control monsters directly such that games similar to 'droidbattle' or 'realtimebattle' can be made where different bots can be either set in contests against each other or as combatants against human players and where the different bot scripts can be given to other players in other sauerbraten games.
Such bot scripting can even be a contest in its own right.

reply to this message

#7: Re: ..

by Razgriz on 05/28/2010 09:27, refers to #5

you're overdoing it quin. this might be my personal "wishlist" but i'm quite sure i'm not the only one who could find use in what i've posted. The suggestions are there for people to try out, its not my call on this what "they" choose to make or not.

And yea, pretty much of what i suggested "exposes" more possibilities to cube script.

"I'm planning extending CubeScript by adding more functions, read-only vars and menu script stuff."

If he meant something else that is irrelevant to what i posted, please take time to clarify then. I suggested functions, read-only var and some menu command modification, and gave examples as per such.

reply to this message

#8: ..

by degrave on 05/28/2010 13:28

Think only one really usefull improvemnt for cube script it improve single player part and try add cooperative "single" player to modes.

reply to this message

#9: ..

by Fischkopf on 05/29/2010 00:49

singleplayer needs teleport to other maps is that possible?

reply to this message

#10: Re: ..

by Q009 on 05/29/2010 10:19, refers to #9

no

reply to this message

#11: Hers some I made earlier :)

by rknigh21 on 05/29/2010 22:05

Hi All

I have had a try at enhancing cubscript for sp mode.

I was able to add cubscript commands to change the monster parameters including the model and monsters state. This allows any md2 or md3 characters to be used in the sp game. See http://www.quadropolis.us/node/1501. on Quodropis.

I was also able to add a hock into the ai to allow a cubscript function to be run for each monster on each refresh. This currently does nothing useful but proves it can be done.

NOTE THIS DOES NOT WORK FOR THE CURRENT RELEASE (was developed for the previous release). I have updated it for the trouper release but never released it. I will update it for the upcoming release once it's out.

The code change is minor about 40 lines of c++ I think, but pretty hacked and not up to the dev's standard. It was intended as a demo to show how much more potential the sp game had with minor changes.

I have also written a sp cubscript guide at http://rknigh21.110mb.com/cubescript_1.html which I hope is helpful to anyone wanting to create a sp game. I have a sp game development guide in the pipeline to be release shortly.

I am happy to help with cubscript enhancements however I currently have limited spare time due to other commitments.

Robin

reply to this message

#12: text vars.

by |ice|sub-zero|L on 05/31/2010 01:52

being able to use text instead of numbers to grab vars, such as to make "random mode" and "random map" buttons that allow you to grab the map name and game mode at random instead of having to go through a long process for setting a map to a number so it can pick with map to play.

(Sorry, i know it sounds a bit dumb, but i'd like to be able to make a random map and random mode button to play in multiplayer)

reply to this message

#13: Re: text vars.

by SheeEttin on 05/31/2010 06:55, refers to #12

http://sauerbraten.org/docs/config.html#at

reply to this message

#14: ..

by .sCaSd. on 06/01/2010 23:57

I wrote a function which creates corresponding obj.cfg files for exported models generated by the writeobj(...) function. Located in worldio.cpp. If you implement such a function I would turn to Sauer-enhanced. Below is the example code and the documentation. You have to paste it into worldio.cpp file of Sauerbraten:



<code>
/*
Write a Cube 2 level as model file and create a matching texture config.

usage: writemodel [name] [scale 0/1.0] [noclip 0] [ambiente 0/100%] [specscale 0/1.0] [info]

This command writes Cube 2-map geometry as textured wavefront obj file to packages/model/[name] folder.
Multiple subdires are allowed and - if required - created. Shaderparameters are translated as good as possible.
Alpha-blending is only supported for images with alpha channel. Dont use the alpha-material,
just apply an alpha-texture as normal stdworld texture or with spec/bump/env/glow parameters. The created model will turn it on.
Alpha-materials and sky-surfaces are removed. Use a plain, white diffuse-map with envworld shader turned on to get a skybox-effect then.
Also mdlenvmap command with the required skybox has to be added manually to the object config. See mdlenvmap of the model-doc.

Supported shaders: *specworld, *envworld, specmap or glowmap, envmap, bump*, alpha-channel

Shaderparams (monochrome only): envscale, specscale, glowcolor



Parameters:

name: model name, located in the packages/models folder.
scale: size of the model, default is 1.0 (400%).
noclip: create a clip-box by default (0) or disable clipping, if specified (1).
ambient: see mdlambient command, zero means default value (100%) or -1 turns ambient off.
specscale: specularity scale of the model, see mdlspec in the models-doc: zero means default (100%, 1.5?) or -1 turns specularity off entirely.
This value is usefull to adjust specularity of textures, for example phillipk textures require a higher value (3.0)
while mitaman's meters are looking better with values <1.0
info: write shader info, in case manual adjustment of the output file is required



Example script commands:
mapmodelreset;writemodel test;mmodel test;newent mapmodel 0;

Those commands called in editing mode writes the curent level as model test and loads it as model number 0.
Note: the mapmodel list is also cleared and an instance of the model is being created - near the curent selection.



Bugs:
* parallax is not working and if glow-map is specified, the specularity is disabled because masks have to contain
spec- and glowmap which mismatches then. Also texscroll, alpha-material and pulseglow are ignored.
* Sometimes the glow is too dark, when glow is enabled and the underlaying diffusetexture has dark pixels at this position.
* Glow, spec and envmap-colors are interpreted as monochrome values.
* When plain envworld shaders is specified, the reflection of the model is not plain, because the chrome-map has to be enabled.
Use a plain diffuse-map with envworld shader to get mirror, or skybox-effects then.
* The texturedata of your model must have the same packadir as your model when using two or more subfolders.
Sauerbraten would requires a objdir command or similar to fix this issue.
* The *.mtl file can be removed, its not required.
* When stencil-buffer is disabled, alpha-blending cuts off models behind an alpha surface (this is a cube-specific blendfunc bug)



Tested with textures of aard(default), philipk(glow, spec), lunaran, mitaman(spec) and painkillah(envmap) and some envworld/specworld shaders.
License of this code-snipped: zlib, author: scasd
*/

void writemodel(char *name, char *scale, char *noclip, char *ambient, char *spec, char *noremip, char *writeinfo)
{
if (strlen (name) <= 0)
{
conoutf("usage: writemodel [name] [scale 0/1.0] [noclip 0] [ambiente 0] [specscale 0/1.0] [info 0]");
return;
}
if (strchr(name, '/') || strchr(name, '\\'))
conoutf("WARNING: the texturedata of the model must have the same packadir as the model when using two or more subfolders !");

defformatstring(mdldir)("packages/models/%s", path(name));
defformatstring(fname)("%s/model", mdldir);
extern void remip_(); remip_(); writeobj(fname); // write optimized obj model - bloat snatch

extern vector<vtxarray *> valist; // find used materials...
vector<int> usedmtl;
loopv(valist) loopj(valist[i]->texs) if(usedmtl.find(valist[i]->eslist[j].texture) < 0) usedmtl.add(valist[i]->eslist[j].texture);
usedmtl.sort(mtlsort);

// create relative texture path, the makerelpath() function bugs with painkillah's texture config
int slashes = 2; { char *p = name + strlen(name); while(--p > name) if (*p == '/' || *p == '\\') slashes++; }
char *fixpath = new char[3 * slashes + 1]; fixpath[0] = 0; while (slashes--) strcat (fixpath, "../");
#define EXBRAC(s) (s[0] == '<' ? ( &((strrchr(s, '>')) ?: ">")[1] ) : s) // remove <brackets> of path, painkillah textures require this

// generate texture config file
defformatstring(cfgname)("%s/obj.cfg", mdldir);
stream *f = openfile(cfgname, "w");
if(!f) return;
f->printf("// config file of Cube 2 obj-model\n\n");

float specscale = (atof(spec) ?: 1.0f) * 2.0f; // default scale is 1.0 = 100% specularity
int defaultspec = (specscale < -0.0f) ? -1 : (int)(100.0f * specscale);
f->printf("objload \"model.obj\"\nmdlglare 0.1 1\nmdlalphatest 0.01\nmdlscale %i\nmdlcollide %i\nmdlambient %i\nmdlspec -1\n\n",
(int)(atof(scale) * 400.0f) ?: 400, atoi(noclip) ? 0 : 1, atoi(ambient) ?: 100);
int info = atoi(writeinfo);

loopv(usedmtl) // collect shader data of material slots...
{
int id = usedmtl[i]; VSlot &vslot = lookupvslot(id, false); Slot *slot = vslot.slot;
int shtype = slot->shader->type, sw = shtype & SHADER_NORMALSLMS, ew = shtype & SHADER_ENVMAP; // specworld, envworld
int mask = (sw||ew) ? 0 : -1, gm = slot->texmask & (1<<TEX_GLOW), sm = slot->texmask & (1<<TEX_SPEC); // glowmap, specmap

// write shader info, in case manual adjustment of the output file is required
if (info)
{
f->printf("// shader-type: %i%s%s, shader params: %i\n", shtype, (sw?", specworld":""), (ew?", envworld":""), slot->params.length());
if (slot->params.length()) loopvj(slot->params)
{
ShaderParam *param = &vslot.slot->params[j];
f->printf("// %s: %.3f, %.3f, %.3f, %.3f\n", param->name, param->val[0], param->val[1], param->val[2], param->val[3]);
}
if (gm) f->printf("// glowcolor: %.3f, %.3f, %.3f\n", vslot.glowcolor[0], vslot.glowcolor[1], vslot.glowcolor[2]);
else if (sm) f->printf("// envscale: %.3f, %.3f, %.3f\n", vslot.envscale[0], vslot.envscale[1], vslot.envscale[2]);
}

// cycle slots and write skin/mask with their custom properties
if (slot->sts[0].t->bpp == 32) f->printf("objcullface slot%d 0\n", id);
loopvj (slot->sts) if (slot->sts[j].type == (gm ? TEX_GLOW : TEX_SPEC)) mask = j; // only address specmap, if no glow is specified
else if (slot->sts[j].type == TEX_NORMAL) f->printf("objbumpmap slot%d %s%s\n", id, fixpath, EXBRAC(slot->sts[j].name));
f->printf("objskin slot%d %s%s", id, fixpath, EXBRAC(slot->sts[0].name));
if (mask >= 0)
{
vec *vses = &vslot.envscale; float maxenv = max(vses->x, max(vses->y, vses->z)), minenv = min(vses->x, min(vses->y, vses->z));
f->printf(" %s%s %.4f %.4f\n", fixpath, EXBRAC(slot->sts[mask].name), (ew ? 1.0 : maxenv), (ew ? 1.0 : minenv) );

// toggle objspec and objglow
if (!gm && (sw || sm))
{
int slotspec = defaultspec; ShaderParam *param; // find specscale shader parameter, index: 1
if (sm) loopvj(slot->params) if ((param = &slot->params[j])->type == SHPARAM_LOOKUP && param->index == 1)
slotspec = (int)((param->val[0] + param->val[1] + param->val[2]) * 33.3333333f * specscale);
f->printf("objspec slot%d %i\n", id, slotspec);
}
f->printf("objglow slot%d %i\n\n", id, gm ? (int)(max(vslot.glowcolor[0], max(vslot.glowcolor[1], vslot.glowcolor[2])) * 300.0f) : -1);
} else f->printf("\n\n"); // plain texture without masks
}
delete f; conoutf("wrote model %s", mdldir);
delete fixpath;
#undef EXBRAC
}

COMMAND(writemodel, "ssssss");



</code>



PS: I made a mappack containing top-rated quadropolis maps, mostly not in svn. It consists of maps with at least 8.5/10 points and more than 15 votes. If you want to include those in Sauer-enhanced, just tell me, and I will upload it. There are lots of textures and Mapmodels in it. By the way, nice work with your map spaceshift, I love the texture which change its color when looking to one of the flags.

reply to this message

#15: Re: ..

by Q009 on 06/02/2010 14:09, refers to #14

wrong thread....
this thread is about cube script ideas

reply to this message

#16: ..

by .sCaSd. on 06/03/2010 02:46

The above thread is a cube-command. Um, I feel so useless - who knows why...

reply to this message

   Board Index   


Unvalidated accounts can only reply to the 'Permanent Threads' section!


content by Aardappel & eihrul © 2001-2024
website by SleepwalkR © 2001-2024
53872056 visitors requested 71647259 pages
page created in 0.015 seconds using 10 queries
hosted by Boost Digital