Non-threaded

Forums » Advanced Editor Forum » Read Thread

Get help from the experts on variables, scripts, items, and other scary things.

Item lowers different variable if first hits zero

6 years ago

I want magic abilities to be represented by an item, something like 'Magic Spell'. You have a magic reserve as a variable, and whenever you use the spell, it goes down by five. If it reaches zero, it starts taking five health instead. This is supposed to represent death if you exhaust yourself by overusing magic. I'm assuming that in order to achieve this, I would have to use scripting, which I'm okay with.

Basically, each time you use 'Magic Spell', Reserve goes down by five. If it hits zero, 'Magic Spell' takes five from Variable2.

Item lowers different variable if first hits zero

6 years ago
Sounds like you have the steps needed pretty well figured out, just use IF statements to drop health if the spell variable is at or below zero. And a global script I guess to take them to the death page if the health reaches zero.

Item lowers different variable if first hits zero

6 years ago
On Spell Use Link/Item Link -

%MAGPOINTS := %MAGPOINTS - 5
IF %MAGPOINTS < 0 THEN %HITPOINTS := %HITPOINTS + %MAGPOINTS
IF %HITPOINTS < 0 THEN $DEST := @P9000

(Where Page 9000 is death by horrible magic overload, etc...)

Item lowers different variable if first hits zero

6 years ago
What's the exclamation point for? I've never used it to jump to a page.

Item lowers different variable if first hits zero

6 years ago
What exclamation point? I see no exclamation point. This is not the exclamation point you re looking for. ^v^

Item lowers different variable if first hits zero

6 years ago
IF %MAGPOINTS < 0 THEN %HITPOINTS := %HITPOINTS + %MAGPOINTS
I don't understand this. Why is there a +? Wouldn't it be just:
IF %MAGPOINTS < 0 THEN %HITPOINTS := %HITPOINTS - 5
Also, if you only have the < sign, wouldn't that mean that the scrip started taking 5 health only if magpoints was -1 or less? <= might make more sense. Sorry if I'm wrong, I don't actually know anything about this shit.

Item lowers different variable if first hits zero

6 years ago
Adding a negative number to a positive number lowers the positive number. And a flat -5 to hit points I think would detract hit points every turn instead of only when the spell was used.

Item lowers different variable if first hits zero

6 years ago
True, but that negative number wouldn't be 5. Since magpoints is being lowered either way, it's going to be lower every time the item is used. And no, -5 wouldn't lower the variable constantly, that makes no sense. Check the first line of the script:
%MAGPOINTS := %MAGPOINTS - 5

Item lowers different variable if first hits zero

6 years ago
It may appear that hit points are being deducted at a faster rate than 5 at a time, but I'm positive if you come back later today and read it again that won't be the case and it will be obvious you were just hallucinating.

Item lowers different variable if first hits zero

6 years ago
Don't worry, I saved the current post elsewhere so I can make sure it wasn't just my imagination. :)

Item lowers different variable if first hits zero

6 years ago
I see what you are asking. If MagPoints never regenerate and you keep casting spells, the -5 will quickly turn into -10, -15, -20, etc.

%MAGPOINTS := %MAGPOINTS - 5
IF %MAGPOINTS < 0 THEN %HITPOINTS := %HITPOINTS - 5
IF %HITPOINTS < 0 THEN $DEST := @P9000

Item lowers different variable if first hits zero

6 years ago
Thank you, this makes more sense. :) The < sign still bothers me, though. If you start with 10 magpoints, for example, then the first 2 spells work normaly, but when you get to the third one, health won't take a penalty; 0 is not < 0. So it could be either:
IF %MAGPOINTS <= 0 THEN %HITPOINTS := %HITPOINTS - 5
IF %MAGPOINTS < 1 THEN %HITPOINTS := %HITPOINTS - 5
I'm sorry if I'm annoying you, I might be overthinking this.

Item lowers different variable if first hits zero

6 years ago
Spell One: 10 - 5 = 5
Spell Two: 5 - 5 = 0
Spell Three: 0 - 5 = -5

(-5 is less than 0)

If you use <= 0 then you get hit on the second spell as well. If you are Resetting MagPoints to zero when they drop below zero, then you might want to make the script do so after evaluating for < 0.

Item lowers different variable if first hits zero

6 years ago
Oh wait, you're right! This was complete stupidity on my part. I meant the second spell, but you're right, there is no reason to remove health if 5 magpoints were already removed. That would only make sense if you had a situation like if magpoints are less or equal to 0, remove 5 hp, else remove 5 magpoints. That would be useful if magpoints couldn't be restored instantly, but you would instead get something like +5 magpoints when resting. I was just confused. Sorry for stealing your thread, Crazycat.