Welcome to the Builder Academy

Question Creating spell that gives a Skin/Transform to player - Like Demon Skin Glitch

More
08 Jun 2025 20:28 #10753 by wlessard1
So I setup the applies for the Demon Skin. It is working fine except for one thing.

When I do a apply_hit or apply_move and try and put MORE than 100 as the modifier, it ends up giving me a negative number to the Maxhits/Maxmoves.

  case SPELL_DEMON_SKIN:
    af[0].location = APPLY_AC;
    af[0].duration = 1 + (GET_LEVEL(ch) / 2);
    af[0].modifier = -50;
    SET_BIT_AR(af[0].bitvector, AFF_DEMON);

    af[1].location = APPLY_HITROLL;
    af[1].duration = 1 + (GET_LEVEL(ch) / 2);
    af[1].modifier = (GET_LEVEL(ch))/4;
    SET_BIT_AR(af[1].bitvector, AFF_DEMON);

    af[2].location = APPLY_DAMROLL;
    af[2].duration = 1 + (GET_LEVEL(ch) / 2);
    af[2].modifier = (GET_LEVEL(ch))/4;
    SET_BIT_AR(af[2].bitvector, AFF_DEMON);

    af[3].location = APPLY_HIT;
    af[3].duration = (GET_LEVEL(ch) / 2);
    af[3].modifier = 200;
    SET_BIT_AR(af[3].bitvector, AFF_DEMON);

    af[4].location = APPLY_MOVE;
    af[4].duration = 1 + (GET_LEVEL(ch) / 2);
    af[4].modifier = 200;
    SET_BIT_AR(af[4].bitvector, AFF_DEMON);

    to_vict = "You skin becomes leathery.";
    break;

Results -- If I see the modifier to 100, it works fine but anything over that produces a negative to maxmove and hits, probably maxmana as well.

Affected by: DEMON
SPL: ( 29hr) Demon Skin            -56 to MAXMOVE, sets DEMON,
SPL: ( 28hr) Demon Skin            -56 to MAXHIT, sets DEMON,
SPL: ( 29hr) Demon Skin            +13 to DAMROLL, sets DEMON,
SPL: ( 29hr) Demon Skin            +13 to HITROLL, sets DEMON,
SPL: ( 29hr) Demon Skin            -50 to ARMOR, sets DEMON,


I would like to be able to run the modifier up a bit higher as I want to add some other spells that do things like this.

Bramage
Thanks for any help.

Just a guy coding a mud at home for no reason but the challenge.

Please Log in or Create an account to join the conversation.

More
09 Jun 2025 05:17 - 09 Jun 2025 05:18 #10754 by Salty
Stock TBAmud has the following in structs.h
Code:
/** An affect structure. */ struct affected_type {   sh_int spell; /**< The spell that caused this */   sh_int duration; /**< For how long its effects will last      */   sbyte modifier;  /**< Added/subtracted to/from apropriate ability     */   byte location;   /**< Tells which ability to change(APPLY_XXX). */   int bitvector[AF_ARRAY_MAX]; /**< Tells which bits to set (AFF_XXX). */   struct affected_type *next; /**< The next affect in the list of affects. */ };

sbyte is defined in structs.h as:
Code:
typedef signed char sbyte;          /**< 1 byte; vals = -127 to 127 */

If you want larger values for affect.modifier[] you will need to change it to something like sh_int or ubyte.

I'n my game I went with sh_int:
Code:
/** An affect structure. */ struct affected_type {   sh_int spell;                /**< The spell that caused this */   sh_int duration;             /**< For how long its effects will last      */   sh_int modifier;             /**< Added/subtracted to/from apropriate ability     */   byte location;               /**< Tells which ability to change(APPLY_XXX). */   int bitvector[AF_ARRAY_MAX]; /**< Tells which bits to set (AFF_XXX). */   struct affected_type *next; /**< The next affect in the list of affects. */ };

You could use ubyte or sh_int, whichever suits your fancy.  They are defined as:
Code:
typedef unsigned char ubyte;        /**< 1 byte; vals = 0 to 255 */ typedef signed short int sh_int;    /**< 2 bytes; vals = -32,768 to 32,767 */


Hope this helps
Last edit: 09 Jun 2025 05:18 by Salty.

Please Log in or Create an account to join the conversation.

More
19 Jun 2025 15:04 #10761 by wlessard1
Still looking around at the code. Haven't found where I can change the bonus off of 127 for maxmana, maxhit and maxmoves.

I understand what you are saying and why. Just not finding where it is pulling it.

I am not a coder but will be trying a few things otherwise as a test and see.

Just a guy coding a mud at home for no reason but the challenge.

Please Log in or Create an account to join the conversation.

More
20 Jun 2025 23:01 #10762 by thomas
As Salty wrote, it's in structs.h
The following user(s) said Thank You: wlessard1

Please Log in or Create an account to join the conversation.

More
22 Jun 2025 21:37 #10763 by wlessard1
I found where it is determined in structs.h

struct char_point_data
{
sh_int mana; /**< Current mana level */
sh_int max_mana; /**< Max mana level */
sh_int hit; /**< Curent hit point, or health, level */
sh_int max_hit; /**< Max hit point, or health, level */
sh_int move; /**< Current move point, or stamina, level */
sh_int max_move; /**< Max move point, or stamina, level */

/** Current armor class. Internal use goes from -100 (totally armored) to
* 100 (totally naked). Externally expressed as -10 (totally armored) to
* 10 (totally naked). Currently follows the old and decrepit Advanced
* Dungeons and Dragons method of dealing with character defense, or
* Armor class. */
sh_int armor;
int gold; /**< Current gold carried on character */
int bank_gold; /**< Gold the char has in a bank account */
int exp; /**< The experience points, or value, of the character. */

sbyte hitroll; /**< Any bonus or penalty to the hit roll */
sbyte damroll; /**< Any bonus or penalty to the damage roll */
};

So the system is already using sh_int but still stops at 127 as if it is looking it up by sbyte.

127 = 127 bonus, 128 = -128 bonus.

Just a guy coding a mud at home for no reason but the challenge.

Please Log in or Create an account to join the conversation.

More
22 Jun 2025 21:50 #10764 by wlessard1
I think I found where it is... just have to be careful I don't totally frak the code on this. I see where in Handler.c the mod for stats, abilities, weight, age and such around line 140.

If I understand correctly, I could possibly change the sbyte here to sh_int or ubyte I am guessing? I will try changing it to sh_int and see if I totally break something... hehehehe.

static void aff_apply_modify(struct char_data *ch, byte loc, sbyte mod, char *msg)

some other code... then

case APPLY_MANA:
GET_MAX_MANA(ch) += mod;
break;

case APPLY_HIT:
GET_MAX_HIT(ch) += mod;
break;

case APPLY_MOVE:
GET_MAX_MOVE(ch) += mod;
break;

Just a guy coding a mud at home for no reason but the challenge.

Please Log in or Create an account to join the conversation.

Time to create page: 0.194 seconds