-
Notifications
You must be signed in to change notification settings - Fork 180
Weapon dot-to-target input #7285
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10283,4 +10283,25 @@ float weapon_get_apparent_size(const weapon& wp) { | |
| wep_objp->radius * 2.0f, | ||
| g3_get_hfov(Eye_fov), | ||
| gr_screen.max_w) / i2fl(gr_screen.max_w); | ||
| } | ||
|
|
||
| float weapon_get_target_dot(const weapon& wp) { | ||
| object* wep_objp = &Objects[wp.objnum]; | ||
|
|
||
| vec3d target_pos; | ||
|
|
||
| if(wp.homing_object != &obj_used_list && (wp.homing_object->type != 0)) | ||
| { | ||
| if (!IS_VEC_NULL(&wp.homing_pos)) { | ||
| target_pos = wp.homing_pos; | ||
| } | ||
| } else if(wp.target_num > -1) | ||
| { | ||
| target_pos = Objects[wp.target_num].pos; | ||
| } else { | ||
| return 0.f; | ||
| } | ||
| vec3d dir; | ||
| vm_vec_sub(&dir, &wep_objp->pos, &target_pos); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR description says |
||
| return vm_vec_dot(&dir, &wep_objp->orient.vec.fvec); | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how this could happen, but if
homing_objectis valid butIS_VEC_NULL(&wp.homing_pos)is true, the inner if body is skipped,target_posis never assigned, and the function eventually hitsvm_vec_subwith bad data. Could fix this by adding an else return 0.f, IE