EDuke32 Scripting "CON coding help"
#3048 Posted 28 October 2022 - 05:56 AM
The double jump code worked out great. Thanks for that.
I got a quick question. Is there a way to get the current count of sprites that are in the map and put that value into a gamevar?
This post has been edited by VGames: 28 October 2022 - 07:24 AM
#3049 Posted 28 October 2022 - 11:03 AM
VGames, on 28 October 2022 - 05:56 AM, said:
The double jump code worked out great. Thanks for that.
I got a quick question. Is there a way to get the current count of sprites that are in the map and put that value into a gamevar?
It already exists
https://wiki.eduke32...wiki/Numsprites
#3050 Posted 28 October 2022 - 11:23 AM
Danukem, on 28 October 2022 - 11:03 AM, said:
Alright thanks again. And this numsprites accounts for all the sprites that make up the 16384 sprites allowed in a map correct?
#3051 Posted 28 October 2022 - 11:33 AM
VGames, on 28 October 2022 - 11:23 AM, said:
In theory, yes. But I seem to remember having an issue with it where it wasn't counting some sprites. If you want to be 100% sure of how many sprites there are, make a loop and count all the sprites<16384 that do not have a statnum of 1024
#3052 Posted 28 October 2022 - 11:41 AM
Danukem, on 28 October 2022 - 11:33 AM, said:
Ok I’ll try it out.
Did U ever use this in any of your projects?
This post has been edited by VGames: 28 October 2022 - 11:48 AM
#3053 Posted 28 October 2022 - 11:52 AM
VGames, on 28 October 2022 - 11:41 AM, said:
Did U ever use this in any of your projects?
For debugging and optimization, yes. In fact I have lines of code in some actors like "ifg Numsprites 14000 killit" because some maps get way too close to the sprite limit and you don't want it crashing because of your smoke sprites and whatnot
#3054 Posted 28 October 2022 - 11:58 AM
#3055 Posted 28 October 2022 - 03:44 PM
case COLA
ifpdistl FROZENQUICKKICKDIST
{
ifphealthl MAXPLAYERHEALTH
nullop
else
{
ifpinventory 9 0
{
ifpinventory 9 100
{
addinventory 9 30
killit
}
}
}
}
break
Also, what would be the best way to keep inventory items like jetpacks, nightvision goggles, protective boots, and scuba gear at 100% without locking up the inventory left and right buttons. Something like this:
ifl player[].jetpack_amount JETPACK_AMOUNT addinventory GET_JETPACK JETPACK_AMOUNT
will keep the jetpack at 100% but it locks the inventory left and right buttons out and keeps the cursor on the jetpack when it's in use.
Any ideas?
This post has been edited by VGames: 28 October 2022 - 03:59 PM
#3056 Posted 28 October 2022 - 04:31 PM
setp .jetpack_amount JETPACK_AMOUNT setp .boot_amount BOOT_AMOUNT etc.
There's no need to check if they're less than the max if you are just always trying to set them to max.
I'd also directly add to the medkit using .firstaid_amount for the overheal effect.
#3058 Posted 29 October 2022 - 11:29 AM
This is the button event code:
onevent EVENT_LOOKUP // ************************************************************************************
setvar RETURN -1
ifvare EngageShrink 0
{
ifvare ShrinkDelay 0
{
setvar EngageShrink 1
setvar ShrinkDelay 100
}
}
else
{
ifvare ShrinkDelay 0
{
setvar EngageShrink 0
setvar ShrinkDelay 100
}
}
endevent // ************************************************************************************
This is the code for the actual shrinking effects in the player actor code:
ifvare EngageShrink 1
{
ifvare Shrunk 0
{
palfrom 48 0 48
move PSHRINKING
sound ACTOR_SHRINKING
cstat 0
sizeto 8 9
spawn FRAMEEFFECT1
setvar Shrunk 1
}
}
else ifvare EngageShrink 0
{
ifvare Shrunk 1
{
palfrom 48 0 48
sizeto 42 36
ifgapzl 24
{
strength 0
sound SQUISHED
palfrom 48 64
break
}
setvar Shrunk 0
}
}
And this is the original section of the shrinking code for the player where I commented out some of the code so that the player would stay shrunk even after the SHRUNKCOUNT expired:
ifmove PSHRINKING
{
ifcount 32
{
ifcount SHRUNKDONECOUNT
{
move 0
cstat 257
}
/*
else
ifcount SHRUNKCOUNT
{
sizeto 42 36
ifgapzl 24
{
strength 0
sound SQUISHED
palfrom 48 64
break
}
}
*/
else
ifp ponsteroids
count SHRUNKCOUNT
}
else
{
ifp ponsteroids
count SHRUNKCOUNT
else
{
sizeto 8 9
spawn FRAMEEFFECT1
}
}
}
Is the game looking for that SHRUNKCOUNT to expire? Is there no way to force the player to return to their normal size?
#3059 Posted 29 October 2022 - 12:56 PM
VGames, on 29 October 2022 - 11:29 AM, said:
I don't know if I should be flattered, but a lot of the stuff you ask about is stuff that is in my mods. For example I have this exact feature for the character Wes in Alien Armageddon, since he doesn't have the shrinker gun in his arsenal. In any case, the code manages the shrinking based on count. You can simply change count directly with "count ##". Look at the wiki entry on the count command. You can also replace that with your own variable and then increment it or set it to whatever you want, which is how I manage it.
#3060 Posted 29 October 2022 - 04:01 PM
Danukem, on 29 October 2022 - 12:56 PM, said:
Like minds, right? LOL
Your method of shrinking worked perfectly. Duke can shrink and return back to his original size manually with no problem now. Thanks again. I've begun beta testing my mod with several others and soon I'll have some screenshots and a feature list to post. Thanks again.
This post has been edited by VGames: 29 October 2022 - 06:04 PM
#3062 Posted 29 October 2022 - 07:58 PM
#3063 Posted 29 October 2022 - 08:34 PM
Or in the case of shootable ones they would reduce damage of attacks against the sentry the more of them are left spawned.
As long as whatever spawns them does not get deleted before it dies they will behave the same
#3064 Posted 29 October 2022 - 10:11 PM
Now it's a nice rotating ring but it's got a double axis thing going on.
This post has been edited by lllllllllllllll: 29 October 2022 - 10:36 PM
#3065 Posted 30 October 2022 - 12:27 PM
Instead of trying to mimic the changes to PARENT x/y rotatepoint is used at a set distance indefinitely. This is transcribed expect typos
#3066 Posted 30 October 2022 - 06:23 PM
I've was trying to implement your genericknockcode statement from DukePlus into my mod but I cannot get it to actually work. I searched for other places that state genericknockcode was called on but there isn't anywhere else that calls it. Am I looking into the wrong state to get this working. Here's my version of the state and it's called in the enemy code right next to the state random_wall_jibs call:
state damage_pushback
ifvarg peractor6 0
{
cos xvel peractor5
sin yvel peractor5
setvarvar temp peractor6
ifvarg temp 768 setvar temp 768
mulvarvar xvel temp
mulvarvar yvel temp
shiftvarr xvel 13
shiftvarr yvel 13
setvar zvel 0
movesprite THISACTOR xvel yvel zvel CLIPMASK0 RETURN
ifvarn RETURN 0
{
addvar RETURN 16384
ifvarl RETURN 16384
ifvarg RETURN -1 // hit a sprite
{
getactor[RETURN].picnum picnum
ifvare picnum GLASS
{
setactor[RETURN].htextra peractor6
setactor[RETURN].htpicnum SHOTSPARK1 //RPG
}
}
}
shiftvarr peractor6 1
ifvarl peractor6 4 setvar peractor6 0
}
else
ifg sprite[].htextra 4
{
set tempb 8
geta[].htextra bleeding
ifl bleeding 32 set bleeding 32
//ifvare CURRWEAP 11 ifvare gravgun YES
ifwasweapon SHOTSPARK1 setvar bleeding 200
ifvarn tempb 0
ifvarn sprite[].htpicnum FREEZEBLAST
ifvarn sprite[].htpicnum DC_FLAME
{
getactor[THISACTOR].htang peractor5 // the angle monster will move in
setvarvar peractor6 bleeding
mulvarvar peractor6 tempb // peractor6 is the knockback force
setvarvar temp weight
shiftvarl temp 1
subvarvar peractor6 temp
ifvarl peractor6 0 setvar peractor6 0
}
}
ends
This is how I'm calling it in the state that checks if a monster is hit:
ifwasweapon SHOTSPARK1 state damage_pushback
There isn't any push from bullet impacts on the enemies at all.
This post has been edited by VGames: 30 October 2022 - 06:24 PM
#3067 Posted 30 October 2022 - 07:08 PM
#3068 Posted 31 October 2022 - 05:03 AM
Danukem, on 30 October 2022 - 07:08 PM, said:
Ok I think that’s the issue. I have it inside the ifhitweapon section but I see what u mean now. I’ll fix it ASAP. Thanks
#3069 Posted 02 November 2022 - 02:46 PM
Interrupting the pain sound of an enemy with a rapid-hitting weapon doesn't sound good most of the time, and preventing that with
ifactorsoundwill still result in a 'loop' whenever your firing rate scales neatly with the audio duration.
Making the pain sound proc on a ifrnd x results in a lack of feedback where you sometimes question whether your shot hit or not. Setting a guaranteed pain sound followed by an ifrnd if the sound is already playing results in occasional instances of the no-delay interrupt you encounter in the default game.
So on one end having enemies remain silent on some shots doesn't look right if it's not a sentry
on the other when you hit them with something like chaingun their pain sound is on a set loop (which is worse the shorter the length of their cry is; faster loop)
I figure setting a small randomcount on the initial pain sound and checking that count if the pain sound is playing would give the best outcome. But the duration of the cry is important to account for with the count or you'll end up with longer silence in some instances or not enough on others.
//state PAINCOUNT being whatever means of setting a count with a small random range
//(A) pain sound always plays if cry sound has finished, if unfinished only if count is met
ifactorsound THISACTOR PRED_PAIN
{
ifcount PAINCOUNT
{
sound PREDPAIN
state PAINCOUNT
}
}
else
{
sound PRED_PAIN
state PAINCOUNT
}
//(B) pain sound always plays if cry sound has finished, if unfinished only sometimes if count is met
ifactorsound THISACTOR PRED_PAIN
{
ifrnd 128 nullop
else
ifcount PAINCOUNT
{
sound PREDPAIN
state PAINCOUNT
}
}
else
{
sound PRED_PAIN
state PAINCOUNT
}
//(C) painsound only plays after count is met
ifcount PAINCOUNT
{
sound PREDPAIN
state PAINCOUNT
}
//(D) pain sound sometimes plays if cry sound has finished, otherwise only if count is met
ifactorsound THISACTOR PRED_PAIN
{
ifcount PAINCOUNT
{
sound PREDPAIN
state PAINCOUNT
}
}
else
{
ifrnd 128
{
sound PRED_PAIN
state PAINCOUNT
}
else
ifcount PAINCOUNT
{
sound PRED_PAIN
state PAINCOUNT
}
}
#3070 Posted 02 November 2022 - 08:21 PM
#3071 Posted 03 November 2022 - 02:54 PM
ifcount 12
ifvarg TEMP 11
resetcount
set TEMP 0
and while count accumulates on its own you'd have to add 1 to the var each tick?
#3072 Posted 03 November 2022 - 05:47 PM
add PAINSOUNDCOUNT 1
And then set it back to 0 when you want to reset it, like you would resetcount.
#3073 Posted 07 November 2022 - 07:23 PM
ifcount 1 {
addvar COUNT 1
resetcount
} i did
#3074 Posted 08 November 2022 - 05:01 AM
If you want to get the current counter value outside of ifcount (some other if statement, a switch, etc.), then you can use .htg_t 0 to retrieve it. I can sort of understand if this is before .htg_t was implemented.
ifcount 33 state somecode ifge sprite[].htg_t 0 33 state somecode
These 2 behave identically.
switch sprite[].htg_t 0
{
case 33
state somecode
break
}
endswitchThis is one example of examining the actor counter directly, outside of ifcount.
#3075 Posted 08 November 2022 - 12:58 PM
#3076 Posted 08 November 2022 - 01:34 PM
RPD Guy, on 24 May 2022 - 10:33 AM, said:
paldata[(pal number)].nofloorpal 1
For example: If sector x have pal 10, then it should'n affect it's containing sprites.
But it seems that paldata is read only, so I can't simply do that:
set paldata[10].nofloorpal 1
As paldata is read only, I guess that the "nofloorpal" flag are probably stored under these guys: LOOKUP.DAT / PALETTE.DAT / TABLES.DAT or it's hardcoded somewhere in eduke32.
@Danukem
The answer for this is nofloorpalrange.
Problem solved.
#3077 Posted 09 November 2022 - 06:05 AM
Reaper_Man, on 08 November 2022 - 05:01 AM, said:
If you want to get the current counter value outside of ifcount (some other if statement, a switch, etc.), then you can use .htg_t 0 to retrieve it. I can sort of understand if this is before .htg_t was implemented.
ifcount 33 state somecode ifge sprite[].htg_t 0 33 state somecode
These 2 behave identically.
switch sprite[].htg_t 0
{
case 33
state somecode
break
}
endswitchThis is one example of examining the actor counter directly, outside of ifcount.
i think it was a case of overthinking.
useractor notenemy LOCKPLAYER
cstat 32768
getactor[].hitag FOUNDHITAG
// ifpdistl 1024 // remove remlines to make it non global!
{
setvar ONPARA 1 // gamevar ONPARA triggers a lockplayer situation wich was initially used for a descending with a "parachute" type of thing, but it works just as well when the player is already on the ground.
/*
ifcount 1 {
addvar COUNT 1 // the original "timer"
resetcount
}
*/
add COUNT 1
ife FOUNDHITAG COUNT { setvar ONPARA 0 killit }
else
ifcount 10240 { setvar ONPARA 0 killit } // used to kill the actor after a specific time in case HT wasnt set.
}
enda
for completionists sake, here is the actual onpara setting, this goes into the APLAYER code
ifvare ONPARA 1 { setp[].movement_lock 15 setp[].weapon_pos 20 } // if on parachute, dont move forward back or to the side and lower the weapon
else
ifvare ONPARA 0 { setp[].movement_lock 0 } // when on the ground give the player back controll.
and the gamevar itself
gamevar ONPARA 0 1 gamevar COUNT 0 2 gamevar FOUNDHITAG 0 2
This post has been edited by jimbob: 09 November 2022 - 06:11 AM

Help
Duke4.net
DNF #1
Duke 3D #1


