Welcome to the Builder Academy

Question I keep finding weird problems - argument/one_argument/two_argument and spells.c

More
01 Oct 2025 12:47 #10922 by wlessard1
Well, I am trying to change a spell and I decided "argument" and "one_argument" would help in the spell.

Apparently spells.c won't accept these.

I  get implicit declaration of function with one_argument
and
undeclared first use for argument

I check the includes and they match up with other files that use those terms.

What am I missing?

Thanks

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
01 Oct 2025 18:26 #10923 by Salty
Can you link the code for the spell?  I ask because I have some custom spells and none require arguments that aren't handled in the ASPELL() macro.

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

More
01 Oct 2025 19:12 #10924 by wlessard1
What I am trying to do, I thought would be simple. I am trying to make teleport require a target/victim.
I changed spell_parser.c to TAR_CHAR_WORLD, which helped to a point.

so...
cast 'teleport' <name/mob required> 
Been butchering it left and right trying anything then I noticed if I used argument as part of a piece of code, it would get upset. Right now I don't have argument but I was trying to do a line like this.
Code:
  if ((location = find_target_room(ch, argument)) == NOWHERE)     return;

And when compiling it would give me undeclared first use of this when I had "argument" as part.

I searched high and low for any function that declares "argument" and other than in the very top of some spells and such, nothing.

This is currently my spell_teleport which compiles but doesn't work properly except it does check for the target/victim.
Code:
ASPELL(spell_teleport) {   room_rnum to_room;   char buf[MAX_INPUT_LENGTH];   if (ch == NULL || victim == NULL)     return;   if (GET_LEVEL(victim) > MIN(LVL_IMMORT - 1, level + 3)) {     send_to_char(ch, "The targets power deflects you!");     return;   }   if (MOB_FLAGGED(victim, MOB_NOSUMMON)) {     send_to_char(ch, "Your victim is protected!\r\n");     return;   }   if (ZONE_FLAGGED(GET_ROOM_ZONE(IN_ROOM(victim)), ZONE_NOASTRAL) ||       ZONE_FLAGGED(GET_ROOM_ZONE(IN_ROOM(ch)), ZONE_NOASTRAL)) {     send_to_char(ch, "A bright flash prevents your spell from working!");     return;   } /*  if ((to_room = find_target_room(ch, buf)) == NOWHERE)     return; */   act("$n slowly fades out of existence and is gone.", FALSE, ch, 0, 0, TO_ROOM);   char_from_room(ch);   char_to_room(ch, to_room);   act("$n slowly fades into existence.", FALSE, ch, 0, 0, TO_ROOM);   look_at_room(ch, 0);   entry_memory_mtrigger(ch);   greet_mtrigger(ch, -1);   greet_memory_mtrigger(ch); }

It is not a big deal but it is something I wanted to change. 

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
01 Oct 2025 21:51 #10925 by thomas
ASPELL already handles parsing the argument for you.
The declaration looks like this:
Code:
#define ASPELL(spellname) \ void spellname(int level, struct char_data *ch, \ struct char_data *victim, struct obj_data *obj)
As you can see, once the spell is parsed, the ASPELL function is called with the appropriate argument.

However, like in locate object spell, you can check the value of the cast_arg2 global variable. It is populated with any extra parameters after the first (which was used to look up the object/character). This is somewhat obscure and I understand why you didn't find it.

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

More
03 Oct 2025 03:11 #10928 by Salty

What I am trying to do, I thought would be simple. I am trying to make teleport require a target/victim.


As Thomas said, the ASPELL macro handles this.

See the example of a similar spell I have named 'astral walk'
Code:
ASPELL(spell_astral_walk) {   int target;   if (!IS_NPC(victim) && ((GET_LEVEL(victim) >= LVL_IMMORT)))   {     send_to_char(ch, "The immortal power of %s repels your magic!\r\n", GET_NAME(victim));     return;   }   // Rooms we cannot astral walk from   if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_PRIVATE))   {     send_to_char(ch, "Something prevents you from leaving the room.\r\n");     return;   }   // Rooms we cannot astral walk to   if (ROOM_FLAGGED(IN_ROOM(victim), ROOM_PRIVATE) || ROOM_FLAGGED(IN_ROOM(victim), ROOM_TUNNEL) ||       ROOM_FLAGGED(IN_ROOM(victim), ROOM_GODROOM) || ROOM_FLAGGED(IN_ROOM(victim), ROOM_NOTRACK) ||       ROOM_FLAGGED(IN_ROOM(victim), ROOM_NOTELEPORT) || ROOM_FLAGGED(IN_ROOM(victim), ROOM_PURGATORY))   {     send_to_char(ch, "Something prevents you from reaching that player!\r\n");     return;   }   // Zones we cannot astral walk to   if (ZONE_FLAGGED(GET_ROOM_ZONE(IN_ROOM(victim)), ZONE_NOASTRAL) || ZONE_FLAGGED(GET_ROOM_ZONE(IN_ROOM(victim)), ZONE_CLOSED))   {     send_to_char(ch, "You cannot reach that zone!\r\n");     return;   }   if ((GET_LEVEL(ch) + 5) < GET_LEVEL(victim))   {     send_to_char(ch, "You failed.\r\n");     return;   }   if (victim_savingthrow(victim, ch, SAVING_SPELL, SPELL_ASTRAL_WALK, 0))   {     send_to_char(ch, "You fail to %s to %s.\r\n", spell_info[SPELL_ASTRAL_WALK].name, GET_SHORT(victim));     return;   }   act("$n opens a doorway in space and steps in.", true, ch, 0, 0, TO_ROOM);   target = victim->in_room;   char_from_room(ch);   char_to_room(ch, target);   act("Suddenly, a doorway appears from nowhere. $n steps out and the doorway disappears.", true, ch, 0, 0, TO_ROOM);   act("You open a doorway to the astral plane and step out in front of $N.", false, ch, 0, victim, TO_CHAR);   do_look(ch, "", 0, 0); }
The following user(s) said Thank You: wlessard1

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

More
03 Oct 2025 12:27 #10929 by wlessard1
Looking through your code, it was not too hard to pick out the pieces and see if they work.

thanks much everyone for your 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.

Time to create page: 0.253 seconds