Forum

Coding a scripting language in QC

Discuss programming in the QuakeC language.

Moderator: InsideQC Admins

Coding a scripting language in QC

Postby MauveBib » Fri Apr 11, 2008 1:46 pm

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?
Apathy Now!
User avatar
MauveBib
 
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Postby MauveBib » Fri Apr 11, 2008 2:18 pm

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?
Apathy Now!
User avatar
MauveBib
 
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Postby FrikaC » Fri Apr 11, 2008 3:03 pm

Doable.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby RenegadeC » Fri Apr 11, 2008 11:09 pm

Reminds me of when leilei wanted me to take 2D Cam and allow plugin characters in a fighting game; essentially Mugen in Quake.
User avatar
RenegadeC
 
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada

Postby MauveBib » Fri Apr 11, 2008 11:44 pm

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.
Apathy Now!
User avatar
MauveBib
 
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Postby RenegadeC » Sat Apr 12, 2008 12:25 am

Consider me interested, I believe this'll lead to even greater mod potential; especially for newbies who simply like to tweak values instead of code.
User avatar
RenegadeC
 
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada

Postby leileilol » Sat Apr 12, 2008 3:54 am

RenegadeC wrote:Reminds me of when leilei wanted me to take 2D Cam and allow plugin characters in a fighting game; essentially Mugen in Quake.

I still think you should do this
i should not be here
leileilol
 
Posts: 2783
Joined: Fri Oct 15, 2004 3:23 am

Postby frag.machine » Sat Apr 12, 2008 4:46 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)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby Error » Sat Apr 12, 2008 9:45 am

already did with all of Elder vale's npc's :)

although Elder Vale turned into Realms of Quake
User avatar
Error
InsideQC Staff
 
Posts: 865
Joined: Fri Nov 05, 2004 5:15 am
Location: VA, USA

Postby daemon » Mon Apr 14, 2008 10:38 pm

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... :P
-daemon [ daemonforge.org ]
User avatar
daemon
 
Posts: 63
Joined: Wed Nov 07, 2007 11:10 pm

Postby Spike » Mon Apr 14, 2008 10:47 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.
Spike
 
Posts: 2892
Joined: Fri Nov 05, 2004 3:12 am
Location: UK

Postby MauveBib » Mon Apr 14, 2008 10:59 pm

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 :)
Apathy Now!
User avatar
MauveBib
 
Posts: 634
Joined: Thu Nov 04, 2004 1:22 am

Postby Chris » Mon Apr 14, 2008 11:57 pm

http://survivalhorrormaker.ru1337.com


same concept, it does indeed work, very simple concept :)
Chris
 
Posts: 79
Joined: Sat Aug 05, 2006 5:31 am

Postby daemon » Tue Apr 15, 2008 5:12 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
-daemon [ daemonforge.org ]
User avatar
daemon
 
Posts: 63
Joined: Wed Nov 07, 2007 11:10 pm

Postby Urre » Tue Apr 15, 2008 7:53 am

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
User avatar
Urre
 
Posts: 1109
Joined: Fri Nov 05, 2004 2:36 am
Location: Moon

Next

Return to QuakeC Programming

Who is online

Users browsing this forum: No registered users and 1 guest