Advertisement
ywkls

EWM_FALL and EWM_THROW Sideview

Jan 26th, 2020
149
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. bool OnSidePlatform(int x, int y, int xOff, int yOff, int h, int w) {
  2. for(int i =0;i<=w-1;i++){
  3. if(Screen->isSolid((x+xOff+i),(y+yOff)+h)
  4. && Screen->Flags[SF_ROOMTYPE]&4)
  5. return true;
  6. }
  7. return false;
  8. }
  9.  
  10. void __UpdateEWMThrow(eweapon wpn)
  11. {
  12. // __EWI_WORK: Current jump
  13. // __EWI_WORK_2: Current Z position
  14. // __EWI_MOVEMENT_ARG: Initial jump
  15. // __EWI_MOVEMENT_ARG_2: Flags
  16.  
  17. wpn->Jump=0; // Override engine handling of Z movement
  18.  
  19. // Just thrown
  20. if(wpn->Misc[__EWI_WORK]==0 && wpn->Misc[__EWI_MOVEMENT_ARG]!=0)
  21. {
  22. wpn->Misc[__EWI_WORK]=wpn->Misc[__EWI_MOVEMENT_ARG];
  23. wpn->Misc[__EWI_MOVEMENT_ARG]=0;
  24. }
  25.  
  26. // Fall
  27. wpn->Misc[__EWI_WORK_2]=Max(wpn->Misc[__EWI_WORK_2]+wpn->Misc[__EWI_WORK], 0);
  28. if(!IsSideview())
  29. wpn->Z=wpn->Misc[__EWI_WORK_2];
  30. else
  31. wpn->Y = 176-wpn->Misc[__EWI_WORK_2];
  32.  
  33. // Hit the ground
  34. // Still in the air; adjust velocity
  35. if(wpn->Misc[__EWI_WORK_2]>0 &&
  36. !OnSidePlatform(wpn->X, wpn->Y,
  37. wpn->HitXOffset,
  38. wpn->HitYOffset,
  39. wpn->HitHeight,wpn->HitWidth)) // Z>0
  40. wpn->Misc[__EWI_WORK]=Max(wpn->Misc[__EWI_WORK]-GH_GRAVITY, -GH_TERMINAL_VELOCITY);
  41.  
  42. // Hit the ground
  43. else
  44. {
  45. bool done=false;
  46.  
  47. // Bounce
  48. if((wpn->Misc[__EWI_MOVEMENT_ARG_2]&EWMF_BOUNCE)!=0)
  49. {
  50. // Falling fast enough?
  51. if(wpn->Misc[__EWI_WORK]<-0.5) // Jump<=-0.5
  52. {
  53. wpn->Misc[__EWI_WORK]*=-0.5;
  54. wpn->Step*=0.75;
  55. }
  56. // Not fast enough
  57. else
  58. done=true;
  59. }
  60. // Don't bounce
  61. else
  62. done=true;
  63.  
  64. // Movement ended; stop or die?
  65. if(done)
  66. {
  67. if((wpn->Misc[__EWI_MOVEMENT_ARG_2]&EWMF_DIE)!=0)
  68. {
  69. wpn->Z=0;
  70. KillEWeapon(wpn);
  71. }
  72. else
  73. {
  74. wpn->Misc[__EWI_MOVEMENT]=0;
  75. wpn->Step=0;
  76. }
  77. }
  78. }
  79. }
  80.  
  81. void __UpdateEWMFall(eweapon wpn)
  82. {
  83. wpn->Jump=0; // Override engine handling of Z movement
  84. wpn->Misc[__EWI_WORK_2]-=wpn->Misc[__EWI_WORK];
  85. if(!IsSideview())
  86. wpn->Z=wpn->Misc[__EWI_WORK_2];
  87. else{
  88. wpn->HitYOffset= wpn->Misc[__EWI_WORK_2];
  89. wpn->DrawYOffset=wpn->Misc[__EWI_WORK_2];
  90. }
  91.  
  92. wpn->Misc[__EWI_WORK]=Min(wpn->Misc[__EWI_WORK]+GH_GRAVITY, GH_TERMINAL_VELOCITY);
  93.  
  94. // Hit the ground?
  95. if(wpn->Misc[__EWI_WORK_2]<=0
  96. && !OnSidePlatform(wpn->X, wpn->Y,
  97. wpn->HitXOffset,
  98. wpn->HitYOffset,
  99. wpn->HitHeight)){
  100. bool done=false;
  101.  
  102. // Bounce
  103. if((wpn->Misc[__EWI_MOVEMENT_ARG_2]&EWMF_BOUNCE)!=0)
  104. {
  105. // Falling fast enough?
  106. if(wpn->Misc[__EWI_WORK]<-0.5) // Jump<=-0.5
  107. {
  108. wpn->Misc[__EWI_WORK]*=-0.5;
  109. wpn->Step*=0.75;
  110. }
  111. // Not fast enough
  112. else
  113. done=true;
  114. }
  115. // Don't bounce
  116. else
  117. done=true;
  118.  
  119. // Movement ended; stop or die?
  120. if(done)
  121. {
  122. if((wpn->Misc[__EWI_MOVEMENT_ARG_2]&EWMF_DIE)!=0)
  123. {
  124. wpn->Z=0;
  125. KillEWeapon(wpn);
  126. }
  127. else
  128. {
  129. wpn->Misc[__EWI_MOVEMENT]=0;
  130. wpn->Step=0;
  131. }
  132. }
  133. }
  134. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement