
EDuke32 Scripting "CON coding help"
#230 Posted 24 August 2009 - 03:12 AM
I first noticed this when I saw my actor perform its random idle pose but it cut out half way through and went to its walking actions. At first I had no idea why it did that and since it only ends its animation after an actioncount of 26 and it worked fine all the other times.
Problem now is that I have a rarther longish climb animation which is heavilly based on counts synced to its actions - turn away for 2 or so seconds and then when you return my actor will be in a stupid pose and it could look as bad as seeing it half submerged in the sector's floor still trying to climb a wall.
My question is:
How do I force the model itself to be rendered when not in view assuming that its animations do indeed continue to play?
This post has been edited by Chip: 24 August 2009 - 03:17 AM
#231 Posted 24 August 2009 - 08:53 AM
#232 Posted 25 August 2009 - 01:49 AM
My actor is also an "useractor notenemy" so it may be another limitation to that.
This post has been edited by Chip: 25 August 2009 - 01:50 AM
#233 Posted 25 August 2009 - 06:09 AM
useractor enemy CHAV CHAV_NORMAL_STRENGTH //Basic Setup sizeat 40 20 fall ifonwater cstat 128 else cstat 257 ifcansee ifai NO { ai CHAVWALKS ifrnd 128 sound PRED_RECOG } //Shooting ifrnd 8 ifcanseetarget ifpdistl 9000 { ai CHAVSHOOTS shoot CHAVSHOT sound PISTOL_FIRE } //reset code ifcount 48 ifrnd 16 ifai CHAVSHOOTS ai CHAVWALKS //attacked code ifhitweapon { spawn BLOOD ifdead { addkills 1 ai CHAVDEAD sound PRED_DYING ai CHAVDEAD spawn BLOODPOOL } ifrnd 8 sound PRED_PAIN } //death ifai CHAVDEAD { ifactioncount 6 killit spawn CHAVCORPSE } enda
Help a veteran n00b out, what am I doing wrong here.
#234 Posted 25 August 2009 - 06:45 AM
I have a tiny question. This code gives this error on log;
Quote
whilevarn spritenum2 16384 { addvar spritenum2 1 getactor[spritenum2].picnum picnum switch picnum case CHAINGUNNER canseespr THISACTOR spritenum2 returnvar7 ifvare returnvar7 1 { setactorvar[spritenum2].para 1 setvar randomvar 1 randvar randomvar 24 mulvar randomvar 48 setactor[spritenum2].htextra randomvar } break endswitch }
The chaingunner's picnum is 1551 and onwards. (Frames) I think it's showing the APLAYER as the result, though I do not know why. How can I fix that error ? (Note : This is in APLAYER Code, checked by a ifvarg KICKBACKPIC 85; and spritenum2 is set to 0 when kickbackpic is 84.)
#235 Posted 25 August 2009 - 07:28 AM
You should use statnum to check if the sprite exist. Statnum of 1024 belongs to non-existing sprites.
This post has been edited by Ilovefoxes: 25 August 2009 - 10:00 AM
#236 Posted 25 August 2009 - 07:52 AM
useractor enemy CHAV CHAV_NORMAL_STRENGTH //Basic Setup sizeat 40 20 fall ifonwater cstat 128 else cstat 257 ifcansee ifai NO { ai CHAVWALKS ifrnd 128 sound PRED_RECOG } //death ifai CHAVDEAD { ifactioncount 6 { killit spawn CHAVCORPSE } break } //Shooting ifrnd 8 ifcanseetarget ifpdistl 9000 { ai CHAVSHOOTS shoot CHAVSHOT sound PISTOL_FIRE } //reset code ifcount 48 ifrnd 16 ifai CHAVSHOOTS ai CHAVWALKS //attacked code ifhitweapon { spawn BLOOD ifdead { addkills 1 ai CHAVDEAD sound PRED_DYING ai CHAVDEAD spawn BLOODPOOL } ifrnd 8 sound PRED_PAIN } enda
#237 Posted 25 August 2009 - 08:11 AM
Chip, on Aug 25 2009, 04:49 AM, said:
My actor is also an "useractor notenemy" so it may be another limitation to that.
Care to post the relevant code?
#238 Posted 25 August 2009 - 08:25 AM
I'm surprised there isn't much by way of tutorials regarding putting in new enemies.
Thanks again.
#239 Posted 25 August 2009 - 09:17 AM
RockstarForADay, on Aug 25 2009, 09:25 AM, said:
There's some useful tutorials here: http://concode.planetduke.gamespy.com/
I have thought about writing my own and adding it to the wiki, but I'm afraid it would spin out of control and take too much of my time.
#240 Posted 25 August 2009 - 10:43 AM
I think that would be an awesome edition to the wiki. Would take a while to write up though like you said. Still, the wiki could use a few more tutorials on there.
#241 Posted 26 August 2009 - 04:08 AM
whilevarn spritenum2 16384 { addvar spritenum2 1 ifvarvarn spritenum2 THISACTOR { getactor[spritenum2].picnum picnum getactor[spritenum2].statnum statnum getactor[spritenum2].sectnum mysector ifvarn statnum 1024 ifvarn mysector -1 { switch picnum case ENLISTEE case LIZTROOP case PIGCOP case LIZMAN case ZOMBIEPLS case OCTABRAIN case COMMANDER case DEVIL case SHADE case CHAINGUNNER case EXTERMINATOR case TANK case BLOODSEEKER case NEWBEAST case NNEWWBEAST case CDEMON case PAINE case LSOUL case APLAYER canseespr THISACTOR spritenum2 returnvar7 ifvare returnvar7 1 { setactorvar[spritenum2].para 1 setactorvar[spritenum2].para_counter 0 randvar randomvar 24 mulvar randomvar 48 setactor[spritenum2].htextra randomvar } break endswitch } } }
I've played around with the code and I'm still having the same error, with these this time ;
Quote
Line 6794, getactor: tried to get statnum on invalid target sprite (16384) from spr 0 pic 1405 gv spritenum2
Line 6795, getactor: tried to get sectnum on invalid target sprite (16384) from spr 0 pic 1405 gv spritenum2
It gets stuck on APLAYER sprite for some reason. I don't know why. (1405 = Aplayer) What am I doing wrong here ? (Spritenum2 is -1 2)
This post has been edited by XThX2: 26 August 2009 - 04:11 AM
#242 Posted 26 August 2009 - 06:18 AM
^What that means is that sprite 0, which is a player sprite, is trying to get information from an invalid sprite (number 16384).
Put the addvar spritenum2 1 at the END of the while loop instead of the beginning.
#243 Posted 26 August 2009 - 07:27 AM
#244 Posted 26 August 2009 - 07:55 AM
Also, it is working perfectly now, thanks.

This post has been edited by XThX2: 26 August 2009 - 07:55 AM
#245 Posted 26 August 2009 - 08:43 AM
Mblackwell, on Aug 25 2009, 05:11 PM, said:
I bring you pictures and everything!
Observe picture 1:
Everthing works fine, of course I'm facing the actor through the whole situation.
(If you click the image to gointo Imageshack, then once its loaded, click the image again to get it to a single window - then click once more to full size the image but this last part may vary depending on your web browser)

In this next test, I turn away when the climbing animation starts and then when I return its in a horrible mess!

Clearly its gone wrong all because the player turned away. I'm certain this has to be down to the whole models (well sprites and what ever they have set to them) dissapearing when out of sight and thus screwing with the animations either by pausing them or resetting them, either way my movement code carries on and forces my actor into the possitions its meant to be at but of course the animation lost sync with it and it looks silly.
Here's the climbing code:
state pokeclimbstate ifmove MPOKEHANG1 nullop else move MPOKEHANG1 geth getv ifvare APPLYONCE 0 { getsector[TEMP5].floorz z2 subvar z2 90 setvar APPLYONCE 1 } getactor[THISACTOR].z z ifvarvarl z z2 { ifcount 120 setactor[THISACTOR].xvel 32 } else { subvar z 140 setactor[THISACTOR].z z } ifactioncount 45 { state resetvarsstate setvar TIMEOUT 3 setvar TEMP 2 action APOKEWALK } ends
Here's the defined animation:
anim { frame0 "FRAME396" frame1 "FRAME480" fps 19 flags 1 } frame { name "FRAME396" tile 5747 } // Climb up and over!
The actor is a "useractor notenemy", it does not have any share gamevars - all the ones it uses are per actor. There isn't a single player related command in any of its states.
This post has been edited by Chip: 26 August 2009 - 08:46 AM
#246 Posted 26 August 2009 - 09:23 AM
Oh and I reformatted your code so it's easier to read.
state pokeclimbstate ifmove MPOKEHANG1 nullop else move MPOKEHANG1 geth getv ifvare APPLYONCE 0 { getsector[TEMP5].floorz z2 subvar z2 90 setvar APPLYONCE 1 } getactor[THISACTOR].z z ifvarvarl z z2 { ifcount 120 setactor[THISACTOR].xvel 32 } else { subvar z 140 setactor[THISACTOR].z z } ifactioncount 45 { state resetvarsstate setvar TIMEOUT 3 setvar TEMP 2 action APOKEWALK } ends
#247 Posted 26 August 2009 - 10:10 AM
#248 Posted 26 August 2009 - 12:02 PM
Quote
All actions and vars are being set from another state followed by an instant "break" (in this case it was set in its hang state which it does before climbing) TEMP5 holds the sector's ID where it plans on climbing to which was set in its jump state. Its only reset in its standard paving stuff. Resetvarsstate is a state used to set my important gamevars to 0 (In this case my jumpable vars since the otheres were untouced)
That ifcount however isn't being reset - I forgot about that so I may throw into the resetvarsstate but it shouldn't cause any problems since it will get automaticaly reset in its seekstate upon the first invalid spotted sector. (It has an ifcount 2 { resetcount ......stuff... } when it doesn't like the look of the upcoming sector) My actor doesn't do anything else with that count so its harmless at the moment.
Quote
That's how I used to always write out my code but I actually started finding it easier to read in the other way, Its especially quicker to skim past.
Quote
I guess that's a little more evidence that models and animations needs a little looking into. For me this bug of re-animating dead monsters always occurs when I reload a saved gamed.
This post has been edited by Chip: 26 August 2009 - 12:07 PM
#249 Posted 26 August 2009 - 01:02 PM
http://wiki.eduke32.com/wiki/Mdflags
#250 Posted 27 August 2009 - 04:24 AM
DeeperThought, on Aug 26 2009, 10:02 PM, said:
http://wiki.eduke32.com/wiki/Mdflags
Yeah I tried that but it unfortunately didn't work, assuming I used it right. (which I may have not now that I think about it). I will however also try changing my actor from notenemy to enemy to see if that makes any change since enemies do alot more stuff then notenemies (I've only recently found out the enemy tagged actors have a built in paving code to help it avoid walls - not a good one but there is indeed one in there. I guess that's why it jerks in movement.)
This post has been edited by Chip: 27 August 2009 - 04:27 AM
#251 Posted 27 August 2009 - 04:38 AM
#252 Posted 27 August 2009 - 04:55 AM
If you're still having problems then you could aways try cansee which indeed can cross sectors (else it would be pointless for the command to need sector IDs imputted for botth points) but with that you'll need to obtain more details before using the command.
Side note, cansee is fantastic for paving code!
This post has been edited by Chip: 27 August 2009 - 04:57 AM
#253 Posted 27 August 2009 - 06:49 AM
#254 Posted 27 August 2009 - 07:35 AM
XThX2, on Aug 27 2009, 07:49 AM, said:
I'm guessing that when you used cansee, you set the z coordinates appropriately. canseespr works fine too, but keep in mind that sprites see from the bottoms of their feet, so it's a good idea to lift them up before using it.
#256 Posted 29 August 2009 - 10:46 AM
M210, on Aug 29 2009, 03:52 AM, said:
What's sector effector 12? (I don't know the numbers by heart)
Quote
Tried that again but still nothing.
I guess this may only be something that TerminX can solve but I don't want to hassle people (especially if they may allready know about due to it being apart of a bug that's existed for a while) so I wont speak more of this till some time passes by.
New issues: Slopes!!!!
It appears sloped sectors are evil, my actors see them not as a slope but of the unmodifed block that the slope starts at. A slope that starts from the ground and slopes up counts as being flat on the ground and one that starts at the top then slopes down counts as being flat at the top.
As such my actors avoid them thinking those are too high or too low and so wont either step foot on them or if they do (starts at the ground and slopes up) then they wont walk off the top onto the higher sector. Also I guess the actor's z possition isn't really where the sprite is but still on the floor / at the top regardless of possition. I believe that since my actor checks his new possition's floor with subvar 8000 (so its not flat on the floor) against his own z possition (again with subvar 8000 so he's seeing higher up) His cansee shouldn't be blocked due to that so its failing because of my hack stopping him from walking into wall that's 5000 higher then his own Z possition. (and by higher I mean lower)
I'm not too bothered about getting the exact slope details, at this point I just want my actor to have an accurate z possition when on the slope.
For this I need to know the angle of the sloped sector. This I don't know how to obtain since the only getsector slope detail I saw was the amount the slope had gone up / down by.
With that I can hopefully do the rest by checking all the points to each other and conpair the angle between those points to the sloped sector to see which 2 points closely match the slope's angle and as such can assume that these 2 points I have are 1 from the top of the slope and 1 from the bottom allowing me to work out the height of both ends of the slope by obtaining the adjacent floor's Z .....then do some kind of XY thing with the actor to work out where he is on the slope and add or sub a value from his z checking.
*edit*
What if my sector slopes to a cliff edge? I guess I'll have to throw in the floorslope amount in there as well.
In short, my question is: how do I find out a sector's slope angle?
Oh and is there a much better way to work out my z possition on a sector slope then what I posted above? (Which I'm certain there are 500 more)
Also what does EXTRA hold from Walls? The wiki says sectors and walls have an EXTRA but it doesn't say what it holds.
*edit once more*
///////////////////////////////////////////////////////////////////////////////// ///////////
Never mind, about the Z possition on sloped sectors, I saw this: http://wiki.eduke32....Getflorzofslope !
Another fantastic command hidden within the wiki!
This post has been edited by Chip: 29 August 2009 - 11:01 AM
#257 Posted 29 August 2009 - 11:09 AM
Chip, on Aug 29 2009, 10:46 PM, said:
It's a light switch SE, which switch-on light on the sector when push at button, and swicth-off if shot at lighter or push to off the button
#258 Posted 31 August 2009 - 11:21 PM
Some time ago on 3D Realms forums, I came up with an idea for a mod/tc that was basically Duke Nukem 2 style in Duke Nukem 3D, I did a bit of work and then kind of forgot about it, but I keep thinking of starting it up again, there's only one thing that stops me - CON Code, i can't really seem to get back into that, I've been slowly moving away from programming for a couple of years now, and CON code just doesn't seem to be something that will go back into my head (And I think it's a bit different if i want to take advantages of the EDuke32 features anyway) so, If I did decide to start the mod again, would someone perhaps give me a hand with that? I would literally be doing everything else for it except the CON Coding, well, might decide i needed a few models, but more likely I would use Sprites, as it would be like a 3D SideScroller (DNMP Style).
This isn't something I am definitely going to do mind, but I am really thinking about it for when I have my Music Packs finished as I would have no more foreseeable projects lined up.