Duke4.net Forums: EDuke32 Scripting - Duke4.net Forums

Jump to content

  • 124 Pages +
  • « First
  • 95
  • 96
  • 97
  • 98
  • 99
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   jimbob 

#2873

trying to make a toggle button for setting the scope to active or inactive. but it immediatly switches even when pressing the key very shortly, how do i make it so that after each keystroke you have to release the key, then press it again for it to change? i tried setting a ifcount 32 or a break at the end, even setting setvar RETURN -1 but nothing seems to help :o
0

User is offline   Danukem 

  • Duke Plus Developer

#2874

Increment your var to the next scope level when the scope key is pressed but only if it wasn't being pressed during the previous tic.
0

User is offline   jimbob 

#2875

there is only one scope level, either on or off. but holding the key cycles though on and off ( i set gamevar USESCOPE to 1 or 0 )

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.
0

User is offline   Danukem 

  • Duke Plus Developer

#2876

Same difference. You don't want it to change the state if the key was held during the last tic. You need to learn how to detect input bits and save the last bits. See event_processinput and the bit listings in the input structures.
0

User is offline   jimbob 

#2877

i did, there are no examples in there on how to set them up
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

0

User is offline   Danukem 

  • Duke Plus Developer

#2878

The default value of bits is not 0. But the important thing is to use ifvarand or equivalent to check which bits are set. Save the value as the *old* value *after* your check in the LOOKDOWN event happens. In that event, you compare the old value with the current value and make sure to change the scope state only if the bit is set on the current value but not the old one.
0

User is offline   quakis 

#2879

I've been getting back into CON scripting recently, haven't touched it since 2007-ish. I didn't bother with understanding the core basics properly back then, which only caused further confusion and code hacked together with duct tape. I'm remedying that problem now by starting over and ensuring everything has sunk in. It's been going a lot more smoother this time round, coding features I had trouble with in the past with a better understanding and reading existing code doesn't feel like I'm looking at alien scriptures.

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?
Spoiler


ife vs ifn?
Spoiler


Timers?
Spoiler


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.
0

User is offline   VGames 

  • Extra Crispy

#2880

Is there a way to adjust the height of the spawn point for custom projectiles? I know PROJ_OFFSET adjusts the X axis value for the spawn point but what about the Z axis or Y axis? I’m not sure which one pertains to the high and low of a weapon position.

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

0

User is offline   jimbob 

#2881

i usually adjust the Z value in event EGS or spawn

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

0

User is offline   VGames 

  • Extra Crispy

#2882

Ok cool. I didn’t even think about the EGS EVENT

What about the spread adjustment for RPG like projectiles?
0

User is offline   jimbob 

#2883

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
0

User is offline   VGames 

  • Extra Crispy

#2884

View Postjimbob, 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

0

User is offline   Danukem 

  • Duke Plus Developer

#2885

@quakis

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
1

User is offline   quakis 

#2886

@Danukem

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

0

#2887

View Postjimbob, 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?
0

User is offline   VGames 

  • Extra Crispy

#2888

View Postjimbob, on 18 July 2022 - 07:53 AM, said:

i usually adjust the Z value in event EGS or spawn

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
}


0

User is offline   Danukem 

  • Duke Plus Developer

#2889

@VGames It's bad form to say that code throws errors and to not say what the errors are...

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.
0

User is offline   VGames 

  • Extra Crispy

#2890

I did say what the error was. The game won’t load. But now that u mention it I did not declare z. I feel dumb now lol. That’s has to be the issue. Sorry for the confusion guys.
0

User is offline   dandouglas 

#2891

View PostDanukem, on 16 July 2022 - 01:27 AM, said:

Declare a per-actor gamevar:

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 150
Again, 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!
0

User is offline   Danukem 

  • Duke Plus Developer

#2892

View PostVGames, on 18 July 2022 - 08:33 PM, said:

I did say what the error was. The game won’t load. But now that u mention it I did not declare z. I feel dumb now lol. That’s has to be the issue. Sorry for the confusion guys.


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.
0

User is offline   VGames 

  • Extra Crispy

#2893

View PostDanukem, on 19 July 2022 - 02:28 AM, 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.


Gotcha thanks for the tip
0

User is offline   Reaper_Man 

  • Once and Future King

#2894

Finalizing AWOL and there's a few effects or code snippets that should work standalone I wanted to share. This is a "Proximity Activator" that we used for Metal Gear Solid style doors that would automatically open when you were nearby, and allow for keycard requirements. It's like a touchplate without the actual touchplate. This works by abusing the sector locking lotag. Place it in a sector where you would otherwise put an ACTIVATOR or ACTIVATORLOCKED. We ran in to some weirdness with multi-sector effects, IE double ST doors with windows. I'm sure this could be solved but we just avoided those setups instead. Also DNUNLOCK probably breaks this, so might want to fix that if you care.

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

3

User is offline   Danukem 

  • Duke Plus Developer

#2895

That's pretty cool. You didn't mention this in the description, but from the code I can see that it also closes the door again when the player gets out of range. It seems to me that it might be improved somewhat if the effect had a deadzone -- so that it waits until the player has taken a few extra steps (ACTORSEARCHRANGE+2048?) before closing the door again.
0

User is offline   dandouglas 

#2896

Is it possible to make any custom actor spawnable via the RESPAWN sprite? At the moment I'm just editing the hardcoded respawn-compatible actors, which works but isn't ideal. Thanks!
0

User is offline   Danukem 

  • Duke Plus Developer

#2897

Yes. Although it seems to me you could have tested that more quickly than posting and waiting for an answer. :lol:

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.
0

User is offline   Reaper_Man 

  • Once and Future King

#2898

View PostDanukem, on 19 July 2022 - 07:55 PM, said:

That's pretty cool. You didn't mention this in the description, but from the code I can see that it also closes the door again when the player gets out of range. It seems to me that it might be improved somewhat if the effect had a deadzone -- so that it waits until the player has taken a few extra steps (ACTORSEARCHRANGE+2048?) before closing the door again.


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!
0

User is offline   dandouglas 

#2899

View PostDanukem, on 20 July 2022 - 02:22 AM, said:

Yes. Although it seems to me you could have tested that more quickly than posting and waiting for an answer. :lol:

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!
0

User is offline   VGames 

  • Extra Crispy

#2900

Is JIB6 capable of detecting whether or not it hits a wall so that it can use shoot BLOOD? I’ve been using some code to make it detect this but it doesn’t seem to work. The rest of the code that I use to force stream effects and a resize works just fine but the state that is called to check for a wall touch while in the air doesn’t. I know the code should work because I have other actors use it for various reasons but I thought maybe there was something internal about JIB6 that doesn’t allow it.

This post has been edited by VGames: 20 July 2022 - 04:25 AM

0

User is offline   VGames 

  • Extra Crispy

#2901

Sorry for the double post but I couldn’t edit my last post.

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

0

User is offline   Reaper_Man 

  • Once and Future King

#2902

View PostVGames, on 21 July 2022 - 08:08 AM, said:

Sorry for the double post but I couldn’t edit my last post.

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.
0

Share this topic:


  • 124 Pages +
  • « First
  • 95
  • 96
  • 97
  • 98
  • 99
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic


All copyrights and trademarks not owned by Voidpoint, LLC are the sole property of their respective owners. Play Ion Fury! ;) © Voidpoint, LLC

Enter your sign in name and password


Sign in options