EDuke32 Scripting "CON coding help"
#2874 Posted 17 July 2022 - 10:57 AM
#2875 Posted 17 July 2022 - 11:18 AM
onevent EVENT_LOOKDOWN setvar RETURN -1
ife player[].curr_weapon 8 // sniper rifle
{
ife USESCOPE 1 { setvar USESCOPE 0 addlogvar USESCOPE break }
ife USESCOPE 0 { setvar USESCOPE 1 addlogvar USESCOPE break }
}
endevent
the var USESCOPE triggers a lot of stuff in other events.
#2876 Posted 17 July 2022 - 11:25 AM
#2877 Posted 17 July 2022 - 11:36 AM
i looked at the bits thing, and using getinput[].bits TEMP then adding ifvarand TEMP 16384, then adding a addlogvar, the log shows a completely different number when pressing that button rather than the listed 16384
This post has been edited by jimbob: 17 July 2022 - 12:53 PM
#2878 Posted 17 July 2022 - 03:50 PM
#2879 Posted 18 July 2022 - 04:00 AM
But there's a couple of simple things I wanted to straighten out for myself as not to form any bad habits as I push onwards. Spoilers used to keep this clean;
Braces vs Non-Braces?
ife vs ifn?
Timers?
I'm sure to have more questions down the line, but these three are currently stumping me right now. Otherwise, so far I've been enjoying my time with CON scripting for a change and have been focusing my learning by recreating functions from other games.
#2880 Posted 18 July 2022 - 06:57 AM
Also is the there something like EVENT_GETSHOTRANGE for projectiles like the rpg that allows adjustment of spread?
This post has been edited by VGames: 18 July 2022 - 07:55 AM
#2881 Posted 18 July 2022 - 07:53 AM
onevent EVENT_EGS
ifactor YOURACTOR
{
geta[].z z, sub z 5120, randvar TEMP2 64 subvarvar z TEMP2 seta[].z z
}
endevent
you can also discard the randvar if you dont want the Z to have any randomisation
This post has been edited by jimbob: 18 July 2022 - 07:54 AM
#2882 Posted 18 July 2022 - 08:54 AM
What about the spread adjustment for RPG like projectiles?
#2883 Posted 18 July 2022 - 10:05 AM
ifactor MYACTOR
{
// Calculate horizontal spread
getactor[THISACTOR].ang TEMP
addvar TEMP 16
randvar TEMP2 32
subvarvar TEMP TEMP2
setactor[THISACTOR].ang TEMP
// Calculate vertical spread
getactor[THISACTOR].zvel TEMP
addvar TEMP 256
randvar TEMP2 512
subvarvar TEMP TEMP2
setactor[THISACTOR].zvel TEMP
}
also in event EGS
#2884 Posted 18 July 2022 - 10:58 AM
jimbob, on 18 July 2022 - 10:05 AM, said:
ifactor MYACTOR
{
// Calculate horizontal spread
getactor[THISACTOR].ang TEMP
addvar TEMP 16
randvar TEMP2 32
subvarvar TEMP TEMP2
setactor[THISACTOR].ang TEMP
// Calculate vertical spread
getactor[THISACTOR].zvel TEMP
addvar TEMP 256
randvar TEMP2 512
subvarvar TEMP TEMP2
setactor[THISACTOR].zvel TEMP
}
also in event EGS
Oh wow this is easier then I thought. Thanks again for the help. This EGS EVENT is great
This post has been edited by VGames: 18 July 2022 - 10:58 AM
#2885 Posted 18 July 2022 - 11:50 AM
What you said about braces is not wrong. Although it seems to me you might be overclomplicating it a bit in your head. If ABC { } simply means that the code inside the { } is executed when and only when the conditions ABC are all true. If there is an else { } then the code in *those* braces is executed when and only when at least one of the conditions ABC is not true. What typically gets people confused in CON is they assume that indenting or spacing has syntactic significance, when it doesn't (CON is not python!)
As for value comparisons like ife, ifn, ifge etc. yes there are different ways to construct equivalent ones.
For timers: yes, generally you want to set a var to a number and then decrement it
#2886 Posted 18 July 2022 - 12:55 PM
Cheers for the confirmations, your explanation on braces is much clearer. I'm definitely more used to seeing how python and similar languages work by comparison, especially indents and such, so this helps keep on track with CON. For value comparisons, I'm guessing I'll just use whichever makes the most logical sense for writing readable code.
This post has been edited by quakis: 18 July 2022 - 01:12 PM
#2887 Posted 18 July 2022 - 07:18 PM
jimbob, on 18 July 2022 - 10:05 AM, said:
ifactor MYACTOR
{
// Calculate horizontal spread
getactor[THISACTOR].ang TEMP
addvar TEMP 16
randvar TEMP2 32
subvarvar TEMP TEMP2
setactor[THISACTOR].ang TEMP
// Calculate vertical spread
getactor[THISACTOR].zvel TEMP
addvar TEMP 256
randvar TEMP2 512
subvarvar TEMP TEMP2
setactor[THISACTOR].zvel TEMP
}
Am I reading this right that the horizontal spread is -16 through 16 degrees and the vertical spread is -256 through 256 units?
#2888 Posted 18 July 2022 - 07:34 PM
jimbob, on 18 July 2022 - 07:53 AM, said:
onevent EVENT_EGS
ifactor YOURACTOR
{
geta[].z z, sub z 5120, randvar TEMP2 64 subvarvar z TEMP2 seta[].z z
}
endevent
you can also discard the randvar if you dont want the Z to have any randomisation
Ok I'm getting errors with this code you suggested. I even declared the TEMP3 as a gamevar but it keeps stopping the game from loading. Here's my version. It's in EVENT_EGS too.
ifactor MISSILE1
{
geta[].z z, sub z 5120, randvar TEMP3 64 subvarvar z TEMP3 seta[].z z
}
#2889 Posted 18 July 2022 - 08:11 PM
You mentioned declaring TEMP3 but did not say that you declared z.
@ lllllllllllllll in build Z coordinates have 8X the precision of XY coordinates. A horizinal distance of 1024 is equivalent to a vertical distance of 8192. So the spread in that code will be twice as horizontal as vertical.
#2890 Posted 18 July 2022 - 08:33 PM
#2891 Posted 19 July 2022 - 02:11 AM
Danukem, on 16 July 2022 - 01:27 AM, said:
gamevar poison 0 2
Also use 65536 as a flag in the workslike of the custom projectile. See PROJECTILE_RADIUS_PICNUM in this list: https://wiki.eduke32...efineprojectile
Now let's say that your projectile is named EGGPROJ
You want every enemy to run some additional code when hit by a weapon. A simple example would be
ifwasweapon EGGPROJ add poison 150Again, that goes *inside* the ifhitweapon code block.
Finally, you also need to add code to each enemy to process the poison damage. I would define a state and then have each enemy call the state when alive and before it calls ifhitweapon. Here's an example of what the state might look like.
defstate newmoncode
ifg poison 0
{
sub poison 1
ifrnd 64
ife sprite[].htextra -1
{
seta[].htextra 1
seta[].htowner player[].i
seta[].htpicnum KNEE
// spawn some custom actor here that looks like puke or poison smoke or something
}
}
ends
Hi Dan, thanks again for this - unfortunately I couldn't get it working properly in my mod, the poison delay effect worked great but the LIZTROOP I was testing it on was stuck in a pain animation frame from sight until death, I suspect due to me inserting "newmoncode" at the wrong place. However, I've found a solution via modifying the flamethrower code from WT which works well enough for what I want to do. Appreciate your help as always!
#2892 Posted 19 July 2022 - 02:28 AM
VGames, on 18 July 2022 - 08:33 PM, said:
No, you didn't say what the specific error was -- if you look in eduke32.log after an error, it will say. It probably said something about 'z' not being a struct member or something along those lines.
When you start looking at the log after errors (always a good idea!) keep in mind though that only the first error can be counted on to be relevant information. Sometimes there will be a cascade of errors all caused by the first one and then the reports about them are essentially meaningless.
#2893 Posted 19 July 2022 - 03:39 AM
Danukem, on 19 July 2022 - 02:28 AM, said:
When you start looking at the log after errors (always a good idea!) keep in mind though that only the first error can be counted on to be relevant information. Sometimes there will be a cascade of errors all caused by the first one and then the reports about them are essentially meaningless.
Gotcha thanks for the tip
#2894 Posted 19 July 2022 - 02:41 PM
Set the palette of the actor to match the keycard you want, or set to PAL 6 to require all 3 keys. This code requires gamevars to be setup. No support will be provided for this code.
/*
// Proximity Activator
// LOTAG = Matching Activator LOTAG
// HITAG = Activation radius in units
// PAL = Require keycard, 1 = Blue, 2 = Red, 7 = Yellow, 6 = ALL 3
*/
appendevent EVENT_LOADACTOR
{
ife sprite[].picnum PROXIMITYACTIVATOR
{
seta .cstat 32768
geta .pal ACTORPATH
seta .pal 0
geta .lotag ACTORSPAWN
seta .lotag 0
// Set minimum range to 128 units, to prevent 0 distance weirdness
geta .hitag ACTORSEARCHRANGE
clamp ACTORSEARCHRANGE 128 MAXINT
seta .hitag 0
// Start sector locked
gets .lotag ACTORTEMP
add ACTORTEMP 16384
sets .lotag ACTORTEMP
}
}
endevent
defstate proximity_activate
{
ife ACTORPATH 0
operateactivators ACTORSPAWN 0
else
{
ife ACTORPATH 1
{
ifand player[].got_access 1 //blue
operateactivators ACTORSPAWN 0
}
else
ife ACTORPATH 2
{
ifand player[].got_access 2 //red
operateactivators ACTORSPAWN 0
}
else
ife ACTORPATH 7
{
ifand player[].got_access 4 //yellow
operateactivators ACTORSPAWN 0
}
else
ife ACTORPATH 6
{
ifand player[].got_access 1
ifand player[].got_access 2
ifand player[].got_access 4 //all
operateactivators ACTORSPAWN 0
}
}
}
ends
useractor notenemy PROXIMITYACTIVATOR
{
sleeptime 300
getu .vm_distance ACTORCHECK2
ifl ACTORCHECK2 ACTORSEARCHRANGE
{
ife ACTORNEAR FALSE
{
set ACTORNEAR TRUE
state proximity_activate
}
}
else
{
ife ACTORNEAR TRUE
{
set ACTORNEAR FALSE
state proximity_activate
}
}
}
enda
This post has been edited by Reaper_Man: 19 July 2022 - 03:19 PM
#2895 Posted 19 July 2022 - 07:55 PM
#2896 Posted 20 July 2022 - 01:10 AM
#2897 Posted 20 July 2022 - 02:22 AM
If you tried it and it didn't seem to work, keep in mind that custom actors will spawn at size 0 (making them effectively invisible) unless a size is specified in their code.
#2898 Posted 20 July 2022 - 03:19 AM
Danukem, on 19 July 2022 - 07:55 PM, said:
Thanks. Yeah I wasn't clear about that but it also closes behind you, although one could make this not the case easily enough. And great suggestion about the deadzone!
#2899 Posted 20 July 2022 - 03:42 AM
Danukem, on 20 July 2022 - 02:22 AM, said:
If you tried it and it didn't seem to work, keep in mind that custom actors will spawn at size 0 (making them effectively invisible) unless a size is specified in their code.
Ah, that makes sense now - I'd tested but wasn't aware they were spawning at size 0, I just assumed they weren't spawning at all (I have the transporter star effect turned off in my mod) - all sorted now, cheers!
#2900 Posted 20 July 2022 - 04:24 AM
This post has been edited by VGames: 20 July 2022 - 04:25 AM
#2901 Posted 21 July 2022 - 08:08 AM
How do I get rid of the expander weapon if it’s ever in your inventory from let’s say a cheat code or console command that gives u all the weapons? I know how to replace the weapon pickups and ammo pickups for it on a map load, but how would I remove it and it’s ammo from your inventory without the player ever noticing it? I’m planing to have the shrinker expand the enemies with the altfire button so the expander will be irrelevant.
This post has been edited by VGames: 21 July 2022 - 08:09 AM
#2902 Posted 21 July 2022 - 09:39 AM
VGames, on 21 July 2022 - 08:08 AM, said:
How do I get rid of the expander weapon if it’s ever in your inventory from let’s say a cheat code or console command that gives u all the weapons? I know how to replace the weapon pickups and ammo pickups for it on a map load, but how would I remove it and it’s ammo from your inventory without the player ever noticing it? I’m planing to have the shrinker expand the enemies with the altfire button so the expander will be irrelevant.
You want the .got_weapon and .ammo_amount player member structs. I'd check this during EVENT_WORLD and set it accordingly.
#2903 Posted 21 July 2022 - 09:49 AM
Reaper_Man, on 21 July 2022 - 09:39 AM, said:
That’ll help a lot. Wasn’t sure where to put this thanks.
Also what’s that old command to make the screen go white for nuke explosions? I can’t remember or find it.
This post has been edited by VGames: 21 July 2022 - 09:51 AM

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


