Advertisement
ZoriaRPG

LinkHurtTile.zs

Jul 9th, 2018
327
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.70 KB | None | 0 0
  1. //A small 2.54 script to use custom tiles when link is hurt.
  2. //By ZoriaRPG, 9th July, 2018
  3.  
  4. int __G[256];
  5. const int gLINKTILECACHE = 100;
  6. const int lmiscHURTTILE = 17;
  7. const int lmiscflagHURTTILE = 1;
  8.  
  9. int frame; //global frame timer. As this will be called often, I'm making it a base int, not an array.
  10.  
  11.  
  12. //fake class
  13. ffc script linktile
  14. {
  15.     void run()
  16.     {
  17.     }
  18.     void clear()
  19.     {
  20.         Link->ScriptTile = -1;
  21.     }
  22.     void clearcache(int slot)
  23.     {
  24.         __G[slot] = -1;
  25.     }
  26.     void cache(int slot)
  27.     {
  28.         __G[slot] = Link->ScriptTile;
  29.     }
  30.     void restore(int cache_slot)
  31.     {
  32.         Link->ScriptTile = __G[cache_slot];
  33.     }
  34.     void dohurt()
  35.     {
  36.         if  ( Link->Action == LA_GOTHURTLAND )
  37.         {
  38.             if ( ! (Link->Misc[lmiscHURTTIMER]&lmiscflagHURTTILE ) )
  39.             {
  40.                 Link->Misc[lmiscHURTTILE] |= lmiscflagHURTTILE;
  41.                 cache(gLINKTILECACHE);
  42.             }
  43.                
  44.             Link->ScriptTile = TILE_LINKHURT + ( 1 * getmodifier()) + animate();
  45.            
  46.         }
  47.         else
  48.         {
  49.             if ( Link->Misc[lmiscHURTTIMER]&lmiscflagHURTTILE )
  50.             {
  51.                 restore(gLINKTILECACHE);
  52.             }
  53.         }
  54.     }
  55.     int animate()
  56.     {
  57.         if ( frame < 30 )
  58.         {
  59.             if ( frame < 15 ) { return 0; }
  60.             return 20;
  61.         }
  62.         else if ( frame < 45 ) return 0;
  63.         return 20;
  64.     }
  65.  
  66.     int getmodifier()
  67.     {
  68.         itemdata shield = Game->LoadItemData(GetHighestlevelItemOwned(I_SHIELD));
  69.         return ( shield->Level -1 ) * 260;
  70.        
  71.     }
  72. }
  73.  
  74. global script Init
  75. {
  76.     void run()
  77.     {
  78.         linktile.clearcache(gLINKTILECACHE);
  79.     }
  80.  
  81. }
  82.  
  83. global script LinkHurtTiles
  84. {
  85.     void run()
  86.     {
  87.         frame = -1;
  88.         while(1)
  89.         {
  90.             if ( ++frame > 60 ) { frame = 0; }
  91.             linktile.dohurt();
  92.             Waitdraw();
  93.             Waitframe();
  94.         }
  95.     }
  96. }
  97.  
  98. global script onExit
  99. {
  100.     void run()
  101.     {
  102.         linktile.restore(gLINKTILECACHE);
  103.     }
  104. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement