Non-threaded

Forums » Advanced Editor Forum » Read Thread

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

Shield

27 days ago
How would I make a shield system in my game, kinda like the one in Warzone where you take damage on your shield which is rechargeable before you take damage on your actual health?

Shield

27 days ago
Variables.

Shield

26 days ago
Preferably some with numbers.

Shield

26 days ago
I tried to script some variables, but it didn't work. My first try was to put
IF SHEILD>0 THEN
HEALTH:= HEALTH+ENEMYDMG

IF HEALTH:=HEALTH+ENEMYDMG THEN
SHEILD:=SHEILD-ENEMYDMG

I put it on the link script after a turn you take damage in. It just made it so health didn't go down and the shield stayed the same.

Shield

26 days ago
It's really fascinating looking at how different people approach the logic to setting up something like this.

I might have some suggestions later, but for now, I see you're adding the enemy's damage to the health variable any time the shield is active? There's nothing here that would subtract health.
Also, check the spelling of the shield variable and the script you're using to reference it, because I notice you seem to get creative with it in your post here.

What is ENEMYDMG actually set to?

And what's the purpose of checking the health before subtracting from the shield?

Shield

26 days ago
ENEMYDMG is set to 5, and I have another line of code taking health away from the player, I just didn't think to include it. I added the ENEMYDMG to the health because it would stop health from taking damage and removing it from sheild

Shield

25 days ago
Yeah, there's no reason to reference health at all if the shield is still active, and this is in just such a convoluted unnecessary way. What Peng suggested should work though. Just have damage subtracted from the shield until it reaches zero, then take it from health instead.

Keep in mind though that none of this stuff will do you any good if the writing isn't up to par. There's nothing inherently interesting about clicking a link over and over to make numbers happen.

Shield

26 days ago
Your check for if H equaled H+D (abbreviating here) will never be true. Having already set H to H+D, the check is essentially asking if (H+D) = ((H+D)+D). This means that your shield will never actually go down.

A simpler way to go about doing this:
If S > D: S = S-D
Else: H=H-(D-S) and S=0

And then recharge S however you want to.

Shield

14 days ago
You can use a item and have people pick it up if you want.