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

Jump to content

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

  • 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 online   Trooper Dan 

  • 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 online   Trooper Dan 

  • 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 online   Trooper Dan 

  • 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

Share this topic:


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