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

Jump to content

  • 124 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 offline   Danukem 

  • Duke Plus Developer

#2574

It's not a gamevar.

Find where there are "defineprojectile" for the projectiles in question. There should be a block of lines for each one of the projectiles. You want to add/replace with "defineprojectile PROJECTILENAME PROJ_FLASH_COLOR 0"

It might not work.
0

User is offline   Mark 

#2575

There is no defineprojectile commands in any of the defs or cons. So I guess its just using defaults. The only weapon related blocks of code I can find for each weapon are gamevars being set for a bunch of parameters.
// Shotgun
gamevar WEAPON2_WORKSLIKE 2 2
gamevar WEAPON2_CLIP 0 2
gamevar WEAPON2_RELOAD 13 2
gamevar WEAPON2_FIREDELAY 4 2
etc...

I guess I'll search around in other projects to see if I can find a chunk of defineprojectile code to learn from. But if its a whole lot of effort to make a projectile from scratch, I'll just live with the flash. Actually, I wouldn't mind keeping the flash but reduce it's size by at least 50-60 percent.

This post has been edited by Mark: 29 August 2020 - 07:35 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2576

^those gamevars only pertain to the player

You said they were "custom coded" so I assumed that meant they were custom projectiles. If the actors are using the regular hardcoded shots ("shoot SHOTGUN", "shoot CHAINGUN", "shoot SHOTSPARK1") then I don't know if there is any way to disable the lights they spawn in polymer. You could replace them with your own projectiles that don't emit light, though.
0

User is offline   Mark 

#2577

Sorry to mislead you. Its been a real treat to find and decipher someone elses old code. I knew there was weapon related code in there but didn't realise it was only player related. Thanks for trying. I'm assuming custom projectiles need math functions and other con functions I'm not familiar with so it will take a back seat to all the other issues I have to solve.

This post has been edited by Mark: 29 August 2020 - 07:51 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2578

View PostMark, on 29 August 2020 - 07:49 PM, said:

I'm assuming custom projectiles need math functions and other con functions I'm not familiar with so it will take a back seat to all the other issues I have to solve.


No, for hitscan they are incredibly simple. Pick an unused tile number (can be a blank one it doesn't matter), define it as hitscan and set damage, decal size and a few other things and you are good to go. No math, no fuss.
1

User is offline   Mark 

#2579

cool, I'll 'xperiment tomorrow. I see Dukeplus is loaded with custom projectiles for reference.

This post has been edited by Mark: 29 August 2020 - 08:46 PM

0

User is offline   Mark 

#2580

Its working and with no flashing. I just need to tweak parameters. Thanks again Danny boy.

Now I'm wondering if its possible/feasible to define and spawn my own SE light of a much smaller radius than the default flash was.
1

User is offline   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 offline   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 offline   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 offline   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 offline   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 offline   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 offline   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 offline   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 offline   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 offline   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

Share this topic:


  • 124 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