Advertisement
ywkls

Throwing Code

Oct 22nd, 2019
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Handles Lweapons thrown in an arc.
  2.  
  3. void __UpdateLWMThrow(lweapon wpn)
  4. {
  5. // LW_ZH_I_WORK: Current jump
  6. // LW_ZH_I_WORK_2: Current Z position
  7. // LW_ZH_I_MOVEMENT_ARG: Initial jump
  8. wpn->Jump=0; // Override engine handling of Z movement
  9.  
  10. // Just thrown
  11. if(wpn->Misc[LW_ZH_I_WORK]==0 && wpn->Misc[LW_ZH_I_MOVEMENT_ARG]!=0)
  12. {
  13. wpn->Misc[LW_ZH_I_WORK]=wpn->Misc[LW_ZH_I_MOVEMENT_ARG];
  14. wpn->Misc[LW_ZH_I_MOVEMENT_ARG]=0;
  15. }
  16.  
  17. // Fall
  18. wpn->Misc[LW_ZH_I_WORK_2]=Max(wpn->Misc[LW_ZH_I_WORK_2]+wpn->Misc[LW_ZH_I_WORK], 0);
  19. if(!IsSideview())
  20. wpn->Z=wpn->Misc[LW_ZH_I_WORK_2];
  21. else
  22. wpn->Y = 176-wpn->Misc[LW_ZH_I_WORK_2];
  23. if(wpn->Misc[LW_ZH_I_WORK_2]>0 &&
  24. !OnSidePlatform(wpn->X, wpn->Y,
  25. wpn->HitXOffset,
  26. wpn->HitYOffset,
  27. wpn->HitHeight,wpn->HitWidth)) // Z>0
  28. wpn->Misc[LW_ZH_I_WORK]=Max(wpn->Misc[LW_ZH_I_WORK]-GH_GRAVITY, -GH_TERMINAL_VELOCITY);
  29. else{
  30. bool done=false;
  31.  
  32. // Bounce
  33. if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LWMF_BOUNCE)!=0){
  34. // Falling fast enough?
  35. if(wpn->Misc[LW_ZH_I_WORK]<-0.5){ // Jump<=-0.5
  36. wpn->Misc[LW_ZH_I_WORK]*=-0.5;
  37. wpn->Step*=0.75;
  38. }
  39. // Not fast enough
  40. else
  41. done=true;
  42. }
  43. // Don't bounce
  44. else
  45. done=true;
  46.  
  47. // Movement ended; stop or die?
  48. if(done){
  49. if((wpn->Misc[LW_ZH_I_MOVEMENT_ARG2]&LWMF_DIE)!=0){
  50. wpn->Z=0;
  51. KillLWeapon(wpn);
  52. }
  53. else{
  54. wpn->Misc[LW_ZH_I_MOVEMENT]=0;
  55. wpn->Step=0;
  56. }
  57. }
  58. }
  59. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement