Welcome, Guest. Please login or register.

What openbor you prefer: Double dragon,battletoads or final fight !? by lirexpatrio
[December 07, 2012, 07:15:27 pm]


what are your favorite games OpenBOR?! by lirexpatrio
[December 07, 2012, 07:09:46 pm]


Post Some Awesome Videos by maxman
[December 07, 2012, 05:51:39 pm]


Can @cmd playmusic "aaaa" 1 also increse music sound ? by BeasTie
[December 07, 2012, 05:24:38 pm]


Streets of Rage: Silent Storm by mtrain
[December 07, 2012, 03:45:05 pm]


Site will be down for maintenance on 12/8/2012 thru 12/10/2012 by Damon Caskey
[December 07, 2012, 07:42:42 am]


Cancelled SOR 3d Remake by riccochet
[December 07, 2012, 03:58:33 am]


Dungeon Fighter: B.O.R. by msmalik681
[December 07, 2012, 03:24:27 am]


[TUTORIAL] How to create 4 Games of OpenBOR in 1 CD (650 MB) by magggas
[December 06, 2012, 09:46:25 pm]


custknife by Bloodbane
[December 06, 2012, 09:34:09 pm]


blockfx help by B.Kardi
[December 06, 2012, 04:09:14 pm]


street of age 4 hd by corradlo
[December 06, 2012, 01:41:36 pm]


ClaFan - Classic Fantasy ver 1.17 by soniczxblade
[December 06, 2012, 05:01:20 am]


Bug Archive by Bloodbane
[December 06, 2012, 02:00:44 am]


"Bio-Doom" and "Gears of Doom" by BulletBob
[December 05, 2012, 10:07:21 pm]


Contra Locked 'N' Loaded v2 by Bloodbane
[December 05, 2012, 09:39:43 pm]


Downloadable OpenBoR Manual by BeasTie
[December 05, 2012, 08:31:24 pm]


Having trouble testing changes by B.Kardi
[December 05, 2012, 03:05:53 pm]


DragonBall Absalon by msmalik681
[December 05, 2012, 02:52:13 pm]


[Hi-Res] Swamp by Vibrant
[December 05, 2012, 10:47:14 am]


  • Dot Guests: 139
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.



Author Topic: level up system  (Read 1456 times)

0 Members and 1 Guest are viewing this topic.

Offline Pierwolf

  • Sr. Member
  • ****
  • Posts: 348
    • Pierwolf's Magic chamber of abstract theories about relativity of Karma and metempsychosis
level up system
« on: May 25, 2012, 09:26:33 am »
hi everybody,

as you can see in the attachment below, studying the bare knukle Z mod scripts and playing with scripts i've implemented a level up system in my mod.

for how it works now, everytime you level up you regain full Healt and mp:

Code: [Select]
void lvup(int plIndex)
{
void score=getplayerproperty(plIndex,"score");
void ent=getplayerproperty(plIndex,"entity");
int oldLevel=getglobalvar("level."+plIndex);
int lv=getLevel(score);
if (oldLevel==NULL()){oldLevel=0;}
if (lv>oldLevel){
changeentityproperty(ent,"health",getentityproperty(ent,"maxhealth"));
changeentityproperty(ent,"mp",getentityproperty(ent,"maxmp"));
setglobalvar("level."+plIndex,lv);
spawnLvup(ent);
}
            setglobalvar("score"+plIndex,score);
}

now, how can i proceed if i want that everytime the chars level up, it gains, let's say, +5  to healt and mp permanently? any tips?

i've tryed this, but it doesn't works, so i'm not in the right path:
Code: [Select]
void lvup(int plIndex)
{
void score=getplayerproperty(plIndex,"score");
void ent=getplayerproperty(plIndex,"entity");
int oldLevel=getglobalvar("level."+plIndex);
int lv=getLevel(score);
if (oldLevel==NULL()){oldLevel=0;}
if (lv>oldLevel){
changeentityproperty(ent,"health",getentityproperty(ent,"maxhealth", + 5));
changeentityproperty(ent,"mp",getentityproperty(ent,"maxmp", + 5));
setglobalvar("level."+plIndex,lv);
spawnLvup(ent);
}
            setglobalvar("score"+plIndex,score);
}

thanks in advance.


My current project:

Knights & Dragons: The Endless Quest - COMPLETE!

Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: level up system
« Reply #1 on: May 25, 2012, 10:10:45 am »
changeentityproperty(ent,"maxhealth",getentityproperty(ent,"maxhealth")+ 5);changeentityproperty(ent,"maxmp",getentityproperty(ent,"maxmp") + 5);
changeentityproperty(ent,"health",getentityproperty(ent,"maxhealth"));changeentityproperty(ent,"mp",getentityproperty(ent,"maxmp"));

Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Re: level up system
« Reply #2 on: May 25, 2012, 10:19:33 am »
That doesn't work if you quit the level or exit the game. So you need to store the level up information in some global variables and do some check in your spawn or respawn animation.


Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: level up system
« Reply #3 on: May 25, 2012, 11:10:50 am »
I've been thinking but havn't tried yet but a possible way is...

Code: [Select]
ent = getlocalvar("self");
int whateverlevelcharacteris = getentityproperty(ent,"score") / 5000; //so every level will be + 1 for every 5000 score/xp or what ever method you be using
if ( getentityproperty(ent,"maxhealth") == getentityproperty(ent,"health") ) //this mean if the characters health is full then full up his health and max his bar
{
changeentityproperty(ent,"maxhealth",getentityproperty(ent,"maxhealth")+ (5 * whateverlevelcharacteris) );
changeentityproperty(ent,"health",getentityproperty(ent,"maxhealth")+ (5 * whateverlevelcharacteris) );
} else { //just max out his bar without touching his health
changeentityproperty(ent,"maxhealth",getentityproperty(ent,"maxhealth")+ (5 * whateverlevelcharacteris) );
}


and I don't think that you will need to save to a file then. O and put this command in the onspawnscript of a character.

Offline Pierwolf

  • Sr. Member
  • ****
  • Posts: 348
    • Pierwolf's Magic chamber of abstract theories about relativity of Karma and metempsychosis
Re: level up system
« Reply #4 on: May 25, 2012, 07:24:23 pm »
anyway i've tried it and it didn't work. :dunce:

maybe you would examine my mod updated. i've added the level up system i've done until now.

you can download  here.
My current project:

Knights & Dragons: The Endless Quest - COMPLETE!

Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: level up system
« Reply #5 on: May 25, 2012, 07:45:42 pm »
I'd love to help you.
I'll download it and fix it when I have time.

Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: level up system
« Reply #6 on: May 26, 2012, 09:45:37 am »
Ok. Tested and make the fix for ya.
1.Overwrite the scripts below to your scripts folder.
2.Add a line to each header of all the hero entities.
For example elf.txt
onspawnscript      data/scripts/spawn/player.c
3.Remove the line in every hero entity.
script            data/scripts/level.c
4.Delete data/scripts/level.c.

Of course, don't forget to backup your mod.

It should work now.
Good luck.


Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: level up system
« Reply #7 on: May 26, 2012, 10:16:09 am »
Haven't looked at the fixes here, but just in case; don't forget about filestreams for saving character levels and similar data. They are tailor made for this kind of thing. I find them much easier to use than trying to deal with all the side effects that come from OpenBOR's default save game system.

DC
OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: level up system
« Reply #8 on: May 26, 2012, 10:32:53 am »
The idea is only to save scores to globalvars .
You can tell the level and the ability from score.
And the feature the engine saves globalvars is very useful.

Offline Damon Caskey

  • Hero Member
  • *****
  • Posts: 5335
    • The Gorge
Re: level up system
« Reply #9 on: May 26, 2012, 10:48:29 am »
Yeah I get the part about using scores to determine the character's level. Leveraging formulas to keep code and variables to a minimum is coding 101.

About global variables though, those are nothing but a headache. The main trouble comes when you want the character levels and other saved data to be fully independent of where the player is in the game. If the player say, goes back and loads up a saved game from stage 2, your script gets those globals instead of what was stored when he saved stage 7. Filestreams bypass that problem completely and give you consistent results.

DC
OpenBOR Wiki.

Coming Soon:
Spoiler
Fatal Fury Chronicals


Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Re: level up system
« Reply #10 on: May 26, 2012, 11:05:39 am »
That depends on what he really needs to do. To me, loading a saved game means I want to abandon current progress, so it is OK to overwrite the values. Besides, if the save flag is set to 2, your stage 7 information will be saved and overwrite the old save from stage 2.  Real problem is all informations must be stored as global variables, no arrays nor pointers are acceptable. If you want a large trunk of data to be saved,  you'll have to fill a large amount of global variables.

However, if you want a save system like an RPG, for example, multiple save slots, the filesteam might be useful. You have to design your save data carefully, decide which variables are necessary and when to read/write the file.

Offline rafhot

  • Hero Member
  • *****
  • Posts: 557
  • Raf Smash!
    • my creations
Re: level up system
« Reply #11 on: May 26, 2012, 05:46:09 pm »
i started to play with volcanic fixes trying to add more features

it is possible do something like this to increase offense and defense at lvl up?

Quote
changeentityproperty(ent,"offense",getentityproperty(ent,"offense", openborconstant("ATK_NORMAL")+0.1*(lv - 1)));


do you think something like that should work?
« Last Edit: May 26, 2012, 06:01:43 pm by rafhot »

Offline volcanic

  • Hero Member
  • *****
  • Posts: 706
  • Nobody
Re: level up system
« Reply #12 on: May 26, 2012, 06:18:24 pm »
Yes. It is doable.
Almost all the properties such as speed,defense, even delay can be changed.
But your script is not very correct.
« Last Edit: May 26, 2012, 06:22:20 pm by volcanic »

Offline rafhot

  • Hero Member
  • *****
  • Posts: 557
  • Raf Smash!
    • my creations
Re: level up system
« Reply #13 on: May 26, 2012, 07:32:52 pm »
what is the correct syntax for offense, defense and velocity changes?

Offline utunnels

  • Developer
  • Hero Member
  • *****
  • Posts: 2713
Re: level up system
« Reply #14 on: May 27, 2012, 04:19:29 am »
Something like

changeentityproperty(ent, "offense", openborconstant("ATK_NORMAL"), value);

You need to specify the type of the attack type.
« Last Edit: May 27, 2012, 04:22:16 am by utunnels »

 



 0%




SimplePortal 2.3.3 © 2008-2010, SimplePortal