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

Jump to content

  • 115 Pages +
  • « First
  • 85
  • 86
  • 87
  • 88
  • 89
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is online   Danukem 

  • Duke Plus Developer

#2581

You can, but it's hacky. Spawning an SE will crash the game, so you spawn a different picnum, then change the picnum to SE, change the statnum to 3, and give it lotag 49, hitag for distance, xvel/yvel/zvel 0-255 for the RGB color you want. Importantly, make sure it gets deleted after a few tics, and that means you have to mark it for deletion in some way, have it use a timer and then delete itself in EVENT_GAME.
0

User is offline   Reaper_Man 

  • Once and Future King

#2582

Say I have ACTOR1 and want to check if ACTOR2 has a per-actor gamevar set to a certain value.

How would I read (or write) another actor's per-actor gamevar? This seems simple and I'm sure I'm overlooking something obvious.
0

User is online   Danukem 

  • Duke Plus Developer

#2583

View PostReaper_Man, on 22 September 2020 - 08:16 AM, said:

Say I have ACTOR1 and want to check if ACTOR2 has a per-actor gamevar set to a certain value.

How would I read (or write) another actor's per-actor gamevar? This seems simple and I'm sure I'm overlooking something obvious.


It is simple, but you have to have the sprite ID number of the other actor in a gamevar first. That's the only part that can be tricky, depending on the context. But let's say you have done that already, by using findnearactor or by searching sprites via a loop or whatever.

Assume that "SPRITE" is a var that is set to the ID of the other sprite, and "VAR1" is a per-actor var. Then, in the code of an actor, you could write:

getactorvar[SPRITE].VAR1 VAR1

The above line would copy the value of VAR1 from the sprite SPRITE to the VAR1 in the current sprite (THISACTOR).

setactorvar[SPRITE].VAR1 VAR1

That would write the current copy of VAR1 in THISACTOR to the copy of that var in SPRITE

You can also abbreviate those commands to getav and setav
1

User is offline   Mark 

#2584

never mind, dan beat me to it

This post has been edited by Mark: 22 September 2020 - 09:04 AM

0

User is offline   Reaper_Man 

  • Once and Future King

#2585

Thanks guys, I had completely forgotten about get/setactorvar. I knew it was going to be something simple!
0

User is offline   Reaper_Man 

  • Once and Future King

#2586

Is there a vertical clipdist member, or some other way that controls how "tall" the "hitbox" is of an Actor? Or is there some other way to recalculate their bounding box?

I am using the Player sprites for an actor that can stand and crouch, but when they crouch down, their collision remains the same dimensions as their standing sprite, so I can shoot them where their upper body existed, and when I stand on them there is a giant open space between me and the Actor since I am standing on what used to be their head. Hopefully this terrible image helps demonstrate the problem.

Posted Image
0

User is online   Danukem 

  • Duke Plus Developer

#2587

Just do what I have always done and cactor into the shorter sprite when they are crouched, and cactor back to the taller actor when standing up or dying. It's pretty simple, you just have 2 different actors running the same code (make a state for the code and both actors call the state); the main thing to watch for is the actions of the shorter actor are adjusted for the starting tile number of base crouch tile.

I can't think of another way to do it, honestly.
1

User is offline   Reaper_Man 

  • Once and Future King

#2588

Thanks as always Dan, I'll give that a try. I am guessing that's going to mess up my animation offsets, and I'll have to adjust the crouching ones for the new actor's tile position.

Still, that makes me wonder what structure member controls this, and why it can't be set programmatically.
0

User is online   Danukem 

  • Duke Plus Developer

#2589

View PostReaper_Man, on 30 September 2020 - 03:56 AM, said:

Thanks as always Dan, I'll give that a try. I am guessing that's going to mess up my animation offsets, and I'll have to adjust the crouching ones for the new actor's tile position.

Still, that makes me wonder what structure member controls this, and why it can't be set programmatically.


https://wiki.eduke32.com/wiki/Htg_t

Current frame offset should be in htg_t 3

I try not to mess with those, though. Redefining the actions only takes a minute.
0

#2590

Hey,
how do you change the palette of Greenslime's guts after it's been killed? I know that it's hardcoded to be spritepal 6.
0

User is online   Danukem 

  • Duke Plus Developer

#2591

First thing I would try:

appendevent EVENT_SPAWN ifspawnedby GREENSLIME spritepal 0 endevent


That should change everything it spawns to pal 0.
1

#2592

View PostDanukem, on 06 October 2020 - 12:38 AM, said:

First thing I would try:

appendevent EVENT_SPAWN ifspawnedby GREENSLIME spritepal 0 endevent


That should change everything it spawns to pal 0.


Unfortunately this does not work :)
0

User is online   Danukem 

  • Duke Plus Developer

#2593

How good are you with CON? My next step would be to use either SPAWN or EGS events, use the log function and see if anything has the htpicnum of GREENSLIME when you kill them. Sometimes this game is weird and for hardcoded reasons the jibs might not say they are spawned by it. It could also be that the pal is being changed after spawn, in which case you could try the same thing with EVENT_GAME.
1

#2594

Ok, switching EVENT_SPAWN to EVENT_GAME did the trick. Thanks!
0

User is online   Danukem 

  • Duke Plus Developer

#2595

View PostDecember Man, on 06 October 2020 - 11:31 PM, said:

Ok, switching EVENT_SPAWN to EVENT_GAME did the trick. Thanks!


That confirms the reason the EVENT_SPAWN version didn't work is the pal hadn't been set yet. The bad thing about putting that code in EVENT_GAME is that every single sprite in the game will run that line of code 30 times per second, even though it won't do anything unless the sprite is spawned by a slimer. That's very unlikely to cause you any issues but it's not optimal. If you had a big complex project with lots of code it would be worth improving.
1

User is offline   Reaper_Man 

  • Once and Future King

#2596

Out of curiosity, what would be a preferable alternative? The wiki says EVENT_EGS executes before EVENT_SPAWN, but if the palette isn't set in SPAWN then certainly that means it still won't be set at EGS, right? I would think that EGS would be preferable here as it runs for actors that are spawned at runtime, and it seems that SPAWN only runs for actors that exist on map load.

This post has been edited by Reaper_Man: 07 October 2020 - 06:35 AM

0

User is online   Danukem 

  • Duke Plus Developer

#2597

View PostReaper_Man, on 07 October 2020 - 04:49 AM, said:

Out of curiosity, what would be a preferable alternative? The wiki says EVENT_EGS executes before EVENT_SPAWN, but if the palette isn't set in SPAWN then certainly that means it still won't be set at EGS, right? I would think that EGS would be preferable here as it runs for actors that are spawned at runtime, and it seems that SPAWN only runs for actors that exist on map load.



One option would be using EVENT_WORLD, since the code would run-once-per tic instead of once-per-tic-per-sprite. But the code would need to be different since it wouldn't be run by the specific sprite in question.
0

#2598

View PostDanukem, on 07 October 2020 - 12:31 AM, said:

That confirms the reason the EVENT_SPAWN version didn't work is the pal hadn't been set yet. The bad thing about putting that code in EVENT_GAME is that every single sprite in the game will run that line of code 30 times per second, even though it won't do anything unless the sprite is spawned by a slimer. That's very unlikely to cause you any issues but it's not optimal. If you had a big complex project with lots of code it would be worth improving.


Is EVENT_PREGAME any more efficient in this regard than EVENT_GAME?
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#2599

View PostReaper_Man, on 07 October 2020 - 04:49 AM, said:

Out of curiosity, what would be a preferable alternative? The wiki says EVENT_EGS executes before EVENT_SPAWN, but if the palette isn't set in SPAWN then certainly that means it still won't be set at EGS, right? I would think that EGS would be preferable here as it runs for actors that are spawned at runtime, and it seems that SPAWN only runs for actors that exist on map load.

EVENT_EGS is used internally to initialize newly spawned sprites. It's where the structures are reset, in case the same ID was used for another sprite before.

EVENT_SPAWN is used for both sprites that already existed in the map or newly spawned sprites. Internally it's where it changed the size of enemies, etc.

Projectiles are, however, excluded from EVENT_SPAWN, and you would use EVENT_EGS instead.
0

User is online   Danukem 

  • Duke Plus Developer

#2600

View PostDecember Man, on 08 October 2020 - 05:03 AM, said:

Is EVENT_PREGAME any more efficient in this regard than EVENT_GAME?


No.

https://wiki.eduke32...i/EVENT_PREGAME
0

User is offline   Salvation 

#2601

A few questions:

I would like to make a bullet / projectile which has average velocity but its going to drop very soon. The idea is to make a weapon which is very good at close range but with no chance when shooting longer distances. I tried to do it myself but i can't get work on it as i planned

What's wrong with the code or is there something missing?
define SCARBULLET 15

defineprojectile SCARBULLET PROJ_WORKSLIKE 1
defineprojectile SCARBULLET PROJ_SPAWNS SMALLSMOKE
defineprojectile SCARBULLET PROJ_DECAL BULLETHOLE
defineprojectile SCARBULLET PROJ_EXTRA 20
defineprojectile SCARBULLET PROJ_XREPEAT 6
defineprojectile SCARBULLET PROJ_YREPEAT 6
defineprojectile SCARBULLET PROJ_TNUM 2
defineprojectile SCARBULLET PROJ_VEL 500
defineprojectile SCARBULLET PROJ_DROP -200



Second question: When you choose weapon like chaingun a weapon starts to appear and you are able to use it. How to change that "draw time"?
Idea is to simulate real world where lightweight weapon is easier to draw out and heavier weapon is slower.


Third question: My ironsight code does not have any penalty time when switching it on and off. I would like to have one, is there any command available or should i paste the code above?
0

User is online   Danukem 

  • Duke Plus Developer

#2602

For the projectile, you need its fall to accelerate, rather than fall at a fixed rate. The projectile definition only allows for a fixed rate. This is one of those cases where you have to add some additional code outside of the projectile definition, possibly in EVENT_GAME. You might be able to get away with "appendevent EVENT_GAME ifactor SCARBULLET fall endevent" but maybe not. If that doesn't work you track its zvel in a peractor var, add to it from the previous amount and keep setting it every tic in EVENT_GAME. Also, you might want to make its vel faster.
0

User is offline   Salvation 

#2603

View PostDanukem, on 09 October 2020 - 09:27 AM, said:

For the projectile, you need its fall to accelerate, rather than fall at a fixed rate. The projectile definition only allows for a fixed rate. This is one of those cases where you have to add some additional code outside of the projectile definition, possibly in EVENT_GAME. You might be able to get away with "appendevent EVENT_GAME ifactor SCARBULLET fall endevent" but maybe not. If that doesn't work you track its zvel in a peractor var, add to it from the previous amount and keep setting it every tic in EVENT_GAME. Also, you might want to make its vel faster.


So should i make an actor for the scarbullet?

Something like this:

 TRAILFRAME2 0 1 1 1 15
useractor notenemy BEAMTRAIL 0 TRAILFRAME2
spritepal 2			
ifaction TRAILFRAME2 {
ifactioncount 3 { killit }
else
ifactioncount 2 { cstat 32768 }
else
ifactioncount 1 { cstat 2 }
}
enda


Then EVENT_GAME i add the value that after certain amount of time the projectile starts to fall? Can it be so simple?

This post has been edited by Salvation: 12 October 2020 - 10:47 AM

0

User is offline   MC84 

#2604

I've got a noob question regarding ifrnd - basically I have a wall tile that once hit will shuffle between 3 different break tiles.

ife wall[RETURN].picnum GLASSFRONT
{ sound GLASS_BREAKING 
  lotsofglass 20 
  ifrnd 85
  { setw[RETURN].picnum GLSSFRNTBR1 }
  ifrnd 85
  { setw[RETURN].picnum GLSSFRNTBR2 }
  else
  { setw[RETURN].picnum GLSSFRNTBR3 }
  }


85 is 255/3, yet it seems to choose the final picnum (GLSSFRNTBR3) more frequently than the other two.. is this normal? It's hardly a big deal but I thought that perhaps I'd incorrectly used ifrnd? And is it preferable to use integers that are divisible by 8?
0

User is offline   Hendricks266 

  • Weaponized Autism

  #2605

The first thing I see is that the second ifrnd needs an else before it. Otherwise there is a 1/3 chance of using the second tile, a 2/3 chance of the third, and no chance of the first.

Second, I don't think chaining "ifrnd 85 else ifrnd 85 else" will give each result an equal 1/3 chance. The first one would have a 1/3 chance. The else would cover the 2/3 remaining chance, and the second result would have 1/3 of that = 2/9. Then the third result would have the remaining 4/9 chance. It would need to be ifrnd 85 else { ifrnd 128 else }.

Generally I prefer to avoid ifrnd messes if you want all the results to have the same likelihood. Just use randvar and a switch/case.

  randvar temp 2
  switch temp
    case 0
      setw[RETURN].picnum GLSSFRNTBR1
      break
    case 1
      setw[RETURN].picnum GLSSFRNTBR2
      break
    case 2
      setw[RETURN].picnum GLSSFRNTBR3
      break
  endswitch

2

User is offline   MC84 

#2606

Much better! Thanks for the explanation - it probably would have never occurred to me that each ifrnd statement alters the probability..

I assumed that this gamevar would be a 'per actor' variable, but out of curiosity I set it to 'global' and it still works? In my limited understanding of coding I would have assumed that making it global would cause issues when there are multiple states of the actor walltile being hit?

This post has been edited by MC84: 16 October 2020 - 12:20 PM

0

User is offline   Hendricks266 

  • Weaponized Autism

  #2607

Each ifrnd is its own dice roll, so you have to model your math based on that.

Scratch variables like temp should be marked global. There is no concurrency in CON so the variable is not contested in any way. You only need to mark a variable per-actor if each actor's value needs to be preserved from one game world tick to the next.
2

User is offline   Salvation 

#2608

I would like to change the font of health, armor and ammo.
I put the following code:

onevent EVENT_DISPLAYREST
	getactor[THISACTOR].extra TEMP2
	{
	digitalnumber 2992 360 160 TEMP2 0 0 0 0 0 xdim ydim
	}
endevent


The new font is now on screen on the right side but the existing one is also there, so it's a duplicate. See the attachment.

What should i do to change the font?

Attached thumbnail(s)

  • Attached Image: duke0018.png

0

User is online   Danukem 

  • Duke Plus Developer

#2609

You can't pick and choose individual elements of the hud to replace; you have to disable the entire hardcoded display by setting RETURN to -1 in the event and then redraw every single thing yourself.
1

#2610

Hey, I'm using the following code to have the Jibs remain on the floor:


state rf
getactor[THISACTOR].cstat TEMP4
ifvare TEMP7 259 { cstat 2 } else
ifvare TEMP7 771 { cstat 514 } else
{ 
  ifrnd 128
    cstat 4
  else
	cstat 0
}
ends

state getfloordist
  getactor[THISACTOR].x x
  getactor[THISACTOR].y y
  updatesector x y TEMP7 // You should not trust [THISACTOR].Sectnum
  getflorzofslope TEMP7 x y z
  getactor[THISACTOR].z TEMP8
  subvarvar z TEMP8
  shiftvarr z 8
  subvar z 1
ends
				
onevent EVENT_GAME
			
ifactor JIBS1
{
state getfloordist
ifvarl z 0 
	{
	sound GIB_LAND2
	changespritestat THISACTOR 1
	state rf
	setactor[THISACTOR].picnum 2249
	      ifrnd 84
        spawn BLOODPOOL
        else
		guts JIBS6 3
}
}
endevent


Each time a Jib drops inside an invalid sector, eDuke32.log spills out the error:

Line 801, getflorzofslope: invalid sector -1


This error is being spammed in dozens of kilobytes over an hour of gameplay. Is there a way to avoid this?

This post has been edited by December Man: 28 October 2020 - 11:49 AM

0

Share this topic:


  • 115 Pages +
  • « First
  • 85
  • 86
  • 87
  • 88
  • 89
  • 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