TribesNext

Welcome, Guest. Please login or register.
Did you miss your activation email?


TribesNext >  TribesNext.com Forums >  Tribes 2 >  Mods and Customization >  Airfield « previous next »
Pages: [1] Print
Author Topic: Airfield
4TR3X
Nugget²
Posts: 63

View Profile
July 21, 2009, 04:22:40 PM »
Got a problem with my airfield. Basically its a forcefield but instead of being vertical its horizontal and the centre of the platform is the centre of the emitter(but 8m above it).

The problem I am having is the location of the forcefield in comparison with the emitter is different depending on wether I look north, south, east or west. This is the code for that;

Code:
function SmallForceFieldDeployableImage::onDeploy(%item, %plyr, %slot)
{   
   $team = %plyr.client.team;
   $owner = %plyr.client;
   
   %xform = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
   %rot = %item.rotation;
   
   %fBase = 3.00;  // this constant is 1/2 forcefield width on the x-coordinate (i.e. %fBase = 4.0, forcefield width = 8.0)
     %dis = 1.22;  // this constant is distance from deployed to forcefield
   
   %deplTrf = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
     
   %plyrPos = (getWord(%deplTrf, 0)) @ " " @ (getWord(%deplTrf, 1)) @ " " @ (getWord(%deplTrf, 2)); // X(east), Y, Z -sb 
   $deplRot = %plyr.rotation;
   
   if(getWord(%plyr.rotation,2) == -1)
      %angle = 3.1415 / (180.0 / (360.0 - (getWord(%plyr.rotation,3))));
   else
      %angle = 3.1415 / (180.0 / getWord(%plyr.rotation,3));
       
   %alpha = %dis / (180 / (3.1415 /mTan(%fBase))); // [(%dis) is deployed to forcefield distance] ; [(%fBase) is length of forcefield x-axis]
   %theta = 180.0 - (90.0 + %alpha);               // [(%theta) is angle to forcefield origin (x,y) coordinates from players view angle]
   %rTheta = 3.1415 / (180.0 / %theta);            // [convert (%theta) to radians]
   %vecA = %fBase / mCos(%alpha);                  // [vector length from deployed to forcefield origin (x,y) coordinates]
     
   %xAdd = -6.000;
   %yAdd = -6.000;
   %zAdd = 1.000;

   %vSum = (%xAdd @ " " @ %yAdd @ " " @ %zAdd);
   $deplPos = VectorAdd(%plyrPos, %vSum);
 
   %obj.shield = Parent::onDeploy(%item, %plyr, %slot); 
   return %obj.shield;
}

This is the standard forcefield orientation code I have which aligns it in the middle of the emitter when vertical;

Code:
function SmallForceFieldDeployableImage::onDeploy(%item, %plyr, %slot)
{   
   $team = %plyr.client.team;
   $owner = %plyr.client;
   
   %xform = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
   %rot = %item.rotation;
   
   %fBase = 3.00;  // this constant is 1/2 forcefield width on the x-coordinate (i.e. %fBase = 4.0, forcefield width = 8.0)
     %dis = 1.22;  // this constant is distance from deployed to forcefield
   
   %deplTrf = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
     
   %plyrPos = (getWord(%deplTrf, 0)) @ " " @ (getWord(%deplTrf, 1)) @ " " @ (getWord(%deplTrf, 2)); // X(east), Y, Z -sb 
   $deplRot = %plyr.rotation;
   
   if(getWord(%plyr.rotation,2) == -1)
      %angle = 3.1415 / (180.0 / (360.0 - (getWord(%plyr.rotation,3))));
   else
      %angle = 3.1415 / (180.0 / getWord(%plyr.rotation,3));
       
   %alpha = %dis / (180 / (3.1415 /mTan(%fBase))); // [(%dis) is deployed to forcefield distance] ; [(%fBase) is length of forcefield x-axis]
   %theta = 180.0 - (90.0 + %alpha);               // [(%theta) is angle to forcefield origin (x,y) coordinates from players view angle]
   %rTheta = 3.1415 / (180.0 / %theta);            // [convert (%theta) to radians]
   %vecA = %fBase / mCos(%alpha);                  // [vector length from deployed to forcefield origin (x,y) coordinates]
     
   %xAdd = %vecA * mSin(%angle - %rTheta);
   %yAdd = (%vecA * mCos(%angle - %rTheta))-0.100;
   %zAdd = 1.000;

   %vSum = (%xAdd @ " " @ %yAdd @ " " @ %zAdd);
   $deplPos = VectorAdd(%plyrPos, %vSum);
 
   %obj.shield = Parent::onDeploy(%item, %plyr, %slot); 
   return %obj.shield;
}

Does anyone know the code so I can orientate the forcefield platform centred over the emitter whichever direction I look? If so could you also explain it.
4TR3X
Nugget²
Posts: 63

View Profile
1: July 22, 2009, 01:08:24 AM »
Or does anyone know how I can have 2 forcefields from 1 deployable? I can only get 1 up each time.
4TR3X
Nugget²
Posts: 63

View Profile
2: July 23, 2009, 04:33:06 AM »
Anyone got a clue?
VashTexan
Nugget

Posts: 41

View Profile
3: July 31, 2009, 01:16:51 PM »
I don't have much time right now to look too much into it, I'll see tomorrow or the next day, but I don't even remember quite how the airfield deployed. Was the line from the beacon to the shield always parallel to the z-axis (I think it was more this way) or just perpendicular to the ground?

Plus, I think I might need to fidget around with it myself to see what's wrong and how to fix it, but only if you're willing. Personally, I'm much more "liberal" when it comes to software and information, as I've seen open source projects develop much better and last MUCH longer than anything proprietary or hidden, but that's not up to me. Wink

Read the FAQ.
4TR3X
Nugget²
Posts: 63

View Profile
4: August 01, 2009, 07:47:13 AM »
Here is the file I have usual password.

When I get back off hol (go in a few hours) I will see about making the source available. But the reason I am holding off is because it will mean we have unique items. Will think more when I am outta holiday mood Tongue
Attached files
* airfield.rar (2.44 KB - downloaded 48 times.)
VashTexan
Nugget

Posts: 41

View Profile
5: August 02, 2009, 06:32:04 AM »
Dang, I need some of the other .cs files cuz it's not currently included in the inventory of the Engineer or any (this is one of the many reasons I'm pushing for open source... so what if anyone steals it... maybe they'll make a better mod and keep Tribes 2 from disappearing altogether, or maybe even improve this mod, as I've seen it crash quite a lot while I'm hosting, not even sure why...).

I'll try to improvise by temp adding it to Classic mod and editing it there.

Read the FAQ.
Thyth
Apotheosis Incarnate

Posts: 689

View Profile
6: August 02, 2009, 11:08:13 AM »
I'm amused that you want people to help you but you want to keep the code proprietary.

Your positioning and rotation code is all wrong for 3D space, by the way. What you're doing might be sufficient for a 2D game, but you'll need to compute a proper 3D rotation here.

Sarcastic, narcissistic, genius, resurrecting the game with brilliant strokes of wizardry.
4TR3X
Nugget²
Posts: 63

View Profile
7: August 12, 2009, 01:34:50 AM »
Vash I will send you the full code later tonight(if I remember). The problem I have with sharing the code is that other people dont share theres and so nothing unique will be made to the mod as people will take what they want. Also I know you say it may make Tribes better as people have access to more but all they have to do is ask me and I will give them certain weapons/packs/features which they want or try and help them to mod one we already have to suit there needs. Obviously I will limit this to an item here and there just to keep this unique.

But I will give full code if I ever leave(also pass the buck of taking over the developement to someone else) and I will give full code to anyone who wants to help me with this. I will however limit the coders though too many will get too messy.
Pages: [1] Print 
« previous next »
Jump to:  

irc.tribalwar.com / #TribesNext Powered by SMF 1.1.18 | SMF © 2005, Simple Machines
anything