
EDuke32 Scripting "CON coding help"
#2783 Posted 19 October 2021 - 02:36 AM
#2784 Posted 19 October 2021 - 07:17 AM
jimbob, on 19 October 2021 - 02:36 AM, said:
Bullets all share the same SHOTSPARK1 actor if i remember correctly.
HTpicnum checks the ID of the projectile that hit you, so you can get the picnum of the ID.
HTowner gets the id of the enemy that shot at you, so if you need to do some more digging to figure out if it was a bullet, you can see what the enemy picnum was and see if it's an enemy that shoot bullets.
This post has been edited by bullerbullerseven: 19 October 2021 - 07:20 AM
#2785 Posted 19 October 2021 - 08:54 AM
getactor[THISACTOR].htextra TEMP ifvarg TEMP 0 // if the actor is set to take some damage from a weapon... { getactor[THISACTOR].htowner TEMP // gets the owner of the weapon into TEMP ifvarvare TEMP THISACTOR // if the owner of the weapon IS this actor setactor[THISACTOR].htextra 0 // set the damage to 0 }
#2786 Posted 19 October 2021 - 09:08 AM
ife sprite[].htpicnum SHOTSPARK1 seta .htextra -1
Set this before the "ifhitweapon" call.
That example is interesting, in that they set the damage to 0 instead of -1, since 0 will still trigger "ifhitweapon".
This post has been edited by Reaper_Man: 19 October 2021 - 09:21 AM
#2787 Posted 24 October 2021 - 10:21 PM
#2788 Posted 28 October 2021 - 01:43 AM
this bit of code came pretty much straight from the package that was shared here for making a lifebar, i just reworked into an enemy lifebar. the boss has 5000 health. and the code is in event EVENT_DISPLAYREST
ifvare BOSSFIGHT2 1 { getactor[PANZER].extra temp // get the boss'health divvar temp 50 // divide the health so the lifebar isnt rediculously long. { ifvarl temp 10 { break } else // if health lower than 10 stop doing this code setvar xvar 75 // set starting x coordinate whilevarn temp 0 // loop for each hitpoint { rotatesprite xvar 16 49152 0 199 0 2 16 0 0 xdim ydim // draws HEALTHBAR screentext BIGALPHANUM 160 14 32768 0 0 132 0 0 0 0 5 16 1 2 1056768 0 0 xdim ydim addvar xvar 2 // move to the right subvar temp 1 // next hitpoint } } }
hmm, this test it went perfectly, maybe because i move iftempl 10 before the actual code instead of after, maybe luck, maybe its a rounding error that happens when the vehicle gets hit and does an odd number of damage.
speaking of the vehicle, i want it to be unable to move into sectors that have an X amount of height difference, for the player you can use autostep, but i cant find a similar command for actors. if there is non i will just make the actor stayput and map accordingly.
This post has been edited by jimbob: 28 October 2021 - 01:55 AM
#2789 Posted 28 October 2021 - 10:03 AM
I'm going to assume this code is in a state and is not directly part of a display event, because if it were then the "break" would cause the rest of the event code to abort as well.
ifvare BOSSFIGHT2 1 ifn PANZER -1 ifge sprite[PANZER].extra 0 { getactor[PANZER].extra temp // get the boss' health divvar temp 50 // divide the health so the lifebar isnt ridiculously long. ifvarl temp 10 break // if health lower than 10 stop doing this code setvar xvar 75 // set starting x coordinate whilevarn temp 0 // loop for each hitpoint { rotatesprite xvar 16 49152 0 199 0 2 16 0 0 xdim ydim // draws HEALTHBAR screentext BIGALPHANUM 160 14 32768 0 0 132 0 0 0 0 5 16 1 2 1056768 0 0 xdim ydim addvar xvar 2 // move to the right subvar temp 1 // next hitpoint } }
#2790 Posted 28 October 2021 - 10:10 AM
just tested it, remmed the ifvar templ 10 line and it seems to work just fine, will do some aditional testing but so far this seems to be working great, thanks

the ifvar templ 10 is redundant anyway with the ifge sprite[PANZER].extra 0 line
This post has been edited by jimbob: 28 October 2021 - 10:18 AM
#2791 Posted 28 October 2021 - 11:10 AM
jimbob, on 28 October 2021 - 10:10 AM, said:
Not really because even if extra is > 0 that doesn't mean extra/50 is > 0
#2792 Posted 28 October 2021 - 11:31 AM
#2793 Posted 28 October 2021 - 11:46 AM
jimbob, on 28 October 2021 - 11:31 AM, said:
It won't cause a hang because the drawing loop won't even start if temp is 0 after the division. I was just pointing out that there are cases where the break will be executed.
#2794 Posted 24 November 2021 - 09:27 AM
I don't know if someone asked this before, but, is there a way to tint a sector without affecting its containing sprites' pal?
I know that "spritenopal" kinda "solves" this, but I don't want to set every game sprite with this definition.
#2795 Posted 24 November 2021 - 06:24 PM
#2796 Posted 24 November 2021 - 06:30 PM
define NOPALSPRITE #### gamevar tempsprite 0 0 gamevar tempvar 0 0 eventloadactor NOPALSPRITE cstat 32769 headspritesect tempsprite sprite[].sectnum whilevarn tempsprite -1 { geta[tempsprite].htflags tempvar orvar tempvar 64 seta[tempsprite].htflags tempvar nextspritesect tempsprite tempsprite } enda
I think that will work but I'm not entirely sure because the htflags might get overwritten after map load. If that's the case then the code would need to run later.
#2797 Posted 13 December 2021 - 10:43 AM
It seems that all dmg incurred at the same tick is actually accumulated, but htowner and htpicnum and so on contains a "random" value among those that hit Duke in that tick.
I thought I could manipulate some value, e.g. setactor[THISACTOR].htowner some_id_that_is_not_the_actor_itself, but that doesn't seem to have any influence on whether Duke suicides or not.
Same but different: Whenever Duke is hit, the opponent hitting Duke is notified (say, by a hitmarker), but if multiple opponents hit Duke in the same tick, how would I go about notifying all opponents? Atm I'm using htowner, which obviously only holds a single value, so how would I go about this?
#2799 Posted 14 December 2021 - 07:37 PM
Reaper_Man, on 14 December 2021 - 06:14 PM, said:
I'll bet you are right. That event should be triggered every time there is damage, even if it happens to the same sprite multiple times in one tic.
gamevar htowner2 -1 1 gamevar damagetime 0 1 gamevar playerID 0 1 onevent EVENT_DAMAGESPRITE ife sprite[RETURN].picnum APLAYER { geta[RETURN].yvel playerID ife playervar[playerID].damagetime player[playerID].player_par setplayervar[playerID].htowner2 sprite[THISACTOR].owner else setplayervar[playerID].htowner2 -1 setplayervar[playerID].damagetime player[playerID].player_par } endevent
I don't normally work with different player IDs since I have only been scripting singleplayer stuff for a long time, but if that code above is correct what it will do is put a second sprite ID into the htowner2 var for the specific player who got damaged by two sprites in the same tic. I think the likelihood of there being a third sprite doing damage in the same tic is pretty low, so having two IDs should be sufficient. Even assuming that works, it won't save how much damage was done by each, so more work would be needed for that feature. However, if one sprite was the same player who got hit and the other sprite is a different player, it would then be easy to always set the htowner to one or the other in that situation, giving credit where it is desired.
EDIT: Also, htowner2 should be cleared back to -1 by the damage handling code that gives credit; otherwise, it stays set until the player is damaged again.
This post has been edited by Danukem: 14 December 2021 - 07:41 PM
#2800 Posted 30 December 2021 - 07:23 AM
Is it possible to make sprites only visible to some of the players in a multiplayer game? I want to show trailing footsteps of players if nightvision is turned on, but I don't want all players to see these footsteps, only those who have nightvision on.
#2801 Posted 01 January 2022 - 03:35 PM

#2803 Posted 06 February 2022 - 01:15 PM
so far i tried using onevent EVENT_CUTSCENE, using IFCUTSCENE cutscene { screentext etc etc } endevent
but it doesnt seem to render, atleast not as an overlay, so before i waste more time on this, i wonder if it is at all possible?
[edit] it seems possible, but using redefinequote makes it hard to pinpoint the exact video file, since im using a custom episode intro video using redefinequote the overlay appears on the 'logo' video file rather than my custom one.
This post has been edited by jimbob: 06 February 2022 - 01:20 PM
#2804 Posted 06 February 2022 - 02:02 PM
#2806 Posted 08 February 2022 - 01:40 PM
#2807 Posted 18 February 2022 - 03:35 PM
anyway, back to mucking about.
#2808 Posted 18 February 2022 - 04:43 PM
jimbob, on 18 February 2022 - 03:35 PM, said:
anyway, back to mucking about.
AFAIK there is no way to do that. I have this problem as well. So I end up with code like this:
ifactorsound THISACTOR EDFL_PAIN1 nullop else ifactorsound THISACTOR EDFL_PAIN2 nullop else ifactorsound THISACTOR EDFL_PAIN3 nullop else { rand temp 2 ife temp 0 sound EDFL_PAIN1 ife temp 1 sound EDFL_PAIN2 ife temp 2 sound EDFL_PAIN3 }
And believe me I have much worse examples than that, that's just the first one I found on a quick search of my code.
#2809 Posted 19 February 2022 - 04:34 AM


#2810 Posted 20 March 2022 - 07:11 AM
This post has been edited by jimbob: 20 March 2022 - 07:14 AM
#2811 Posted 24 March 2022 - 01:48 PM
Reason being is that I'm using map caching code but I can't get it to retain the correct stats between linked maps (when the nuke button is hit or the player enters an end-level sector, only stats from the specific map it's located in are displayed, not the accumulated total between linked maps).
I've tried studying the AMC Squad map caching code but I can't work out how it's retaining these stats within hubs (something to do with saving arrays I think, but I'm way too inexperienced with CON to work out what).
I know I can disable the bonus/intermission screens entirely, but I don't want to, as I want breaks between certain maps in my mod, and while I've tried custom intermissions using the startscreen command, they're too abrupt and easily skipped by the player (unless I can completely disable player input for a specified amount of time when one of these screens is displayed?) Besides, I'd like to keep the animation of Duke reloading his shotgun.
The only other option I can think of is drawing sprites on bonus/intermission screen using EVENT_DISPLAYBONUSSCREEN to literally conceal the times/kills/secrets popping up, but that seems somewhat clumsy, and the RPG sound effect will still play when each stat is displayed.
Cheers!
#2812 Posted 24 March 2022 - 02:59 PM
// disable menu sounds
state remove_explosion
ifvare RETURN PIPEBOMB_EXPLODE
setvar RETURN -1
ends
state remove_kickhit
ifvare RETURN KICK_HIT
setvar RETURN -1
ends
state remove_lasertrip
ifvare RETURN LASERTRIP_EXPLODE
setvar RETURN -1
ends
onevent EVENT_SOUND
getplayer[THISACTOR].gm temp
getplayer[THISACTOR].palette temp
ifvare temp 6 state remove_explosion state remove_kickhit state remove_lasertrip // ANMs
ifvare temp 4 state remove_explosion state remove_kickhit state remove_lasertrip // title screen
ifvarand temp 1 state remove_explosion state remove_kickhit state remove_lasertrip // menus
ifvarand temp 8 state remove_explosion state remove_kickhit state remove_lasertrip // end-of-level
endevent