Massassi Forums Logo

This is the static archive of the Massassi Forums. The forums are closed indefinitely. Thanks for all the memories!

You can also download Super Old Archived Message Boards from when Massassi first started.

"View" counts are as of the day the forums were archived, and will no longer increase.

ForumsCog Forum → I need a better math wiz then me!
I need a better math wiz then me!
2003-08-17, 4:59 AM #1
Okay, here's the problem. I'm working on a radar system that picks up an actor or player and prints in on a little display on the screen. I can find and locate tehm and scale it properly to fit the screen.

The problem is this, how do I get the things' distance and vector to correspond correctly from the game to the screen and outputting using FireProjectile verb to correct for the player's headpitch. ie What is the formula to rotate the scaled VectorSub and distance 90º and creating the final thing with FireProjectile().

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-08-17, 5:51 PM #2
Anyone? Questions or solutions.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-08-18, 3:40 AM #3
Let me get this straight, you want a radar that will always be centered to the player, whether or not the head is pitched?

If you rotate question was asking to find the vector 90 degrees upward, then GetThingUVec(thing); *should* work (i've never actually tested it)

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-08-18, 10:35 AM #4
Kinda no, and no. I just want to use the FireProjectile() verb because that corrects for the headpitch of the player. But I want to rotate the direction of the thing to player 90º upwards.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-08-18, 7:33 PM #5
SM! GBK! Hellcat! HR! Checksum! Anyone out there who can help me!!!!

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-08-19, 1:29 PM #6
Even if you say you can't do anything. Please post or give me some suggestions or tell me something. Please, I need help!

Also, I have another question. I have this cog here and whenever I try to delete a sentry, it always reverts back to the normal view. And ideas?
Code:
Timer:
   If(GetSenderID() == 1)
      canMove = 1;
   Else If(GetSenderID() == 3)
      canDestroy = 1;
   Else
      StopKey(player, holsterTrack, 0);
   Return;

# ........................................................................................

Pulse:
   If(GetCurrentCamera()) CycleCamera();
   SetThingPos(player, pos);
   id = cur;

   If(IsThingCrouching(player) && canDestroy)
   {
      dummy = 0;
      For(i=cur; !dummy; i=i+1)
      {
         If(GetThingUserData(i) <= 300 && GetThingTemplate(i) == sentry)
         {
            If(IsMulti())
            {
               For(j=0; j<GetNumPlayers(); j=j+1)
               {
                  If((GetMultiModeFlags() & 0x1) && (GetPlayerTeam(j) == GetPlayerTeam(player)))
                  {
                     If(GetThingParent(i) == GetPlayerThing(j))
                     {
                        cur = i;
                        dummy = 1;
                     }
                  }
               }
            }
            If((!IsMulti()) || (!BitTest(GetMultiModeFlags(), 0x1)))
            {
               If(GetThingParent(i) == player)
               {
                  cur = i;
                  dummy = 1;
               }
            }
         }
         If(i >= GetThingCount()) i = 0;
         If(i == cur-1 && (!dummy)) dummy = -1;
      }
      // The reason why we doing everything here is because
      // We don't want to send a message to the old sentry
      If(dummy == -1)
      {
         SetCameraFocus(0, player);
         SetThingPos(player, pos);
         SetThingLook(player, Lvec);
         ClearActorFlags(player, 0x800000);
         If(GetCurrentCamera() != origanalCam) CycleCamera();
         SetPulse(0);
         on = 0;
      }
      Else
      {
         SetCameraFocus(0, cur);
         SendMessageEx(GetThingClassCog(cur), user0, cur, 1, 0, 0);
         DestroyThing(dummy);
         SetTimerEx(.25, 1, 0, 0);
         canMove = 0;
      }
      SetTimerEx(.05, 3, 0, 0);
      canDestroy = 0;
      DestroyThing(id);
      Return;
   }
   // This is so you can only destroy one per keypress
   If(IsThingCrouching(player) && !canDestroy)
   {
      KillTimerEx(3);
      SetTimerEx(.05, 3, 0, 0);
   }

   If(canMove)
   {
      If(VectorX(GetThingThrust(player)) > 0)
      {
         dummy = 0;
         For(i=cur; !dummy; i=i+1)
         {
            If(GetThingUserData(i) <= 300 && GetThingTemplate(i) == sentry)
            {
               If(IsMulti())
               {
                  For(j=0; j<GetNumPlayers(); j=j+1)
                  {
                     If((GetMultiModeFlags() & 0x1) && (GetPlayerTeam(j) == GetPlayerTeam(player)))
                     {
                        If(GetThingParent(i) == GetPlayerThing(j))
                        {
                           cur = i;
                           dummy = 1;
                        }
                     }
                  }
               }
               If((!IsMulti()) || (!BitTest(GetMultiModeFlags(), 0x1)))
               {
                  If(GetThingParent(i) == player)
                  {
                     cur = i;
                     dummy = 1;
                  }
               }
            }
            If(i >= GetThingCount()) i = 0;
            If(i == cur-1 && (!dummy)) dummy = -1;
         }
         SetTimerEx(.25, 1, 0, 0);
         canMove = 0;
      }
      Else If(VectorX(GetThingThrust(player)) < 0)
      {
         dummy = 0;
         For(i=cur; !dummy; i=i-1)
         {
            If(GetThingUserData(i) <= 300 && GetThingTemplate(i) == sentry)
            {
               If(IsMulti())
               {
                  For(j=0; j<GetNumPlayers(); j=j+1)
                  {
                     If((GetMultiModeFlags() & 0x1) && (GetPlayerTeam(j) == GetPlayerTeam(player)))
                     {
                        If(GetThingParent(i) == GetPlayerThing(j))
                        {
                           cur = i;
                           dummy = 1;
                        }
                     }
                  }
               }
               If((!IsMulti()) || (!BitTest(GetMultiModeFlags(), 0x1)))
               {
                  If(GetThingParent(i) == player)
                  {
                     cur = i;
                     dummy = 1;
                  }
               }
            }
            If(i < 0) i = GetThingCount();
            If(i == cur+1 && (!dummy)) dummy = -1;
         }
         SetTimerEx(.25, 1, 0, 0);
         canMove = 0;
      }
   }
   SetCameraFocus(0, cur);
   SendMessageEx(GetThingClassCog(id), user0, id, -1, 0, 0);
   SendMessageEx(GetThingClassCog(cur), user0, cur, 1, 0, 0);
   dummy = FireProjectile(player, ghost, -1, -1, '0 0 0', '0 0 0', 0,0,0,0);
   SetThingLook(cur, GetThingLvec(dummy));
   DestroyThing(dummy);
   Return;
I know this is only a part of the code, but no stealing off of this idea of mine, if you can even understand it. [http://forums.massassi.net/html/tongue.gif]

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!

[This message has been edited by Descent_pilot (edited August 19, 2003).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-08-19, 3:23 PM #7
not sure if this will help but...
couldnt you just switch the X and Z cords or something like that to rotate the vector 90º?

------------------
Famous last words - "It seemed like a good idea at the time."
Famous last words - "It seemed like a good idea at the time."
2003-08-21, 3:36 AM #8
One more question about the rotation, do you want it to rotate like this
Code:
P+

Px

P+

Where the ghost (+) turns 90 degrees around itself (doesn't change X/Y/Z coords.)
Or
Code:
P+
--------
 +
P
--------
+
P

Where the ghost changes X/Y/Z coords to go from in front of the player to above him?

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"


[This message has been edited by SG-fan (edited August 21, 2003).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-08-21, 5:13 AM #9
DSLS, thank you. That idea didn't work, but that did help me come up with a solution that will. To rotate a normal vector +90º pitch, flip the Y (forward) and Z (up/down). (X is left right, so that would rotate it 90º roll [http://forums.massassi.net/html/tongue.gif]) Thank you.

BTW - Here's the logical way of thinking. Since you are rotating it along the pitch axis, you don't want to change the left/right posistion. So if you flip the foward with the height, you'll make the hieght be equal to the forward distance and thats kinda redundant, but you get the idea, nuh? [http://forums.massassi.net/html/tongue.gif]

edit - sorry for not being clear on what axis I wanted to rotate on. And SG-fan, I wanted to do it like RotatePivot(). So uh, yeah. [http://forums.massassi.net/html/redface.gif]

edit edit - Wow, I wish I had thought of that verb sooner.... Now all I need is the second question with the code answered. Anyone up to the challenge?

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!

[This message has been edited by Descent_pilot (edited August 21, 2003).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack
2003-08-21, 6:13 PM #10
It would really help to have the whole code to actually debug it, but if you don't want to... try adding a print here
Code:
      // The reason why we doing everything here is because
      // We don't want to send a message to the old sentry
      If(dummy == -1)
      {
#----> print("debug");
         SetCameraFocus(0, player);
         SetThingPos(player, pos);
         SetThingLook(player, Lvec);
         ClearActorFlags(player, 0x800000);
         If(GetCurrentCamera() != origanalCam) CycleCamera();
         SetPulse(0);
         on = 0;
      }

see if that prints anything.

------------------
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"

[This message has been edited by SG-fan (edited August 21, 2003).]
Sam: "Sir we can't call it 'The Enterprise'"
Jack: "Why not!"
2003-08-21, 7:15 PM #11
At least my logic is right in this section. [http://forums.massassi.net/html/biggrin.gif] Thankyou, but I've found the problem. I've got a failsafe installed so when a sentry is destroyed, you revert back to the normal view. So all the code was needed and yeah, small logic problem. Thanks anyways, sorry for my gripes and your time.

------------------
The Sniper Missions. Current project, The Sniper Missions

The Magician Saber System.

The 2 riddle!

[This message has been edited by Descent_pilot (edited August 21, 2003).]
Major projects working on:
SATNRT, JK Pistol Mod, Aliens TC, Firearms

Completed
Judgement Day (HLP), My level pack

↑ Up to the top!