Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //RPG Macros
- const int LM_XP = 31; //Index of Link->Misc to use for drawing xP
- // Xp arard.timer
- const float XP_DRAW_TIME = 0.10; //frames
- const int XP_DRAW_COLOUR_FG = 0x02;
- const int XP_DRAW_COLOUR_BG = 0x0F; //shadow
- const int XP_DRAW_XOFS = 18; //from Link
- const int XP_DRAW_YOFS = -8; const int XP_DRAW_XOFS = 18; //from Link
- const int XP_DRAW_SHADOW_XOFS = -1;
- const int XP_DRAW_SHADOW_YOFS = -1;
- const int XP_DRAW_FONT = 0;
- const int XP_LEVEL_NEXT = 5002; //holds value of next needed XP
- const int G_XP_DRAW_TIMER = 5001;
- const int G_XP_DLAST_AWARD = 5000;
- const float RPG_LEVEL_01 = 0.0050;
- const float RPG_LEVEL_02 = 0.0100;
- const float RPG_LEVEL_03 = 0.0200;
- const float RPG_LEVEL_04 = 0.0500;
- const float RPG_LEVEL_05 = 0.1000;
- const float RPG_LEVEL_06 = 0.2000;
- const float RPG_LEVEL_07 = 0.5000;
- const float RPG_LEVEL_08 = 1.0000;
- const float RPG_LEVEL_09 = 2.0000;
- const float RPG_LEVEL_10 = 5.0000;
- const float RPG_LEVEL_11 = 10.0000;
- const float RPG_LEVEL_12 = 20.0000;
- const float RPG_LEVEL_13 = 50.0000;
- const float RPG_LEVEL_14 = 100.0000;
- const float RPG_LEVEL_15 = 500.0000;
- const float RPG_LEVEL_16 = 1000.0000;
- const float RPG_LEVEL_17 = 5000.0000;
- const float RPG_LEVEL_18 = 10000.0000;
- const float RPG_LEVEL_19 = 50000.0000;
- const float RPG_LEVEL_20 = 100000.0000;
- const float RPG_LEVEL_LAST = 21; //end of array
- const int RPG_CUR_PLAYER_LEVEL = 5004;
- const int NPCA_XP = 29; //NPC Attribute for XP Award Value
- const int NPCA_XP_MAX_PLAYER_LEVEL = 30; //NPC Attribute for Max Player Level to get award. (A zero value in this field will always award XP)
- const int NPCA_CR = 31; //NPC Attribute for enemy Challenge Rating
- ffc script rpg
- {
- void run(){}
- void XP(int xp)
- {
- if ( !xp ) return; //ignore and break on 0 value
- GRAM[XP] += xp / 10000; //XP is awarded as 1/10000 per point for MAX LONG purposes
- GRAM[G_XP_LAST_AWARD] = xp;
- GRAM[G_XP_DRAW_TIMER] = XP_DRAW_TIME;
- //Link->Misc[LM_XP] = 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 xp()
- {
- return GRAM[XP];
- }
- //call when starting the game
- void xp_init()
- {
- GRAM[XP_LEVEL_NEXT] = RPG_LEVEL_01;
- }
- void set_next_xp()
- {
- int xp_table[RPG_LEVEL_LAST]=
- {
- RPG_LEVEL_01, RPG_LEVEL_02, RPG_LEVEL_03, RPG_LEVEL_04, RPG_LEVEL_05,
- RPG_LEVEL_06, RPG_LEVEL_07, RPG_LEVEL_08, RPG_LEVEL_09, RPG_LEVEL_10,
- RPG_LEVEL_11, RPG_LEVEL_12, RPG_LEVEL_13, RPG_LEVEL_14, RPG_LEVEL_15,
- RPG_LEVEL_16, RPG_LEVEL_17, RPG_LEVEL_18, RPG_LEVEL_19, RPG_LEVEL_20
- };
- GRAM[XP_LEVEL_NEXT] = xp_table[current_level()];
- }
- int current_level()
- {
- return GRAM[RPG_CUR_PLAYER_LEVEL];
- }
- float need_xp()
- {
- return GRAM[GRAM[XP_LEVEL_NEXT]];
- }
- //returns true if the character should level up
- bool levelup
- {
- if ( xp() >= need_xp() ) return true;
- }
- void draw_xp_award()
- {
- /*too slow
- int amt = Link->Misc[LM_XP]
- int time = ( amt - ( amt << 0 ) ) * 10000;
- amt = amt << 0;
- */
- if ( !GRAM[G_XP_DRAW_TIMER] ) return; //Don't draw if timer has elapsed.
- if ( !GRAM[G_XP_LAST_AWARD] ) return; //Don't draw 0 XP
- int xpstr[8];
- itoa(GRAM[G_XP_LAST_AWARD], xpstr); //as these reversed?
- //draw two strings using XP values in Link->Misc
- --GRAM[G_XP_DRAW_TIMER];
- }
- const int RPG_HUD_XP_X = 180;
- const int RPG_HUD_XP_Y = -20;
- const int RPG_HUD_XP_FONT = 0;
- const int RPG_HUD_XP_COLOUR = 0x02;
- //onst int RPG_HUD_
- void draw_xp_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
- }
- int get_xp(int id)
- {
- npcdata nd = Game->LoadNPCData(id);
- return nd->Attributes[NPCA_XP];
- }
- int get_xp(npc n)
- {
- return n->Attributes[NPCA_XP];
- }
- int get_xp(npcdata nd)
- {
- return nd->Attributes[NPCA_XP];
- }
- //Determines if the player is entitled to a reward, and awards that amount.
- //should this merely do XP(getxp()) ?
- //No, we need a monster check that does:
- // XP(get_canaward_xp(id))
- int get_canaward_xp(int id)
- {
- npcdata nd = Game->LoadNPCData(id);
- if ( nd->Attributes[NPCA_XP_MAX_PLAYER_LEVEL] )
- {
- if ( current_level <= nd->Attributes[NPCA_XP_MAX_PLAYER_LEVEL] ) return get_xp(id);
- return 0;
- }
- return get_xp(id);
- }
- int get_canaward_xp(npc n)
- {
- if ( n->Attributes[NPCA_XP_MAX_PLAYER_LEVEL] )
- {
- if ( current_level <= nd->Attributes[NPCA_XP_MAX_PLAYER_LEVEL] ) return get_xp(n);
- return 0;
- }
- return get_xp(n);
- }
- int get_canaward_xp(npcdata nd)
- {
- if ( nd->Attributes[NPCA_XP_MAX_PLAYER_LEVEL] )
- {
- if ( current_level <= nd->Attributes[NPCA_XP_MAX_PLAYER_LEVEL] ) return get_xp(id);
- return 0;
- }
- return get_xp(id);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement