
EDuke32 Scripting "CON coding help"
#2843 Posted 23 June 2022 - 11:49 AM
This post has been edited by dandouglas: 23 June 2022 - 11:58 AM
#2844 Posted 23 June 2022 - 12:03 PM
setuserdef[].show_level_text NO
^Execute that line of code before the level's name displays upon map load (for example in EVENT_NEWGAME). If you want it only temporarily disabled then you have to turn it off and on depending on the situation.
#2845 Posted 23 June 2022 - 12:04 PM
useractor notenemy FENCE1 cstat 17 enda
this blocks the player from walking through it, but lets the bullets pass through.
for some strange reason, userart always blocks hitscan and projectiles unless you specifically change the cstat.
This post has been edited by jimbob: 23 June 2022 - 12:07 PM
#2846 Posted 23 June 2022 - 12:32 PM
Danukem, on 23 June 2022 - 12:03 PM, said:
setuserdef[].show_level_text NO
^Execute that line of code before the level's name displays upon map load (for example in EVENT_NEWGAME). If you want it only temporarily disabled then you have to turn it off and on depending on the situation.
Thanks a lot

This post has been edited by Seb Luca: 23 June 2022 - 12:33 PM
#2847 Posted 23 June 2022 - 01:25 PM
jimbob, on 23 June 2022 - 12:04 PM, said:
useractor notenemy FENCE1 cstat 17 enda
this blocks the player from walking through it, but lets the bullets pass through.
for some strange reason, userart always blocks hitscan and projectiles unless you specifically change the cstat.
This is perfect, thanks so much! I've used cstat 32785 to make invisible sprites

#2848 Posted 23 June 2022 - 09:13 PM
Danukem, on 22 June 2022 - 08:30 PM, said:
gamevar sleeping NO 2 // note that NO and YES are normally defined as 0 and 1 in DEFS.CON onevent EVENT_GAME switch sprite[].picnum case MYENEMY ife sprite[].statnum 2 set sleeping YES break // presumably you will want other cases... endswitch endevent // then elsewhere... useractor enemy MYENEMY MYENEMYHP // lotsa code blah blah blah ife sleeping YES ifg sprite[].extra 0 { sound MYRECOGSOUND set sleeping NO } enda
Note that if an enemy is discovered it may be going from statnum 0 to 1 (not 2 to 1) so it may never have been sleeping; therefore, you would still want to have it making the sound in your ifai 0 block (or ifmove 0, or however you initialize the enemy)
All sprites running the argument every tick sounds intensive yeah.
The idea to check statnum for sleep is perfect.
Since the actor itself can't run code after falling asleep can a spawned sprite reference its parent, and the parent reference a sprite it spawned?
Supposing the useractor spawns an unrendered noclipping sprite which follows duke so it never falls asleep, and that sprite will check the parent's statnum every x count, is the parent be able to kill that sprite (and more importantly would that sprite be able to set a per-actor variable for the parent)?
spriteflags myghost yyyy //unrendered noclipping useractor myactor ifvare temp1 0 //var indicating was asleep { sound myactor_recog spawn myghost setvar temp1 1 } ifdead {myghost}.killit //parent kills spawned sprite enda useractor myghost ifcount 256 { ife {myactor}sprite[].statnum 2 //spawned sprite checks parent's statnum { setvar {myactor}temp1 0 //spawned sprite sets parent's var indicating was sleep killit } else resetcount } enda
#2849 Posted 23 June 2022 - 11:09 PM
lllllllllllllll, on 23 June 2022 - 09:13 PM, said:
There's a simple fix for that though which I didn't include because it will cause problems if you are already using EVENT_GAME. But assuming you are not:
onevent EVENT_GAME switch sprite[].picnum case MYENEMY ife sprite[].statnum 2 set sleeping YES break default geta[].htflags RETURN orvar RETURN 128 seta[].htflags RETURN break endswitch endevent
So now only the cases you want will check statnum to set sleeping, and all other sprites in the game will be exluded from any processing in EVENT_GAME after the initial check. https://wiki.eduke32.com/wiki/Htflags
Spawning an additional sprite to check on the first sprite is possible, although it comes with its own baggage. For example, some maps get close to the sprite limit so spawning lots of extra sprites should be discouraged.
But it occurs to me that there may be a better method than either of those. As a sprite gets closer to sleeping, its .httimetosleep member gets incremented. I have never researched the precise behavior of that counter, but what if the counter only gets lower when it is reset upon wakeup? If that's the case, then you could simply have the actor make the RECOG sound whenever httimetosleep is < what it was last tic:
ifl sprite[].httimetosleep sleeptime sound MYRECOG geta[].httimetosleep sleeptime
#2850 Posted 24 June 2022 - 10:31 AM
Danukem, on 23 June 2022 - 11:09 PM, said:
ifl sprite[].httimetosleep sleeptime sound MYRECOG geta[].httimetosleep sleeptime
As you thought it only lowers after the enemy is awakened again, it gives strange results though.
First I used
useractor myactor ife sprite[].httimetosleep 0 sound MYRECOG enda
This resulted in sleeping and reawakening enemies playing their RECOG properly, but enemies spawned via respawn didn't play the sound.
That made me think the respawning enemies have a higher initial value for httimetosleep, so I combined the above with the previous:
useractor myactor ifvare temp1 0 { sound MYRECOG setvar temp1 1 } else ife sprite[].httimetosleep 0 sound MYRECOG enda
This resulted in all forms of the enemy playing their sound after a 4 tick delay.
I figured that httimetosleep was somehow still being calculated on the first tick:
useractor myactor ifvare temp1 1 { ife sprite[].httimetosleep 0 sound MYRECOG } else { sound MYRECOG setvar temp1 1 } enda
but this results in even weirder behavior. All forms of enemies are playing the sound after ~4 tick delay but it doesn't always play.
It makes it seem like httimetosleep is starting with negative values and the times it doesn't play are where the increment skips 0.
But even in that case I don't understand why the bit following else is not working whenever ife sprite[].httimetosleep is used.
After messing around with it more I ended up with
useractor myenemy ifvare temp1 0 { sound MYRECOG setvar temp1 1 } else ifvare temp1 1 { ifcount 64 setvar temp1 2 } else ife sprite[].httimetosleep 0 sound MYRECOG state actorcode enda
and, as far as I've tested, this works
Thankfully when they fall asleep httimetosleep gets set to exactly 0
#2851 Posted 03 July 2022 - 11:01 AM
I've experimented with using activatecheat to toggle god mode on and off for the duration of the movement lock (and removing the associated quote), and this works great, with a couple of issues: player health is brought up to 100 when god mode is engaged, and when disengaged the screen flashes red. Both of these issues I'd like to avoid. Any suggestions? Cheers!
#2852 Posted 03 July 2022 - 01:48 PM

during the lockplayer duration, resize the player to something really small to reduce it's hitscan area making it way less likely to be hit. This of course would move the player view down to the floor so right after resizing, use a command to move the player up to normal.
Would it be possible to spawn a protective shield of invisible sprites around the player during lockplayer
Not sure exactly where to place it or how, ifhitweapon nullop nested in there somewhere for aplayer.
This post has been edited by Mark: 03 July 2022 - 01:50 PM
#2853 Posted 03 July 2022 - 03:26 PM
dandouglas, on 03 July 2022 - 11:01 AM, said:
Just use seta[].htextra -1 in the player code *before* ifhitweapon. This nullifies any damage caused by weapon hits or explosions.
#2854 Posted 04 July 2022 - 06:13 AM
Danukem, on 03 July 2022 - 03:26 PM, said:
Thanks Dan - that works great!
@Mark - thanks for the suggestions, I'd considered using invisible sprite shields too!
#2855 Posted 05 July 2022 - 12:09 PM
#2856 Posted 05 July 2022 - 02:48 PM
dandouglas, on 05 July 2022 - 12:09 PM, said:
I recommend just keep editing the files you have. For the sounds you can mostly just replace the sound files without changing the sound definitions.
#2857 Posted 06 July 2022 - 12:40 AM
Danukem, on 05 July 2022 - 02:48 PM, said:
Thanks again Dan, good shout.
#2858 Posted 07 July 2022 - 08:01 AM
gamevar WEAPON8_WORKSLIKE 8 0
gamevar WEAPON8_FLAGS 16384
any tips on that?
#2859 Posted 07 July 2022 - 12:33 PM
jimbob, on 07 July 2022 - 08:01 AM, said:
gamevar WEAPON8_WORKSLIKE 8 0
gamevar WEAPON8_FLAGS 16384
any tips on that?
I know I have solved this problem, because in Alien Armageddon the default weapon on that slot is the spider mines which you can throw. In my code I am constantly setting WEAPON8_WORKSLIKE to 6 but I don't remember why. Perhaps the game is hardcoded to revert WEAPON8_WORKSLIKE to the default value when you switch weapons?
#2860 Posted 08 July 2022 - 07:19 AM
[edit] while it does shoot right, it displays the frames for the weapon 6 slot despite the "state weapon8_display" command

ill take a look at the alien armageddon code and see how that sniper works, its probably something simple im overlooking.
This post has been edited by jimbob: 08 July 2022 - 07:27 AM
#2861 Posted 08 July 2022 - 12:06 PM
jimbob, on 08 July 2022 - 07:19 AM, said:
[edit] while it does shoot right, it displays the frames for the weapon 6 slot despite the "state weapon8_display" command

ill take a look at the alien armageddon code and see how that sniper works, its probably something simple im overlooking.
Yes, it is supposed to show different tiles when you change that value. That just proves that what you did before was not doing anything.
In my mods I have my own weapon display code that overrides the tiles it would normally display. What you have to do is set RETURN to -1 in the weapon display event, then use screen drawing commands to draw your own tiles. I didn't even occur to me that you weren't doing that already, since the alternative is being stuck with the the vanilla display code.
#2862 Posted 09 July 2022 - 02:42 PM
onevent EVENT_DRAWWEAPON ifvare currentweapon 1 { setvar RETURN -1 ifvare LUGERSELECTED 1 { state luger_display } else { state draw_pistol } } ifvare currentweapon 2 { setvar RETURN -1 state mp40_display } ifvare currentweapon 3 { setvar RETURN -1 state thompson_display } ifvare currentweapon 4 { setvar RETURN -1 state bazooka_display } ifvare currentweapon 6 { setvar RETURN -1 state flamethrower_display ifsound FTFIRE { stopactorsound APLAYER FTIDLE } else soundonce FTIDLE } ifvare currentweapon 7 { setvar RETURN -1 state MG42_display } ife currentweapon 8 // ifvare currentweapon 8 { setvar RETURN -1 state k98_display } ifvare currentweapon 9 { setvar RETURN -1 state garand_display } ifvare currentweapon 11 { setvar RETURN -1 state greaser_display } endevent
#2863 Posted 09 July 2022 - 03:00 PM
As an intermediate level CON coder you picked the hardest possible weapon slot to put a sniper rifle on.
#2864 Posted 09 July 2022 - 03:06 PM

[edit] well that kinda works, now it insists on displaying both tiles at the same time :')
[edit]nevermind, setting the workslike weapon to 9, since its practically the same gun, then also adding plaer[]/curr_weapon to that weapon fixed that. now on to code this sucker

This post has been edited by jimbob: 09 July 2022 - 03:11 PM
#2865 Posted 10 July 2022 - 04:35 PM
[edit] i suppose i could make the bolt action part of the firing animation as a cheap out alternative.
This post has been edited by jimbob: 10 July 2022 - 04:36 PM
#2866 Posted 10 July 2022 - 08:16 PM
#2867 Posted 11 July 2022 - 06:59 AM
here's an example of my actual weapon draw code, wich is probably needlesly "drawn out"
state flamethrower_display switch weaponcount case 0 ifinwater nullop else { setvar digz 32768 setvar digx 175 // was 150 setvar digy 200 setvar shade -127 setvar picnum 3864 // flame! // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal 1 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 250 setvar picnum 3863 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break // fire case 1 case 2 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5552 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 3 case 4 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5553 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 5 case 6 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5554 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 7 case 8 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5555 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 9 case 10 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5556 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 11 case 12 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5557 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim case 13 case 14 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5558 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 15 case 16 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5559 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 17 case 18 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5560 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 19 case 20 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5561 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break case 21 case 22 ifinwater nullop else { setvar digz 32768 setvar digx 170 setvar digy 215 setvar shade -127 setvar picnum 5562 // flame // setvar orientation 33 state initweapondisplay rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim } // break setvar digz 32768 setvar digx 240 setvar digy 260 setvar picnum 3868 setvar orientation 0 state initweapondisplay rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim break endswitch ends // end flamethrower
but that gives an idea how it looks like
[edit] well right now im setting the total time to the fire animation and the racking combined, and then i will set another bunch of frames for the reload animation. so far this seems to work(ish)
This post has been edited by jimbob: 11 July 2022 - 08:27 AM
#2868 Posted 12 July 2022 - 11:44 AM
jimbob, on 11 July 2022 - 06:59 AM, said:
Make the code branch and display the other sequence of tiles when the gun is doing a full reload. I'm not sure what you are really asking, though. Are you having trouble figuring out how to detect whether the weapon is doing a full reload? Are you having trouble with the WEAPONX_RELOAD var itself?
#2869 Posted 15 July 2022 - 12:51 PM
for example, like the shotgun, say it has 5 shells in it, you pump in a new round every shot, but when it's empty you want a different animation to open the chamber so you can insert new rounds.
then i have to make a scope and massively increase the damage when using it. wich is easy enough
#2870 Posted 15 July 2022 - 01:40 PM
If you are using a variable to track how many rounds are in the magazine, then the obvious way would be when magazine == 0 and reloading is not 0
#2871 Posted 15 July 2022 - 11:51 PM
The backstory is that, in my mod, the aliens are going to have severe egg allergies so Duke can throw eggs at them, but they don't die straight away.
I've got an RPG-style projectile working nicely, thrown on an arch with a little splash when it lands, but it currently only does damage on impact.
#2872 Posted 16 July 2022 - 01:27 AM
dandouglas, on 15 July 2022 - 11:51 PM, said:
The backstory is that, in my mod, the aliens are going to have severe egg allergies so Duke can throw eggs at them, but they don't die straight away.
I've got an RPG-style projectile working nicely, thrown on an arch with a little splash when it lands, but it currently only does damage on impact.
Declare a per-actor gamevar:
gamevar poison 0 2
Also use 65536 as a flag in the workslike of the custom projectile. See PROJECTILE_RADIUS_PICNUM in this list: https://wiki.eduke32...efineprojectile
Now let's say that your projectile is named EGGPROJ
You want every enemy to run some additional code when hit by a weapon. A simple example would be
ifwasweapon EGGPROJ add poison 150Again, that goes *inside* the ifhitweapon code block.
Finally, you also need to add code to each enemy to process the poison damage. I would define a state and then have each enemy call the state when alive and before it calls ifhitweapon. Here's an example of what the state might look like.
defstate newmoncode ifg poison 0 { sub poison 1 ifrnd 64 ife sprite[].htextra -1 { seta[].htextra 1 seta[].htowner player[].i seta[].htpicnum KNEE // spawn some custom actor here that looks like puke or poison smoke or something } } ends