
EDuke32 Scripting "CON coding help"
#3121 Posted 29 November 2022 - 06:42 AM
One more quick question. Is there any way to change the position of the button layout in the options menu where u bind your keys to certain commands? I’ve changed the names of several buttons to accommodate some of the new features in my mod they were changed to work for like the look up and look down buttons are used for new fire modes. But I’d like them to be located next to the original fire and alt fire button locations on the key bind menu screen. Is there a way to reposition these button commands so the player doesn’t have to search for them?
This post has been edited by VGames: 29 November 2022 - 06:43 AM
#3122 Posted 29 November 2022 - 08:44 AM
I wanted to have the monsters use additive translucency when frozen, I've already done this, and it also returns to it's previous sprite pal when it thaws. However, it maintains translucency when it was frozen. How do I get it to become solid again after it thaws? Doesn't it have something to do with cstator?
#3123 Posted 29 November 2022 - 09:25 AM
VGames, on 29 November 2022 - 06:42 AM, said:
Nope. They will always appear in the order gamefuncs are defined.
Mav3r1ck, on 29 November 2022 - 08:44 AM, said:
You'll need to modify each enemy's code to reset the transparency cstat (and presumably the blend mode back to 0). You can do this a few ways:
If you already know the desired cstat, just set it back. This is probably fine in 99% of cases. Most enemies use 257 (blocking + hitscan):
cstat 257
If you just want to remove a given cstat value, you can get and subtract the value. This may produce unintended results so for safety you should add some checks before doing this:
geta .cstat TEMP
sub TEMP 2
seta .cstat TEMP
A fun trick is to bitwise AND the negative of the cstat (or cstats, plural) you want to remove, plus 1. This would safely clear both transparency cstats (2 + 512):
geta .cstat TEMP
and TEMP -515
seta .cstat TEMP
#3124 Posted 29 November 2022 - 12:48 PM
VGames, on 29 November 2022 - 06:42 AM, said:
Actually you can. Doom64hunter added this feature as a DEF command a while ago. I did not realize that it was completely undocumented until I saw Reaper_Man's post.
If you want your custom keys to be higher up on the list of keys, you can do it via the DEF command:
keyconfig
{
gamefunc_Move_Forward
gamefunc_Move_Backward
gamefunc_Strafe_Left
gamefunc_Strafe_Right
...
}
The gamefunc names are exposed by the source as built-in labels.
the order in which you list the gamefuncs will be the order in which they appear. Those you do not list will not appear. Note that the capitalization follows how they are given here; https://wiki.eduke32...inegamefuncname
If you want to see a full example, you can check duke3d.def in Alien Armageddon.
#3126 Posted 29 November 2022 - 01:47 PM
VGames, on 29 November 2022 - 05:34 AM, said:
use a var as a flag whenever health is added to the player in atomichealth's actor, then reset it after whatever you're doing upon detecting it
#3127 Posted 29 November 2022 - 05:50 PM
The problem however is moving the mouse(look) causes the screen to shake/jitter around while as if fighting against being forced back into it's stored setp variables while moving around a mouse cursor onscreen works as intended.
The "lockplayer" function would be perfect since the screen remains unmoving, but I can't use that here because it also stops updating mouse cursor movements entirely (I'm using getinput for both .q16avel and .q16horz here) and any EVENT_FIRE actions which I use as a click function.
I've referred to code from other projects and afaik they do similar methods of grabbing and storing previous .ang/.horiz and setting them, without the screen shake issues. The other exception is they're also use "lockplayer" as well while their cursors are still functioning as intended. Been examining their code and tinkering with my own to no better results or understanding. Now I'm stuck or just missing something, need to fix this issue before doing any further gui related stuff.
Can someone help break down exactly what I should be doing to lock the player's horizontal / vertical axis properly under these or similar circumstances?
#3128 Posted 29 November 2022 - 09:14 PM
Danukem, on 29 November 2022 - 12:48 PM, said:
If you want your custom keys to be higher up on the list of keys, you can do it via the DEF command:
keyconfig
{
gamefunc_Move_Forward
gamefunc_Move_Backward
gamefunc_Strafe_Left
gamefunc_Strafe_Right
...
}
The gamefunc names are exposed by the source as built-in labels.
the order in which you list the gamefuncs will be the order in which they appear. Those you do not list will not appear. Note that the capitalization follows how they are given here; https://wiki.eduke32...inegamefuncname
If you want to see a full example, you can check duke3d.def in Alien Armageddon.
Thanks a lot. This makes things easier for mod users when setting up the mod for themselves.
#3129 Posted 29 November 2022 - 10:22 PM
quakis, on 29 November 2022 - 05:50 PM, said:
The method you are describing that you found in other mods, can still work. But nowadays it requires additional code in a display event. That's because, a few years ago the game was changed so that the player's angle and horiz are updated with drawn frames, instead of only 30 times per second. That change broke a lot of things.
Anyway, here's a solution for you. It assumes that you did a full lock on the player.
onevent EVENT_DISPLAYROOMS
ife player[].movement_lock 31
ife player[].on_crane -1
{
set cameraang player[].oang
set camerahoriz 100
}
endevent
#3130 Posted 30 November 2022 - 08:34 AM
Danukem, on 29 November 2022 - 10:22 PM, said:
Anyway, here's a solution for you. It assumes that you did a full lock on the player.
That does explain a lot, wouldn't have considered EVENT_DISPLAYROOMS as an answer. Thank you so much for the help, this solution is working wonderfully! Cheers.
#3131 Posted 10 December 2022 - 01:34 PM
state cutscene_cleanup
stopallmusic
ifvarn SCREENALPHA 255
setvar SCREENALPHA 255
ifvarn CUTSCENE_STEP 0
setvar CUTSCENE_STEP 0
ends
onevent EVENT_PRELEVEL // ************************************************************************************
ife VOLUME 3
ife LEVEL 0
{
stopallsounds
stopallmusic
starttrackslot 0 1 // Play BRIEFING.MID
redefinequote 230 VOL41A.ANM
startcutscene 230
redefinequote 230 VOL42A.ANM
startcutscene 230
redefinequote 230 VOL43A.ANM
startcutscene 230
stopallsounds
}
state cutscene_cleanup
ifvare VOLUME 0
{
ifvare LEVEL 1 // HOLLYWOOD HOLOCAUST
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
starttrackslot 7 4
startscreen // FIRST SCREEN
screensound RPG_EXPLODE // SOUND EFFECT AT THE START OF THE SECOND SCREEN
startscreen // SECOND SCREEN
}
ifvare LEVEL 4 // TOXIC DUMP
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
// starttrackslot 7 4
startscreen // FIRST SCREEN
}
}
ifvare VOLUME 1
{
// note that LEVEL is bumped up by 1 due to start menu shenanigans
ifvare LEVEL 1 // SPACEPORT
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
// starttrackslot 7 4
startscreen // FIRST SCREEN
}
ifvare LEVEL 4 // FUSION STATION
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
// starttrackslot 7 4
startscreen // FIRST SCREEN
}
ifvare LEVEL 9 // OVERLORD
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
// starttrackslot 7 4
startscreen // FIRST SCREEN
}
}
ifvare VOLUME 2
{
ifvare LEVEL 1 // RAW MEAT
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
// starttrackslot 7 4
startscreen // FIRST SCREEN
}
ifvare LEVEL 5 // MOVIE SET
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
// starttrackslot 7 4
startscreen // FIRST SCREEN
}
ifvare LEVEL 9 // STADIUM
{
stopallsounds
// ADD SOME MUSIC TRACK IF NEEDED
// starttrackslot 7 4
startscreen // FIRST SCREEN
}
}
endevent // ************************************************************************************
appendevent EVENT_ENDLEVELSCREEN // ************************************************************************************
state cutscene_cleanup
// ifvare VOLUME 0
// ifvare LEVEL 2 // RED LIGHT DISTRICT
// {
// stopallsounds
// startscreen
// }
endevent // ************************************************************************************
onevent EVENT_SCREEN // ************************************************************************************
set z 65536
ifvare RETURN 0
{
ifvarg SCREENALPHA 0 // QUICK FADEOUT
{
screenpal 0 0 0 SCREENALPHA
subvar SCREENALPHA 5
}
}
else ifvare RETURN 1
setvar SCREENALPHA 255
ifvare VOLUME 0
{
ifvare LEVEL 1
{
ifvare CUTSCENE_STEP 0 // FIRST SCREEN
{
setvar CUTSCENE_SCREEN 6792
ifvare RETURN 1 // IF THE PLAYER USES ANY KEY TO SKIP THE SCENE
setvar CUTSCENE_STEP 1 // CHANGE TO THE NEXT SCREEN
}
else ifvare CUTSCENE_STEP 1 // SECOND SCREEN
{
setvar CUTSCENE_SCREEN 6793
ifvare RETURN 1 // IF THE PLAYER USES ANY KEY TO SKIP THE SCENE
setvar CUTSCENE_STEP 2 // CHANGE TO THE NEXT SCREEN
}
}
ifvare LEVEL 4
{
setvar CUTSCENE_SCREEN 6794
}
}
ifvare VOLUME 1
{
ifvare LEVEL 1
{
setvar CUTSCENE_SCREEN 6795
}
ifvare LEVEL 4
{
setvar CUTSCENE_SCREEN 6796
}
ifvare LEVEL 9
{
setvar CUTSCENE_SCREEN 6797
}
}
ifvare VOLUME 2
{
ifvare LEVEL 1
{
setvar CUTSCENE_SCREEN 6798
}
ifvare LEVEL 5
{
setvar CUTSCENE_SCREEN 6799
}
ifvare LEVEL 9
{
setvar CUTSCENE_SCREEN 6800
}
}
rotatesprite 160 100 z 0 CUTSCENE_SCREEN 0 0 0 0 0 xdim ydim
endevent // ************************************************************************************
#3132 Posted 10 December 2022 - 08:47 PM
https://forums.duke4...post__p__294547
I think it would make more sense for you to start with that rather than copying the Alien Armageddon version which has added bells and whistles and oddities.
#3133 Posted 11 December 2022 - 12:31 AM
Danukem, on 10 December 2022 - 08:47 PM, said:
https://forums.duke4...post__p__294547
I think it would make more sense for you to start with that rather than copying the Alien Armageddon version which has added bells and whistles and oddities.
Much appreciated. I’ll check it out ASAP.
#3134 Posted 18 December 2022 - 11:50 PM
define LOCKEDDOOR 5817
useractor notenemy LOCKEDDOOR
cstat 32784 // invisible, wall-aligned
ifpdistl 1024
ifp pfacing
ifp palive
ifhitspace
ifcount 30
switch sprite[].pal
case 0
{ soundonce DOOR_LOCK_A }
break
case 1
{ soundonce DOOR_LOCK_B }
break
case 2
{ soundonce DOOR_LOCK_C }
break
endswitch
enda
But when I add an extra command 'quote 4' it creates a recurring loop where the door lock sound plays continuously?
define LOCKEDDOOR 5817
useractor notenemy LOCKEDDOOR
cstat 32784 // invisible, wall-aligned
ifpdistl 1024
ifp pfacing
ifp palive
ifhitspace
ifcount 30
quote 4
switch sprite[].pal
case 0
{ soundonce DOOR_LOCK_A }
break
case 1
{ soundonce DOOR_LOCK_B }
break
case 2
{ soundonce DOOR_LOCK_C }
break
endswitch
enda
#3135 Posted 19 December 2022 - 12:12 AM
define LOCKEDDOOR 5817
useractor notenemy LOCKEDDOOR
cstat 32784 // invisible, wall-aligned
ifpdistl 1024
ifp pfacing
ifp palive
ifhitspace
ifcount 30
{
quote 4
switch sprite[].pal
case 0
soundonce DOOR_LOCK_A
break
case 1
soundonce DOOR_LOCK_B
break
case 2
soundonce DOOR_LOCK_C
break
endswitch
}
enda
#3136 Posted 19 December 2022 - 12:35 AM
#3137 Posted 19 December 2022 - 12:56 AM
Danukem, on 19 December 2022 - 12:35 AM, said:
Thanks Dan - I had a feeling I was missing brackets.
#3138 Posted 19 December 2022 - 04:55 AM
ifpdistl 1024
ifp pfacing
ifp palive
ifhitspace
ifcount 30
{
quote 4
}
switch sprite[].pal
case 0
{ soundonce DOOR_LOCK_A }
break
case 1
{ soundonce DOOR_LOCK_B }
break
case 2
{ soundonce DOOR_LOCK_C }
break
endswitch
Although this is just an example of the literal interpretation the compiler is seeing, there's actually no harm in adding brackets around single command conditionals, and in some cases may make for more readable code. You actually do this with the soundonce commands within your switch statement, and if you wanted you could remove those brackets without change in the code behavior.
You can also safely (and IMO should) put brackets surrounding the content of actor, (def)state, and event code as well:
useractor notenemy LOCKEDDOOR
{
cstat 32784 // invisible, wall-aligned
[. . .]
}
endswitch
}
enda
#3140 Posted 20 December 2022 - 03:01 PM
This post has been edited by lllllllllllllll: 20 December 2022 - 03:02 PM
#3141 Posted 20 December 2022 - 11:49 PM
#3142 Posted 21 December 2022 - 12:44 AM
gamevar ISWET 0 2
define WETTIME 150 // time you stay wet
gamevar WETCOUNT 0 2
state drippingwet
// code to make the player spawn waterdrips when wet.
ifinwater { setvar ISWET 1 setvar WETCOUNT WETTIME break }
ifonwater { setvar ISWET 1 setvar WETCOUNT WETTIME break }
ifn ISWET 0
{
subvar WETCOUNT 1
ifg WETCOUNT 60 { ifrnd 128 spawn WATERDRIP }
ifl WETCOUNT 60 { ifrnd 64 spawn WATERDRIP }
ifl WETCOUNT 30 { ifrnd 32 spawn WATERDRIP }
ife WETCOUNT 0 { setvar ISWET 0 }
}
ends
and add state drippingwet under APLAYER
i guess it would work for any actor really.
[edit] for a more realistic effect, add this to event_egs
ifactor WATERDRIP
{
ifspawnedby APLAYER
{
geta[].z z, sub z 10240 seta[].z z
geta[].x TEMP addvar TEMP 128 randvar TEMP2 256 subvarvar TEMP TEMP2 seta[].x TEMP
geta[].y TEMP addvar TEMP 128 randvar TEMP2 256 subvarvar TEMP TEMP2 seta[].y TEMP
}
}
this makes the waterdrips spread out around the player at a random distance to give a volumetric effect rather than spawning dead center all the time like when unfreezing. coincidentally, when thawing this should also make the thawing effect better. you could add ifspawnedby whatever enemy too.
This post has been edited by jimbob: 21 December 2022 - 12:50 AM
#3143 Posted 21 December 2022 - 03:12 PM
where sector 2 is tagged with SECRET AREA and sector 1 is not.
#3144 Posted 21 December 2022 - 06:10 PM
#3145 Posted 21 December 2022 - 10:44 PM
lllllllllllllll, on 21 December 2022 - 03:12 PM, said:
where sector 2 is tagged with SECRET AREA and sector 1 is not.
Tag BOTH sectors as secrets. Define a special sprite and add one copy of it to each tagged sector, and make the sprites share a lotag. Code the sprite to detect whether the player is entering its sector, when the player does have it look for the other sprite with the same lotag, if it finds it then untag the other sector.
#3146 Posted 22 December 2022 - 12:09 AM
I couldn't think of a way to use findsprite and ignore the closest instance of in favor of finding one with a particular lotag.
If I place a Trigger -> Respawn -> Sprite that sets its sector's Lotag to 0 and kills itself,
will I need to also detect and kill the Trigger in the other secret sector to prevent the secret sector duke just entered from being tinkered with later? Or is the game setting Lotag to 0 after tallying the secret anyway?
(both sectors tagged Secret, both sectors have a Trigger linked to the other's Respawn,,, duke enters sector 1 which spawns a sprite in sector 2 and strips sector 2's lotag, then duke enters sector 2 which in turn spawns a sprite that strips sector 1's lotag)
#3147 Posted 22 December 2022 - 12:19 AM
lllllllllllllll, on 21 December 2022 - 03:12 PM, said:
where sector 2 is tagged with SECRET AREA and sector 1 is not.
just only tag one sector as the actual secret area, not all of them, it will count every single sector with the tag as an individual secret area. so simply only tag one.
#3148 Posted 22 December 2022 - 12:54 AM
lllllllllllllll, on 22 December 2022 - 12:09 AM, said:
That should work. I was going to suggest a different method but it would have required you to learn some new stuff, so your method is better in that respect.
#3149 Posted 22 December 2022 - 01:48 PM
define SECRETSPOOF 9999
onevent EVENT_LOADACTOR
ifactor SECRETSPOOF
{
getactor[THISACTOR].lotag othersector
setactor[THISACTOR].lotag 0
getactor[THISACTOR].hitag duplicatesecrets
setactor[THISACTOR].hitag 0
}
endevent
onevent EVENT_SPAWN
ifactor SECRETSPOOF
{
getplayer[THISACTOR].max_secret_rooms secretstotal
subvarvar secretstotal duplicatesecrets
setplayer[THISACTOR].max_secret_rooms secretstotal
}
endevent
actor SECRETSPOOF
getsector[THISACTOR].lotag sectorlotag
ifvare sectorlotag 0
{
setsector[othersector].lotag 0
killit
}
enda
var othersector 0 2
var duplicatesecrets 0 2
var secretstotal 0 2
var sectorlotag 0 2
Usage:
No bugs after 20 seconds of rigorous testing