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

Jump to content

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

EDuke32 Scripting  "CON coding help"

User is offline   dandouglas 

#2851

Is it possible to make the player temporarily invulnerable without using god mode? I have sprites in my mod which lock player movement for a short time while sequenced events play out, and while I'm being careful not to place enemies in the close vicinity, I can't predict everything and I want to ensure the player can't unfairly take damage while rooted to the spot.

I've experimented with using activatecheat to toggle god mode on and off for the duration of the movement lock (and removing the associated quote), and this works great, with a couple of issues: player health is brought up to 100 when god mode is engaged, and when disengaged the screen flashes red. Both of these issues I'd like to avoid. Any suggestions? Cheers!
0

User is offline   Mark 

#2852

Feel free to laugh at these suggestions. ;)

during the lockplayer duration, resize the player to something really small to reduce it's hitscan area making it way less likely to be hit. This of course would move the player view down to the floor so right after resizing, use a command to move the player up to normal.

Would it be possible to spawn a protective shield of invisible sprites around the player during lockplayer

Not sure exactly where to place it or how, ifhitweapon nullop nested in there somewhere for aplayer.

This post has been edited by Mark: 03 July 2022 - 01:50 PM

0

User is online   Danukem 

  • Duke Plus Developer

#2853

View Postdandouglas, on 03 July 2022 - 11:01 AM, said:

Is it possible to make the player temporarily invulnerable without using god mode? I have sprites in my mod which lock player movement for a short time while sequenced events play out, and while I'm being careful not to place enemies in the close vicinity, I can't predict everything and I want to ensure the player can't unfairly take damage while rooted to the spot.


Just use seta[].htextra -1 in the player code *before* ifhitweapon. This nullifies any damage caused by weapon hits or explosions.
1

User is offline   dandouglas 

#2854

View PostDanukem, on 03 July 2022 - 03:26 PM, said:

Just use seta[].htextra -1 in the player code *before* ifhitweapon. This nullifies any damage caused by weapon hits or explosions.


Thanks Dan - that works great!

@Mark - thanks for the suggestions, I'd considered using invisible sprite shields too!
0

User is offline   dandouglas 

#2855

A year ago when I started my mod I had no idea what I was doing, and built it using the World Tour edition. Now I'd like to strip out all of the changes, the revoiced lines, flamethrower etc. - do you recommend I try to reverse-engineer the existing CON files I have, or rebuild them from scratch using Atomic Edition files as a base? I've made a lot of changes across the board so ideally I'd like to just edit the files I have already, but can anyone think of any pitfalls in doing that?
0

User is online   Danukem 

  • Duke Plus Developer

#2856

View Postdandouglas, on 05 July 2022 - 12:09 PM, said:

A year ago when I started my mod I had no idea what I was doing, and built it using the World Tour edition. Now I'd like to strip out all of the changes, the revoiced lines, flamethrower etc. - do you recommend I try to reverse-engineer the existing CON files I have, or rebuild them from scratch using Atomic Edition files as a base? I've made a lot of changes across the board so ideally I'd like to just edit the files I have already, but can anyone think of any pitfalls in doing that?


I recommend just keep editing the files you have. For the sounds you can mostly just replace the sound files without changing the sound definitions.
0

User is offline   dandouglas 

#2857

View PostDanukem, on 05 July 2022 - 02:48 PM, said:

I recommend just keep editing the files you have. For the sounds you can mostly just replace the sound files without changing the sound definitions.


Thanks again Dan, good shout.
0

User is offline   jimbob 

#2858

imtrying to make the stickybombs into a (sniper )rifle, but it only fires when im close to a wall ( leftover code somewhere probably ) despite setting the flags to
gamevar WEAPON8_WORKSLIKE 8 0
gamevar WEAPON8_FLAGS 16384

any tips on that?
0

User is online   Danukem 

  • Duke Plus Developer

#2859

View Postjimbob, on 07 July 2022 - 08:01 AM, said:

imtrying to make the stickybombs into a (sniper )rifle, but it only fires when im close to a wall ( leftover code somewhere probably ) despite setting the flags to
gamevar WEAPON8_WORKSLIKE 8 0
gamevar WEAPON8_FLAGS 16384

any tips on that?


I know I have solved this problem, because in Alien Armageddon the default weapon on that slot is the spider mines which you can throw. In my code I am constantly setting WEAPON8_WORKSLIKE to 6 but I don't remember why. Perhaps the game is hardcoded to revert WEAPON8_WORKSLIKE to the default value when you switch weapons?
0

User is offline   jimbob 

#2860

i'll try setting it to six and see what happens, i tried setting it to 9 wich is another rifle in the freeze thrower slot but then it just displays those frames instead of the art i specify for weapon 8
[edit] while it does shoot right, it displays the frames for the weapon 6 slot despite the "state weapon8_display" command :o

ill take a look at the alien armageddon code and see how that sniper works, its probably something simple im overlooking.

This post has been edited by jimbob: 08 July 2022 - 07:27 AM

0

User is online   Danukem 

  • Duke Plus Developer

#2861

View Postjimbob, on 08 July 2022 - 07:19 AM, said:

i'll try setting it to six and see what happens, i tried setting it to 9 wich is another rifle in the freeze thrower slot but then it just displays those frames instead of the art i specify for weapon 8
[edit] while it does shoot right, it displays the frames for the weapon 6 slot despite the "state weapon8_display" command :o

ill take a look at the alien armageddon code and see how that sniper works, its probably something simple im overlooking.


Yes, it is supposed to show different tiles when you change that value. That just proves that what you did before was not doing anything.

In my mods I have my own weapon display code that overrides the tiles it would normally display. What you have to do is set RETURN to -1 in the weapon display event, then use screen drawing commands to draw your own tiles. I didn't even occur to me that you weren't doing that already, since the alternative is being stuck with the the vanilla display code.
0

User is offline   jimbob 

#2862

i did do that, but for whatever reason it insists of displaying the wrong tiles.

onevent EVENT_DRAWWEAPON
ifvare currentweapon 1
 {
	setvar RETURN -1
	ifvare LUGERSELECTED 1
	{ state luger_display }
else
	{ state draw_pistol }
 }
ifvare currentweapon 2
  {
   setvar RETURN -1
   state mp40_display
  }
ifvare currentweapon 3
 {
   setvar RETURN -1
   state thompson_display
  }
ifvare currentweapon 4
  {
	setvar RETURN -1
 state bazooka_display
  }
ifvare currentweapon 6
  {
	setvar RETURN -1
	state flamethrower_display	
	ifsound FTFIRE { stopactorsound APLAYER FTIDLE }
	else soundonce FTIDLE
  }
ifvare currentweapon 7
	{
		setvar RETURN -1
		state MG42_display
	}
ife currentweapon 8 // ifvare currentweapon 8
  	{
		setvar RETURN -1
		state k98_display
	}
ifvare currentweapon 9
	{
	   setvar RETURN -1
	   state garand_display
	}
ifvare currentweapon 11
  {
	setvar RETURN -1
	state greaser_display
  }
endevent

0

User is online   Danukem 

  • Duke Plus Developer

#2863

I don't have the time to look it up right now, but I suspect that changing the workslike *also* changes the value of currentweapon, which is after all a display related var. You may have to base it on player[].curr_weapon which will give you the actual weapon number.

As an intermediate level CON coder you picked the hardest possible weapon slot to put a sniper rifle on.
0

User is offline   jimbob 

#2864

yes, this was a late addition since i had no practical use for the tripmines :P i'll try setting it to player[].curr_weapon

[edit] well that kinda works, now it insists on displaying both tiles at the same time :')
[edit]nevermind, setting the workslike weapon to 9, since its practically the same gun, then also adding plaer[]/curr_weapon to that weapon fixed that. now on to code this sucker :D

This post has been edited by jimbob: 09 July 2022 - 03:11 PM

0

User is offline   jimbob 

#2865

ok, so now im creating all the frames for the weapon, but how do i tell the game it will have to use two different reload animations, one for extracting, and pushing in a new round with the bolt, and one for inserting new shells into the gun. there seems to be a somewhat similar function in WW2 gi on the mauser, but the weapon code itself seems to be hidden somewhere.

[edit] i suppose i could make the bolt action part of the firing animation as a cheap out alternative.

This post has been edited by jimbob: 10 July 2022 - 04:36 PM

0

User is online   Danukem 

  • Duke Plus Developer

#2866

It sounds to me like there is one reload animation, but some frames can be used in it multiple times. What I usually do is have a switch statement in the display code where the cases are weaponcount numbers, and it will specify which tile to display on which weaponcount. The same tile can be diplayed on many different weaponcounts.
0

User is offline   jimbob 

#2867

what i mean is that it should kind of work as the shotgun, meaning fire a round, then go through a specific animation for inserting a new round, but after the rifle is empty ( after 5 rounds ) go to a different animation of putting in new rounds

here's an example of my actual weapon draw code, wich is probably needlesly "drawn out"

state flamethrower_display
 switch weaponcount
  case 0 
ifinwater nullop else 
	{
   setvar digz 32768
   setvar digx 175 // was 150
   setvar digy 200
   setvar shade -127
   setvar picnum 3864 // flame!
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal 1 0 0 xdim ydim
	}
  // break
   setvar digz 32768
   setvar digx 240
   setvar digy 250
   setvar picnum 3863
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
// fire
case 1 case 2
ifinwater nullop else
	{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5552 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
	}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 3 case 4
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5553 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 5 case 6
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5554 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 7 case 8
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5555 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 9 case 10
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5556 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 11 case 12
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5557 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
case 13 case 14
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5558 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 15 case 16
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5559 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 17 case 18
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5560 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 19 case 20
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5561 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
case 21 case 22
ifinwater nullop else
{
   setvar digz 32768
   setvar digx 170
   setvar digy 215
	setvar shade -127
   setvar picnum 5562 // flame
   // setvar orientation 33
   state initweapondisplay
   rotatesprite digx digy digz -192 picnum shade pal orientation 0 0 xdim ydim
}
 // break
   setvar digz 32768
   setvar digx 240
   setvar digy 260
   setvar picnum 3868
   setvar orientation 0
   state initweapondisplay
   rotatesprite digx digy digz angvar picnum shade pal orientation 0 0 xdim ydim
  break
 endswitch
ends

// end flamethrower

but that gives an idea how it looks like

[edit] well right now im setting the total time to the fire animation and the racking combined, and then i will set another bunch of frames for the reload animation. so far this seems to work(ish)

This post has been edited by jimbob: 11 July 2022 - 08:27 AM

0

User is online   Danukem 

  • Duke Plus Developer

#2868

View Postjimbob, on 11 July 2022 - 06:59 AM, said:

what i mean is that it should kind of work as the shotgun, meaning fire a round, then go through a specific animation for inserting a new round, but after the rifle is empty ( after 5 rounds ) go to a different animation of putting in new rounds


Make the code branch and display the other sequence of tiles when the gun is doing a full reload. I'm not sure what you are really asking, though. Are you having trouble figuring out how to detect whether the weapon is doing a full reload? Are you having trouble with the WEAPONX_RELOAD var itself?
0

User is offline   jimbob 

#2869

what i want to know is how i prevent the weapon from going through the bolt action, instead it should skip that and go straight into the reload animation, for example now it goes shoot, open the bolt and extract the shell, push in a new one and get ready to fire. after the last one there is no bullet to push in, so instead open the bolt to push in 5 new rounds and closing the bolt to slide the first one in. since i now have it set up to always play the entire extration, and reinsertion animation it will do that, then open it up again to put in new shells so i need to get to detect when the actual last round is fired so it can go straight to the actual reload animation.

for example, like the shotgun, say it has 5 shells in it, you pump in a new round every shot, but when it's empty you want a different animation to open the chamber so you can insert new rounds.

then i have to make a scope and massively increase the damage when using it. wich is easy enough
0

User is online   Danukem 

  • Duke Plus Developer

#2870

Again, I'm not sure what the sticking point is. If you know how to detect in your code whether a full reload has started, then you can branch your reload and reload display code to handle it.

If you are using a variable to track how many rounds are in the magazine, then the obvious way would be when magazine == 0 and reloading is not 0
0

User is offline   dandouglas 

#2871

Does anyone know how I might go about creating a projectile which inflicts gradual incremental damage after impact, kind of like poison?

The backstory is that, in my mod, the aliens are going to have severe egg allergies so Duke can throw eggs at them, but they don't die straight away.

I've got an RPG-style projectile working nicely, thrown on an arch with a little splash when it lands, but it currently only does damage on impact.
0

User is online   Danukem 

  • Duke Plus Developer

#2872

View Postdandouglas, on 15 July 2022 - 11:51 PM, said:

Does anyone know how I might go about creating a projectile which inflicts gradual incremental damage after impact, kind of like poison?

The backstory is that, in my mod, the aliens are going to have severe egg allergies so Duke can throw eggs at them, but they don't die straight away.

I've got an RPG-style projectile working nicely, thrown on an arch with a little splash when it lands, but it currently only does damage on impact.



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

0

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 online   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 online   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 online   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 

#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

Share this topic:


  • 115 Pages +
  • « First
  • 94
  • 95
  • 96
  • 97
  • 98
  • 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