Welcome to the Builder Academy

Question Assistant with integrating corpse host?

More
29 Dec 2022 07:21 #10242 by Nero
I am trying to integrate www.circlemud.org/pub/CircleMUD/submissi...kills/corpsehost.txt into my code
I am assuming that the actual ASpell code is supposed to go into spells.c which is where I have it but it doesn't seem to link up and nothing happens when I cast the spell.
I am also assume that we have to add that code instead to magic.c under mag_summons possibly? When I do it that way though game crashes
The following user(s) said Thank You: Vatiken

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

More
29 Dec 2022 18:23 - 29 Dec 2022 18:26 #10243 by Vatiken
That snippet is pretty old and some of the underlying functionality has changed. I was able to implement it into a relatively fresh version of tbaMUD and get it to compile, work and run with some minor alterations.

Code:
diff --git a/src/act.wizard.c b/src/act.wizard.c index b0694ee..db0aa88 100644 --- a/src/act.wizard.c +++ b/src/act.wizard.c @@ -1261,6 +1261,9 @@ void return_to_char(struct char_data * ch)    if (ch->desc->original->desc) {      ch->desc->original->desc->character = NULL;      STATE(ch->desc->original->desc) = CON_DISCONNECT; + +  if (affected_by_spell(ch->desc->original, SPELL_CORPSE_HOST)) +    affect_from_char(ch->desc->original, SPELL_CORPSE_HOST);    }      /* Now our descriptor points to our original body. */ @@ -1270,6 +1273,9 @@ void return_to_char(struct char_data * ch)    /* And our body's pointer to descriptor now points to our descriptor. */    ch->desc->character->desc = ch->desc;    ch->desc = NULL;   + +  if (affected_by_spell(ch, SPELL_CORPSE_HOST)) +        die(ch, NULL);  }    ACMD(do_return) diff --git a/src/class.c b/src/class.c index 6efd9da..68f540e 100644 --- a/src/class.c +++ b/src/class.c @@ -1561,6 +1561,7 @@ void init_spell_levels(void)  {    /* MAGES */    spell_level(SPELL_MAGIC_MISSILE, CLASS_MAGIC_USER, 1); +  spell_level(SPELL_CORPSE_HOST, CLASS_MAGIC_USER, 1);    spell_level(SPELL_DETECT_INVIS, CLASS_MAGIC_USER, 2);    spell_level(SPELL_DETECT_MAGIC, CLASS_MAGIC_USER, 2);    spell_level(SPELL_CHILL_TOUCH, CLASS_MAGIC_USER, 3); diff --git a/src/fight.c b/src/fight.c index e4b74b5..92da825 100644 --- a/src/fight.c +++ b/src/fight.c @@ -720,16 +720,17 @@ int damage(struct char_data *ch, struct char_data *victim, int dam, int attackty    }      /* Help out poor linkless people who are attacked */ -  if (!IS_NPC(victim) && !(victim->desc) && GET_POS(victim) > POS_STUNNED) { + if (!IS_NPC(victim) && !(victim->desc) && GET_POS(victim) > POS_STUNNED && !affected_by_spell(victim, SPELL_CORPSE_HOST)) {      do_flee(victim, NULL, 0, 0);      if (!FIGHTING(victim)) {        act("$n is rescued by divine forces.", FALSE, victim, 0, 0, TO_ROOM); -      GET_WAS_IN(victim) = IN_ROOM(victim); +      GET_WAS_IN(victim) = victim->in_room;        char_from_room(victim);        char_to_room(victim, 0);      }    }   +    /* stop someone from fighting if they're stunned or worse */    if (GET_POS(victim) <= POS_STUNNED && FIGHTING(victim) != NULL)      stop_fighting(victim); diff --git a/src/handler.c b/src/handler.c index 87269bb..b7d718b 100644 --- a/src/handler.c +++ b/src/handler.c @@ -305,6 +305,12 @@ void affect_remove(struct char_data *ch, struct affected_type *af)      return;    }   +  /* return corpse host people to their proper bodies */ +  if (af->spell == SPELL_CORPSE_HOST && ch->desc && ch->desc->original) { +    command_interpreter(ch, "return"); +    die(ch, NULL); +  } +    affect_modify_ar(ch, af->location, af->modifier, af->bitvector, FALSE);    REMOVE_FROM_LIST(af, ch->affected, next);    free(af); diff --git a/src/spell_parser.c b/src/spell_parser.c index dd2f7f7..dfd8b46 100644 --- a/src/spell_parser.c +++ b/src/spell_parser.c @@ -258,6 +258,10 @@ int call_magic(struct char_data *caster, struct char_data *cvict,        MANUAL_SPELL(spell_charm)        ;        break; +    case SPELL_CORPSE_HOST: +      MANUAL_SPELL(spell_corpse_host) +      ; +      break;      case SPELL_CREATE_WATER:        MANUAL_SPELL(spell_create_water)        ; @@ -771,6 +775,9 @@ void mag_assign_spells(void) {    spello(SPELL_CONTROL_WEATHER, "control weather", 75, 25, 5, POS_STANDING,    TAR_IGNORE, FALSE, MAG_MANUAL, NULL);   +  spello(SPELL_CORPSE_HOST, "corpse host", 35, 10, 3, POS_STANDING, +  TAR_OBJ_ROOM, FALSE, MAG_MANUAL, NULL); +    spello(SPELL_CREATE_FOOD, "create food", 30, 5, 4, POS_STANDING,    TAR_IGNORE, FALSE, MAG_CREATIONS, NULL);   diff --git a/src/spells.c b/src/spells.c index d9785b7..bc31d8f 100644 --- a/src/spells.c +++ b/src/spells.c @@ -447,3 +447,51 @@ ASPELL(spell_detect_poison)      }    }  } + +ASPELL(spell_corpse_host) +{ +  struct affected_type af; +  struct char_data* mob; + +  if ((obj == NULL) || !IS_CORPSE(obj)) { +    send_to_char(ch, "Thats not what you need to be concentrating on.\r\n"); +    return; +  } + +  mob = read_mobile(MOB_CORPSE_HOST, VIRTUAL); +  char_to_room(mob, ch->in_room); + +  mob->player.name = "Ju-Ju Zombie\r\n"; +  mob->player.long_descr = "a Ju-Ju Zombie is standing here.\r\n"; +  mob->player.short_descr = "a Ju-Ju Zombie"; + +  GET_LEVEL(mob) = GET_LEVEL(ch); + +  GET_MAX_MANA(mob) = GET_MAX_MANA(ch); +  GET_MANA(mob) = GET_MANA(ch); + +  GET_MAX_HIT(mob) = GET_MAX_HIT(ch); +  GET_HIT(mob) = GET_HIT(ch); + +  GET_INT(mob) = GET_INT(ch); +  GET_WIS(mob) = GET_WIS(ch); +  GET_STR(mob) = 18; +  GET_CON(mob) = 15; +  GET_CHA(mob) = 3; +  GET_DEX(mob) = 8; + +  extract_obj(obj); + +  af.spell = SPELL_CORPSE_HOST; +  af.duration = (GET_INT(ch) + GET_CON(ch) + GET_WIS(ch)) / 3; +  af.modifier = 0; +  af.location = 0; + +  affect_to_char(mob, &af); +  affect_to_char(ch, &af); + +  ch->desc->character = mob; +  mob->desc = ch->desc; +  mob->desc->original = ch; +  ch->desc = NULL; +} diff --git a/src/spells.h b/src/spells.h index 4bcb8ec..b3f9e59 100644 --- a/src/spells.h +++ b/src/spells.h @@ -93,8 +93,9 @@  #define SPELL_IDENTIFY               52 /* Reserved Skill DO NOT CHANGE */  #define SPELL_FLY                    53 /* Reserved Skill DO NOT CHANGE */  #define SPELL_DARKNESS               54 +#define SPELL_CORPSE_HOST            55  /** Total Number of defined spells */ -#define NUM_SPELLS                   54 +#define NUM_SPELLS                   55    /* Insert new spells here, up to MAX_SPELLS */  #define MAX_SPELLS            130 @@ -228,6 +229,7 @@ ASPELL(spell_information);  ASPELL(spell_identify);  ASPELL(spell_enchant_weapon);  ASPELL(spell_detect_poison); +ASPELL(spell_corpse_host);    /* basic magic calling functions */   diff --git a/src/structs.h b/src/structs.h index 08e47db..782730b 100644 --- a/src/structs.h +++ b/src/structs.h @@ -224,8 +224,9 @@  #define MOB_NOBLIND        17   /**< Mob can't be blinded */  #define MOB_NOKILL         18   /**< Mob can't be attacked */  #define MOB_NOTDEADYET     19   /**< (R) Mob being extracted */ +#define MOB_CORPSE_HOST    20   -#define NUM_MOB_FLAGS      19 +#define NUM_MOB_FLAGS      20    /* Preference flags: used by char_data.player_specials.pref */  #define PRF_BRIEF         0   /**< Room descs won't normally be shown */

 

tbaMUD developer/programmer
Last edit: 29 Dec 2022 18:26 by Vatiken.

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

More
30 Dec 2022 05:22 #10244 by Nero
Thanks for taking the time to update that!
I had to adjust a few things but it seems to be working
the only issue is it only works on my Implementer but not any of my actual mortal characters. This at least gets me in the ballpark though! Thank you again!

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

More
01 Jan 2023 10:15 - 01 Jan 2023 10:17 #10245 by Nero
For the most part its working but now I am running into an issue where if a person casts corpse host on a corpse, it lets them take over the corpse, and they can return from that corpse by using the return command, however, if the spell/affect duration ends it crashes.

I had to set tweak a few things to get it to boot up and work on my end.
Two major differences is I used af.type but also add af.bitvector to apply a corpsehost affect for both the character and the zombie
And I eliminated it creating a mob based on the players level, stats, etc and just have a generic level 35 zombie it 'summons' when the corpse host spell is cast.
The issue seems to be from how the aspell interacts with the snippet in handler.c

Code:
ASPELL(spell_corpse_host) {   struct affected_type af;   struct char_data *mob;   if ((obj == NULL) || !IS_CORPSE(obj)) {     send_to_char(ch, "Thats not what you need to be concentrating on.\r\n");     return;       }     send_to_char(ch, "You transfer your life force into the fresh corpse.\r\n\r\n");   mob = read_mobile(MOB_CORPSE_HOST, VIRTUAL);   char_to_room(mob, ch->in_room);   extract_obj(obj);     af.type = SPELL_CORPSE_HOST;     af.duration = 0;     af.modifier = 0;     af.location = APPLY_NONE;     af.bitvector = AFF_CORPSEHOST;   act("$n transfers their life force into the fresh corpse.", TRUE, ch, 0, 0, TO_ROOM);     affect_to_char(mob, &af);   affect_to_char(ch, &af);   ch->desc->character = mob;   mob->desc = ch->desc;   mob->desc->original = ch;   ch->desc = NULL; }


Code:
       /* return corpse host people to their proper bodies */   if (af->type == SPELL_CORPSE_HOST && ch->desc && ch->desc->original) {     command_interpreter(ch, "return");     die(ch, NULL);   }
Last edit: 01 Jan 2023 10:17 by Nero.

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

Time to create page: 0.179 seconds