$$QUERY Objects b:[o:TargetObject] is within the [i:Cone=90] degree view cone of [o:Object] qObjCanSeeObj Can object see the target object Determines if the specified object can see the other object Parameters: Object: The object doing the looking TargetObject: The target object Cone: Angle between 0-360 which makes the viewcone that determines if the object can see the other object $$END
| 5336 | $$END |
| 5337 | */ |
| 5338 | bool qObjCanSeeObj(int handletarget, int cone, int handlesrc) { |
| 5339 | vector vsource, vtarget; |
| 5340 | |
| 5341 | msafe_struct mstruct; |
| 5342 | |
| 5343 | // Get half of the angle that the user specified because they specified a cone, and we want an angle |
| 5344 | double cangle = (double)((double)cone / (double)2); |
| 5345 | |
| 5346 | double testangle = cos(cangle * PI / 180); |
| 5347 | |
| 5348 | mstruct.objhandle = handletarget; |
| 5349 | MSafe_GetValue(MSAFE_OBJECT_POS, &mstruct); |
| 5350 | vtarget = mstruct.pos; |
| 5351 | |
| 5352 | mstruct.objhandle = handlesrc; |
| 5353 | MSafe_GetValue(MSAFE_OBJECT_POS, &mstruct); |
| 5354 | vsource = mstruct.pos; |
| 5355 | |
| 5356 | mstruct.objhandle = handlesrc; |
| 5357 | MSafe_GetValue(MSAFE_OBJECT_ORIENT, &mstruct); |
| 5358 | |
| 5359 | vector subvec = vtarget - vsource; |
| 5360 | vm_VectorNormalizeFast(&subvec); |
| 5361 | float dotp = vm_DotProduct(&subvec, &mstruct.orient.fvec); |
| 5362 | |
| 5363 | if (dotp > testangle) { |
| 5364 | return true; |
| 5365 | } |
| 5366 | return false; |
| 5367 | } |
| 5368 | |
| 5369 | /* |
| 5370 | $$QUERY |
no test coverage detected