
"I Need Help Programming" Thread
#1 Posted 17 March 2013 - 04:51 PM
I have major experience in CON, C/C++, and Windows batch files.
I have minor experience in PHP, bash, and Java.
I seek to learn Lua.
#2 Posted 17 March 2013 - 05:09 PM
I also have been reading Lua, it resembles Python a lot and I like the feel of it. It will be a great addition to our scripting abilities. I'm curious about how to build eduke to run using Lua, I would like to test it out. I have Decoda, a open source Lua editor. I've read up on love an open source Lua based 2D game engine, nice simple code to get a rough idea of the language.
#3 Posted 17 March 2013 - 06:17 PM
#4 Posted 17 March 2013 - 08:51 PM
#5 Posted 18 March 2013 - 11:03 AM

#6 Posted 18 March 2013 - 12:55 PM
#7 Posted 18 March 2013 - 03:38 PM
... but I too would love to learn more about the Lua script. It's part of EDuke32 soon. So anyone with some good know-how sites and very good books, please post some links.

This post has been edited by Hank: 18 March 2013 - 03:39 PM
#9 Posted 19 March 2013 - 08:42 AM
#10 Posted 19 March 2013 - 11:44 AM
The new models and animations are def'ed in and I figured out how to change the easy con stuff like sounds, jibs, what projectile they fire.... But I haven't had much success with how to disable some un-needed actions or ai that my new enemies don't need. I'll tackle one enemy at a time here.
I'm using the newbeast code for this first new enemy because it matches closely with the what the new enemy will do. What I need to do is remove the shrinker fire from the code because I only want the close distance scratching attack. Being a noob I tried trial and error commenting out certain portions containing the shooting code and of course generated a lot of errors along the way. Next noob trick I tried was to replace every instance of AINEWBEASTSHOOT with AINEWBEASTWALK but the enemy still shoots the shrinker. No errors though. I don't see an ACTION for shooting to mess with so I'm out of ideas. Second issue is a minor one. It seems to me that the scratch attack starts from too far away. I would prefer the enemy gets a little closer to the player before attacking.
#11 Posted 19 March 2013 - 12:26 PM
If I've ever said to make a completely new enemy I meant like so; in this instance;
You have art, be it a model or sprites, you have code from the Newbeast. You should put the two together, like it is now except defined on new tiles, unused by duke3d and untouched by hardcoded engine side things. Stay above tile 5120 I believe.
Now I may have been wrong about issue 1, but issue 2 is fairly easy. This is from the top of the state newbeastseekstate, it is directly under the newbeasts ai definitions.
state newbeastseekstate ifactornotstayput { ifp palive ifcansee ifpdistl 1596 // <<<------------- This line is read, if player distance less than 1596 ... { ai AINEWBEASTSCRATCHENEMY break }
#12 Posted 19 March 2013 - 12:37 PM
Actor code is like a control flow. move, action, and ai can all change an actor's operating state.
What we want to do is prevent the Protector Drone from entering the shooting state. It enters the shooting state in these four blocks of code:
ifrnd 1 ifpdistg 4096 ifp palive ifcansee { ai AINEWBEASTSHOOT break }
state newbeastfleestate ifcount 8 { ifrnd 64 ifpdistg 3500 ifp palive ifcansee ai AINEWBEASTSHOOT } else
ifactioncount 3 { ifrnd 128 { ifpdistg 3500 ifp palive ifcansee ai AINEWBEASTSHOOT } else ai AINEWBEASTGETENEMY }
ifrnd 32 ai AINEWBEASTFLINTCH else ifrnd 32 ifpdistg 3500 ifp palive ifcansee ai AINEWBEASTSHOOT
So we disable it:
/* ifrnd 1 ifpdistg 4096 ifp palive ifcansee { ai AINEWBEASTSHOOT break } */
state newbeastfleestate ifcount 8 { /* ifrnd 64 ifpdistg 3500 ifp palive ifcansee ai AINEWBEASTSHOOT */ } else
ifactioncount 3 { /* ifrnd 128 { ifpdistg 3500 ifp palive ifcansee ai AINEWBEASTSHOOT } else */ ai AINEWBEASTGETENEMY }
ifrnd 32 ai AINEWBEASTFLINTCH /* else ifrnd 32 ifpdistg 3500 ifp palive ifcansee ai AINEWBEASTSHOOT */
There is still this code that handles the shooting state:
else ifai AINEWBEASTSHOOT { ifp pshrunk ai AINEWBEASTGETENEMY else ifcount 26 ai AINEWBEASTGETENEMY else ifcount 25 shoot SHRINKER else { ifcount 5 nullop else ifcount 4 sound NEWBEAST_SPIT } }
But it won't hurt if you leave it in. It's just kind of inactive. You could comment the exact block above if you really wanted to.
To decrease the scratch range, the actor code uses the value 1596 in some places:
state newbeastseekstate ifactornotstayput { ifp palive ifcansee ifpdistl 1596 { ai AINEWBEASTSCRATCHENEMY break } ifai AINEWBEASTCHARGEENEMY { ifp palive ifpdistl 1596 ifcansee { ai AINEWBEASTSCRATCHENEMY break }
ifactioncount 16 { ifp palive ifpdistl 1596 ifcansee { ai AINEWBEASTSCRATCHENEMY break } }
ifpdistg 1596 ai AINEWBEASTTHINK
ifcount 14 { ifpdistl 1596 soundonce NEWBEAST_ATTACK else soundonce NEWBEAST_ATTACKMISS }
You would need to modify all these values, but what I recommend is replacing them with a label so you can change them all at once. (Don't do an automatic "replace all" because 1596 is used other places in the code.)
define NEWBEASTSCRATCHDIST 1596 state newbeastseekstate ifactornotstayput { ifp palive ifcansee ifpdistl NEWBEASTSCRATCHDIST { ai AINEWBEASTSCRATCHENEMY break } ifai AINEWBEASTCHARGEENEMY { ifp palive ifpdistl NEWBEASTSCRATCHDIST ifcansee { ai AINEWBEASTSCRATCHENEMY break }
ifactioncount 16 { ifp palive ifpdistl NEWBEASTSCRATCHDIST ifcansee { ai AINEWBEASTSCRATCHENEMY break } }
ifpdistg NEWBEASTSCRATCHDIST ai AINEWBEASTTHINK
ifcount 14 { ifpdistl NEWBEASTSCRATCHDIST soundonce NEWBEAST_ATTACK else soundonce NEWBEAST_ATTACKMISS }
Voilà . Let me know how it works.
#13 Posted 19 March 2013 - 01:01 PM
I assume I copy/paste the original newbeast code into my new con file. Then I modify it to my liking. Use an "include" line in games.con to make sure the new con file runs.
How do I direct this new con file to affect my newly def'ed model instead of the original?
Thanks guys. I'll be trying out your ideas later this evening.
This post has been edited by Mark.: 19 March 2013 - 01:02 PM
#14 Posted 19 March 2013 - 02:20 PM
From what I see "ifpdistl" means if the distance is less than
and "ifpdistg" means greater than
LOOK AT ME. I'M A CON EXPERT. Anybody have any questions?

This post has been edited by Mark.: 19 March 2013 - 02:33 PM
#15 Posted 19 March 2013 - 02:55 PM
Quote
I assume this is for a bigger project rather than a simple one enemy mod, in which case, yes IMO it's easier to work with new tiles for me.
Quote
That works and is probably best for your situation. To be clear, you don't really need new con files, you can add to or alter the existing ones. I want to mention defs.con here. You'll need to add a define "MYNEWENEMY" like what you see in defs.con, here is where you will give your new actor a name and set its tile number.
Quote
Quote
Whatever tile number you've set it in defs.con, is what you need to direct your model to in "art style defs".def
The two def type of code files can confuse.
defs.con is Duke3D defining tile numbers and actors, add to this list any new actors.
duke3d.def or "art style defs".def is for telling the engine what gets drawn when the actor is called. Meaning .def's won't tell the engine to draw anything without defs.con first defining actors.
added: I spent a long time typing, ate supper... Good work using your noggin.

ifvarvare
This post has been edited by Drek: 19 March 2013 - 02:59 PM
#16 Posted 19 March 2013 - 03:12 PM
It doesn't sound right. If I change AINEWBEASTTHINK to AISKELETONTHINK, there is no skeleton ai code to run. What am I misunderstanding?
This post has been edited by Mark.: 19 March 2013 - 03:45 PM
#17 Posted 19 March 2013 - 04:49 PM
Anyways, you can't make a new enemy without a new name, this will create a whole new actor and leave the newbeast in the game as is. Your new actor will be like a clone of the newbeast to start. It's a quick job to replace the action and ai names. I use notepad++, copy the entire newbeast code to a new file, highlight an action or ai name to be changed, go to search -> replace and rename it. Tedious but there are really only a dozen or two. Then just sort out renaming the actual actor names. You bit off a large task, so don't get discouraged, take your time.
Quote
If you only do it once or, not everywhere then no, it won't work right. However, if you replace universally, then yes, there will be code to run.
#18 Posted 19 March 2013 - 05:18 PM
This post has been edited by Mark.: 19 March 2013 - 05:29 PM
#19 Posted 20 March 2013 - 04:26 PM
#20 Posted 20 March 2013 - 05:01 PM
#21 Posted 20 March 2013 - 05:40 PM

What does the error log say? Print it out and see if you can trace a pattern of an error. then you can 1. avoid the same mistake twice and 2. probably find a quick way to fix it.
#22 Posted 20 March 2013 - 06:41 PM
This is obviously just a few lines of errors. There are lots more from other name changes.
Compiling: EDUKE.CON (3116 bytes)
Including: GAME.CON (151579 bytes)
Including: DEFS.CON (36012 bytes)
Including: USER.CON (42938 bytes)
Including: SKELETON.CON (9497 bytes)
SKELETON.CON: In actor `SKELHANG':
SKELETON.CON:18: error: parameter `SKELHANG' is undefined.
SKELETON.CON:18: error: parameter `SKELSTRENGTH' is undefined.
SKELETON.CON:21: error: parameter `SKELHANG' is undefined.
SKELETON.CON:29: error: parameter `SKEL' is undefined.
SKELETON.CON: In actor `SKELSTAYPUT':
SKELETON.CON:432: error: parameter `SKELSTAYPUT' is undefined.
SKELETON.CON:432: error: parameter `SKELSTRENGTH' is undefined.
SKELETON.CON:432: error: parameter `SKEL' is undefined.
SKELETON.CON: In actor `SKELJUMP':
SKELETON.CON:433: error: parameter `SKELJUMP' is undefined.
SKELETON.CON:433: error: parameter `SKELSTRENGTH' is undefined.
SKELETON.CON:433: error: parameter `SKEL' is undefined.
SKELETON.CON: In state `skelcode':
In all of those lines, the only change made was to replace NEWBEAST with SKEL. Another question. Along with renaming the actions and ai's I also renamed states with the skel replacement. Was that a mistake too?
This post has been edited by Mark.: 20 March 2013 - 06:50 PM
#23 Posted 20 March 2013 - 07:06 PM
So go to line 18 upwards and see if Skelhang is defined in any of the lines above. If not, something went wrong with the mass replacement.
It may sounds stupid, but it seems that you made just one error that spread out and multiplied. Once you fixed up one, the others are simply a repeat.
This post has been edited by Hank: 20 March 2013 - 07:10 PM
#24 Posted 20 March 2013 - 07:42 PM
This post has been edited by Mark.: 21 March 2013 - 03:49 AM
#25 Posted 20 March 2013 - 07:53 PM
This post has been edited by Mark.: 20 March 2013 - 08:38 PM
#26 Posted 21 March 2013 - 02:48 PM
if ASKELHANG is SKELHANG, SKELHANG is not defined.
Also, NEWBEASTSTRENGHT was originally defined in the user.con
I found my notes, and one thing I started changing are the definitions ANEWACTORRUNNINGUP became actionNewActorRunningUp. It is easier to read and reduces typos. Good luck.
p.s. I just can't wait when we do this with LUA

This post has been edited by Hank: 21 March 2013 - 02:50 PM
#27 Posted 22 March 2013 - 02:59 PM
#28 Posted 22 March 2013 - 04:18 PM
When I started, I had no internet connection let alone Google. I simply added a new actor right into the game.con to the bottom of the file. My first modification was the Shark, then the O-Brain. Then, I gave up on this and methodically wrote actors from scratch.
Before you get toooooo frustrated, and if you plan to use hacking techniques instead of programming; what I did with the Brain was to read through it, then pasted every state name to a check file. Then I searched through the game.con and copied a given state it to the new MyGame.con. It was a simple to do and I had very few errors later.
#29 Posted 22 March 2013 - 04:29 PM
My plan of attack overall for con coding is to figure out how to use specific parts of existing code with slight tweaks. Then, because the cons will be seperated into smaller files I'm hoping they will be easier to learn from.
This post has been edited by Mark.: 22 March 2013 - 04:30 PM
#30 Posted 23 March 2013 - 12:41 PM
But the next problem is the animation frames that used to line up perfectly are out of sync now that the skeleton has its own con file. Nothing changed in the def file. What step did I miss? I assume it worked before because the frames in the def file were matched to the hardcoded tile numbers for the Newbeast. Now that the skeleton is on its own set of tiles and con file it has nothing to work from?
This post has been edited by Mark.: 23 March 2013 - 12:58 PM