Jump to content

Photo

Experience system


  • Please log in to reply
25 replies to this topic

#1 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 21 November 2015 - 12:56 PM

Hi I found this good script for system experience by ZoriaRPG.
I am looking to have the experience given instantly by the monsters (not gradual).
How to do please?
Spoiler

  • MermaidCim likes this

#2 MoscowModder

MoscowModder

    Sometimes lurking. Rarely posting.

  • Members
  • Location:Wisconsin

Posted 21 November 2015 - 02:00 PM

It looks like this should give you EXP as soon as the monsters die. What's gradual about it?



#3 Alucard648

Alucard648

    Wizard

  • Members
  • Location:castle Dracula

Posted 21 November 2015 - 02:08 PM

Find this:

void giveEXP(int amount){
    //Give EXP
    Game->Counter[CR_XP] += amount;
    }

And change to this:

void giveEXP(int amount){
    //Give EXP
    Game->DCounter[CR_XP] += amount;
    }

  • Gégé likes this

#4 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 22 November 2015 - 04:42 AM

Thank you but it has not worked. I remove the display of message string it freeze the screen and while it is displayed, the amount of experience is given to infinity and consequently the levels too. I no longer this problem now.
It remains just this problem: I defined giveEXP (enem-> Attributes [9]); to gain experience but it is always multiplied by 15.

Spoiler

Edited by Gégé, 22 November 2015 - 05:16 AM.


#5 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 22 November 2015 - 02:30 PM

It's pretty difficult to keep supporting stuff 20 versions old, but I'll do me best... I went over this, up and down.

 

First, I should mention that this is the oldest version of the XP system that I made available to forumers, and you might want to use at least a moderately newer one...other than that, I don't see anything actually wrong.

 

I think the problem may be using e->Attributes[9] (the editor Attribute Number 10 slot). Try using e->Attributes[10] (editor Misc Attribute 11), and see if it persists. If you want a newer version of the base script, or if you need support, send me a note. The newer one uses a table to list XP awards, but can use e->Attributes, if desired.

 

It also strips out some of the generally tedious, repetitive codeblocks, and other flaws.  :shrug:

 

If you want a hackish patch...and you are certain that the XP award is always multiplied by 15:

 

Change:

void giveEXP(int amount){
//Give EXP
Game->Counter[CR_XP] += amount;

}

....to...

void giveEXP(int amount){
//Give EXP
Game->Counter[CR_XP] += ( amount / 15 ) ;

}

I otherwise have no way to explain the infinite award that you encountred. I'm guessing that you hadn't set up something, or changed a value somewhere. Check that you aren't using Counters 12, 13, 14, 15 elsewhere. Also, if you don't need an XP count above 32,768, it's much simpler to run the numbers to a counter.


Edited by ZoriaRPG, 22 November 2015 - 02:37 PM.

  • Gégé likes this

#6 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 22 November 2015 - 03:13 PM

Forgive me, I just wanted a simple script like this one. Just for a Zelda II game.
I tried, the result is always multiplied by 15. I use ghost.



Problem possible cause of that ?
I think :

(enem->Misc[DMG_MISC1]/5)  enem->Misc[DMG_MISC1]=45;)

 

Spoiler


Or if you can, make a list of id monsters with the appropriate gain ?

I used the same working as for EnemyDamage to display [amount] above link. It is not multiplied.


Edited by Gégé, 22 November 2015 - 06:08 PM.


#7 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 22 November 2015 - 10:30 PM

You may need to change the registers for n->Misc[reg]:

 

const int NPC_MISC_MAXHP = 0; //Which npc->Misc[] value to store HP in (don't touch)
const int EXP_HP_RATIO = 1; //Enemy EXP value = HP divided by this

 

Try using 8, and 9, instead of 0 and 1.

 

In other words, find out what registers of n->Misc[reg] you use elsewhere, and don't duplicate them. ( If you use a table-based version, that won't matter. )

 

Here is a patch, if you want to use a table to assign the value for each enemy in the game manually, without needing the editor attribute slots.

 

File: _SUPPORT_RPG_zh_v0.78_Patch_Enemy_XP_Table.zs

 

Replace the old checkEnemiesKilled() with the one here, and fill in the table spaces with a value other than 0, based on the enemy editor ID numbers for each enemy. I set it up with 25 on a line, and at the end of each line is a reference for which enemies are covered by that line.

 

That is, if you want to give an 2-XP award for a Red Octorock (Slow), [Default Enemy ID 20], you would find number 20 in that table, and change the '0' to a '2', like this:

 

 

If you want a simplified version, that works by enemy type, let me know. That table would have only 42 total awards possible. It would distinguish only enemies by their class, but not by anything else. For example, Red, blue, and magic octorocks would all give the same award that way. It's not ideal, unless you are only using Z1 enemies.

 

The 512 index table (above), instead uses one index for each possible enemy in the editor, allowing you to set an award individually. Note that when killing segmented enemies, such as lanmolas, the award will be given per segment, so you should adjust its value to account for that.


  • Alucard648 likes this

#8 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 23 November 2015 - 04:09 AM

Thank you very much, it works correctly ;).



#9 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 23 November 2015 - 06:43 AM

Thank you very much, it works correctly ;).

 

Good, good. That's pretty much how the newer systems both work, except that the latest one uses floats.

 

This is to allow a max XP value of '2,147,479,999' (technically, 214747.9999, but drawn to the screen as an integer) rather than 214,747. While I'd never need a value that high, it does easily allow 2-million XP, with decimal places for fractional values. One system update back, used something close to what I gave you there.

 

Both also have optional modifier tables, and level offsets to, for example, avoid giving rewards for low-level monsters, when the player is at Nth level, or above. That prevents canon-fodder grinding, and becomes increasingly important at mid-game.

 

Another improvement, was using a level/xp amount chart, rather than all those if statements. Checking if the character level should be updated, is around four instructions. Likewise, the strings for each level are now in a table, and the rate of HP/MP and other bonuses are set by tables, and constants. It's all very nicely automated, in stead of that mess of LevelN() functions.

 

That said, it's still partially incomplete, which is why I've yet to integrate it into a usable demo. That's mostly from a combination of not having the time to work on this for a while, and generally not wanting to do a full run-through test, and re-implementation in an existing game; which I will eventually need to do. :shrug:

 

Still, other things have priority, and I'm glad that you have that old version working as you want. If you want to add in any limits, to prevent players from grinding on extremely weak enemies, let me know, and I'll post another patch for that. (It's possible to add it into the system you are using.)


  • Gégé likes this

#10 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 25 November 2015 - 06:06 PM

There is a means to show the experience received above Link, each gain in counter12 ?

Edited by Gégé, 25 November 2015 - 06:11 PM.


#11 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 25 November 2015 - 10:01 PM

 

There is a means to show the experience received above Link, each gain in counter12 ?

 

 

You mean, to draw it over Link? Sure, you can do that. Just pass the value into a function to draw it.

 

If you mean something different, please explain.



#12 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 26 November 2015 - 03:00 AM

As I do not know how to make, I took the example here:

EnemyDamage by Jamian 
Spoiler


I wrote this :
 
void giveEXP(int amount){
    //Give EXP
    Game->Counter[CR_XP] += amount;
Screen->DrawInteger(6, Link->X+offset, Link->Y-18+(8), FONT_Z3SMALL, DMG_FONTCOL, 0, -1, -1, amount, 0, 128);
    
    }
I have just one small problem, it appears very quickly. What did I forgot ?

#13 Timelord

Timelord

    The Timelord

  • Banned
  • Location:Prydon Academy

Posted 26 November 2015 - 04:12 AM

As I do not know how to make, I took the example here:

EnemyDamage by Jamian 

Spoiler


I wrote this :
 
void giveEXP(int amount){
    //Give EXP
    Game->Counter[CR_XP] += amount;
Screen->DrawInteger(6, Link->X+offset, Link->Y-18+(8), FONT_Z3SMALL, DMG_FONTCOL, 0, -1, -1, amount, 0, 128);
    
    }
I have just one small problem, it appears very quickly. What did I forgot ?

 

 

You didn't forget anything, I'm afraid. It'll only draw for one frame, that way. Try this instead:

void giveEXP(int amount){
    Game->Counter[CR_XP] += amount; //Award XP value.
    RunFFCScript(FFC_DRAW_XP,amount,DRAW_XP_DURATION); //Display it next to Link.
}
    
const int FFC_DRAW_XP = 0; //Set to the ID of the slot that will hold the ffc script 'Draw XP'.
const int DRAW_XP_DURATION = 80; //Frames to display XP award.
    
ffc script DrawXP{
    void run(int amount, int duration){
        int drawing = duration;
        while(drawing > 0){
            for ( int q = 0; q < duration; q++ ) {
                Screen->DrawInteger(6, Link->X+offset, Link->Y-18+(8), FONT_Z3SMALL, DMG_FONTCOL, 0, -1, -1, amount, 0, 128);
                drawing--;
                Waitframe();
            }
            Waitframe();
        }
        this->Data = 0;
        this->Script = 0;
        Quit();    
    }
}

Requires ffcscript.zh.

 

The alternative requires making a global timer-based function, and drawing it while that global timer is > 0. If you put a for loop with a Waitframe() instruction in your global script, it will cause it to halt all other function calls, and instructions as soon as it hits that, which is why I used an ffc script here, as the ffc Waitframe() call will not cause that problem.

 

This is sort of why I would like to add duration-based drawing, to the ZC engine at some point.


Edited by ZoriaRPG, 26 November 2015 - 04:15 AM.


#14 Alucard648

Alucard648

    Wizard

  • Members
  • Location:castle Dracula

Posted 26 November 2015 - 04:18 AM

You didn't forget anything, I'm afraid. It'll only draw for one frame, that way. Try this instead:

void giveEXP(int amount){
    Game->Counter[CR_XP] += amount; //Award XP value.
    RunFFCScript(FFC_DRAW_XP,amount,DRAW_XP_DURATION); //Display it next to Link.
}
    
const int FFC_DRAW_XP = 0; //Set to the ID of the slot that will hold the ffc script 'Draw XP'.
const int DRAW_XP_DURATION = 80; //Frames to display XP award.
    
ffc script DrawXP{
    void run(int amount, int duration){
        int drawing = duration;
        while(drawing > 0){
            for ( int q = 0; q < duration; q++ ) {
                Screen->DrawInteger(6, Link->X+offset, Link->Y-18+(8), FONT_Z3SMALL, DMG_FONTCOL, 0, -1, -1, amount, 0, 128);
                drawing--;
                Waitframe();
            }
            Waitframe();
        }
        this->Data = 0;
        this->Script = 0;
        Quit();    
    }
}

Requires ffcscript.zh.

 

The alternative requires making a global timer-based function, and drawing it while that global timer is > 0. If you put a for loop with a Waitframe() instruction in your global script, it will cause it to halt all other function calls, and instructions as soon as it hits that, which is why I used an ffc script here, as the ffc Waitframe() call will not cause that problem.

 

This is sort of why I would like to add duration-based drawing, to the ZC engine at some point.

You can use Link->Misc[] variable, instead of the global one to save space in global var limit.



#15 Gégé

Gégé

    Senior

  • Members
  • Real Name:Gérard
  • Location:France

Posted 26 November 2015 - 06:24 AM

I got this :

Line 183: error t21: Could not match type signature runffcscript (float, float, float).

 

I have ffcscript.zh, version 1.1.1

Spoiler

Edited by Gégé, 26 November 2015 - 06:30 AM.



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users