MODULE: Character Accessories

Started by tostiok, Wed 15/06/2022 06:00:46

Previous topic - Next topic

tostiok

I just released a module I'm using for adding accessories to characters, like hats, glasses, wigs, etc.
It's similar than Character::FollowCharacter but my module allows you to specify the z-index of each accessory. So if you have a wig, and over that you need a hat, you can specify the z-index of the wig as 1, and the z-index of the hat as 2.

If you later need to replace the hat with another hat, you can simply add the new hat as an accessory on the same z-index than the previous one.

Usage
// supose cJoe is a Character that is being used as the player character
// cHat is a Character that portays a hat
// cGlasses is a Character that portrays a pair of glasses
// cSunGlasses is Character that portrays a pair of sunglasses

cJoe.CL_AddAccessory(cHat,1); // adds the hat to the player
cJoe.CL_AddAccessory(cGlasses,2); // adds the glasses to the player

// later
cJoe.CL_RemoveAccessory(cHat); // removes the hat from the player, but not from the screen.
cJoe.CL_SetAccessoryOffsetZ(cGlasses, 20); // the glasses will be drawn 20 pixeles above the natural Y position
cJoe.CL_AddAccessory(cSunGlasses, 2); // replaces the regular glasses by the sunglasses. The regular glasses are not removed from the screen.
if (cJoe.CL_HasAccessory(cGlasses)) {
cJoe.Say("I'm still wearing my glasses");
}

Notices
By default the module allows to have 5 characters with accessories. If you need more, increase the constant MODULE_CL_ACCESSORIES_MAX_COUNT
By default, each character can have up to 5 accessories. If you need more, increase the constant MODULE_CL_ACCESSORIES_COUNT_PER_CHARACTER


https://github.com/tostiok/ags-character-accessories

AndreasBlack

This sounds promising  8-) I have to give it a go later.  (nod) But can it animate aswell without additional code? That is follow the walkcycles, it recognises when the characters turns left, up, down, etc.
If not, that's something you should try and feature in it, i think. Like forexample if the player gets an medieval armor or something and walks around with it.

AndreasBlack

Tried your module now! Some suggestions. Option of having the cGlasses, cHat, or whatever accessories being clickable on top of the character as a verb saying "take of glasses" or "take of hat" and then a parameter if you want leftclick or rightclick to take them off. Not that it's hard to fix yourself, but still. Also when taking of the glasses, maybe i did something wrong but, they stay in the air when i take them off with cCharacter.CL_RemoveAccessory(cGlasses); so i had to call transparency=100; shouldn't either be neccessary, they float in the air otherwise (laugh) . Another would be to add a parameter for custom animation putting on the glasses, and off the glasses. Just my thoughts, after trying it! Good job so far! :)

 

SMF spam blocked by CleanTalk