TheBlueTophat

Scrolling Code Module 3

May 20th, 2016
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.72 KB | None | 0 0
  1. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
  2. // Coolgamers Z3 Scrolling, Version 2 Update/Itteration 4 Module 3. \\
  3. // Module 3:                                                        \\
  4. // Custom weapons.                                                  \\
  5. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \\
  6.  
  7. // ~ Misc Constants ~
  8. const int SCRL_LW_DEADSTATE_DEAD = 0; // Removes the weapon.
  9. const int SCRL_LW_DEADSTATE_ALIVE = -1; // Weapon isn't removed over time.
  10.  
  11. // ~ ->Misc[] indices ~
  12. const int MISC_LW_DEADSTATE = 0; // Custom deadstate, basically.
  13. const int MISC_LW_NORMAL_FLAGS = 1; // Stores a set of flags that change the behavior of the weapon.
  14. const int MISC_LW_SCRIPT_FLAGS = 2; // Stores a set of flags that change the behavior of the weapon on a more technical level.
  15. const int MISC_LW_SPAWN_X = 3; // The X position that the weapon was spawned at.
  16. const int MISC_LW_SPAWN_Y = 4; // The Y position that the weapon was spawned at.
  17.  
  18. // ~ Scripted Weapon Types (sword, spear, boomerang, etc) ~
  19. // Put these in D0 in the item editor, before the decimal point.
  20. const int SCRL_LW_NONE = 41; // No built in use currently.
  21. const int SCRL_LW_TESTWEP = 42;
  22.  
  23. // ~ Scripted Weapon Flags ~
  24. // Script-related flags; You probably don't want to mess with these too much. Probably.
  25. // The sum of all the flags you want to use is the number to put in D1, before the decimal point.
  26.  
  27. // WARNING: The functionality of these hasn't been implimented (or completely) yet, they also may be changed in the future.
  28. const int SCRL_WEP_FLAG_HURTSLINK = 00000000001b; // Hurts Link
  29. const int SCRL_WEP_FLAG_HURTSENEMY = 00000000010b; // Hurts Enemies
  30. const int SCRL_WEP_FLAG_DESTROYED_ON_LINK = 00000000100b; // Destroys the weapon when it hits Link
  31. const int SCRL_WEP_FLAG_DESTROYED_ON_ENEMY = 00000001000b; // Destroys the weapon when it hits an Enemy
  32. const int SCRL_WEP_FLAG_DESTROYED_ON_SOLID_COMBO = 00000010000b; // Destroys the weapon when it hits any solidity in a combo.
  33. const int SCRL_WEP_FLAG_OBEY_SIDEVIEW_GRAVITY = 00000100000b; // If the weapons Z pos decreases when > 0 in normal screens.
  34. const int SCRL_WEP_FLAG_OBEY_Z_GRAVITY = 00001000000b; // If the weapons Y pos decreases when > 0 in sideview screens.
  35. const int SCRL_WEP_FLAG_TRANSPARENT = 00010000000b; // If the weapon is Transparent.
  36. const int SCRL_WEP_FLAG_INVISIBLE = 00100000000b; // If the weapon is Invisible.
  37. const int SCRL_WEP_FLAG_CAN_BE_REFLECTED = 01000000000b; // If the weapon can be reflected by mirrors/shields/etc
  38. const int SCRL_WEP_FLAG_PICKUPITEMS = 10000000000b; // If the weapon will pickup items;
  39. // A flag on the items themselves will choose if they're instantly collected or pulled with the weapon.
  40.  
  41.  
  42. // ~ Functions ~
  43.  
  44.  
  45. lweapon CreateCustomWeapon(int wepType, int wepFlags, int scriptWepFlags, int wepSprite, int wepDeadState, int x, int y)
  46. {
  47.     lweapon lwep = CreateLWeaponAt(wepType, 120, 80);
  48.  
  49.     lwep->HitXOffset = (x - 120);
  50.     lwep->HitYOffset = (y - 80);
  51.     lwep->DrawXOffset = lwep->HitXOffset;
  52.     lwep->DrawYOffset = lwep->HitYOffset;
  53.    
  54.     lwep->Misc[MISC_LW_DEADSTATE] = wepDeadState;
  55.     lwep->Misc[MISC_LW_NORMAL_FLAGS] = wepFlags;
  56.     lwep->Misc[MISC_LW_SCRIPT_FLAGS] = scriptWepFlags;
  57.    
  58.     lwep->Misc[MISC_LW_SPAWN_X] = x;
  59.     lwep->Misc[MISC_LW_SPAWN_Y] = y;
  60.    
  61.     lwep->UseSprite(wepSprite);
  62.    
  63.     lwep->CollDetection = false;
  64.    
  65.     return lwep;
  66. }
  67.  
  68. void HandleCustomWeapons()
  69. {
  70.     for(int i = 1; i <= Screen->NumLWeapons(); i += 1)
  71.     {
  72.         lweapon lwep = Screen->LoadLWeapon(i);
  73.        
  74.         if(lwep->ID == SCRL_LW_TESTWEP)
  75.         {
  76.             lwep->DeadState = WDS_ALIVE;
  77.  
  78.             if(lwep->Misc[MISC_LW_DEADSTATE] == SCRL_LW_DEADSTATE_DEAD)
  79.             {
  80.                 Remove(lwep);
  81.             }
  82.             else
  83.             {
  84.                 lwep->Misc[MISC_LW_DEADSTATE] -= 1;
  85.             }
  86.         }
  87.     }
  88. }
Add Comment
Please, Sign In to add comment