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.
[RESOLVED]Either I'm not seeing it or....

0 Members and 1 Guest are viewing this topic.

*
Rep:
Level 88
Something something events
Project of the Month winner for December 2008
Well, for my game I'm working on making the AI for the first party member that joins you, a healer. What I'm trying to do is make it so if the player falls below 60% HP, then the healer will take his next turn to cast a healing spell on that player. Here is the event code:



Here is what it's suppost to do line by line

Spoiler for:
Line 1: Recast label
Line 2: Sets the variable equal to Levin's (the healer) MP (though I call it TP)
Line 3: Sets the variable equal to Mihli's MaxHP
Line 4: Sets the variable equal to Mihli's current HP
Line 5:    "
Line 6: Divides Mihli's current HP by her max HP and saves the remainder (This is where I might be going wrong. I don't understand Mod 100%)
Line 7: Condition Branch: If the variable is less then or equal to 60
Line 8: Checks to see if Levin has enough TP to use the healing move
Line 9: If he doesn't, then the sweat drop appears showing he is low on TP
Line 10: If he does, it calls the common event to calc how much he can heal for
Line 11: Animation blah blah
Line 12: Healing blah blah
Line 13: Delay untill next turn
Line 14: Jump to Label Recast

Even though Mihli is at max HP and not below 60%... this happens....



So either it's something I'm not understanding about Mod (since I'm not 100% sure what it completely does) or it's something else I'm not seeing =x
« Last Edit: January 04, 2009, 06:51:35 PM by HowlingWinds »

*****
Rep:
Level 88
Mod actually stores the remainder into the variable.

So what's happening is this...

Spoiler for:
Check Max HP
  (Max HP = 50)
Check current HP
  (HP = 50)
Mod HP Calc
  (Max/HP)
  (50/50)
  (1)
  (Remainder = 0)
HP Calc = 0
Check if HP Calc <= 60
  (HP Calc = 0)
  (0 >= 60)
  (HP Calc >=60)
Heal
Repeat

I used the 50 HP as an example number. Basically, Mod isn't the thing to use. I figure you saw the % sign and thought it did percents, but it actually doesn't.

I hope that helped, ask any questions if I confused you at all.

*
Rep:
Level 88
Something something events
Project of the Month winner for December 2008
oh, I'm guessing mod stores up to set amount of numbers like a variable could. I just took a calculator and tried: 30(current)/58(Max) and got .51724137(yada yada) so it's probably storing "51724137" into the variable ><; and it probably reads left to right until it hits capped amount it can store.

Bummer, guess I'll have to think of another way to do his AI  :-\

EDIT: Was just talking to a friend and he figured out a way (if above is the case) I would just make a simple loop of

loop
if number > 100
number /10
end loop

and before the loop I just make a condition branch that checks if the mod is = 0 (full HP) I'll put resolved in the title once I test this out.

EDIT2: Ugh... still doesn't work. Here is what I have now

Spoiler for:


If my math is wrong, then that could be the problem (again), but if it isn't it "should" work. Though it doesn't... could it be possible that since this is a parallel process that RMVX is over looking the labels and is skipping them completely?
« Last Edit: January 04, 2009, 10:03:05 AM by HowlingWinds »

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
No, mod stores a remainder. Any number can be written as a*b + c

When you mod something by a, then c is the reminder and c is what mod stores.

So:  17 % 5

17 = 5*3 + 2

2 is the remainder, so 17 % 5 = 2

24 % 7

24 = 7*3 + 3,     24 % 7 = 3


What you really want to do is multiply by 100 and then divide.

So:


Control Variables: [32:Levin HP Calc (Max)] = [Mihli]'s Max HP
Control Variables: [41:HP Calc] = [Mihli]'s HP
Control Variables: [41: HP Calc] *= 100
Control Variables: [41: HP Calc] /= [32:Levin HP Calc (Max)]


The number in Hp Calc should now be the percentage of HP left. Make sure that you don't bother using the Heal spell if the actor's HP is 0

*
Rep:
Level 88
Something something events
Project of the Month winner for December 2008
oohh >< Now I feel stupid lol. I've been thinking of "remainer" in the wrong way. Thanks MA and Revo for the help, as the AI works now.