
EDuke32 Scripting "CON coding help"
#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
#2873 Posted 17 July 2022 - 08:58 AM

#2874 Posted 17 July 2022 - 10:57 AM
#2875 Posted 17 July 2022 - 11:18 AM
onevent EVENT_LOOKDOWN setvar RETURN -1 ife player[].curr_weapon 8 // sniper rifle { ife USESCOPE 1 { setvar USESCOPE 0 addlogvar USESCOPE break } ife USESCOPE 0 { setvar USESCOPE 1 addlogvar USESCOPE break } } endevent
the var USESCOPE triggers a lot of stuff in other events.
#2876 Posted 17 July 2022 - 11:25 AM
#2877 Posted 17 July 2022 - 11:36 AM
i looked at the bits thing, and using getinput[].bits TEMP then adding ifvarand TEMP 16384, then adding a addlogvar, the log shows a completely different number when pressing that button rather than the listed 16384
This post has been edited by jimbob: 17 July 2022 - 12:53 PM
#2878 Posted 17 July 2022 - 03:50 PM
#2879 Posted 18 July 2022 - 04:00 AM
But there's a couple of simple things I wanted to straighten out for myself as not to form any bad habits as I push onwards. Spoilers used to keep this clean;
Braces vs Non-Braces?
ife vs ifn?
Timers?
I'm sure to have more questions down the line, but these three are currently stumping me right now. Otherwise, so far I've been enjoying my time with CON scripting for a change and have been focusing my learning by recreating functions from other games.
#2880 Posted 18 July 2022 - 06:57 AM
Also is the there something like EVENT_GETSHOTRANGE for projectiles like the rpg that allows adjustment of spread?
This post has been edited by VGames: 18 July 2022 - 07:55 AM