Coding a scripting language in QC
Moderator: InsideQC Admins
18 posts
• Page 1 of 2 • 1, 2
Coding a scripting language in QC
I've recently had an idea that going to push my QC abilites pretty much to their max.
I want to code a scripting language in QC. Yes, a scripting language in a scripting language.
I want to make all of DiD2's units to be defined in external text files, read in by FRIK_FILE and made available ingame.
I've never really played around with FRIK_FILE much, is it up to the task or should I look at an alternate solution?
I want to code a scripting language in QC. Yes, a scripting language in a scripting language.
I want to make all of DiD2's units to be defined in external text files, read in by FRIK_FILE and made available ingame.
I've never really played around with FRIK_FILE much, is it up to the task or should I look at an alternate solution?
Apathy Now!
-

MauveBib - Posts: 634
- Joined: Thu Nov 04, 2004 1:22 am
I'm thinking something along these lines:
The definition files will contain many lines, each with two "words" seperated by a space or other delinator.
An example file might look something like:
name trooper
model progs/trooper.mdl
type infantry
health 100
standframes 5
walkframes 5
shootframes 3
dieframes 6
weapontype direct
reloadtime 1
weapondamage 25
etc
I'd load the file a line at a time, then have a function to split each line into two strings at the deliniator. Then I'd do a switch/series of ifs on the left string, comparing it to various builtin names, and then set the appropriate flags/variables on an entity, with one entity for each unit type which is then used ingame as a template for creating the units.
Workable?
The definition files will contain many lines, each with two "words" seperated by a space or other delinator.
An example file might look something like:
name trooper
model progs/trooper.mdl
type infantry
health 100
standframes 5
walkframes 5
shootframes 3
dieframes 6
weapontype direct
reloadtime 1
weapondamage 25
etc
I'd load the file a line at a time, then have a function to split each line into two strings at the deliniator. Then I'd do a switch/series of ifs on the left string, comparing it to various builtin names, and then set the appropriate flags/variables on an entity, with one entity for each unit type which is then used ingame as a template for creating the units.
Workable?
Apathy Now!
-

MauveBib - Posts: 634
- Joined: Thu Nov 04, 2004 1:22 am
I've done a bit of work and got the basic parser working.
Now comes the hard part of linking the parser to the game. All the units types are currently hard coded, and so I'll need to rewrite quite a lot of the main code.
Once I'm done it'll be great though, because it'll be so easy to create new units. It'll be so easy to use the chasis to create a totally different style of RTS.
Now comes the hard part of linking the parser to the game. All the units types are currently hard coded, and so I'll need to rewrite quite a lot of the main code.
Once I'm done it'll be great though, because it'll be so easy to create new units. It'll be so easy to use the chasis to create a totally different style of RTS.
Apathy Now!
-

MauveBib - Posts: 634
- Joined: Thu Nov 04, 2004 1:22 am
MauveBib wrote:I'm thinking something along these lines:
The definition files will contain many lines, each with two "words" seperated by a space or other delinator.
An example file might look something like:
name trooper
model progs/trooper.mdl
type infantry
health 100
standframes 5
walkframes 5
shootframes 3
dieframes 6
weapontype direct
reloadtime 1
weapondamage 25
etc
I'd load the file a line at a time, then have a function to split each line into two strings at the deliniator. Then I'd do a switch/series of ifs on the left string, comparing it to various builtin names, and then set the appropriate flags/variables on an entity, with one entity for each unit type which is then used ingame as a template for creating the units.
Workable?
Yay! Smells like LameScript!
http://fragmachine.quakedev.com/
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC
(LordHavoc)
-

frag.machine - Posts: 2090
- Joined: Sat Nov 25, 2006 1:49 pm
-

Error - InsideQC Staff
- Posts: 865
- Joined: Fri Nov 05, 2004 5:15 am
- Location: VA, USA
i did this sort of thing in feral flesh. also made their menus/quests scriptable. everything editable in-game.
my only complaint is that I can't delete files that i no longer wish to use unless i do it manually...
my only complaint is that I can't delete files that i no longer wish to use unless i do it manually...
-daemon [ daemonforge.org ]
-

daemon - Posts: 63
- Joined: Wed Nov 07, 2007 11:10 pm
I made something somewhat similar in my test csqc mod - q3 animation.cfg parsing, for stealing q3 player models, so definitly workable.
Admittedly I used FTE_STRINGS too to simplify things, but its possible to work around that with FRIK_FILE, its just less efficient to do so. With a file layout of your own choosing, it should be much easier. Don't underestimate parts of KRIMZON_SV_PARSECLIENTCOMMAND either... Depending on how many extensions you want to use.
Really, the only issue with just FRIK_FILE you'll have is finding where to split the lines in an efficient maner. The other two extensions have features that can help make it easy.
Admittedly I used FTE_STRINGS too to simplify things, but its possible to work around that with FRIK_FILE, its just less efficient to do so. With a file layout of your own choosing, it should be much easier. Don't underestimate parts of KRIMZON_SV_PARSECLIENTCOMMAND either... Depending on how many extensions you want to use.
Really, the only issue with just FRIK_FILE you'll have is finding where to split the lines in an efficient maner. The other two extensions have features that can help make it easy.
- Spike
- Posts: 2892
- Joined: Fri Nov 05, 2004 3:12 am
- Location: UK
That's why I decided to keep the format of the file simple, with 2 parts to each line with a space as a delineator. I used FRIK_FILE to go through each line a letter at a time and split it at the space.
It's working nicely, though I still need to link it into the menus etc. Currently the structure of the menus is hardcoded, just taking the unit stats from the external file, but I want to have the menus based on what units are in the external files.
Oh, and I chose .did as the file extension
It's working nicely, though I still need to link it into the menus etc. Currently the structure of the menus is hardcoded, just taking the unit stats from the external file, but I want to have the menus based on what units are in the external files.
Oh, and I chose .did as the file extension
Apathy Now!
-

MauveBib - Posts: 634
- Joined: Thu Nov 04, 2004 1:22 am
you could use tokenize to find your first word or command, then strlen it to figure out where to begin your substring for the rest if necessary
even tokenizebyseperator might be useful depending on what you want to do
even tokenizebyseperator might be useful depending on what you want to do
-daemon [ daemonforge.org ]
-

daemon - Posts: 63
- Joined: Wed Nov 07, 2007 11:10 pm
I've done this in the past, certainly doable. I made a scriptable weapons system, one which could be reloaded during gameplay, so you could write changes to a weapon, and supply an impulse in the game to reload scripts.
I was once a Quake modder
-

Urre - Posts: 1109
- Joined: Fri Nov 05, 2004 2:36 am
- Location: Moon
18 posts
• Page 1 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 1 guest