Welcome to the Builder Academy

Question Item with spell trigger starts to fight me when i locate the object

More
08 Mar 2018 20:23 - 08 Mar 2018 20:36 #7683 by JTP
Ok what is happening here:
Code:
Ok side question, just noticed that an obj i carry has a spell trigger on. When i try locate the obj name this happends, but only some times: cast 'locate obj' tooth Okay. a toothpick is burned when she hits you. A toothpick tells you: Get out of here before I call the guards! A toothpick slaps you. Ow! This mob is protected. You can't help laughing as a toothpick sends a magic missile at you. <<-- This is from the trigger on my item. So why does it suddently start a fight, and suddently come with the mob is protected ? Is that an error in triggers or something else ? The trigger is: Name: 'obj cast magic missile', VNum: [ 2324], RNum: [ 698] Trigger Intended Assignment: Objects Trigger Type: Cast , Numeric Arg: 100, Arg list: None Commands: if %already_cast% wait 15 s unset already_cast else dg_cast 'magic missile' %actor.name% set already_cast 1 global already_cast end


No mob is called toothpick anywhere.
Had fireshield on the above attempt.


Another attempt with no fireshield:
cast 'locate obj' toothpick
Okay.
You can't help laughing as a toothpick sends a magic missile at you.


Another:
cast 'locate obj' toothpick
Okay.
a toothpick is being carried by ...


So its not the same each time.

Same happends if the item lies on the floor of the room im in
Last edit: 08 Mar 2018 20:36 by JTP.

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

More
08 Mar 2018 21:49 #7684 by thomas
Yeah, this is a bit funny. The locate object has the wrong target set. It should be TAR_IGNORE

github.com/tbamud/tbamud/blob/27a2f4bdc8.../spell_parser.c#L869
Code:
spello(SPELL_LOCATE_OBJECT, "locate object", 25, 20, 1, POS_STANDING, - TAR_OBJ_WORLD, FALSE, MAG_MANUAL, + TAR_IGNORE, FALSE, MAG_MANUAL, NULL);
While this is counterintuitive, it will still work, because the argument is stored before the method is called, and the passed object isn't used in ASPELL(spell_locate_object).

You'd normally not see this, unless you have this exact kind of trigger. Nicely spotted.

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

More
08 Mar 2018 21:59 #7685 by thomas
Oh, and the reason this fails is that since TAR_OBJ_WORLD locates the closest object with the given name, and assigns this to tobj in call_magic(), it triggers the cast_otrigger() there.
The trigger then runs, casting an aggressive spell at you, which is done by changing the name of puff (yes, the dragon), moving him to your room and letting _him_ cast the spell at you. But puff has a special so he can't be harmed, so you get the "This mob is protected" message.

On your second call, the script is sleeping, and the cast goes through normally.

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

More
08 Mar 2018 22:19 - 08 Mar 2018 22:21 #7686 by JTP
Just tried the TAR_IGNORE

Got this:

cast 'locate obj' toothpick
Okay.
You sense nothing.


cast 'locate obj' sword
Okay.
You sense nothing.
Last edit: 08 Mar 2018 22:21 by JTP.

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

More
08 Mar 2018 23:01 #7687 by thomas
Typical. I just wrote that "it isn't used". But of course it is, at github.com/tbamud/tbamud/blob/27a2f4bdc8...86/src/spells.c#L216
Code:
ASPELL(spell_locate_object) { struct obj_data *i; char name[MAX_INPUT_LENGTH]; + int j, k; - int j; - - if (!obj) { - send_to_char(ch, "You sense nothing.\r\n"); - return; - } /* added a global var to catch 2nd arg. */ sprintf(name, "%s", cast_arg2); j = GET_LEVEL(ch) / 2; /* # items to show = twice char's level */ + k = j; for (i = object_list; i && (j > 0); i = i->next) { if (!isname_obj(name, i->name)) continue; send_to_char(ch, "%c%s", UPPER(*i->short_description), i->short_description + 1); if (i->carried_by) send_to_char(ch, " is being carried by %s.\r\n", PERS(i->carried_by, ch)); else if (IN_ROOM(i) != NOWHERE) send_to_char(ch, " is in %s.\r\n", world[IN_ROOM(i)].name); else if (i->in_obj) send_to_char(ch, " is in %s.\r\n", i->in_obj->short_description); else if (i->worn_by) send_to_char(ch, " is being worn by %s.\r\n", PERS(i->worn_by, ch)); else send_to_char(ch, "'s location is uncertain.\r\n"); j--; } if (k == j) send_to_char(ch, "You sense nothing.\r\n"); }
Yeah, just typical me...

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

Time to create page: 0.198 seconds