Here's a code I have for one of my game:
Here's a small script that Alex helped me with.
IF %EXPERIENCE > 0 THEN <--This means that the variable experience variable is above 0.-->
BEGIN <-- This is the what happens part if the above is true. -->
IF %LEVEL = 1 THEN <-- This is another condition where Level has to be one. -->
BEGIN <-- Another Begin trait -->
%LEVEL := %LEVEL + 1 <-- This is used so that each bonus is different.. -->
%ATTACK := %ATTACK + 2 <--This makes it so that hits are stronger. -->
%DEFENSE := %DEFENSE + 1 <-- This makes the person get less damage from an attack -->
%MAGIC := %MAGIC + 1 <-- Makes Magic Atks stronger -->
%MAGICDEF := %MAGIC + 1 <-- More resistance to magic attacks -->
%EXPERIENCE := %EXPERIENCE - 39 - 1D21 <--Check My Notes -->
END <-- Ends the Level = 1 condition -->
IF %LEVEL = 2 THEN <--Starts new condition for Level equaling 2 -->
BEGIN
%LEVEL := %LEVEL + 1
%ATTACK := %ATTACK + 2
%DEFENCE := %DEFENSE + 2 <-- This is the only real difference as it adds one more than above. -->
%MAGIC := %MAGIC + 1
%MAGICDEF := %MAGICDEF + 1
%EXPERIENCE := %EXPERIENCE - 174 - 1D51 <-- Check My Notes -->
END
END <-- End's the Experience > 0 condition -->
MY NOTES
You see the -39 - 1D21. Well, here's how it works:
I started with -50 and only -50. Than I thought, lets make it a little more random. I made the following:
-50 - 1D10. Well, this would get anywhere between -51 and -60. I though that'd make it a little too tough so I changed it:
-40 - 1D20. Well, this would get anywhere between -41 and -60. I just "added" one more to -40 for -39 and made it 1d21 so that it get's anywhere from -40 to -60. It's the same with the level 2 thing.
This is a wonderful script that can run in the background so that you don't have to make a level up page with 50 links that say: Go Back. I noticed I made a few flaws in my script (for my game, which you won't see here) and will go fix them. Anybody else get a nice script to work.