
EDuke32 Scripting "CON coding help"
#2270 Posted 26 May 2018 - 04:29 AM
I already tried to shoot hitscan and knee-type on projectile impact, but with no result...
This post has been edited by RichardStorm: 26 May 2018 - 04:30 AM
#2271 Posted 26 May 2018 - 03:03 PM
RichardStorm, on 26 May 2018 - 04:29 AM, said:
Strange, because I have made that hack work for me before. Importantly, it should be a player who fires the hitscan, though, since switches do not respond otherwise. One way to do this is to make the projectile cactor APLAYER, fire a short range hitscan at the exact right spot, then cactor back to its correct picnum. If you take a look at Duke Forces, search for "switchbulletcode" and you will see.
#2272 Posted 28 May 2018 - 06:11 AM
I tried some variations on your code, but your version is the only that works fine. Thanks

#2273 Posted 28 May 2018 - 10:48 AM
Here is the code:
onevent EVENT_DRAWWEAPON ifvarand TEMP4 268435456 // Is the player holding the Alternate Fire key down? ifvare player[THISACTOR].curr_weapon 3 // M4A1 Carbine Iron Sight { setplayer[THISACTOR].runspeed 42100 setvar RETURN -1 setvar x 160 setvarvar WEAP_DISPLAY_TEMP2 WEAPSWAYX divvar WEAP_DISPLAY_TEMP2 2 subvarvar x WEAP_DISPLAY_TEMP2 setvar y 140 setvarvar WEAP_DISPLAY_TEMP3 WEAPSWAYY divvar WEAP_DISPLAY_TEMP3 2 subvarvar y WEAP_DISPLAY_TEMP3 setvarvar WEAP_DISPLAY_TEMP4 weapon_xoffset // setvar the weapon x sway to displaytemp4 divvar WEAP_DISPLAY_TEMP4 2 // divide it by 2 addvarvar x WEAP_DISPLAY_TEMP4 // add it to x subvar x 5 // offset it by 5 subvar y 40 setvar x 160 subvarvar x WEAPSWAYX subvar x 10 addvarvar x weapon_xoffset setvar y 142 subvarvar y WEAPSWAYY rotatesprite x y 52500 0 3825 shade pal 0 0 0 xdim ydim // iron sight break } getplayer[THISACTOR].weapon_pos WEAP_DISPLAY_TEMP2 mulvar WEAP_DISPLAY_TEMP2 -20 setvar tilenum 2536 rotatesprite x y 2536 WEAP_DISPLAY_TEMP2 tilenum shade pal 0 0 0 xdim ydim setplayer[THISACTOR].runspeed RUNNINGSPEED endevent TURNAROUND key has been disabled: onevent EVENT_TURNAROUND setvar RETURN -1 endevent This one will disable the crosshair once iron sight has been activated: onevent EVENT_DISPLAYCROSSHAIR ifvare player[THISACTOR].curr_weapon 3 ifvarand TEMP4 268435456 { setvar RETURN -1 } endevent
#2274 Posted 28 May 2018 - 11:20 AM
gamevar turnaround_keytime 0 1 gamevar sight_on 0 1 ... ifvarand TEMP4 268435456 { addvar turnaround_keytime 1 } else { setvar turnaround_keytime 0 } ifvare turnaround_keytime 1 { xorvar sight_on 1 } ifvare sight_on 1 { /* your code here */ } ....
This post has been edited by RichardStorm: 28 May 2018 - 11:21 AM
#2275 Posted 28 May 2018 - 11:23 AM
I would simplify this, make a variable ALT_FIRE = 1, set it to ALT_FIRE = ALT_FIRE * -1; if turnaround key is pressed, ezpz toggle switch, check to see if it's positive or negative then draw the proper weapon, do the proper things...
This post has been edited by Drek: 28 May 2018 - 11:26 AM
#2277 Posted 28 May 2018 - 11:30 AM
#2278 Posted 28 May 2018 - 02:41 PM
This post has been edited by thisbecasper: 28 May 2018 - 03:29 PM
#2279 Posted 28 May 2018 - 04:31 PM
thisbecasper, on 28 May 2018 - 02:41 PM, said:
Or when I look at them? I really have a hard time of figuring out how to get the sprite ID or whatever of what I'm interacting with...
This post has been edited by thisbecasper: 28 May 2018 - 04:51 PM
#2280 Posted 28 May 2018 - 07:20 PM
RichardStorm, on 28 May 2018 - 06:11 AM, said:
I tried some variations on your code, but your version is the only that works fine. Thanks

The code fires 2 bullets at slightly different heights. One fires from the base of the sprite and one fires a little above. The code was made for laser blasters, which are considerably larger than bullets. What would happen sometimes without the second bullet is the top half of the laser would hit the switch but it would not register as a hit. The reason it does not count as a double press is hard coding in Duke 3D. Without that hard coding, the shotgun would double press buttons whenever an even number of pellets hit.
#2281 Posted 28 May 2018 - 07:24 PM
thisbecasper, on 28 May 2018 - 04:31 PM, said:
What I do in my mods is constantly have the player hitscan and save the sprite id each tic so I know what is currently being scanned. But sometimes you are "looking at" an enemy even though it is not hitscanned (e.g. the hitscan is missing the enemy a little to the left or right). One way to address that issue is by having enemies set themselves as the looking target when the hitscan target is empty and certain conditions are met (ifcansee ifp pfacing...)
#2282 Posted 29 May 2018 - 05:29 AM
Trooper Dan, on 28 May 2018 - 07:24 PM, said:
I'm really sorry, but I have no clue what you mean by this. I would really like to get access to the data of the actor I'm looking at, I just don't know how it works in the code....
#2283 Posted 29 May 2018 - 07:13 AM
RichardStorm, on 28 May 2018 - 11:20 AM, said:
gamevar turnaround_keytime 0 1 gamevar sight_on 0 1 ... ifvarand TEMP4 268435456 { addvar turnaround_keytime 1 } else { setvar turnaround_keytime 0 } ifvare turnaround_keytime 1 { xorvar sight_on 1 } ifvare sight_on 1 { /* your code here */ } ....
#2284 Posted 29 May 2018 - 07:31 AM
thisbecasper, on 29 May 2018 - 05:29 AM, said:
Maybe a concrete example can help:
onevent EVENT_GAME ifp pfacing getactor[THISACTOR].extra actorhp endevent
Would this show the hp of the enemy I'm looking at. Does THISACTOR refer to the sprite ID of the actor duke is facing, because it is in a pfacing branch?
This post has been edited by thisbecasper: 29 May 2018 - 07:33 AM
#2285 Posted 10 July 2018 - 01:35 AM
REMOVED
This post has been edited by thisbecasper: 10 July 2018 - 02:17 AM
#2286 Posted 21 July 2018 - 07:28 PM
50 - makes spotlight that casts a shadow.
49 - point light (do not cast shadow)
But is there any def or con codes to make sprites act like that?
To make sprites emitting light radius like projectiles etc does.
I'm sure in projectile is hard coded.
Same for fires, atomic health etc.
#2287 Posted 21 July 2018 - 08:09 PM
Zaxtor, on 21 July 2018 - 07:28 PM, said:
The only way I know how to do it is spawn a new SE, set it up appropriately, and then link it to the actor and make it fixed to the actor's coordinates. And don't forget to make the SE go away if the sprite dies or is deleted.
An example of this is shown in a video I linked in the very first post of the EDuke32 2.0 and Polymer thread back in 2009:
#2289 Posted 21 July 2018 - 08:22 PM
Zaxtor, on 21 July 2018 - 08:11 PM, said:
It's literally an SE that is constantly being set to the location of the sprite which you want to glow. I'm guessing that AMC uses the same idea.
#2290 Posted 21 July 2018 - 08:53 PM
Is a portal.
#2291 Posted 22 July 2018 - 06:19 PM
Currently I contemplate doing that for hitting the nuke button. I found this in the source for Duke:
int const fistY = klabs(pPlayer->look_ang) / 9; int const fistZoom = clamp(65536 - (sintable[(512 + (fistInc << 6)) & 2047] << 2), 40920, 90612); int const fistYOffset = 194 + (sintable[((6 + fistInc) << 7) & 2047] >> 9); int const fistPal = P_GetHudPal(pPlayer); int wx[2] = { windowxy1.x, windowxy2.x }; rotatesprite((-fistInc + 222 + (fix16_to_int(g_player[screenpeek].inputBits->q16avel) >> 5)) << 16, (fistY + fistYOffset) << 16, fistZoom, 0, FIST, fistShade, fistPal, 2, wx[0], windowxy1.y, wx[1], windowxy2.y);
I'm not sure how to translate that into CON code. I could eventually do it, with some learning and trial and error, but maybe there is someone around here who could do it much more easily than I. If so, I would really appreciate it!
#2292 Posted 22 July 2018 - 11:15 PM
Trooper Dan, on 22 July 2018 - 06:19 PM, said:
Currently I contemplate doing that for hitting the nuke button. I found this in the source for Duke:
int const fistY = klabs(pPlayer->look_ang) / 9; int const fistZoom = clamp(65536 - (sintable[(512 + (fistInc << 6)) & 2047] << 2), 40920, 90612); int const fistYOffset = 194 + (sintable[((6 + fistInc) << 7) & 2047] >> 9); int const fistPal = P_GetHudPal(pPlayer); int wx[2] = { windowxy1.x, windowxy2.x }; rotatesprite((-fistInc + 222 + (fix16_to_int(g_player[screenpeek].inputBits->q16avel) >> 5)) << 16, (fistY + fistYOffset) << 16, fistZoom, 0, FIST, fistShade, fistPal, 2, wx[0], windowxy1.y, wx[1], windowxy2.y);
I'm not sure how to translate that into CON code. I could eventually do it, with some learning and trial and error, but maybe there is someone around here who could do it much more easily than I. If so, I would really appreciate it!
It's late so forgive any errors, but this should be about right if I didn't fall asleep while typing (it is possible!):
set y1 player[].look_ang div y1 9 abs y1 set z1 65536 set z2 player[].fist_incs shiftl z2 6 add z2 512 and z2 2047 sin z2 z2 sub z1 z2 clamp z1 40920 90612 set y2 player[].fist_incs add y2 6 shiftl y2 7 and y2 2047 sin y2 y2 shiftr y2 9 add y2 194 set x1 input[].q16avel shiftr x1 5 set x2 player[].fist_incs inv x2 add x2 222 add x1 x2 shiftl x1 16 add y1 y2 shiftl y1 16 rotatesprite x1 y1 z1 0 FIST gs actor[player[].i].pal 2050 windowx1 windowy1 windowx2 windowy2
#2293 Posted 23 July 2018 - 02:06 AM
By the way, the following commands you used above are not listed at all in the Eduke32 wiki "full command list":
abs
clamp
inv
EDIT: There is one little thing...the avel stuff is no bueno. If you factor in input.q16avel, all that does is make the fist disappear when the player is pressing movement keys (I guess because it is throwing off the coordinates big time and causing it to draw off screen). But it works fine if the input isn't included. I wonder why the heck that is in the source.
Final code in my project ended up like this:
appendevent EVENT_DISPLAYFIST ife pchar 1 { set RETURN -1 // thanks to Mblackwell for fist CON code, adapted from Duke source set y player[].look_ang div y 9 abs y set z 65536 set z2 player[].fist_incs ifg z2 32 set z2 32 shiftl z2 6 add z2 512 and z2 2047 sin z2 z2 sub z z2 clamp z 40920 90612 set y2 player[].fist_incs ifg y2 32 set y2 32 add y2 6 shiftl y2 7 and y2 2047 sin y2 y2 shiftr y2 9 add y2 194 set x player[].fist_incs ifg x 32 set x 32 inv x add x 222 shiftl x 16 add y y2 shiftl y 16 rotatesprite x y z 0 SHELLYFIST gs sprite[player[].i].pal 2050 0 0 xdim ydim } endevent
This post has been edited by Trooper Dan: 23 July 2018 - 02:29 AM
#2295 Posted 14 August 2018 - 11:10 AM
#2296 Posted 14 August 2018 - 11:16 AM
thisbecasper, on 14 August 2018 - 11:10 AM, said:
This should work:
appendevent EVENT_GAME ifactor HOLODUKE ifn sprite[].statnum 1 changespritestat THISACTOR 1 endevent
#2297 Posted 14 August 2018 - 11:44 AM
Trooper Dan, on 14 August 2018 - 11:16 AM, said:
appendevent EVENT_GAME ifactor HOLODUKE ifn sprite[].statnum 1 changespritestat THISACTOR 1 endevent
I should say that I'm using the eduke old-mp build, and maybe that's why it wont run your code.
GAME.CON: In event `EVENT_GAME':
GAME.CON:37: error: expected a keyword but found `ifn'.
GAME.CON:37: error: expected a keyword but found `sprite'.
GAME.CON:37: error: expected a keyword but found `.statnum'.
GAME.CON:37: error: expected a keyword but found `1'.
EDIT: I've got it to work - but thanks! I was basically doing the same thing, but under actor holoduke (and that just doesn't work :-P )
This post has been edited by thisbecasper: 14 August 2018 - 11:53 AM