So, the easiest way to do multiple characters that require different palettes is by using ring items, but what happens if you want to upgrade defense, too? So, yeah, that's what I'm looking for, an item script that can replicate the functions of the "ring" items (minus the palette change; although, I guess I could do it with just an if statement, but I'm not sure how to affect Link's defense through scripting).
Scripted armor
#1
Posted 31 March 2015 - 06:37 PM
- SkyLizardGirl likes this
#2
Posted 31 March 2015 - 07:48 PM
The simplest way is to check if Link's HP decreased each frame, and if so increase it by a percentage of health lost. That's what I do for my defense stat, defense potions, and shield blocking in Solaris.
#3
Posted 31 March 2015 - 09:05 PM
You can do it using a custom itemclass with link tile modifications instead of a palette change. It means duplicating the big shield or anything else that uses a tile mod in subsequent tile pages. This way you can have the rings be separate from the character.
Another option is to have a global variable for whether or not a defensive ring has been picked up. Have two (or three) rings for each character, one with the damage divisor set to one (for normal damage) and one set to two. At the point where the characters change, run a check against the global variable. If the defense ring has been found already, the item to give to change the palette to the other character will be the one that has the defense boost, otherwise it will be one that only changes the palette.
#4
Posted 31 March 2015 - 11:17 PM
You can do it using a custom itemclass with link tile modifications instead of a palette change. It means duplicating the big shield or anything else that uses a tile mod in subsequent tile pages. This way you can have the rings be separate from the character.
The problem with that is all the characters have to share CSet 6, it's fine for 2-3 characters, but if you have more, like the 10 I'm working with for Champion of Balance, using ring class items is the only option, because you'll have to use multiple CSets (Assuming you don't want all your characters to look the same), and Extra Sprite Palettes are pretty much the only option.I was thinking about something along the lines of this (mind you, I'm almost certain this wouldn't work, because I'm just making up names of things)
global script ArmorClasses { void run() { while (true) { if (Link->Item[LightArmor] = true) { ArmorThickness=.5; } else if (Link->Item[MediumArmor] = true) { ArmorThickness=1; } else if (Link->Item[HeavyArmor] = true) { ArmorThickness=1; } if (Link->Item[ThickRobes] = true) { ArmorDefense=2; } else if (Link->Item[PaddedRobes] = true) { ArmorDefense=4; } else if (Link->Item[SorcererRobes] = true) { ArmorDefense=8; } if (Link->Item[LeatherArmor] = true) { ArmorDefense=2; } else if (Link->Item[Chainmail] = true) { ArmorDefense=4; } else if (Link->Item[EnchantedChainmail] = true) { ArmorDefense=8; } if (Link->Item[HalfPlateMail] = true) { ArmorDefense=2; } else if (Link->Item[FullPlateMail] = true) { ArmorDefense=4; } else if (Link->Item[SacredPlateMail] = true) { ArmorDefense=8; } Link->Defense = ArmorThickness * ArmorDefense } Waitframe(); } }
But,it looks like MoscowModder's workaround is probably the only thing I can do.
Edited by Binx, 31 March 2015 - 11:20 PM.
- SkyLizardGirl likes this
#5
Posted 31 March 2015 - 11:33 PM
Unfortunately, Link->Defense does not exist. Your only options are my way (giving HP back in your script) or jsm's way (giving out ring items by script).
Note that I'm pretty sure you can set a ring's extra sprite palette number separately from its level, so multiple rings can share the same color.
#6
Posted 01 April 2015 - 10:15 AM
Yeah, that being said, I did have another idea, what if I made 3-4 Rings per character,with various LTMs, then just script them so when you get a higher level one, it removes all lower level versions. The only pain will be making sure the inventory doesn't get screwed up by using this system.
Also,i could have sworn there was some way to affect the amount of damage Link takes via script. I seem to remember having a scripted ring item that actually reduced Link's defense, instead of improving it, and I coulda sworn it just worked by multiplying the ring item's power, or something like that.
#7
Posted 01 April 2015 - 01:15 PM
Ok, upon looking over the script (it was for elemental damage,but I don't think we were ever able to get it to work right), it used these functions:
//Global variables for Link int MISC_LINK_HP = 1; int Link_Defense = 1; int Link_Element = 0; int GetLinkDamageMultiplier(int attackElement, int Link_Element) { if (attackElement == 0 && Link_Element == 0) {return 1;} //other elements here // Finally, return 1 if for some reason we haven't found a multiplier yet. return 1;} // Updates this npc. void Link_Update() { Link_Damage();} // Take damage as appropriate. void Link_Damage() { // See if we took any hits, and quit if we didn't. int hit = MISC_LINK_HP - Link->HP; if (hit <= 0) {return;} // Go back up to the hp we had before (so we can subtract the proper // amount this time.) Link->HP = MISC_LINK_HP; // Item editor only let's us specify damage in increments of 2, // so half the damage here where we interpret it. hit >>= 1; // Interpret the hit value. int element = hit % 10; int damage = (hit * 0.2) >> 0; // Damage multipliers damage *= GetLinkDamageMultiplier(element, Link_Element); damage /= Link_Defense; // Apply damage. Link->HP -= damage; // Update the 'old' value to the new amount. MISC_LINK_HP = Link->HP; }
Like I said, we had to do some funky stuff with the HP to get it to work right, but something similar could be done with this idea, with "armor type" (light, medium, heavy)standing in for the "element" variable (and removing the attack element variable, altogether), yeah? Then, I should be able to attach Link_Armor and Link_Defense to an item script and voila, instant non-ring defensive item, no?
Edited by Binx, 01 April 2015 - 01:32 PM.
- SkyLizardGirl likes this
#8
Posted 01 April 2015 - 08:16 PM
So can't you set itemdata->Power to modify rings by script?
- Binx likes this
#9
Posted 01 April 2015 - 08:31 PM
Um, can you do that? That seems like it would be a million times easier than what I've seen.(P.S. I've been looking everywhere for a list of stuff in the Itemdata pointer).
#11
Posted 01 April 2015 - 09:32 PM
see,I couldn't find it in zscript.txt. must not have looked hard enough. that other link is very handy, though. thanks!
So, what I'd do, here, is set a ring item with something along the lines of Itemdata->Power = Defense asa pickup script, then use global functions to set the defense variable based on the product of the ArmorType and ArmorPower variables I'd make up (Defense = ArmorType * ArmorPower), and then set THOSE variables by creating non-ring items that set the variables, i.e.
item script LightArmor1 { void run() { ArmorType = 0.5; ArmorPower = 1; } }
Now, I have just one more question. Will I have to spawn the character item/Armor item on Link every time I switch characters,or will it be able to update automatically just by having the armor in my inventory?
#12
Posted 01 April 2015 - 09:48 PM
To answer your question though, i'm not sure if putting an item in link's inventory via script makes the pickup code run, but I'd wager no it doesn't.
#13
Posted 01 April 2015 - 09:53 PM
yeah, generally, setting Link->Item[] to true won't activate pickup scripts. Oh well, I'll just have to figure out how to set Link holding up an item to a character change pose, while still making it a pose that can hold up an item. It can be worked around.
#14
Posted 01 April 2015 - 11:30 PM
Not sure if this helps anything, but you can set Link->Action and Link->HeldItem to hold up an arbitrary item (if you want to give the item by script, for example). The function holdUpItem() in stdExtra.zh can handle giving and holding up items (on land or in water apparently land-only - I should change that) in one call.
Edited by MoscowModder, 01 April 2015 - 11:31 PM.
#15
Posted 01 April 2015 - 11:35 PM
Well, Ideally, I'd want it to not be noticeable at all when the armor items are spawned via character change. But, since silently adding them to the inventory won't activate the necessary scripts,I have to find a way to make it look like something else is going on. Oh,wait,did you mean to hold up a random different item, even though it's not the one picked up?
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users