Here are 2 WW functions

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
Enigma
Private First Class
Private First Class
Posts: 212
Joined: Sat Apr 23, 2005 3:13 am

Here are 2 WW functions

Post by Enigma »

Here are some functions that may be useful. Basically, each function fires a world weapon at a player or an arbitrary position. The parameter variable names should indicate what each one is for, so I will not comment on them.

I did not test the functions, but the math should be correct.

Code: Select all


bool fireWorldWepAt(char const * flagType,
                       float lifetime, 
                       float wepPos[3],
                       float targetPos[3],
                       int shotID,
                       float dt)
{
  float x = *targetPos - *wepPos;
  float y = *(targetPos + 1) - *(wepPos + 1);
  float z = *(targetPos + 2) - *(wepPos + 2);
  
  float theta = std::atan2(y, x);  
  float phi = std::asin(z/std::sqrt(x*x + y*y + z*z));
  
  return bz_fireWorldWep(flagType, lifetime, wepPos, phi, theta, shotID, dt); 
}

Code: Select all

int fireWorldGMAt(int target, 
                  float lifetime, 
                  float wepPos[3],
                  float targetPos[3],
                  float dt)
{
  float x = *targetPos - *wepPos;
  float y = *(targetPos + 1) - *(wepPos + 1);
  float z = *(targetPos + 2) - *(wepPos + 2);
  
  float theta = std::atan2(y, x);
  float phi = std::asin(z/std::sqrt(x*x + y*y + z*z));
  
  return bz_fireWorldGM(target, lifetime, wepPos, phi, theta, dt);
}
Post Reply