Advertisement
Ulabael

objItem collision

Oct 9th, 2022 (edited)
987
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /// @description
  2.  
  3. for (var i = 0; i < array_length(inv); ++i) {
  4.     if (inv[i].cellType == objectTypes.any) {
  5.         if (inv[i].id == noone
  6.         or inv[i].id == other.object_index and inv[i].stack + other.quantity <= inv[i].maxStack)
  7.         {
  8.             inv[i].name = other.name;
  9.             inv[i].id = other.object_index;
  10.             inv[i].sprite = other.sprite_index;
  11.             inv[i].type = other.type;
  12.             inv[i].stack   += other.quantity;
  13.             inv[i].maxStack = other.maxStack;
  14.             with other instance_destroy();
  15.             break;
  16.         }
  17.         else if (inv[i].id == other.object_index and inv[i].stack + other.quantity > inv[i].maxStack) {
  18.             other.quantity -= inv[i].maxStack - inv[i].stack;
  19.             inv[i].stack = inv[i].maxStack;
  20.         }
  21.     }
  22.     else if other.type == inv[i].cellType {
  23.         if inv[i].id == noone {
  24.             inv[i].name = other.name;
  25.             inv[i].id = other.object_index;
  26.             inv[i].sprite = other.sprite_index;
  27.             inv[i].type = other.type;
  28.             inv[i].stack    = 1;
  29.             inv[i].maxStack = other.maxStack;
  30.             other.quantity -= 1;
  31.             if (other.quantity <= 0) with other instance_destroy();
  32.             break;
  33.         }
  34.     }
  35. }
  36. event_user(3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement