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

Jump to content

  • 115 Pages +
  • « First
  • 102
  • 103
  • 104
  • 105
  • 106
  • 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

#3091

View PostVGames, on 15 November 2022 - 12:12 PM, said:

Oh one other question I’ve been meaning to ask and keep forgetting. Is there a way to track frame rate? I’d like to be able to check if it’s dropped below a certain amount like 30 frames or something. Just wondering


Yeah there is literally a predefined read-only framerate gamevar.

https://wiki.eduke32.../wiki/Framerate
1

User is offline   VGames 

#3092

Yeah I just found it. Sorry
1

User is online   Danukem 

  • Duke Plus Developer

#3093

View PostVGames, on 15 November 2022 - 06:20 AM, said:

I’m referring to the floor in Spin Cycle. How do I make an actor detect if it’s on the floor that’s spinning around in that giant room?


I was going to suggest having the sprites check for the presence of an SE0 in their sector, and then do whatever it is you want them to do if that comes back positive. But that's not enough because the SE0 has a hitag channel and the rotating can be off or on.

If it's the _movement_ that is the issue, you can write code that resets the coords of the sprites that would work independently of the cause of the movement, so you wouldn't need to detect the sector movement at all. If you are trying to keep the sprites in place, you would probably also need to lock down their visible coords in EVENT_ANIMATESPRITES (in addition to their actual coords), because otherwise they will appear to shake as the game moves them and then their actor code resets them 30 times per second.

If you ever do want to detect the presence of SEs in a sector, or any other kinds of sprites for that matter, here are a couple of useful references:

https://wiki.eduke32.../Headspritestat

https://wiki.eduke32.com/wiki/Statnum

You can set up a loop that traverses a linked list of sprites sharing a statnum, which is way more efficient than looping through all sprites. You could also loop through sprites in the sector, depending on your needs (see headspritesect)
1

User is offline   VGames 

#3094

Is there any way to force the Nightvision goggles to turn on and off without the player having to press the button? I wanted to make the nightvision goggles turn on when the sector you are in has a very low shade value and turn off when the sector is more lit up. I tried making a new night vision effect when the player presses the nightvision button by cancelling out the original usenightvision event and setting up some variables to handle all the effects but changing the palette to 3 only makes the screen green and doesn't make the enemies light up like the original night vision effect does. Any ideas or is this impossible?
1

User is online   Danukem 

  • Duke Plus Developer

#3095

View PostVGames, on 18 November 2022 - 02:17 PM, said:

Is there any way to force the Nightvision goggles to turn on and off without the player having to press the button? I wanted to make the nightvision goggles turn on when the sector you are in has a very low shade value and turn off when the sector is more lit up. I tried making a new night vision effect when the player presses the nightvision button by cancelling out the original usenightvision event and setting up some variables to handle all the effects but changing the palette to 3 only makes the screen green and doesn't make the enemies light up like the original night vision effect does. Any ideas or is this impossible?


Well first of all I would set heat_on to 1 in the player struct

https://wiki.eduke32.com/wiki/Heat_on

I don't think that changes the gamepalette though so you would probably have to do that as well. However setting that struct probably takes care of the enemies/items not lighting up
1

User is offline   VGames 

#3096

View PostDanukem, on 18 November 2022 - 02:28 PM, said:

Well first of all I would set heat_on to 1 in the player struct

https://wiki.eduke32.com/wiki/Heat_on

I don't think that changes the gamepalette though so you would probably have to do that as well. However setting that struct probably takes care of the enemies/items not lighting up



ah ok maybe that's what I was missing. Also am I supposed to be using the setgamepalette command to change palettes?

This post has been edited by VGames: 18 November 2022 - 03:02 PM

1

User is offline   Reaper_Man 

  • Once and Future King

#3097

Doing a quick test, it seems like the issue is forcing heat_on without any available heat_amount. If you check or set non-zero heat_amount before forcing heat_on to 1, enemies light up as expected. Otherwise if it's 0, the gamepal changes to 2 so everything visibly turns green, but the actual night vision logic doesn't fire and enemies don't glow.

Side note, setgamepalette is deprecated and no longer required, you can change the gamepal via player[].palette directly now.
1

#3098

Is using a global var for general calcs safe as long as the define/get/function/set are back to back?
1

User is online   Danukem 

  • Duke Plus Developer

#3099

View Postlllllllllllllll, on 20 November 2022 - 12:43 PM, said:

Is using a global var for general calcs safe as long as the define/get/function/set are back to back?


Yes. And they don't have to be back to back, you just need to make sure that nothing is changing the global var in between your uses unbeknownst to you. The main thing to be wary of is spawning stuff, since that fires off events that you may have code on which potentially changes the global var.
1

User is offline   Reaper_Man 

  • Once and Future King

#3100

In a word: Yes.

If you have a series of math commands run on a gamevar, the value of that gamevar will not unexpectedly change between commands even if the gamevar is reused elsewhere. CON commands are instructions executed in sequence order, so any use of or command using that gamevar before or after the block of code you're looking at won't effect it.

CON will always execute in the order that it's written, meaning that code that is written earlier in sequence will always execute before any other code later on down the line, whether in the same file or files loaded after it. The caveat here is code processing in game events, and without going into a really in-depth and kind of confusing explanation, keep in mind that events always execute in a specific order, and code within those events processes following the same sequential execution.

The execution of code and setting of data will also be dependent on the quasi-random execution order of a sprite's ID. Sprites will process their code individually in order of their sprite ID, so if you have 2 of the same actors which run the same code and both check for or set a gamevar's value, and the actor doing the checking happens to execute before the actor doing the setting because it was assigned a lower sprite ID, it won't be until the next gametic when the checker will "see" the value the setter set.

edit: lol

This post has been edited by Reaper_Man: 20 November 2022 - 02:28 PM

1

User is offline   VGames 

#3101

Is there any way to mess around with the Pig Recon Vehicle and how it spawns the PigCop when it crashes? There isn't any code in the CON files for this vehicle unlike the Pig Tank so I figured its hardcoded. Would I need to create an entirely new Pig Recon enemy?
1

#3102

I think you can use event_EGS to modify the spawned actor. Something like

ifactor PIGCOP
ifspawnedby RECON
2

User is offline   Reaper_Man 

  • Once and Future King

#3103

Yup, you can capture the spawn in several different events and alter the spawned actor that way. EVENT_EGS would work, that captures sprites spawned during gameplay. I tend to prefer EVENT_SPAWN to modify actors at spawn time, as it's more generic and will effect ones placed in a map as well as spawns at runtime.
1

#3104

You'll be able to spoof a spawn chance in the same way. The chance to killit will be the chance not to spawn (and need to add -1 to total enemy count)
1

User is offline   VGames 

#3105

Oh ok yeah. I didn’t even think of going through the pigcop and checking if it was spawned by the recon. I’ve added 2 new pigcop variants and I only want the tank and the recon to spawn the original pigcop. But since the original pigcop has a chance to spawn one of the new pigcops and then get removed when it’s spawned sometimes one of the 2 new pigcop variants gets spawned instead when the tank or recon are destroyed. Thanks for the tip. This will help. I’ll have the pigcop spawned by the recon spawn my pigcop clone and remove itself which will then allow the pigcop clone to immediately turn into the original pigcop.
1

User is offline   Reaper_Man 

  • Once and Future King

#3106

Instead of spawning and killing, you can use cactor to simply change which actor type the current actor is.
1

User is offline   VGames 

#3107

View PostReaper_Man, on 22 November 2022 - 06:04 AM, said:

Instead of spawning and killing, you can use cactor to simply change which actor type the current actor is.


Yeah I guess I could do that instead. Good idea.
0

#3108

Is there a way to trigger a lotag via CON?

The reactor sprite pretty much works perfectly as a hidden trigger but it has a minimum radius of electrocuting the player instead of being contained to its sector and it also has hardcoded explosion damage that too has a minimum radius.
Placing the reactor where it can't see the player leaves it asleep and misses the explosion cue. Placing it in places where it can "see" the player sometimes doesn't wake it up in time for the cue.
There didn't seem to be any effectors that could activate things via explosion. The cracks and barrels are limited to other explosions or chaining cracks.

The thing on Reactors stopping rotaters would be cool too if it's possible.



The specific problem I ran into is explodable sectors do not block player Use in the spot that the hole opens up and 'fixing' that requires an activator or masterswitch to fire after it explodes.
0

User is online   Danukem 

  • Duke Plus Developer

#3109

View Postlllllllllllllll, on 22 November 2022 - 10:01 PM, said:

Is there a way to trigger a lotag via CON?

The reactor sprite pretty much works perfectly as a hidden trigger but it has a minimum radius of electrocuting the player instead of being contained to its sector and it also has hardcoded explosion damage that too has a minimum radius.
Placing the reactor where it can't see the player leaves it asleep and misses the explosion cue. Placing it in places where it can "see" the player sometimes doesn't wake it up in time for the cue.
There didn't seem to be any effectors that could activate things via explosion. The cracks and barrels are limited to other explosions or chaining cracks.

The thing on Reactors stopping rotaters would be cool too if it's possible.



The specific problem I ran into is explodable sectors do not block player Use in the spot that the hole opens up and 'fixing' that requires an activator or masterswitch to fire after it explodes.


https://wiki.eduke32...erateactivators
https://wiki.eduke32...emasterswitches
https://wiki.eduke32...Operaterespawns
https://wiki.eduke32.../Operatesectors
1

#3110

Can't get it to work. The sprite does despawn when it's hit by an explosion while it never seems to trip activator/masterswitch. I tried placing the sprite directly into the sector the A/MS was in as well.
Destroying a reactor with the same lotag is still functioning properly. The series of commands were what I cycled through trying to figure it out

actor EFFECTORBOOTLEG
  ifhitweapon
    ifwasweapon RADIUSEXPLOSION
    {
      <operate>
      killit
    }
enda


operatemasterswitches sprite[].lotag
operatemasterswitches sprite[].hitag
operatemasterswitches 130
operateactivators sprite[].lotag    //masterswitch swapped to activator on map
operateactivators sprite[].hitag
operateactivators 130 THISACTOR
operateactivators 130 0
operateactivators 130 1

1

User is online   Danukem 

  • Duke Plus Developer

#3111

The <player id> parameter should always be 0, in singleplayer.

Other than that, it is impossible to tell what you are doing wrong from that code you pasted. My first theory is that the sprite in question does not actually have its hitag or lotag set. For safety, I would use something like this:

gamevar SPRITELOTAG 0 2

eventloadactor EFFECTORBOOTLEG
geta[].lotag SPRITELOTAG
seta[].lotag 0
enda

actor EFFECTORBOOTLEG
  ifhitweapon
    ifwasweapon RADIUSEXPLOSION
    {
      operateactivators SPRITELOTAG 0
      operatemasterswitches SPRITELOTAG
      killit
    }
enda

1

#3112

It's weird

Setting the sprite's Hitag to 130 was causing it despawn via collapse [presumably] instead of running the actor code
Setting the sprite's Hitag & Lotag to 0 while using Activate 130 + Killit made it unresponsive
Setting the sprite's Hitag & Lotag to 0 while using just Killit made it despawn on explosion

It does work with 'operateactivators 130 0' as long as the sprite's hitag/lotag are 0. Because it had been despawning all the while with hitag 130 I didn't change it when testing the direct 130 commands before
0

#3113

Was wall alignment the problem?
0

User is online   Danukem 

  • Duke Plus Developer

#3114

View Postlllllllllllllll, on 23 November 2022 - 12:47 PM, said:

Was wall alignment the problem?


https://wiki.eduke32.../Eventloadactor

Read that entry, especially the phrase "undesired hardcoded effects". Notice in my example a few posts above I don't keep any tags on the sprite, they are moved into vars and then reset to 0.
0

#3115

Yeah that was the problem sorry
Changing it with EGS kept the collapse behavior. I tried using .extra instead then zeroing it out I guess it failed for the same reason.

On the topic of lotagging sprites I made a 'useractor enemy' and then a few more to switch into it like the hardcoded versions (duckshoot, stayput, jetpack, etc). They work as they should up until trying to Lotag them for difficulty settings- the sprite still spawns but as an unresponsive 1st frame.
Is this like RECOG that it must be faked? If so I can use loadactor to prevent their spawn by comparing skill level?
0

User is online   Danukem 

  • Duke Plus Developer

#3116

View Postlllllllllllllll, on 23 November 2022 - 02:08 PM, said:

On the topic of lotagging sprites I made a 'useractor enemy' and then a few more to switch into it like the hardcoded versions (duckshoot, stayput, jetpack, etc). They work as they should up until trying to Lotag them for difficulty settings- the sprite still spawns but as an unresponsive 1st frame.
Is this like RECOG that it must be faked? If so I can use loadactor to prevent their spawn by comparing skill level?


It's difficult to guess what you are doing wrong with only a vague description and not seeing your code.

My first guess would be the unresponsive sprites are ones that are supposed to be deleted due to the difficulty (i.e. a lotag 3 tagged sprite in a game set on Let's Rock). In that situation what you are describing would happen if you did something to prevent the sprite from being deleted (e.g. changed its size in EVENT_SPAWN). Then the sprite would fail to take statnum 1 and would remain inert.
0

#3117

View PostDanukem, on 23 November 2022 - 08:58 PM, said:

(e.g. changed its size in EVENT_SPAWN).

lol
Are all things of that nature supposed to be in loadactor?
0

User is online   Danukem 

  • Duke Plus Developer

#3118

View Postlllllllllllllll, on 23 November 2022 - 10:53 PM, said:

lol
Are all things of that nature supposed to be in loadactor?


So in other words I was right.

You can change size in EVENT_SPAWN, just be careful.

For example, here is a case from a switch statement I have in that event:

case SHARK
	ifrnd 32 
	cactor DOPEFISH
	else 
	ifg sprite[].xrepeat 4 sizeat 40 40
break


If the actor is slated for deletion, its size is already reduced. So if you check the size first before setting size, you can do so safely.
0

User is offline   VGames 

#3119

Is there a way to check when a player picks up an atomic health?
0

User is offline   Reaper_Man 

  • Once and Future King

#3120

You mean, other than in the ATOMICHEALTH actor code?

You could capture EVENT_KILLIT and check for ATOMICHEALTH, but strictly speaking that doesn't actually guarantee the player picked it up, only that it was deleted. The game doesn't track what sprite or actor added health to the player. You could maybe use player[].ftq to get the current displayed quote, but that is a gross hack that seems pointless.
0

Share this topic:


  • 115 Pages +
  • « First
  • 102
  • 103
  • 104
  • 105
  • 106
  • 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