Duke4.net Forums: "I Need Help Programming" Thread - Duke4.net Forums

Jump to content

  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic

"I Need Help Programming" Thread

User is offline   Hendricks266 

  • Weaponized Autism

  #1

I had this idea because some people expressed interest in learning CON or Lua for EDuke32. Here we can ask each other questions.

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.
1

User is offline   Kyanos 

#2

I have minor experience in Python, CON, .bat's and just this weekend some basic HTML.

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.
0

User is offline   Mark 

#3

Back in the 80's which was a lifetime ago, I programmed in Basic for Texas Instruments and Atari computers. But nothing since then. I'll have plenty of questions on Con coding new enemies.
0

User is offline   Hendricks266 

  • Weaponized Autism

  #4

Oh, I can code TI-BASIC on my TI-84+ too. Not very useful outside of high school and associated standardized testing.
0

User is offline   Sangman 

#5

The point of this thread eludes me. Is it really meant to ask questions because all that's happened so far is people saying what languages they know :angry:
0

User is offline   Hendricks266 

  • Weaponized Autism

  #6

There are people who expressed interesting in learning stuff, so as they get started they can get help here.
0

User is offline   Hank 

#7

I still don't get this topic,
... 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. Posted Image

This post has been edited by Hank: 18 March 2013 - 03:39 PM

0

User is offline   Kyanos 

#8

http://www.lua.org/p...ontents.html#P4
1

User is offline   underTaker 

#9

I woud love to learn CON code for Duke, but i haven't got enough time :/ Shouldn't be too hard since i know some programming and scripting languages.
0

User is offline   Mark 

#10

I'm new to con coding. I need some help in replacing original enemies with my own. I was told before that I should create new ones from scratch but that is beyond my skills for now.

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.
0

User is offline   Kyanos 

#11

I'm curious if you are working over the hardcoded Newbeast tileset or if you've def'd your new enemy to a tile range.
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
    }

1

User is offline   Hendricks266 

  • Weaponized Autism

  #12

(I'm working with the unmodified Protector Drone code here.)

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.
1

User is offline   Mark 

#13

Drek... I'm going directly over the existing enemies. If its going to make things easier in the long run, I'll def them to new tiles. How then do I set up a new con file for them?

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

0

User is offline   Mark 

#14

WOO HOO. No more shooting. I'll do the distance thing next. I must have messed up the first time I tried because I had some braces errors in the log file. Hopefully I can transfer some of this book learnin' to my other enemies. Thanks again.

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? :angry:

This post has been edited by Mark.: 19 March 2013 - 02:33 PM

1

User is offline   Kyanos 

#15

Quote

Drek... I'm going directly over the existing enemies. If its going to make things easier in the long run, I'll def them to new tiles.


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

How then do I set up a new con file for them? 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.


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

Then I modify it to my liking.
Yes, set up your names, name the actions and ai too. Be meticulous, don't miss any and don't miss type. By now I'm sure you know eduke will spit out error logs galore, read them if it doesn't run. Look for error line number... then trace it back, patience is the key when doing this for the first time. I always make mistakes in code.

Quote

How do I direct this new con file to affect my newly def'ed model instead of the original?

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. :angry: Now can you guess at this one.
ifvarvare
Spoiler


This post has been edited by Drek: 19 March 2013 - 02:59 PM

0

User is offline   Mark 

#16

Are you saying that if I move the enemy to a new tile location and make a new con file that I have to change all the action and ai names to something different than the originals to make it work?

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

0

User is offline   Kyanos 

#17

You don't have to rename it, but if you keep the name newbeast it will replace the actual newbeast, you're modding an existing actor still. Anything from duke3d, be it actor names or the original tiles, I avoid when making new stuff, hardcoded issues are annoying. It's just a personal preference / generic modding guideline. Somebody once told me to do so, so I do.

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

It doesn't sound right. If I change AINEWBEASTTHINK to AISKELETONTHINK, there is no skeleton ai code to run. What am I misunderstanding?


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.
0

User is offline   Mark 

#18

I don't understand it but I'll try it. Thanks. I should be able to do it quickly with copy / paste if all I have to do is change the "newbeast" portion of any word to "skeleton" . But first I am working on the firing distance of my second replacement enemy. It is replacing the lizcaptain and I want to alter the distances for shooting and spitting attacks. I'm going to try by myself first. If I get stuck I'll be back for help.

This post has been edited by Mark.: 19 March 2013 - 05:29 PM

0

User is offline   The Commander 

  • I used to be a Brown Fuzzy Fruit, but I've changed bro...

#19

Garry's Mod uses LUA, I wonder how different the coding syntax will look.
0

User is offline   Mark 

#20

My results were the mess I expected. Changing actions and ai from ( example ) AINEWBEASTSHOOT to AISKELSHOOT left me with dozens of "not defined" errors in the log. I guess I've misunderstood instructions.
0

User is offline   Hank 

#21

This happens to all of us. Debugging is part of programming. Posted Image


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.
0

User is offline   Mark 

#22

Maybe an explanation might help to clear things up for me. Maybe I'm assuming this wrongly. But for instance, when a line of code is calling for ANEWBEASTSHOOT, I assume its calling for a hardcoded action routine by that name. So if I rename it to ASKELETONSHOOT there is no hardcoded routine to execute and that is why I get the log error telling me it is undefined.
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

0

User is offline   Hank 

#23

I would first, make sure that the definition is above the function.
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

0

User is offline   Mark 

#24

I noticed the dominoe effect when commenting out an error. It leads to others. I wiped out the file and I'm starting over.

This post has been edited by Mark.: 21 March 2013 - 03:49 AM

0

User is offline   Mark 

#25

Yes. ASKELHANG was in the first bunch of lines defining actions. I'm gaining ground here on the error messages. Mostly about jibs and such from previous changes I made when this new enemy was replacing the original. I'll continue the struggle tomorrow.

This post has been edited by Mark.: 20 March 2013 - 08:38 PM

0

User is offline   Hank 

#26

Not sure here,
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 Posted Image

This post has been edited by Hank: 21 March 2013 - 02:50 PM

0

User is offline   Mark 

#27

The misery never ends. After getting rid of the action and ai errors, now I have a bunch of "state" errors for various jibs types. So I looked in I think it was GAME.CON and found where those jibs were being defined if thats the proper word for it here. I copied over those chunks to my new con file and some of the jibs state errors went away but others did not. Did everybody start out this way? If I wasn't already going bald I would be pulling out my hair.
0

User is offline   Hank 

#28

Yep, at least I.

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.
0

User is offline   Mark 

#29

What confused me was copying one state to my con file fixed the errors for those jibs. Copying almost identical state for the other jibs didn't fix the errors.

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

0

User is offline   Mark 

#30

After much hacking I managed to remove all 20 error messages from the log. I was flyin' high.

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

0

Share this topic:


  • 2 Pages +
  • 1
  • 2
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options