Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //RPG XP (for 2.55 'Necromancer')
- //v0.2
- script typedef ffc struct;
- typedef const int def;
- typedef const int config;
- typedef config_f config_f;
- //Global Array indices
- def G_XP_DLAST_AWARD = 5000;
- def G_DRAW_TIMER = 5001;
- def XP_LEVEL_NEXT = 5002; //holds value of next needed XP
- def RPG_CUR_PLAYER_LEVEL = 5003;
- struct script XP
- {
- def NPCA = 15; //npc misc atrribute that holds xp value
- def LM = 30; //Link-Misc index that storews temprary value (for drawing)
- def HUD_X = 180;
- def HUD_Y = -20;
- def HUD_FONT = 0;
- def HUD_COLOUR = 0x02;
- //def RPG_HUD_
- //XP Values
- config_f LEVEL_01 = 0.0050;
- config_f LEVEL_02 = 0.0100;
- config_f LEVEL_03 = 0.0200;
- config_f LEVEL_04 = 0.0500;
- config_f LEVEL_05 = 0.1000;
- config_f LEVEL_06 = 0.2000;
- config_f LEVEL_07 = 0.5000;
- config_f LEVEL_08 = 1.0000;
- config_f LEVEL_09 = 2.0000;
- config_f LEVEL_10 = 5.0000;
- config_f LEVEL_11 = 10.0000;
- config_f LEVEL_12 = 20.0000;
- config_f LEVEL_13 = 50.0000;
- config_f LEVEL_14 = 100.0000;
- config_f LEVEL_15 = 500.0000;
- config_f LEVEL_16 = 1000.0000;
- config_f LEVEL_17 = 5000.0000;
- config_f LEVEL_18 = 10000.0000;
- config_f LEVEL_19 = 50000.0000;
- config_f LEVEL_20 = 100000.0000;
- def LEVEL_LAST = 21; //end of array
- //Temporary drawing
- config_f DRAW_TIME = 0.10; //frames
- config DRAW_COLOUR_FG = 0x02;
- config DRAW_COLOUR_BG = 0x0F; //shadow
- config DRAW_XOFS = 18; //from Link
- config DRAW_YOFS = -8;
- config DRAW_XOFS = 18; //from Link
- config DRAW_SHADOW_XOFS = -1;
- config DRAW_SHADOW_YOFS = -1;
- config DRAW_FONT = 0;
- void run(){}
- void set(int xp)
- {
- GRAM[XP] += xp / 10000; //XP is awarded as 1/10000 per point for MAX LONG purposes
- GRAM[G_XP_LAST_AWARD] = xp;
- GRAM[G_DRAW_TIMER] = DRAW_TIME;
- //Link->Misc[LM_XP] = xp+DRAW_TIME; //too slow
- if ( level_up )
- {
- do_levelup();
- }
- }
- void do_levelup()
- {
- ++GRAM[RPG_CUR_PLAYER_LEVEL];
- set_next_xp();
- //message display and fanfare
- //stats
- //spells
- //abilities
- //bonuses
- }
- float get()
- {
- return GRAM[XP];
- }
- //call when starting the game
- void init()
- {
- GRAM[XP_LEVEL_NEXT] = LEVEL_01;
- }
- void set_next()
- {
- int xp_table[LEVEL_LAST]=
- {
- LEVEL_01, LEVEL_02, LEVEL_03, LEVEL_04, LEVEL_05,
- LEVEL_06, LEVEL_07, LEVEL_08, LEVEL_09, LEVEL_10,
- LEVEL_11, LEVEL_12, LEVEL_13, LEVEL_14, LEVEL_15,
- LEVEL_16, LEVEL_17, LEVEL_18, LEVEL_19, LEVEL_20
- };
- GRAM[XP_LEVEL_NEXT] = xp_table[current_level()];
- }
- int current_level()
- {
- return GRAM[RPG_CUR_PLAYER_LEVEL];
- }
- float needed()
- {
- return GRAM[GRAM[XP_LEVEL_NEXT]];
- }
- //returns true if the character should level up
- bool levelup
- {
- if ( xp() >= need_xp() ) return true;
- }
- void draw_hud(int x, int y, int font, int colour)
- {
- int str[13]; //including sign, dot, and term
- int buf[11]; //no sign or dot
- ftoa(GRAM[XP], str);
- int pos;
- for ( int q = 0; q < 13; ++q; )
- {
- if ( string_h.isnumber(str[q] ) //revised string headers
- {
- buf[pos] = str[q];
- ++pos;
- }
- }
- //drawstring
- }
- void draw_award()
- {
- /*too slow
- int amt = Link->Misc[LM]
- int time = ( amt - ( amt << 0 ) ) * 10000;
- amt = amt << 0;
- */
- if ( !GRAM[G_DRAW_TIMER] ) return;
- int xpstr[8];
- itoa(GRAM[G_XP_LAST_AWARD], xpstr); //as these reversed?
- //draw two strings using XP values in Link->Misc
- --GRAM[G_DRAW_TIMER];
- }
- }
- struct script Enemy
- {
- //const int
- void run(){}
- int get(int id)
- {
- npcdata nd = Game->LoadNPCData(id);
- return nd->Attributes[NPCA];
- }
- int get(npc n)
- {
- return n->Attributes[NPCA];
- }
- int get(npcdata nd)
- {
- return nd->Attributes[NPCA];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement