EDuke32 Scripting "CON coding help"
#1861 Posted 21 February 2016 - 06:35 AM
I need a function that takes parameters: camerax,cameray,cameraz,camerasect,camerahoriz,cameraang, screenx,screeny (xd,yd) and return x,y,z in build coordinates.
Can somebody help with programming such functions for non classic modes?
#1862 Posted 29 February 2016 - 11:38 PM
Now we need to translate it into the CON
input: x, y, Fov, pan, tilt, w, h
output: panRes, tiltRes
pan = tofloat( get("camera","pan") ); tilt = tofloat( get("camera","tilt") ); fov = tofloat( get("camera","fov") ); w = tofloat( get( "applet", "width" ) ); h = tofloat( get( "applet", "height" ) ); x = tofloat( x ); y = tofloat( y ); r = (sqrt(w*w + h*h) / 2.0) / tan( gradToRad(fov/2.0) ); vx = r; vy = w/2.0 - x; vz = h/2.0 - y; pan = gradToRad( pan ); tilt = gradToRad( -tilt ); cosp = cos( pan ); sinp = sin( pan ); cost = cos( tilt ); sint = sin( tilt ); /*My * Mz*/ vx2 = vx*cost*cosp - vy*sinp + vz*cosp*sint; vy2 = vx*cost*sinp + vy*cosp + vz*sint*sinp; vz2 = -vx*sint + vz*cost; sinRes = vy2 / sqrt(vx2*vx2 + vy2*vy2); panRes = radToGrad( asin(sinRes) ); if( vx2 <= 0 && vy2 > 0 ) panRes = 180 - panRes; else if( vx2 < 0 && vy2 <= 0 ) panRes = -180 - panRes; sinRes = vz2 / sqrt(vx2*vx2 + vy2*vy2 + vz2*vz2); tiltRes = radToGrad( asin(sinRes) );
Where:
w, h - width and height of Java Applet (pixels);
Fov - current field of view angle (degrees);
pan, tilt - camera direction point (degrees).
panRes, tiltRes - model coordinates of clicked (x, y) point (degrees).
x, y - screen clicked point coordinates (pixels);
r - panorama model sphere radius;
vx, vy, vz - coordinates of vector from origin to picked point in projection plane;
vx2, vy2, vz2 - transformed vector of picked point.
#1864 Posted 01 March 2016 - 05:05 AM
Fox, on 01 March 2016 - 12:35 AM, said:
Thank you captain! Hitscan does not take into account the position of the cursor on the screen. I need the ability to select objects on the screen by mouse cursor
This post has been edited by Mr. Alias Nameless: 01 March 2016 - 05:06 AM
#1866 Posted 01 March 2016 - 06:17 AM
Fox, on 01 March 2016 - 05:21 AM, said:
Yes, of course I have coded a cursor. But how to use the cursor position in the hitscan function?
#1867 Posted 01 March 2016 - 06:33 AM
#1868 Posted 01 March 2016 - 07:47 AM
Mr. Alias Nameless, on 01 March 2016 - 06:17 AM, said:
Use getangle to determine the angle in relation to the screen cordinates (320px = 90º). Remember that when you are looking up or down the view differs drastically between classic and OpenGL modes.
#1869 Posted 01 March 2016 - 09:49 AM
#1870 Posted 02 March 2016 - 01:04 AM
Fox, on 01 March 2016 - 07:47 AM, said:
thank you this is useful.
Trooper Dan, on 01 March 2016 - 09:49 AM, said:
It is very difficult, due to the fact that there is no floating-point numbers in CON. And there is always the risk of overflow.
#1871 Posted 07 March 2016 - 01:54 PM
Maybe I can draw a graphic on top of where the string appears? EDIT: Nope, it looks like it is only possible to detect whether the player is in a menu, but not which specific menu, unless I am missing something.
This post has been edited by Trooper Dan: 07 March 2016 - 02:05 PM
#1872 Posted 07 March 2016 - 02:50 PM
#1873 Posted 07 March 2016 - 04:12 PM
gamevar screenx 0 0 gamevar screeny 0 0 defstate menuwhatever getuserdef .m_origin_x screenx getuserdef .m_origin_y screeny ifvare current_menu 110 // MENU_SKILL { // use screentext with the <<16 bit set, and *add* the coordinates you want to draw to screenx/y so it animates with the menu } ends onevent EVENT_DISPLAYMENUREST state menuwhatever endevent onevent EVENT_DISPLAYINACTIVEMENUREST state menuwhatever endevent
#1874 Posted 07 March 2016 - 07:55 PM
#1875 Posted 08 March 2016 - 06:04 AM
#1876 Posted 08 March 2016 - 08:26 AM
gamevar screenx 0 0 gamevar screeny 0 0 defstate menuwhatever getuserdef .m_origin_x screenx getuserdef .m_origin_y screeny ifvare RETURN 110 // MENU_SKILL { // use screentext with the <<16 bit set, and *add* the coordinates you want to draw to screenx/y so it animates with the menu } ends onevent EVENT_DISPLAYMENUREST state menuwhatever endevent onevent EVENT_DISPLAYINACTIVEMENUREST state menuwhatever endevent
#1877 Posted 18 March 2016 - 12:13 PM
#1878 Posted 18 March 2016 - 03:43 PM
#1879 Posted 18 March 2016 - 04:10 PM
#1880 Posted 18 March 2016 - 06:06 PM
#1881 Posted 18 March 2016 - 09:22 PM
Fox, on 18 March 2016 - 03:43 PM, said:
Most of the sprites in question are pickable objects, such as ammo. Doing what you suggest would cause the player to pick them up in some cases. What I'm going for is a kind of X-ray vision that reveals objects in secret areas. But it's okay, I've decided I don't really need it, I can make do with something else.
#1882 Posted 18 March 2016 - 11:56 PM
Fox, on 18 March 2016 - 06:06 PM, said:
That's why I said move the sprite next to the player like you suggested but keep it's tspr x and y values at its original location. Anyways what I suggested is not what Dan was looking for, the ability to do that would be insanely useful though.
This post has been edited by Jblade: 18 March 2016 - 11:58 PM
#1883 Posted 19 March 2016 - 12:06 AM
This post has been edited by Fox: 19 March 2016 - 12:07 AM
#1884 Posted 29 April 2016 - 12:02 PM
1. I already created casings that drop on the ground. However, I would like the casings to be visible in first person as they leave the weapon (like the original sprite ones). I know I can modify the angle horizontally that they appear as such, but then the casings drop in front of Duke instead of next to him. I use code such as this:
ifactor RIFLESHELL { move FORWARD getactor[THISACTOR].ang TEMP subvar TEMP -412 randvar TEMP2 128 addvarvar TEMP TEMP2 setactor[THISACTOR].ang TEMP }
I know the fix is probably easy and I'm missing something obvious, but do help a brother out here.
2. Is it possible for the Eggs and Sharks to be counted in the overall tally count BEFORE killing them? (as in, the mid level enemy count that can be turned on in eDuke can show the proper number of enemies instead of an estimate)
#1885 Posted 29 April 2016 - 12:34 PM
move FORWARD getactor[THISACTOR].ang TEMP subvar TEMP -412 randvar TEMP2 128 addvarvar TEMP TEMP2 setactor[THISACTOR].ang TEMP getactor[THISACTOR].owner TEMP8 setvarvar TEMP3 sprite[TEMP8].x addvar TEMP3 256 getactor[TEMP8].ang TEMP4 addvar TEMP4 128 rotatepoint sprite[TEMP8].x sprite[TEMP8].y TEMP3 sprite[TEMP8].y TEMP4 TEMP5 TEMP6 setactor[THISACTOR].x TEMP5 setactor[THISACTOR].y TEMP6 getactor[TEMP8].z TEMP subvar TEMP 8096 ifspawnedby APLAYER { getplayer[THISACTOR].horiz TEMP2 subvar TEMP2 100 mulvar TEMP2 16 subvarvar TEMP TEMP2 } setactor[THISACTOR].z TEMP
Hopefully you can get a gist of what needs doing. I'm sure the code could be improved but I have a dozen other things that need working on at the same time.
This post has been edited by Jblade: 29 April 2016 - 12:35 PM
#1887 Posted 12 August 2016 - 02:21 AM
Mr. Alias Nameless, on 21 February 2016 - 06:35 AM, said:
I need a function that takes parameters: camerax,cameray,cameraz,camerasect,camerahoriz,cameraang, screenx,screeny (xd,yd) and return x,y,z in build coordinates.
Can somebody help with programming such functions for non classic modes?
I did it!
This post has been edited by Mr. Alias Nameless: 12 August 2016 - 02:23 AM
#1889 Posted 15 August 2016 - 11:42 PM
Mblackwell, on 12 August 2016 - 12:46 PM, said:
What do you mean? Screen resolution - yes to all. Aspect setted up by setaspect function - halfway, it is necessary to choose the coefficients for each values of "viewingrange" and "yxaspect". Now I try to find a mathematical relationship.
This post has been edited by Mr. Alias Nameless: 15 August 2016 - 11:47 PM
#1890 Posted 18 August 2016 - 04:44 PM
below the ifwasweapon SHOTSPARK1:
sound SOMETHINGHITFORCE spawn TRANSPORTERSTAR spritepal 7
This post has been edited by stumppy84: 18 August 2016 - 05:20 PM