RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Er, nevermind [Fixed...kinda]

0 Members and 1 Guest are viewing this topic.

**
Rep:
Level 86
Okay, here's the scoop.  A character that I'm making for the current game I'm working on (which is still in the planning stages, sadly,) has an interesting ability.  Basically, she can shift between any one of the four main elements, which changes her attitude, stats, skills, etc etc.  So, for now, I'm just using the four basic RTP Elementals sprites.

Anyway. 

The way I went about it includes a fairly large number of variables and common events, and it works, but it causes a bit of in-game lag when switching in or out of battle, as it has to calculate the new form's current xp, hp, sp, etc etc.  I mean, it's not anything overly annoying, but I was just curious if there was an easy way to manipulate this whole thing with scripts rather than events.

Personally, I prefer events, mainly because I can only do simple scripting : D;  But if we can do this with a script that'll cut down on the lag, I'd say let's go for it. 


I tried it on a friend's computer, which has better specs and it works fine.  My computer just sucks, it seems.  Sorry to be a bother!
« Last Edit: January 07, 2009, 05:08:07 AM by Kularian »

********
Hungry
Rep:
Level 96
Mawbeast
2013 Best ArtistParticipant - GIAW 11Secret Santa 2013 ParticipantFor the great victory in the Breakfast War.2012 Best Game Creator (Non-RM Programs)~Bronze - GIAW 9Project of the Month winner for December 2009Project of the Month winner for August 20082011 Best Game Creator (Non RM)Gold - GIAW Halloween
well, there is a faster way to do it though.

all you'd need to do is make the 4 elemental forms as actors in the database, and switch things around as needed.

unless you're doing something far more complex with the system.

FCF3a A+ C- D H- M P+ R T W- Z- Sf RLCT a cmn+++ d++ e++ f h+++ iw+++ j+ p sf+
Follow my project: MBlok | Find me on: Bandcamp | Twitter | Patreon

**
Rep:
Level 86
Well yes, but I need to keep their equipment and XP the same throughout.  It wouldn't make sense to have a level 15 fire elemental change and a level 22 wind and so on and so forth.  So I can't just 'swap' them. 

Currently the code looks something like this:

Code: [Select]
From Water form to Fire form:

Set Variable 1 = Taria(Fire)'s EXP
Set Variable 2 = Taria(Water)'s EXP
Set Variable 2 -= Variable 1 (to achieve the difference in EXP)
Remove Taria(water)
Add Taria(fire)
Change Exp: Taria(fire) + Variable 2

And since it is impossible, as the system is setup, for the form you're switching to, to have more EXP than the one you're currently in, you won't run into any negative EXP problems.  There's also code to adjust HP and such too, but that wasn't really necessary to post.

But they will level up mid-battle if it has been awhile since you used them, without prompting or anything.  It works rather well, from my tests. ^^

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
That doesn't look like it would cause much lag. Could you post the conditional branches? There might be a way to simplify them and that might reduce lag.

**
Rep:
Level 86
Sure.  ^^  I don't have an issue with it.  But the lag problem is just on my laptop, which I'm pretty sure is just because it's tiny.  One of those Asus eeePC's with like a 2GB hard drive.

Code: [Select]
@>Control Variables: [0096: Fire] = [Taria (Fire)]'s EXP]
@>Control Variables: [0097: Water] = [Taria (Water)]'s EXP
@>Control Variables: [0100: Difference] = Variable [0097: Water]
@>Control Variables: [0100: Difference] -= Variable [0096: Fire]
@>Control Variables: [0094: HP] = [Taria (Water)]'s HP
@>Control Variables: [0095: MP] = [Taria (Water)]'s SP
@>Change Party Member: Remove [Taria (Water)]
@>Change Party Member: Add [Taria (Fire)]
@>Change EXP: [Taria (Fire)], + Variable [0100: Difference]
@>Recover All: [Taria (Fire)]
@>Control Variables: [0094: HP] -= [Taria (Fire)]'s MaxHP
@>Control Variables: [0094: HP] *= -1
@>Conditional Branch: Variable [0094: HP] > 0
   @>Change HP: [Taria (Fire)], - Variable [0094: HP]
   @>
 : Branch End
@>Control Variables: [0095: MP] -= [Taria (Fire)]'s MaxSP
@>Control Variables: [0095: MP] *= -1
@>Conditional Branch: Variable [0095: MP] > 0
   @>Change SP: [Taria (Fire)], - Variable [0095: MP]
   @>
 : Branch End


For the basic synopsis, without having to figure out what I did from just reading the code, this lets you switch between two of the forms, this one being from water to fire.  There are a total of 12 of these common events, each with no trigger, each of them called with an Ability.

Basically it stores the current form's EXP, and the form it's going /to/'s EXP.  Then it subtracts the two in order to find the difference.

e.g. Water form has 192 EXP, Fire form has 150 EXP.  The variables are stored and the difference is 42 EXP.

Then I also store the HP and SP, so that each form can't just switch to fully heal itself.  This process will be explained in a bit.  Then we simply remove water, and add fire.

First thing it does is add the difference in EXP.  From our previous example, the fire form now has 192 EXP, just like the Water.  This ensures that, no matter which form switches to which, they will always have the max EXP for that form.  Then I use the recover all command to bring the form back up to full HP and SP, which will be useful for the next part.

The HP and SP calculations find out the difference between the CurrentHp of the last form and the MaxHP of the new form, in order to make certain it's balanced.

e.g. Water form has 100 HP current when it switches to fire, which has a max of 175.  The calculation takes the current, (100) and subtracts the new max (175) to net it -75, which is then multiplied by -1 and then subtracted from the new form's HP, if it is over 0.  This is to prevent switching to a form with lower HP and losing even more due to an oversight on the creator's part. >.>;

I mean, it's not the prettiest thing ever.  The code works, better than I'd thought, but it's not as crisp and clear as it could be.  Also, I haven't really factored in status effects yet, with this.  I'll probably have...something...that keeps track of those for the purposes of this character.

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Nah, it's done pretty well, and yeah, I would say it's because of the computer. I think it's reasonable to assert that most computers ought to be able to run something like that without lag. Nice work - it seems impossible for the HP difference to not be greater than or equal to 0, so the condition seems unnecessary, but if as you say it is to correct for possible oversight then I suspect you have a reason that it might be possible in the future. Anyway, it's a solid event. :)

**
Rep:
Level 86
Quote
Nice work - it seems impossible for the HP difference to not be greater than or equal to 0, so the condition seems unnecessary, but if as you say it is to correct for possible oversight then I suspect you have a reason that it might be possible in the future.

Well, let's say that you're switching from Earth (who has the most base HP) to Wind (who has the least) 

Earth currently has 420 HP, but the enemy is a bird, who is weak to wind, but strong against earth, so you switch out.  Wind only has 380 hp at this level, currently, so the HP Variable would be set to 40, as 420-380 = 40.  When you multiply that by the -1, it turns to -40.  However, subtracting a -40, as we all know, adds 40, but the HP shouldn't go beyond its max, anyway.  So it can...but testing it doesn't yield a bad result.  However, as much as I try to be, I'm not infallible, :P 

So that bit of code there is pretty much a 'just in case' scenario.  I'd rather have it work flawlessly, with a few extra lines of code, then have to go back in and dig out just what went wrong where when the game is further along ^^

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
Ah, I thought they all had equal base HP. I would suggest taking percentile if that's the case. Otherwise, it can be abused by the player - always start in Earth and then only switch after you have gone below another form's max. Better to take percentile, so that if at 70% life as Earth (288), you go to 70% as Wind (266) when you change.

**
Rep:
Level 86
Hmm...that could work.  Hang on, let me just to put it together real fast, and see.

Control Variables: [HP] = Taria(Fire)'s HP
Control Variables: [HP] /= Taria(Fire)'s Max HP
Change Party Member: Remove Taria(Fire)
Change Party Member: Add Taria(Earth)
Control Variables: [HP] *= Taria(Earth)'s Max HP
Control Variables: [HP] -= Taria(Earth)'s Max HP
Control Variables: [HP] *= -1
Change HP: Taria(Earth), - [HP]

That look like it would work?  Thanks for the idea, by the way ^^

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Best Member2012 Best RPG Maker User (Scripting)2012 Favorite Staff Member2012 Most Mature MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Veteran2011 Favourite Staff Member2011 Most Mature Member2011 Best RPG Maker User (Scripting)2011 Best Use of Avatar and Signature Space2010 Most Mature Member2010 Favourite Staff Member
You'll have to multiply by 100 when getting old HP, and then divide by 100 after multiplying new HP. This is because variables store integers, not floats. Otherwise, it looks fine. Remember to recover the actor like you did before though, before subtracting HP.

**
Rep:
Level 86
Ahhh, okay.  I wasn't sure if they stored decimal places or not.  That works though, *nod*  Thanks for your assistance. ^^