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

Jump to content

  • 119 Pages +
  • « First
  • 29
  • 30
  • 31
  • 32
  • 33
  • Last »
  • You cannot start a new topic
  • You cannot reply to this topic

EDuke32 Scripting  "CON coding help"

User is offline   Reaper_Man 

  • Once and Future King

#901

Feature request: Variants of dist / ldist which accept arbitrary X/Y/Z positions.
0

User is online   Hendricks266 

  • Weaponized Autism

  #902

Should be simple. What should the names of these commands be? {l,}distxyz?

I've been thinking of incorporating some of the math commands added in EDuke 2.1.1, though obviously not the dumb ones like finddist2d. Thoughts?
0

User is offline   Mikko 

  • Honored Donor

#903

What's the code for making an actor permanently blocked (hittable) whether or not the corresponding sprite is blocked in Build?
0

User is offline   CruX 

#904

^^ cstat 257.
0

User is offline   Mikko 

  • Honored Donor

#905

Cool, that gave me a place to start and I found out 256 is what I need.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#906

Actually a cstat of 1 prevents other sprites of passing through it, while a cstat of 256 makes it shootable. Theorically it's possible to make an sprite which you can pass through and still hit it with bullets. And even with cstat 0 the sprite still takes damage from explosions.

This post has been edited by Fox: 19 September 2012 - 05:51 AM

1

User is offline   Mikko 

  • Honored Donor

#907

Nah, I have no experience with cons so I assumed a blocked object blocks automatically both bullets and players but now I know they can be separated.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#908

Additionally, I should tell the mappers that the source code automatically makes blocked objects shootables when they are loaded.

But using CON you can force them to remain only blocked. So you can have objects like Doom, which block your passage but let projectiles fly across it.
1

User is offline   Mikko 

  • Honored Donor

#909

View PostFox, on 19 September 2012 - 06:18 AM, said:

Additionally, I should tell the mappers that the source code automatically makes blocked objects shootables when they are loaded.


Maybe that's why I assumed they (blocking players & blocking bullets) are one and the same.
0

User is offline   Helixhorned 

  • EDuke32 Developer

#910

View PostHendricks266, on 18 September 2012 - 11:53 PM, said:

Should be simple. What should the names of these commands be? {l,}distxyz?

Adding these seems sensible, since what we have now with dist and ldist can lead to kind of API-inverted code ("set sprite positions, call dist, reset positions." Ugh.)
By the way, they compute pretty crude approximations to the hypotenuse length, for example ldist is
125/128 * max(x,y) + 53/128 * min(x,y).
See the second answer for this question on stackoverflow for the idea behind it (53/128 = 0.41406, sqrt(2)-1 = 0.41421, approximately).

Quote

I've been thinking of incorporating some of the math commands added in EDuke 2.1.1, though obviously not the dumb ones like finddist2d. Thoughts?

I'm less sure about those ones being useful. The composite ones like "sin(a - b)" can make sense in a floating point setting, where computing them in a special fashion may significantly increase accuracy, but with integers being the only numeric type in CON, there's not much to be gained. For the hypotenuse length, we have calchypotenuse (unwieldy long name for fear of name collisions). I'm not very happy with the way it turned out though, it currently has a discontinuity at the squared hypotenuse equalling INT32_MAX. X raised to the Yth power is something that CON is missing, but again, with only integers there doesn't seem to be much use for it, since you'd most often use Y=2 or Y=3. Mod and abs would not add anything really new. This leaves the tangent and the logarithm: the first can be calculated by a ratio of the sine to the cosine (with appropriate scaling), and a base-2 log could be useful (but possible to code as loop currently[*]), the natural one looking out of place again.

[*]edit: I'm thinking about the rounded variety here, like "log2(9)=3".
0

#911

Is the FOV accessible through CON?

If not, would this be at all possible to implement? I can see several potential uses for this.
0

User is offline   Reaper_Man 

  • Once and Future King

#912

I was thinking distpos/ldistpos but distxyz/ldistxyz would be fine (though it should probably be ldistxy since it only calculates 2D distances, right?).

As far as adding math commands, I think the more coding features into the engine is always better. The "power" or exponent math would be very attractive for some stuff I'm doing (expvar and expvarvar?). I think having better trig functions would be awesome, but exactly which ones or how they're implemented I'll leave guessing up to people more involved.

This post has been edited by Reaper_Man: 19 September 2012 - 12:25 PM

0

User is offline   Helixhorned 

  • EDuke32 Developer

#913

View PostReaper_Man, on 19 September 2012 - 11:41 AM, said:

The "power" or exponent math would be very attractive for some stuff I'm doing (expvar and expvarvar?).

Do you need the ability to pass fractional bases or exponents? In that case, we'd need to decide where to place the implicit binary point. (Or pass numerator and denominator separately, but I guess that would be just as confusing.)

Quote

I think having better trig functions would be awesome, but exactly which ones or how they're implemented I'll leave guessing up to people more involved.

In which way "better"? CON's sine and cosine have 15 bits of precision. Approximate arctangent is there (getangle), tangent can be calculated as mentioned previously. Is there anything practical missing?
0

User is offline   Reaper_Man 

  • Once and Future King

#914

In my code specifically I just need something like var1 ^ var2.

I'm sorry I meant "more" and not "better". I also can't think of anything off hand, I haven't had to do trig math in eduke in a while, so hopefully someone else can field that better.

EDIT
An absolute value command would be useful too (absvar).

This post has been edited by Reaper_Man: 19 September 2012 - 02:21 PM

0

#915

I think you could use a whilevarn loop to emulate the exponential function (it works only with integers) and a line like this:
 ifvarl X 0 mulvar X -1 

for the "absvar" function.
0

User is online   Hendricks266 

  • Weaponized Autism

  #916

View PostReaper_Man, on 19 September 2012 - 11:41 AM, said:

I was thinking distpos/ldistpos but distxyz/ldistxyz would be fine (though it should probably be ldistxy since it only calculates 2D distances, right?).

I like yours better.

View PostReaper_Man, on 19 September 2012 - 11:41 AM, said:

The "power" or exponent math would be very attractive for some stuff I'm doing (expvar and expvarvar?).

I used to think this but then I realized I only wanted it for ^0.5 to do a square root and then I discovered the sqrt command. Generally you'll only want a square or cube, so you can mulvarvar 2-3 times. Much more and the int32s could overflow.

View PostHelixhorned, on 19 September 2012 - 12:38 PM, said:

Do you need the ability to pass fractional bases or exponents? In that case, we'd need to decide where to place the implicit binary point. (Or pass numerator and denominator separately, but I guess that would be just as confusing.)

This reminds me: there are two things I have promised to add that will have to involve integer <--> float conversion for use in CON. One is a "rotatemodel" command which will be rotatesprite with additional model parameters such as pitch and roll added. The other is a userdef control for the ambient light level. Should I use the same mulscale implementation as the trig commands, use a numerator/denominator style, or something different? I like the fraction myself.
0

User is offline   Mblackwell 

  • Evil Overlord

#917

View PostRichardStorm, on 19 September 2012 - 03:15 PM, said:

I think you could use a whilevarn loop to emulate the exponential function (it works only with integers) and a line like this:
 ifvarl X 0 mulvar X -1 

for the "absvar" function.



Yes it works. My code is littered with things like that. It's not only a wasted cycle/computation it's longer code. It's stupid to run If-Then when you don't need to.
0

User is online   Hendricks266 

  • Weaponized Autism

  #918

View PostMblackwell, on 19 September 2012 - 05:36 PM, said:

Yes it works. My code is littered with things like that. It's not only a wasted cycle/computation it's longer code. It's stupid to run If-Then when you don't need to.

Unless there is a measurable impact of that you can show me, implementing expvar and absvar commands would only perform those instructions on the source side. It would by far be the most optimal way to implement them. Anything else (including going through C math.h functions) would be even slower, which is still only a relative term.

The execution of the CON VM is nowhere close to being a bottleneck. With a constant, maximum 30 game states per second performance requirement, some simple math doesn't have much impact.
0

User is offline   Mblackwell 

  • Evil Overlord

#919

I'm speaking strictly from the CON side. It can affect performance if you do it multiple times in a row for multiple objects for multiple tics. Even if you never notice the difference up front it's always good to have optimized code, and to reduce code size and increase clarity where possible.

Dig?
0

User is offline   Reaper_Man 

  • Once and Future King

#920

I know most of us are used to having to use dirty little tricks like that, but I still think implementing it as a real math function is preferable.

As for floating point math, I'm well used to the dirty trick of multiplying vars by 10 or 100 depending on what decimal place I'll need access to, then diving back down when I'm done. Like I said, used to doing dirty tricks.

This post has been edited by Reaper_Man: 19 September 2012 - 07:36 PM

0

User is offline   Helixhorned 

  • EDuke32 Developer

#921

View PostHendricks266, on 19 September 2012 - 04:47 PM, said:

This reminds me: there are two things I have promised to add that will have to involve integer <--> float conversion for use in CON. One is a "rotatemodel" command which will be rotatesprite with additional model parameters such as pitch and roll added. The other is a userdef control for the ambient light level. Should I use the same mulscale implementation as the trig commands, use a numerator/denominator style, or something different? I like the fraction myself.

The additional parameters for "rotatemodel" being angles, I suggest going the least surprising route and making them BUILD angles (0..2047). For the ambient light, scaling by 100 would be convenient, I think, so that values from 0 to 1000 correspond to r_ambientlight of 0 to 10.
0

#922

'lil bump... How to make a piercing/trepassing rpg-type projectile ?
0

User is offline   Mblackwell 

  • Evil Overlord

#923

View PostHelixhorned, on 20 September 2012 - 12:48 AM, said:

The additional parameters for "rotatemodel" being angles, I suggest going the least surprising route and making them BUILD angles (0..2047). For the ambient light, scaling by 100 would be convenient, I think, so that values from 0 to 1000 correspond to r_ambientlight of 0 to 10.


But you'd lose a lot of the accuracy that way (rotation). It would be better to use something similar to the z parameter so 32768 is half, 65536 is a full rotation if you want it to be flawless. However I believe you're correct and the current pitch/yaw/roll parameters accept/use -1024 to 1024
0

User is online   Hendricks266 

  • Weaponized Autism

  #924

View PostRichardStorm, on 20 September 2012 - 04:23 AM, said:

'lil bump... How to make a piercing/trepassing rpg-type projectile ?

I believe you need to add code so that when any actor is hit by one, it shoots another one with the same values gathered from the ht* members.
0

User is offline   Mblackwell 

  • Evil Overlord

#925

View PostHendricks266, on 20 September 2012 - 04:15 PM, said:

I believe you need to add code so that when any actor is hit by one, it shoots another one with the same values gathered from the ht* members.


That's correct unless you do weird tricks like change the spritestat to actor, move the actor, and then change it back to a projectile. But now I've just confused the situation.
0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#926

View PostHendricks266, on 20 September 2012 - 04:15 PM, said:

I believe you need to add code so that when any actor is hit by one, it shoots another one with the same values gathered from the ht* members.

True, I did something like that with hitscan to make a Railgun. It worked very well in the end.

By the way, the Railgun in Shadow Warrior is veeery lame, while the trail spawns behind any actor (until it hits a wall), the shoot itself stops when it hits the first obstacle. So it gives the illusion of piercing, but in reality he doesn't do that.
0

User is online   Hendricks266 

  • Weaponized Autism

  #927

View PostFox, on 21 September 2012 - 12:08 AM, said:

By the way, the Railgun in Shadow Warrior is veeery lame, while the trail spawns behind any actor (until it hits a wall), the shoot itself stops when it hits the first obstacle. So it gives the illusion of piercing, but in reality he doesn't do that.

This is sadly true. I wanted to test the Railgun's capabilities so I made a test map with a ninja of every SW sprite pal (0-32) lined up in a very narrow corridor, with a dead end on one end and a window with a raised ledge on the other so I could shoot them with impunity. I was very disappointed when they took 33 shots to kill.
1

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#928

Also I should point out that adding a hitscan trail in Eduke32 does the same thing: the shot gives the illusion of piercing when it doesn't.
0

#929

I think to use the coolexplosion type in some ways, but it seems to be invisible, not working, or broken... Anybody knows how to use it ? I would also appreciate the completion of voices in this page of the wiki http://wiki.eduke32..../PROJ_WORKSLIKE

This post has been edited by RichardStorm: 21 September 2012 - 02:57 AM

0

User is offline   Fox 

  • Fraka kaka kaka kaka-kow!

#930

You can make a projectile like Coolexplosion1 manually.
0

Share this topic:


  • 119 Pages +
  • « First
  • 29
  • 30
  • 31
  • 32
  • 33
  • 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