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

Jump to content

  • 87 Pages +
  • « First
  • 84
  • 85
  • 86
  • 87
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

#2551

is there any way to read keystrokes in events EVENT_DISPLAYMENU, EVENT_CHANGEMENU, EVENT_SCREEN or when game is paused setuserdef[] .pause_on 2
This could be very useful for creating an inventory interface, for example.
0

User is offline   Sangman 

#2552

Is it possible to detect if the player has a given tilenumber in view? The way I was thinking of doing it was to do a hitscan check from every pixel covering the player's view, but that sounds entirely ridiculous.
Still, we have some functions like ifcansee that work against actors. I probably need that but for textures.


edit:

Apparently this is exposed via the gotpic array in CON.

ife gotpic[tilenum] 1 => means that tilenum is currently visible

The array doesn't reset on its own (there is an EVENT_RESETGOTPICS but from what I can tell from the source code, this only gets called when handling mirrors), but you can do so manually inside your code bock:

setarray gotpic[tilenum] 0

So far performance seems ok

Credit to Mblackwell for letting me know

This post has been edited by Sangman: 10 February 2020 - 09:29 AM

0

User is offline   Danukem 

  • Duke Plus Developer

#2553

View PostSangman, on 10 February 2020 - 06:44 AM, said:


ife gotpic[tilenum] 1 => means that tilenum is currently visible

The array doesn't reset on its own (there is an EVENT_RESETGOTPICS but from what I can tell from the source code, this only gets called when handling mirrors), but you can do so manually inside your code bock:

setarray gotpic[tilenum] 0



Interesting. So what exactly causes the elements to get set? For example, if a certain enemy dies in a place where no players are around, is its dead body tile "in view"? Or does it require that the tile is actually rendered on a screen?
0

User is offline   Sangman 

#2554

Good questions, which I'm sure somebody can answer :D
0

User is offline   F!re-Fly 

#2555

I just had another rather specific idea. I wonder if it really possible that an enemy can patrol freely in an area until he sees the player, in order to attack him? I wonder if modifying a statnum or using a sprite similar to "locator" could do that, to define a route in a sector.

This post has been edited by Firefly Trooper: 19 February 2020 - 12:48 PM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#2556

View PostTrooper Dan, on 10 February 2020 - 09:44 AM, said:

Interesting. So what exactly causes the elements to get set? For example, if a certain enemy dies in a place where no players are around, is its dead body tile "in view"? Or does it require that the tile is actually rendered on a screen?

It requires the tile to be rendered.

This was added so the skybox in Ion Fury would only be drawn if the skybox texture (which is a blank tile) was visible.

Note that it's only set after it's rendered (meaning that in the Ion Fury example there's a 1 frame delay).
1

User is offline   Danukem 

  • Duke Plus Developer

#2557

View PostFox, on 19 February 2020 - 03:56 PM, said:

It requires the tile to be rendered.

This was added so the skybox in Ion Fury would only be drawn if the skybox texture (which is a blank tile) was visible.

Note that it's only set after it's rendered (meaning that in the Ion Fury example there's a 1 frame delay).


I miss-clicked and downvoted you by accident (that was supposed to be an upvote).

Anyway, that's a good feature for saving resources with an expensive command like showview
0

User is offline   Darkus 

#2558

I want to make an actor shoot at, not another actor, but at a specific spot. I have the X/Y coords of both shooter/target, but I don't know how to measure the distance between two spots. There's ldist but it's only useful with sprites, is there an equivalent for points?
0

User is offline   Darkus 

#2559

Found a solution. It's a bit messy, but it consists of teleporting the player, take measurement, and teleport it back.

getplayer[THISACTOR].posx temp1
getplayer[THISACTOR].posy temp2
setplayer[THISACTOR].posx XPOS
setplayer[THISACTOR].posy YPOS
ldist DISTDIFF THISACTOR player[THISACTOR].i
setplayer[THISACTOR].posx temp1
setplayer[THISACTOR].posy temp2


I'm trying to make monsters shoot at the direction of the player's movements (if you played Unreal games, you know what I mean).
0

User is offline   Danukem 

  • Duke Plus Developer

#2560

Seems legit for a Duke hack. I've done stuff like that. But you could have used the Pythagorean theorem and just calculated it.

EDIT: Here, if the vars "hitx" and "hity" are the distant coordinates, and assuming the other vars have been declared, then this will do the job

	set xydist sprite[].x
	sub xydist hitx
	mul xydist xydist
	set y2 sprite[].y
	sub y2 hity
	mul y2 y2
	add xydist y2
	sqrt xydist xydist


This post has been edited by Trooper Dan: 22 March 2020 - 03:56 PM

0

User is offline   Darkus 

#2561

Thanks, it's the example I needed. It works in both cases, I managed to achieve the effect I wanted: making enemies anticipate your moves.

Example, dodging left:

https://i.postimg.cc/Zn3D9vRp/duke-smartshot1.png

Also made a variant that take account of height. This time dodging left and jetpack on, going up:

https://i.postimg.cc/66GPbg0q/duke-smartshot2.png
2

User is offline   Danukem 

  • Duke Plus Developer

#2562

Cool. The old move parameter "faceplayersmart" also does that, although I'm sure it's very primitive.
0

User is offline   Darkus 

#2563

faceplayersmart don't take account of the distance and projectile speed. Just run toward an enemy that using that move, and I see how he turns you back :lol:
0

User is offline   Jblade 

#2564

Some time ago somebody (I'm fairly certain it was Fox) posted some script showing how to use totalclock or something like that to do smooth 60fps weapon swapping animations. Anybody know what I'm talking about and still have it around?
0

User is offline   spacekebab 

#2565

Hey guys, is there a way to cut/mask wall aligned sprites (like blood decals) through con? like cut off or even wrap around the sprite as soon as the wall ends?
0

User is offline   Danukem 

  • Duke Plus Developer

#2566

View Postspacekebab, on 25 May 2020 - 11:20 AM, said:

Hey guys, is there a way to cut/mask wall aligned sprites (like blood decals) through con? like cut off or even wrap around the sprite as soon as the wall ends?


Not sure what you mean. At first I thought you meant prevent them from hanging off of ledges, but now I doubt that.
0

User is offline   spacekebab 

#2567

View PostTrooper Dan, on 25 May 2020 - 11:37 AM, said:

Not sure what you mean. At first I thought you meant prevent them from hanging off of ledges, but now I doubt that.


That's exactly what I meant, sorry - didn't know how to word it.

This post has been edited by spacekebab: 25 May 2020 - 07:16 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2568

View Postspacekebab, on 25 May 2020 - 07:15 PM, said:

That's exactly what I meant, sorry - didn't know how to word it.


There is hardcoding in the base game which prevents the standard BLOODPOOL from hanging over ledges. So one solution is to spawn BLOODPOOL, then in a game event (EVENT_WORLD may be your best choice) cactor BLOODPOOL into your own actor, and change size and pal if needed. Since BLOODPOOL is already in a verified good location, that should be fine (although it won't be if your sprite is much bigger).

If you want to use your own code then I would suggest a loop where you test out some nearby coordinates (nothing fancy, just add and subtract values to your sprites's x and y) and check to see if the floor height is the same if the tested coords are in a different sector. Also you can check for slopes. If checks indicate a bad situation, you can resize or delete your sprite as appropriate.
1

User is offline   Mark 

#2569

I have player weapons not flashing the screen during firing but haven't been able to do the same for the enemies. I didn't find anything with a quick browse thru the wiki. I'm using Polymer in case it makes a difference.

Maybe set PROJ_FLASH_COLOR to all 0's? Or is there a global command?

This post has been edited by Mark: 29 August 2020 - 01:47 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2570

What exactly are the enemies shooting that is making the screen flash?
0

User is offline   Mark 

#2571

pistol, shotgun, chaingun ( machine gun ) They are already custom coded from previous owner of the project. This might complicate your answer. I was hoping for a simple global command or similar.

This post has been edited by Mark: 29 August 2020 - 03:37 PM

0

User is offline   Danukem 

  • Duke Plus Developer

#2572

I can't tell from your description whether there are polymer lights being spawned when the projectiles fire, whether they are flashing the world in the old-fashioned way (setting global visibility for a moment), or whether they have been specially coded to literally flash the screen (via palfrom or equivalent).

The flash color thing might work if they are polymer lights.
0

User is offline   Mark 

#2573

I'll check again to be sure. I think its polymer. Be right back.

edit: Because of how large an area weapons light up in the map I thought it might be the usual sector based flashing. But switching to Polymost stopped any weapon flashing. So even though the mod is ancient, eduke32 is supplying the flash thru Polymer. Can I just set the PROJ_FLASH with a gamevar or is it an event thing? In all my years of coding I have never messed with weapons. I'm a noob once more. ;)

This post has been edited by Mark: 29 August 2020 - 04:13 PM

0

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

Share this topic:


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