Page 1 of 2

In-game definition editing

Posted: 14 Feb 2007, 00:57
by trepan
The recent lua library rewrite has brought along with it a new feature.
I've added the ".editdefs" command to allow editing unit definitions and
weapon definitions in-game (the commands have to be proxied through
one of the lua interfaces, very easy to do).

This mode is intended to help mod creators tweak their units. I'm not
going to guarantee that it won't crash your game. It's very likely that
it will. The other oddity is that it requires you to create a new unit for
certain parameters to take effect.

Example:

Code: Select all

.editdefs 1
/luaui setudef armcom radarRange 400
.cheat 1
.give armcom
The new armcom will have a radar range of 400.

There are some improvements that could be made (like copying changes
to existing units, and providing access to more complex types like table),
but that'll have to wait for a little while.

Posted: 14 Feb 2007, 00:59
by Guessmyname
I don't suppose this could be tied into the LUA-COB thing in any way, could it?

Posted: 14 Feb 2007, 01:02
by trepan
I rewrote the UnitDefs and WeaponDefs table access methods so
that they have no appreciable loading time, and are normally write-
protected. This change also gave me access to the pointer offsets
for the definition parameters.

Posted: 14 Feb 2007, 03:59
by Nemo
So for the coding nubs among us, is that a yes (to linking it to the lua<->cob deal)?

Posted: 14 Feb 2007, 04:37
by trepan
For the coding nubs:
The ".editdefs" feature is not functionally tied to the
LUA <--> COB features from the viewpoint of the end user.

Posted: 14 Feb 2007, 13:38
by Engine Of Darkness
is it also possible to change bonuses based on experience then ? For example damage, range, reload speed, accuracy etc (on the fly, without creating a new unit)?

Posted: 14 Feb 2007, 13:53
by Guessmyname
those examples would involve weapon editing, though I suppose you could do something like this:

.editdefs 1
/luaui setudef armcom Weapon1 <weaponname>
.cheat 1
.give armcom

so that you switch weapon1 to another (premade) weapon that's a bit different in some way (ie, more accurate etc)

Posted: 14 Feb 2007, 15:18
by Engine Of Darkness
but wouldn't this involve creating a unit (atleast the example you gave would do this)?

I'm rather thinking about an E- Function so the first exp points 0.01 get most of the bonus, and it's then exponentially less (damage, health, range, reload speed, accuracy...) Also is there some kind of "tech level" variable? so you could say "tech level 1 unit" gets stronger boni then a tech level 3 unit (you probably could do this via "if hp>10000" but oh well)

For example for 0.00- 0.01 xp you get 50 hp life bonus, then later ingame you get a 5 hp bonus for 1.00- 1.01 (just as an example)

http://www.ieap.uni-kiel.de/plasma/ag-s ... nktion.jpg The blue line explains very well what I mean.

Change "f(x)" into health bonus in % (or whatever) and "x" into experience.

Basicially its like the exp system is now, just more rewards, less effective the higher exp is and more complicated to code I think.

However this was why I asked if this is possible in lua, so you don't have to recompile the game out of the source to do this.

Posted: 14 Feb 2007, 16:16
by j5mello
just to kinda clear things up but isn't the only point of this system to allow modders to tweak a variable ingame so they can check their effects without having to quit, change the variable, start a new game, etc??

EDIT: im pretty sure that in order to change the bounuses units recieve from exp you would have to do code work i.e. C++ not the FBI tweaking.

Posted: 14 Feb 2007, 17:06
by Engine Of Darkness
maybe not, you wouldn't have to change the fbi, rather the following(Also the weapon "damage" etc is stored in another file (in weapons.tdf)):


I'll just show it via code(no syntax and stuff (just made up while writing)) I've never written lua before I'll just use c#/ c++ as reference (no real syntax). I won't make any thouhts about 1000 problems now as I just want to describe it. I'm speaking of FBI (units) now.
you get their health via let's say "lua_get_maxdamage" (maxdamage represents health I guess) which is written into a variable called damage

Now you create 2 new variables lets say tempmax and finalmax (all variables are initialised in lua).

Now do something like this:


Tempmax=damage

(do calculations with tempmax)

finalmax=tempmax

lua_set_maxdamage(finalmax)
However I think spring wouldn't really like this, because the internal experience system still works, too(I guess). So this may cause overwriting, crashing, bladibla. Mainly because I don't think spring's experience system was designed with this in mind (I may be wrong though).

Well I'm no good coder, atleast not compared to most people here who work on good lua scripts or code the game.

Posted: 14 Feb 2007, 18:48
by AF
You'll need to add callbacks to the AIs for when properties are changed, else AIs that precache this data like AAI will be seriously f*cked over by certain changes.

Posted: 14 Feb 2007, 18:56
by trepan
Nope, don't need to add callbacks for AIs, or to notify lua clients, or
anything else. All I need to add is a warning that goes a little something
like:

WARNING: will likely cause crashes and desyncs

Congrats to jm5ello for being one of those that "gets it".

Posted: 14 Feb 2007, 19:36
by Engine Of Darkness
My question was more of a general question if it would be possible to do this, because I though it would fit into this topic and I didn't want to start a new one.

Maybe I should've started a new one though, my bad.

Re: In-game definition editing

Posted: 27 Sep 2008, 18:09
by Pendrokar
What has changed with this function(exept that .editdefs needs cheats and that there is radardistance not radarrange now)? I tried trepans given example and Guessmyname given example no changes after creating the unit!
Furthermore will the definitions have the new values if I create a unit with LUA? And how to give this command "/luaui setudef armcom radardistance 1000"?

Re: In-game definition editing

Posted: 28 Sep 2008, 10:14
by Gota
This is great.

Re: In-game definition editing

Posted: 28 Sep 2008, 10:40
by Pendrokar
Gota wrote:This is great.
So it worked for you?

Re: In-game definition editing

Posted: 28 Sep 2008, 11:06
by Gota
no,havent tryed it but have been wishing for such a thing for a while.

Re:

Posted: 29 Sep 2008, 23:26
by Forboding Angel
Engine Of Darkness wrote:maybe not, you wouldn't have to change the fbi, rather the following(Also the weapon "damage" etc is stored in another file (in weapons.tdf)):


I'll just show it via code(no syntax and stuff (just made up while writing)) I've never written lua before I'll just use c#/ c++ as reference (no real syntax). I won't make any thouhts about 1000 problems now as I just want to describe it. I'm speaking of FBI (units) now.
you get their health via let's say "lua_get_maxdamage" (maxdamage represents health I guess) which is written into a variable called damage

Now you create 2 new variables lets say tempmax and finalmax (all variables are initialised in lua).

Now do something like this:


Tempmax=damage

(do calculations with tempmax)

finalmax=tempmax

lua_set_maxdamage(finalmax)
However I think spring wouldn't really like this, because the internal experience system still works, too(I guess). So this may cause overwriting, crashing, bladibla. Mainly because I don't think spring's experience system was designed with this in mind (I may be wrong though).

Well I'm no good coder, atleast not compared to most people here who work on good lua scripts or code the game.
Unless I'm mistaken, it's for luadefs only and you are talking about FBI and TDF.

Re: In-game definition editing

Posted: 02 Oct 2008, 17:51
by Pendrokar
WHERE IS TREPAN!?!
Image

EDIT:
With some luck it will be in 77b2, but atm trepan works for bzFlag again :/
Why now!
Image

Re: In-game definition editing

Posted: 03 Oct 2008, 20:28
by jK
Pendrokar wrote:What has changed with this function(exept that .editdefs needs cheats and that there is radardistance not radarrange now)? I tried trepans given example and Guessmyname given example no changes after creating the unit!
Furthermore will the definitions have the new values if I create a unit with LUA? And how to give this command "/luaui setudef armcom radardistance 1000"?
you know you have first to .cheat and then .editdefs (it will then even give ya a message)?