Advertisement
ZoriaRPG

Scripting Unlimited Items

Mar 19th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.36 KB | None | 0 0
  1. script typedef struct ffc;
  2.  
  3. struct script items
  4. {
  5.     const int SLOT_A = 0;
  6.     const int SLOT_B = 1;
  7.     const int I_A = 100;
  8.     const int I_B = 101; //The only two action items in our quest.
  9.     void run(){}
  10.     enum { LAST = 2048 };
  11.     int Have[LAST*2]; //Inventory; ownership
  12.     int Tile[LAST];
  13.     int Scripts[LAST*3];
  14.     int Power[LAST];
  15.     int Class[LAST];
  16.     void init(int id, int tile, int scriptid, int wpnscript, int pscript, int power, int itemclass)
  17.     {
  18.         Tile[id] = tile;
  19.         Scripts[id] = scriptid;
  20.         Scripts[id+LAST] = wpnscript;
  21.         Scripts[id+(LAST*2)] = pscript;
  22.         Power[id] = power;
  23.         Class[id] = itemclass;
  24.     }
  25.     int _max(int a, int b) { return ( a < b ) ? a : b ); }
  26.    
  27.     //Custom subscreen calls this when changing the active item in any slot.
  28.     void set(int slot, int id)
  29.     {
  30.         slot = _max(slot);
  31.         itemdata a = Game->LoadItemData(I_A+slot);
  32.         a->Tile = Tiles[id];
  33.         a->Scipt = Scripts[id];
  34.         a->WeaponScipt = Scripts[LAST+id];
  35.         a->PScipt = Scripts[(LAST*2)+id];
  36.         a->Power = Power[id];
  37.         a->Family = Class[id];
  38.     }
  39.     void Own(int id, bool state)
  40.     {
  41.         Have[id*LAST] = ( state ) ? 1 : 0;
  42.         Have[id] = ( state ) ? 1 : 0;
  43.     }
  44.     bool Owns(int id) { return Have[id*LAST} }
  45.     void Give(int id) { Have[id] = 1; }
  46.     void Take(int id) { Have[id] = 0; }
  47.     void DoScript(int slot, int id, untyped args)
  48.     {
  49.         itemdata a = Game->LoadItemData(I_A+slot);
  50.         a->RunScript();
  51.     }
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement