EDuke32 Scripting "CON coding help"
#3653 Posted 17 December 2024 - 05:19 AM
Sure, everyone has to start somewhere, and CON scripting being someone's entry point into the world of programming is always an interesting choice. But for every Dan Douglas who brings in fresh and genuine creativity, you have a dozen people who think "it works and that's all I care about" and just swim in the wake of those more motivated. Why bother learning to be better at something when one of a handful of people will just do it for you if you pester them enough?
Same as it ever was, though. There's always been a culture of reliance, rather than learning. Again, most people don't actually care to learn, they want it to "just work". Programming has always been the least-represented discipline in "the community" even in the 1.5 days. For whatever it's worth, in my observation, the hangers-on will eventually get bored and move on and never finish their projects because - it turns out - making a whole game is a lot of work.
Why "the community" is small and stagnant is a not-so-separate topic, but there's clearly no lack of broad interest in working with old game engines. Why new people gravitate towards other game communities rather than this one should be a source of introspection, but experience tells me it won't be.
#3654 Posted 17 December 2024 - 06:44 AM
Danukem, on 16 December 2024 - 12:16 PM, said:
Don’t jump to conclusions. I never said anything like that. I was merely telling you some drawbacks that I’ve seen. I’ve cleaned up the code even further and now have about a 25% increase in performance with noticeable reductions in fps spikes. So far I’ve got all the gibs and gore effects set up on timed releases and I’m currently implementing the same for debris and effects created by explosions. It’s getting better for sure. I’ll do the same for other effects as well to reduce the chances of them being spawned at the same time as much as possible. Then I’m going to look into giving as many actors as possible a custom stat to further reduce fps spikes. This is going very well.
#3655 Posted 17 December 2024 - 07:02 AM
#3656 Posted 17 December 2024 - 07:17 AM
I also did some improvements related to the accesscard and accessswitch codes. For example, now when the switch is locked, there are 2 variations of Duke's speech (something the AI wasn't capable to do). And I also added more colors to cards compared to Nuclear Showndown. I had to write codes manually in many occasions. The same thing for the ladder and jumpad effects.
It's just those var and varvar things that still confuses me.
For those who are just starting out in CON, it can be confusing and you end up getting lost. And the documentation regarding these syntaxes is not very intuitive. This is because most of these syntaxes are explained separately. Furthermore, the best way to understand how these syntaxes work within a specific context is through sample models for different purposes, which is limited on the Eduke32 website.
And so you end up having to poke around in mod codes if you want to add or change something that is not documented on that website. Because what is there, for someone who is not a programming expert, does not seem to be enough. More explanatory models are needed, for example, to create new buttons, add effects, new card colors, models that you only find in mods, and even spread across files.
It took a lot of effort, because I had to look for codes in different files related to something specific and organize everything in a single file related to that thing, which was not easy at all. So much so that I had to add lines of code that I ended up having to write myself, even though they were simple. There is also the issue of having a correct order for the codes to work properly.
For example, regarding the ladder codes, I had to test the order of the codes, until I saw that first it should be in this sequence: state pythagoras > state laddercode > state checkwall > state ladderinteraction > eventloadactor LADDER > onevent EVENT_GAME > onevent EVENT_MOVEFORWARD > onevent EVENT_MOVEBACKWARD > onevent EVENT_JUMP > onevent EVENT_PROCESSINPUT and finally, separate the codes for JUMPAD, so there would be no conflict in the loading order. And then it finally worked.
Because of these limitations of explanatory models on the website, I end up not understanding everything that is in the codes for mods and effects and other things that I end up wanting to incorporate into the game. But at least there are certain syntaxes that I already have a certain understanding of, precisely because I had to test codes and their values on several occasions.
That's why I say that what is documented in Eduke32 is more for those who already have a prior understanding of programming language, but for those who are starting from scratch... Unless it's to do simpler things that don't require a lot of code, like breakable objects and simple monsters and babes or simply change something that is already in the game.
So yes, I ended up learning new things that weren't explained on the official website.
Everyone has a different way of starting to learn programming from scratch...
And my way of starting to learn this is by starting to learn the coding patterns, and not specific syntaxes. Once I understand the coding pattern better, I start to understand the use of the syntaxes a little better. In other words, my way of learning this depends a lot on the context the codes that are used.
Maybe that's why I end up having more difficulty with these syntaxes.
#3657 Posted 17 December 2024 - 07:40 AM
eniojr, on 17 December 2024 - 07:17 AM, said:
Sure, but that isn't what you've done here. Or at very least that's not the way you've presented yourself.
You are correct that seeing working examples, or even real-world usage, of specific commands is a good way to learn how to use them. But you didn't use the DukePlus ladder code as a jumping off point, or a way to learn about syntax and usage. You copied it wholesale into your own mod, because you want ladders, and you want it to "just work". And then to make it worse, you came here proud of your "accomplishment" and seem to want others to commend you.
You didn't have difficulty understanding syntax. You had difficulty knowing what code to copy and paste. You literally said as much.
#3658 Posted 17 December 2024 - 08:06 AM
I also learned a lot in the beginning from copy/pasting code from mods and having to figure out what it took to get rid of the 26 errors that popped up along the way along with adding my own tweaks. These days I often hesitate to ask for help because I know I'm lacking in basics and when I get a helpful reply I can't make heads or tails of the technical response I receive and can be too embarassed to admit it. I'll make attempts to figure it out but it doesn't always end in success so I move on to something else. I feel bad because I wasted the time of the helper in that instance. I apologize.
And thanks for all the help you people have given to the community. I did what little I could by bundling together a lot of little code snippits from posts over the years into a "con code tricks" file and have posted it here and elsewhere and sent it to a few who requested it. I still refer to it for ideas.
This post has been edited by Mark: 17 December 2024 - 08:10 AM
#3659 Posted 17 December 2024 - 08:41 AM
Reaper_Man, on 17 December 2024 - 07:02 AM, said:
Thank you. With help from here and loads of examples in existing mods I definitely have a good understanding of Con coding now and I’m trying to get more advanced with it. I use to mess with a lot pre eduke con coding a long time ago but it was never this in depth. Here’s a link to my mod since you didn’t know of it:
https://www.moddb.co...savior-of-babes
It’s doing well and has cut a nice little niche for itself in the duke modding community because of its gameplay style and mass carnage.
Would reducing the number of gamevars to the bare minimum needed help with performance? I’ve got lots of gamevars that I could probably reduce and just use the same ones for different situations instead of making one for each situation. But I wanted to know how taxing gamevar definitions are on the overall performance before I go about doing this because I’m sure I’m gonna run into things I’ll have to fix.
#3660 Posted 17 December 2024 - 09:04 AM
VGames, on 17 December 2024 - 08:41 AM, said:
Reducing gamevars is both less about performance and more about memory, but also about performance. If you have any that are declared and never used, it would be a good idea to get rid of them. If you have 2 (or more) that get used for the same thing then you should refactor your code to just use 1. As a general rule, I have a handful of recurring per-actor vars that I use for all sorts of temporary math and checks: ACTORTEMP / ACTORTEMP2 / ACTORCHECK / ACTORCHECK2 . The "check" ones I try and reserve for anything that returns 0 or 1, and the "temp" ones I try and reserve for math related stuff. But I'll use them whenever necessary. There are very few instances where I need more than 4 temporary vars to accomplish a task.
The poor code pattern I see most often is declaring these sort of per-actor vars, for every actor or enemy or effect. A new "TEMP1" thru "TEMP4" for every enemy. You don't need 4 temporary per-actor vars for an enemy, 4 others for particles, so on. They're per-actor, which more accurately is per-sprite. They're individual to whoever is using them. Similarly, you probably don't need multiple global gamevars for common screen drawing effects. I'll see multiple different X/Y position gamevars to calculate screen drawing, but these can likely all be condensed down too.
I see these poor code patterns most often because A.) the gamevars are declared within the context of some sort of self-contained code snippet that was recycled, and B.) a bunch of code snippets get mushed together with no consideration for the larger project. As Dan said a few pages back, it's common for individual programmers or developers to maintain an internal library of functions, and therefore (at least in my personal scenario) only ever reusing the same handful of named global and per-actor vars.
A project should probably be more than a collection of random effects and disparate code.
#3661 Posted 17 December 2024 - 09:35 AM
Yes, I still can't create something new from scratch without some consultation or without seeing how the codes were put together like many people here can. But for me, each new thing I manage to add to the game is a step forward and I'm proud of that. If my understanding of the CON language was 0%, I wouldn't have been able to add anything to the game. Maybe my understanding of this language is around 25% in total, or less than that. The basics of the basics.
Having an initial notion of how the codes should be organized is part of the initial learning process and I'm still learning that.
I don't just copy and paste codes! I had to make changes on my own to make it work. If I had just copied and pasted it, it wouldn't have worked at all, because I've tried that myself. Once I simply copied and pasted it into a new CON file and what did it result in? Compilation errors, missing definitions or missing states and events! I thought that just copying and pasting would solve the problem, but on several occasions I had to make adjustments so that the codes would load without compilation errors.
That image of the cards in the HUD, for example, I was the one who put that together, I was the one who specified the position of the icons in the HUD according to the color of the card. It was a little different from the original mod, but it worked and I liked it. Regarding the babes, I added codes so that they would say a line after attacking me, as well as making some of them use lasers and coolexplosion1.
The next step will be to understand how to create civilians that walk around the map and I'll also research that in the mods, but as in the previous cases, I'll also have to make changes so that it's compatible with the Legacy mod. Still in the case of babes, I created definitions for each of them, so that it wouldn't result in conflicts and I'll do the same with the walking civilians. Just like I did with the accesscard.
Creating specific definitions and variables for something helps to avoid conflicts. For example, if you keep using temp, temp1, temp2, etc. for everything, this can end up causing conflicts between several things. I say this because I've tested this several times and it really did end up resulting in conflicts. I've had several problems regarding timer conflicts, among other things of the sort.
Don't forget the fact that I'm still adding effects to an existing mod, which increases the challenge even more, the effort needed to avoid possible conflicts with the mod. So it's no small thing that I'm doing. Days and days trying to make new things work with patience isn't for everyone. At least I had the perseverance and stubbornness to do so.
I still have several other things to do, like creating new objects that explode when hit, for example, or others that emit sound. I've already managed to create code to create new water sources that restore HP, and I also intend to create code so that when you touch an object like plasma you will suffer damage (like an electric shock), with sound, maybe even with some visual effect if it's possible.
I've also added new experimental items. But these items will be more like powerups and medicines than something to be stored in the inventory. But this is still in the early stages of testing. I may be able to create some inventory items, since I managed to do this with cards, although this is a different category of inventory.
I'm really still getting started with the syntax, but at least now I have a better understanding of how codes should be organized in a script, which is certainly an important step. For example, I've already done several tests with cstat, as well as with ifpdistl, ifrnd, ifhitspace, soundonce, define, gamevar, action, ai, ifhitweapon, spawn, spritepal, ifactioncount, picnum and a few others.
As I test code by code and syntax by syntax, I learn more about the syntaxes. Little by little. I am absolutely certain that I can already understand something in this language, that's for sure.
The whole point is that many in this community who deal with CON programming have prior programming knowledge and therefore can better understand the structure of the CON language, and I do not.
I have no technical or academic training in game programming!
The little I understand about CON language is from scratch.
#3662 Posted 17 December 2024 - 10:38 AM
#3663 Posted 17 December 2024 - 12:13 PM
VGames, on 17 December 2024 - 06:44 AM, said:
I wasn't jumping to conclusions, I was referring to the specific thing that you told us about. You said you made a separate actor to spawn the jibs so they could be spawned over time, but that it would stop before spawning all of them. Then evidently you gave up on that approach. That indicates that your code didn't work and you didn't know how to debug it. What's puzzling to me is why didn't you present *that* problem and try to get help solving it. I'll bet that could be fixed pretty easily.
#3664 Posted 17 December 2024 - 12:34 PM
#3665 Posted 17 December 2024 - 12:47 PM
VGames, on 17 December 2024 - 12:34 PM, said:
Oh you didn't mention that before. The point of that actor was to mitigate the issue of too many jibs spawning at once. So it works fine now and the problem is solved?
#3666 Posted 17 December 2024 - 02:10 PM
The code is practically ready, I just need to create new definitions, copy the code that already exists and establish a new name for the effect, as well as different values for vertical and horizontal impulse and that's it, I will have a new variation of the jumpad effect. I noticed that there may still be unnecessary codes that I should remove. Some unnecessary lines or words. What is missing is a kind of cleaning up of the codes, so to speak, as well as some simplifications.
But before I start trying to add walking civilians to Duke Nukem Legacy, I'm going to go back to working on breakable objects, because I only added a few more to the total textures related to that, as well as more button effects for new textures, because I only tested that on one texture. In other words, I'm going to focus on the simple stuff for now, and then come back to the complex stuff when I feel more confident with the codes. Because that's when it's going to be for real.
#3667 Posted 17 December 2024 - 05:37 PM
VGames, on 17 December 2024 - 12:34 PM, said:
That doesn't make any sense. An actor running code in a state is not fundamentally any different than running it directly in the actor.
// This code...
useractor notenemy WHAT
{
[ do some stuff ]
}
enda
// ... Is the exact same as this code.
defstate dosomestuff
{
[ do some stuff ]
}
ends
useractor notenemy HUH
{
state dosomestuff
}
endaIf this is actually what you have going on, then you have some other issue somewhere causing problems.
#3668 Posted 17 December 2024 - 08:45 PM
Reaper_Man, on 17 December 2024 - 05:37 PM, said:
It doesn't make sense if that was the only thing he changed, but he must have made changes to the code while moving it out of the state. Maybe the state changed some additional vars because it was made for some other purpose, calling that state changed a var he was using in the spawning loop causing it to end early but he didn't realize the state was changing a var needed to keep the loop going.
#3669 Posted 18 December 2024 - 06:37 AM
I did notice something odd. Doing this timed release for spawning explosion effects, not debris, during an explosion causes more unstable fps then simply having the explosions produce the effects all at once. Why is this? I expected better performance with a timed release system but instead going about having explosions create their effects the old fashioned way keeps performance more stable. It works great for creating gibbed enemy effects but not explosion effects.
#3670 Posted 18 December 2024 - 07:46 AM
VGames, on 18 December 2024 - 06:37 AM, said:
There has to be a reason, though. You should try to identify the reason and resolve it. Sure, spawning a new actor and having it do what you need "just works". But like I said before, "just works" is not actually fixing anything or identifying what the problem is.
Without seeing code I can't help you. I suspect the issue lies somewhere beyond the immediate actor code. As I said last time... Isolate the "problem code" into a new clean project. Add some logging. You need to add some debugging outputs to see what the code is actually doing under the hood.
#3671 Posted 19 December 2024 - 09:32 PM
I've been exploring Dukeplus' EVENT_GAME and now I can get a better idea of how it works and how it should be organized, although there are still codes that I still don't fully understand how they were organized. Knowing how the codes are organized and the reasons for this is an important step for those who want to better understand how the structure of the language for Duke Nukem works. Some people focus on understanding the syntax in more depth first, but in my case, I realized that I first have to understand how the codes should be organized in a script. That way it's easier for me.
Because I learn better by observing patterns first!
Because once I understand more deeply how the codes should be organized in a script, then I'll be able to dedicate myself to studying the specific syntaxes, since by then I'll have a better understanding of the general formatting of the scripts.
I'm currently trying to add some more Dukeplus effects like underwater and some other simpler ones (I think) for Legacy. From what I've edited in the codes inside EVENT_GAME, I've already been able to discard several codes for things I won't use, leaving only those relevant to the effects that I may or may not add later.
I think that most people who start learning how to deal with CON scripts are those who start by creating mods from scratch, while in my case it's a bit more complex, since I'm adding things to an existing mod for fun and because I still intend to create a custom episode for Legacy, containing this extra content...
Who knows, maybe one day I'll release it as a new custom episode for this mod (with the authorization of the Legacy author, of course). When everything is ready, I might give him my episode so he can see whether or not he'll publish it for download.
So that's it, I'm doing my best to better understand the organization pattern of a script in this language, even though I already have some knowledge about how some syntaxes work and what they're for.
#3672 Posted 19 December 2024 - 10:14 PM
In my estimation, looking at DukePlus as a whole is largely a waste of time, although it does contain many different specific examples of how to achieve certain things -- the catch is you need to already have some idea of what you are looking at before you can learn from it.
#3673 Posted 20 December 2024 - 07:46 AM
#3674 Posted 20 December 2024 - 01:08 PM
eniojr, on 20 December 2024 - 07:46 AM, said:
I can't answer that because your understanding depends on skill level, so I'm going to answer a somewhat different question which is: What EDuke32 projects have good CON organization and practices?
That calls for speculation because I don't really look at other CON code bases, but I think Ion Fury likely has very good organization and uses good practices. Mblackwell has been coding in CON for as long as anyone and is about as knowledgeable as can be in that area, and from his posts it seems very likely that would be a well organized codebase using good and efficient techniques. Much the same can be said for Reaper_Man so I would expect the AWOL code to be similarly tidy and up to date using good practices and so on.
My projects tend to suffer from workarounds, bloat, and other issues. That's not to say that I don't have a lot of good code in them to do various things, but you will have a needle in haystack problem if you go in blind.
#3675 Posted 20 December 2024 - 03:02 PM
The SECTOREFFECTOR eventloader still has all the Dukeplus effects, but since I won't be using them all, once everything is set up I'll remove the unnecessary code. But even so, the game is running well, with a high FPS, without performance problems, perhaps because of my PC's settings.
The underwater effect is too complicated, because it's not just about the effect itself, but because it's necessary to make several objects and actors behave in a certain way, which I couldn't do. To create an underwater effect, I would have to do it myself, based on how the original game's codes related to this are. But I think that for this I would have to transcribe the game's source code into the CON language.
But still, for the first time I managed to add a new sector effect to a mod on my own.
#3676 Posted 20 December 2024 - 03:09 PM
#3677 Posted 20 December 2024 - 09:42 PM
eniojr, on 20 December 2024 - 03:09 PM, said:
It sounds like you are confusing game engines with games. EDuke32 is the game engine we are using here. Ion Fury is a game that runs on it. Duke 3D is another game which was ported to it long ago. The CON language of EDuke32 is the same regardless of which game. The exe used for Ion Fury is slightly different from mainline but not in any ways that impact syntax. I think the main difference is it doesn't have most of the hardcoded Duke 3D specific stuff (e.g. certain tile numbers being hardcoded to make certain sounds when they spawn).
#3678 Posted 21 December 2024 - 09:01 AM
eniojr, on 20 December 2024 - 07:46 AM, said:
The problem is how you are approaching problems, logically I mean.
The questions you're asking are "How do I add new Sector Effector effects" or "How do I add ladders" or things like that. Asking about specific effects or specific outcomes.
If you really want a deeper understanding you need to think about WHAT you want in more abstract terms. Your mind needs to think in terms of like "How do I make one sprite communicate with another", for example.
#3679 Posted 21 December 2024 - 10:05 AM
damageeventtile 5269
onevent EVENT_DAMAGEWALL
ife wall[RETURN].picnum 5269 setw[RETURN].picnum 5500
endevent
How would I go about chaining another one after that to change 5500 to tile XXXX for multiple levels of damage with every weapon hit? Or is there a better way to go about this?
I'm looking for a smart alternative to my usual useractors and cstats. I want to keep it simple. No complicated
locational damage like used in AWOL. ( I know, poorly worded since wall aren't useractors
I'm assuming that since 3d models are treated as "sprites" that I could use EVENT_DAMAGESPRITE on them. I might have a question on that later when I tackle it.
And last, probably a simple one but off the top of my head I'm not sure how to do it. I have some 3d model light sources that I am making breakable. I need their accompanying Polymer light SE to get killed along with the model. And I hope the light does indeed stop shining with it's removal. I'm not sure how that works.
This post has been edited by Mark: 21 December 2024 - 10:09 AM
#3680 Posted 21 December 2024 - 10:23 AM
You may need to play around with giving them a "health" or giving them some sort of delay after changing before they will try and cycle damage again, otherwise you may skip tile stages.
In AWOL we only had locational damage for headshots on enemies. Unless you're talking about the "hitpoints per texel" damageable surface stuff. You don't need that to make progressive damage tiles.
3D models are sprites so they should trigger EVENT_DAMAGESPRITE.
Deleting an SE light source should be easy. Figuring out which SE to delete is where it gets hard. You could do something like setting it up so they share a lotag/hitag, and when the map loads you move the tag to a per-actor gamevar. Then when the model/sprite is destroyed, search for SEs with a matching gamevar value and delete it. That's probably the best way to do it.

Help
Duke4.net
DNF #1
Duke 3D #1


