
EDuke32 Scripting "CON coding help"
#2581 Posted 30 August 2020 - 11:04 AM
#2582 Posted 22 September 2020 - 08:16 AM
How would I read (or write) another actor's per-actor gamevar? This seems simple and I'm sure I'm overlooking something obvious.
#2583 Posted 22 September 2020 - 09:00 AM
Reaper_Man, on 22 September 2020 - 08:16 AM, said:
How would I read (or write) another actor's per-actor gamevar? This seems simple and I'm sure I'm overlooking something obvious.
It is simple, but you have to have the sprite ID number of the other actor in a gamevar first. That's the only part that can be tricky, depending on the context. But let's say you have done that already, by using findnearactor or by searching sprites via a loop or whatever.
Assume that "SPRITE" is a var that is set to the ID of the other sprite, and "VAR1" is a per-actor var. Then, in the code of an actor, you could write:
getactorvar[SPRITE].VAR1 VAR1
The above line would copy the value of VAR1 from the sprite SPRITE to the VAR1 in the current sprite (THISACTOR).
setactorvar[SPRITE].VAR1 VAR1
That would write the current copy of VAR1 in THISACTOR to the copy of that var in SPRITE
You can also abbreviate those commands to getav and setav
#2584 Posted 22 September 2020 - 09:03 AM
This post has been edited by Mark: 22 September 2020 - 09:04 AM
#2585 Posted 22 September 2020 - 05:06 PM
#2586 Posted 29 September 2020 - 06:11 AM
I am using the Player sprites for an actor that can stand and crouch, but when they crouch down, their collision remains the same dimensions as their standing sprite, so I can shoot them where their upper body existed, and when I stand on them there is a giant open space between me and the Actor since I am standing on what used to be their head. Hopefully this terrible image helps demonstrate the problem.

#2587 Posted 29 September 2020 - 10:45 AM
I can't think of another way to do it, honestly.
#2588 Posted 30 September 2020 - 03:56 AM
Still, that makes me wonder what structure member controls this, and why it can't be set programmatically.
#2589 Posted 30 September 2020 - 04:26 PM
Reaper_Man, on 30 September 2020 - 03:56 AM, said:
Still, that makes me wonder what structure member controls this, and why it can't be set programmatically.
https://wiki.eduke32.com/wiki/Htg_t
Current frame offset should be in htg_t 3
I try not to mess with those, though. Redefining the actions only takes a minute.
#2590 Posted 06 October 2020 - 12:22 AM
how do you change the palette of Greenslime's guts after it's been killed? I know that it's hardcoded to be spritepal 6.
#2591 Posted 06 October 2020 - 12:38 AM
appendevent EVENT_SPAWN ifspawnedby GREENSLIME spritepal 0 endevent
That should change everything it spawns to pal 0.
#2592 Posted 06 October 2020 - 04:45 AM
Danukem, on 06 October 2020 - 12:38 AM, said:
appendevent EVENT_SPAWN ifspawnedby GREENSLIME spritepal 0 endevent
That should change everything it spawns to pal 0.
Unfortunately this does not work

#2593 Posted 06 October 2020 - 10:30 AM
#2594 Posted 06 October 2020 - 11:31 PM
#2595 Posted 07 October 2020 - 12:31 AM
December Man, on 06 October 2020 - 11:31 PM, said:
That confirms the reason the EVENT_SPAWN version didn't work is the pal hadn't been set yet. The bad thing about putting that code in EVENT_GAME is that every single sprite in the game will run that line of code 30 times per second, even though it won't do anything unless the sprite is spawned by a slimer. That's very unlikely to cause you any issues but it's not optimal. If you had a big complex project with lots of code it would be worth improving.
#2596 Posted 07 October 2020 - 04:49 AM
This post has been edited by Reaper_Man: 07 October 2020 - 06:35 AM
#2597 Posted 07 October 2020 - 06:49 AM
Reaper_Man, on 07 October 2020 - 04:49 AM, said:
One option would be using EVENT_WORLD, since the code would run-once-per tic instead of once-per-tic-per-sprite. But the code would need to be different since it wouldn't be run by the specific sprite in question.
#2598 Posted 08 October 2020 - 05:03 AM
Danukem, on 07 October 2020 - 12:31 AM, said:
Is EVENT_PREGAME any more efficient in this regard than EVENT_GAME?
#2599 Posted 08 October 2020 - 10:02 AM
Reaper_Man, on 07 October 2020 - 04:49 AM, said:
EVENT_EGS is used internally to initialize newly spawned sprites. It's where the structures are reset, in case the same ID was used for another sprite before.
EVENT_SPAWN is used for both sprites that already existed in the map or newly spawned sprites. Internally it's where it changed the size of enemies, etc.
Projectiles are, however, excluded from EVENT_SPAWN, and you would use EVENT_EGS instead.
#2600 Posted 08 October 2020 - 10:22 AM
December Man, on 08 October 2020 - 05:03 AM, said:
No.
https://wiki.eduke32...i/EVENT_PREGAME
#2601 Posted 09 October 2020 - 06:49 AM
I would like to make a bullet / projectile which has average velocity but its going to drop very soon. The idea is to make a weapon which is very good at close range but with no chance when shooting longer distances. I tried to do it myself but i can't get work on it as i planned
What's wrong with the code or is there something missing?
define SCARBULLET 15 defineprojectile SCARBULLET PROJ_WORKSLIKE 1 defineprojectile SCARBULLET PROJ_SPAWNS SMALLSMOKE defineprojectile SCARBULLET PROJ_DECAL BULLETHOLE defineprojectile SCARBULLET PROJ_EXTRA 20 defineprojectile SCARBULLET PROJ_XREPEAT 6 defineprojectile SCARBULLET PROJ_YREPEAT 6 defineprojectile SCARBULLET PROJ_TNUM 2 defineprojectile SCARBULLET PROJ_VEL 500 defineprojectile SCARBULLET PROJ_DROP -200
Second question: When you choose weapon like chaingun a weapon starts to appear and you are able to use it. How to change that "draw time"?
Idea is to simulate real world where lightweight weapon is easier to draw out and heavier weapon is slower.
Third question: My ironsight code does not have any penalty time when switching it on and off. I would like to have one, is there any command available or should i paste the code above?
#2602 Posted 09 October 2020 - 09:27 AM
#2603 Posted 12 October 2020 - 10:46 AM
Danukem, on 09 October 2020 - 09:27 AM, said:
So should i make an actor for the scarbullet?
Something like this:
TRAILFRAME2 0 1 1 1 15 useractor notenemy BEAMTRAIL 0 TRAILFRAME2 spritepal 2 ifaction TRAILFRAME2 { ifactioncount 3 { killit } else ifactioncount 2 { cstat 32768 } else ifactioncount 1 { cstat 2 } } enda
Then EVENT_GAME i add the value that after certain amount of time the projectile starts to fall? Can it be so simple?
This post has been edited by Salvation: 12 October 2020 - 10:47 AM
#2604 Posted 16 October 2020 - 03:07 AM
ife wall[RETURN].picnum GLASSFRONT { sound GLASS_BREAKING lotsofglass 20 ifrnd 85 { setw[RETURN].picnum GLSSFRNTBR1 } ifrnd 85 { setw[RETURN].picnum GLSSFRNTBR2 } else { setw[RETURN].picnum GLSSFRNTBR3 } }
85 is 255/3, yet it seems to choose the final picnum (GLSSFRNTBR3) more frequently than the other two.. is this normal? It's hardly a big deal but I thought that perhaps I'd incorrectly used ifrnd? And is it preferable to use integers that are divisible by 8?
#2605 Posted 16 October 2020 - 10:12 AM
Second, I don't think chaining "ifrnd 85 else ifrnd 85 else" will give each result an equal 1/3 chance. The first one would have a 1/3 chance. The else would cover the 2/3 remaining chance, and the second result would have 1/3 of that = 2/9. Then the third result would have the remaining 4/9 chance. It would need to be ifrnd 85 else { ifrnd 128 else }.
Generally I prefer to avoid ifrnd messes if you want all the results to have the same likelihood. Just use randvar and a switch/case.
randvar temp 2 switch temp case 0 setw[RETURN].picnum GLSSFRNTBR1 break case 1 setw[RETURN].picnum GLSSFRNTBR2 break case 2 setw[RETURN].picnum GLSSFRNTBR3 break endswitch
#2606 Posted 16 October 2020 - 12:15 PM
I assumed that this gamevar would be a 'per actor' variable, but out of curiosity I set it to 'global' and it still works? In my limited understanding of coding I would have assumed that making it global would cause issues when there are multiple states of the actor walltile being hit?
This post has been edited by MC84: 16 October 2020 - 12:20 PM
#2607 Posted 16 October 2020 - 12:35 PM
Scratch variables like temp should be marked global. There is no concurrency in CON so the variable is not contested in any way. You only need to mark a variable per-actor if each actor's value needs to be preserved from one game world tick to the next.
#2608 Posted 27 October 2020 - 12:29 PM
I put the following code:
onevent EVENT_DISPLAYREST getactor[THISACTOR].extra TEMP2 { digitalnumber 2992 360 160 TEMP2 0 0 0 0 0 xdim ydim } endevent
The new font is now on screen on the right side but the existing one is also there, so it's a duplicate. See the attachment.
What should i do to change the font?
#2609 Posted 27 October 2020 - 01:07 PM
#2610 Posted 28 October 2020 - 11:49 AM
state rf getactor[THISACTOR].cstat TEMP4 ifvare TEMP7 259 { cstat 2 } else ifvare TEMP7 771 { cstat 514 } else { ifrnd 128 cstat 4 else cstat 0 } ends state getfloordist getactor[THISACTOR].x x getactor[THISACTOR].y y updatesector x y TEMP7 // You should not trust [THISACTOR].Sectnum getflorzofslope TEMP7 x y z getactor[THISACTOR].z TEMP8 subvarvar z TEMP8 shiftvarr z 8 subvar z 1 ends onevent EVENT_GAME ifactor JIBS1 { state getfloordist ifvarl z 0 { sound GIB_LAND2 changespritestat THISACTOR 1 state rf setactor[THISACTOR].picnum 2249 ifrnd 84 spawn BLOODPOOL else guts JIBS6 3 } } endevent
Each time a Jib drops inside an invalid sector, eDuke32.log spills out the error:
Line 801, getflorzofslope: invalid sector -1
This error is being spammed in dozens of kilobytes over an hour of gameplay. Is there a way to avoid this?
This post has been edited by December Man: 28 October 2020 - 11:49 AM