Advertisement
ZoriaRPG

XPG_XP.zlib (for 2.55, v0.2)

Sep 16th, 2018
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.68 KB | None | 0 0
  1. //RPG XP (for 2.55 'Necromancer')
  2. //v0.2
  3.  
  4. script typedef ffc struct;
  5. typedef const int def;
  6. typedef const int config;
  7. typedef config_f config_f;
  8.  
  9.  
  10. //Global Array indices
  11. def G_XP_DLAST_AWARD = 5000;
  12. def G_DRAW_TIMER = 5001;
  13. def XP_LEVEL_NEXT = 5002; //holds value of next needed XP
  14. def RPG_CUR_PLAYER_LEVEL = 5003;
  15.  
  16. struct script XP
  17. {
  18.     def NPCA = 15; //npc misc atrribute that holds xp value
  19.     def LM = 30; //Link-Misc index that storews temprary value (for drawing)
  20.    
  21.     def HUD_X = 180;
  22.     def HUD_Y = -20;
  23.     def HUD_FONT = 0;
  24.     def HUD_COLOUR = 0x02;
  25.     //def RPG_HUD_
  26.    
  27.     //XP Values
  28.     config_f LEVEL_01 = 0.0050;
  29.     config_f LEVEL_02 = 0.0100;
  30.     config_f LEVEL_03 = 0.0200;
  31.     config_f LEVEL_04 = 0.0500;
  32.     config_f LEVEL_05 = 0.1000;
  33.     config_f LEVEL_06 = 0.2000;
  34.     config_f LEVEL_07 = 0.5000;
  35.     config_f LEVEL_08 = 1.0000;
  36.     config_f LEVEL_09 = 2.0000;
  37.     config_f LEVEL_10 = 5.0000;
  38.     config_f LEVEL_11 = 10.0000;
  39.     config_f LEVEL_12 = 20.0000;
  40.     config_f LEVEL_13 = 50.0000;
  41.     config_f LEVEL_14 = 100.0000;
  42.     config_f LEVEL_15 = 500.0000;
  43.     config_f LEVEL_16 = 1000.0000;
  44.     config_f LEVEL_17 = 5000.0000;
  45.     config_f LEVEL_18 = 10000.0000;
  46.     config_f LEVEL_19 = 50000.0000;
  47.     config_f LEVEL_20 = 100000.0000;
  48.     def LEVEL_LAST = 21; //end of array
  49.    
  50.     //Temporary drawing
  51.     config_f DRAW_TIME =  0.10; //frames
  52.     config DRAW_COLOUR_FG = 0x02;
  53.     config DRAW_COLOUR_BG = 0x0F; //shadow
  54.     config DRAW_XOFS = 18;  //from Link
  55.     config DRAW_YOFS = -8;
  56.     config DRAW_XOFS = 18;  //from Link
  57.     config DRAW_SHADOW_XOFS = -1;
  58.     config DRAW_SHADOW_YOFS = -1;
  59.     config DRAW_FONT = 0;
  60.    
  61.     void run(){}
  62.    
  63.     void set(int xp)
  64.     {
  65.         GRAM[XP] += xp / 10000; //XP is awarded as 1/10000 per point for MAX LONG purposes
  66.         GRAM[G_XP_LAST_AWARD] = xp;
  67.         GRAM[G_DRAW_TIMER] = DRAW_TIME;
  68.         //Link->Misc[LM_XP] = xp+DRAW_TIME; //too slow
  69.         if ( level_up )
  70.         {
  71.             do_levelup();
  72.         }
  73.     }
  74.  
  75.     void do_levelup()
  76.     {
  77.         ++GRAM[RPG_CUR_PLAYER_LEVEL];
  78.         set_next_xp();
  79.         //message display and fanfare
  80.         //stats
  81.         //spells
  82.         //abilities
  83.         //bonuses
  84.     }
  85.  
  86.     float get()
  87.     {
  88.         return GRAM[XP];
  89.     }
  90.  
  91.     //call when starting the game
  92.     void init()
  93.     {
  94.         GRAM[XP_LEVEL_NEXT] = LEVEL_01;
  95.     }
  96.  
  97.     void set_next()
  98.     {
  99.         int xp_table[LEVEL_LAST]=
  100.         {
  101.             LEVEL_01, LEVEL_02, LEVEL_03, LEVEL_04, LEVEL_05,
  102.             LEVEL_06, LEVEL_07, LEVEL_08, LEVEL_09, LEVEL_10,
  103.             LEVEL_11, LEVEL_12, LEVEL_13, LEVEL_14, LEVEL_15,
  104.             LEVEL_16, LEVEL_17, LEVEL_18, LEVEL_19, LEVEL_20
  105.         };
  106.         GRAM[XP_LEVEL_NEXT] = xp_table[current_level()];
  107.     }
  108.     int current_level()
  109.     {
  110.         return GRAM[RPG_CUR_PLAYER_LEVEL];
  111.     }
  112.     float needed()
  113.     {
  114.         return GRAM[GRAM[XP_LEVEL_NEXT]];
  115.     }
  116.  
  117.     //returns true if the character should level up
  118.     bool levelup
  119.     {
  120.         if ( xp() >= need_xp() ) return true;
  121.     }
  122.  
  123.    
  124.     void draw_hud(int x, int y, int font, int colour)
  125.     {
  126.         int str[13]; //including sign, dot, and term
  127.         int buf[11]; //no sign or dot
  128.         ftoa(GRAM[XP], str);
  129.         int pos;
  130.         for ( int q = 0; q < 13; ++q; )
  131.         {
  132.             if ( string_h.isnumber(str[q] ) //revised string headers
  133.             {
  134.                 buf[pos] = str[q];
  135.                 ++pos;
  136.             }
  137.         }
  138.         //drawstring
  139.        
  140.     }
  141.    
  142.     void draw_award()
  143.     {
  144.         /*too slow
  145.         int amt = Link->Misc[LM]
  146.         int time = ( amt - ( amt << 0 ) ) * 10000;
  147.         amt = amt << 0;
  148.         */
  149.         if ( !GRAM[G_DRAW_TIMER] ) return;
  150.         int xpstr[8];
  151.        
  152.         itoa(GRAM[G_XP_LAST_AWARD], xpstr); //as these reversed?
  153.         //draw two strings using XP values in Link->Misc
  154.         --GRAM[G_DRAW_TIMER];
  155.        
  156.     }
  157. }
  158.  
  159.  
  160.  
  161. struct script Enemy
  162. {
  163.     //const int
  164.    
  165.     void run(){}
  166.    
  167.     int get(int id)
  168.     {
  169.         npcdata nd = Game->LoadNPCData(id);
  170.         return nd->Attributes[NPCA];
  171.        
  172.     }
  173.     int get(npc n)
  174.     {
  175.         return n->Attributes[NPCA];
  176.     }
  177.     int get(npcdata nd)
  178.     {
  179.         return nd->Attributes[NPCA];
  180.     }
  181.    
  182. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement