AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved [ H3LP ] Flip angle horizontally (https://forums.alliedmods.net/showthread.php?t=307903)

CrazY. 05-29-2018 18:01

[ H3LP ] Flip angle horizontally
 
Hello, I'm with a doubt. How I can flip a angle vector horizontally?

I've tried this, but doesn't work as well.

Quote:

The reflected amount (just looking at the maths) would be (180 - angle)

Code:

Angle | Reflection
------+-----------
    0 |        180
  90 |        90
  89 |        91
  91 |        89
  360 |      -180
  270 |        -90

Note the negatives if you fall below the "horizontal plane" - which you could leave as they are, or handle as a special case.

klippy 05-30-2018 03:34

Re: [ H3LP ] Flip angle horizontally
 
Wait, do you have an angle vector (a unit vector pointing into a direction) or a vector of angles in degrees (0-360)?
Even better, show some code.

CrazY. 05-30-2018 09:14

Re: [ H3LP ] Flip angle horizontally
 
So, basically what I'm doing is a lasermine. Based in lasermine angle, I will create a velocity vector by the mine aim (velocity_by_aim) and get the end origin in a distance of 9999. After some tests, I see that when I do this while the mine is placed in wall, it work, but if it is in the ground or in "roof" get the inverse direction than I want. Then if it is on the ground, laser will be generated in ground direction, if in roof, laser will be generated in roof direction. I hope you understand, but this was solved.

Code:
new Float:flVecStart[3], Float:flVecEnd[3], Float:flVecPlane[3], Float:flFraction; entity_get_vector(pPlayer, EV_VEC_origin, flVecStart); getAimOrigin(pPlayer, 65, flVecEnd); engfunc(EngFunc_TraceLine, flVecStart, flVecEnd, DONT_IGNORE_MONSTERS, pPlayer, 0); get_tr2(0, TR_flFraction, flFraction); new pHit = max(get_tr2(0, TR_pHit), 0); if (flFraction == 1.0 || pHit) {     zp_colored_print(pPlayer, "You can't set a lasermine at this location.");     return; } get_tr2(0, TR_vecEndPos, flVecEnd); get_tr2(0, TR_vecPlaneNormal, flVecPlane); vectorMulScalar(flVecPlane, 8.0, flVecPlane); // The mine origin vectorAdd(flVecEnd, flVecPlane, g_flVecAim[pPlayer]); // The mine angles vector_to_angle(flVecPlane, g_flVecAngles[pPlayer]); // The mine laser end point vectorMulScalar(flVecPlane, 9999.0, flVecPlane); vectorAdd(g_flVecAim[pPlayer], flVecPlane, g_flVecEnd[pPlayer]);


All times are GMT -4. The time now is 04:32.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.