Welcome to the Builder Academy

Question Portal as a skill problems

More
04 Oct 2017 00:49 - 04 Oct 2017 06:29 #6961 by JTP
Im trying to make a portal skill, that takes the entire group with the user. Or just the user If alone.

I have the following problems though:
1 - If the user is not grouped and portal something, mud crashes. If in a group it works, both If alone Or with people.

2 - But if a group member is not in the same room as the user of the skill, they are also ported to the target, should only be those in the same room as the user.

3 - The user of the portal skill, see the room description 2 times when arriving at the target.


How one of you can help to solve those 3 issues.
Code:
ACMD(do_portal) { char arg[MAX_INPUT_LENGTH]; struct char_data *victim; room_rnum to_room; struct char_data *pFoll; one_argument(argument, arg); if (arg[0] == '\0') { send_to_char(ch, "Format: portal [name of player or mob]\r\n"); return; } if (GET_MANA(ch) < 100) { send_to_char(ch, "You do not have enough mana!\r\n"); return; } if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_PORTAL)) { send_to_char(ch, "You have no idea how.\r\n"); return; } if ((victim = get_char_vis(ch, arg, NULL,FIND_CHAR_WORLD)) == NULL) { send_to_char(ch, "You sense no pressence such as that.\r\n"); return; } to_room = IN_ROOM(victim); if (ROOM_FLAGGED(to_room, ROOM_NOMAGIC)) { send_to_char(ch, "You attempt to focus, but cannot seem to!"); return; } ch->points.mana -= 100; act("$n opens a portal through the aether, and step through!!", FALSE, ch, 0, 0, TO_ROOM); char_from_room(ch); char_to_room(ch, to_room); act("A shimmering portal takes shape in the area, and $n steps through.", FALSE, ch, 0, 0, TO_ROOM); look_at_room(ch, 0); entry_memory_mtrigger(ch); greet_mtrigger(victim, -1); greet_memory_mtrigger(ch); while((pFoll = (struct char_data *)simple_list(ch->group->members)) != NULL) { act("$n follows through the portal!", FALSE,pFoll, 0, 0, TO_ROOM); act("You follow $n, and steps through the portal.", FALSE,pFoll, 0, 0, TO_CHAR); char_from_room(pFoll); char_to_room(pFoll, to_room); entry_memory_mtrigger(pFoll); greet_mtrigger(victim, -1); greet_memory_mtrigger(pFoll); look_at_room(pFoll, 0); act("$n steps through the portal!", FALSE,pFoll, 0, 0, TO_ROOM); } return; }

If you see any other problems with above code, other then the 3 issues i have, pls let me know to.




Backtrace of the crash:
#0 0x0806a7e9 in do_portal (ch=0xa0bfe98, argument=0xbfc370da " beholder",
cmd=620, subcmd=0) at act.movement.c:1608
1608 while((pFoll = (struct char_data *)simple_list(ch->group->members))$
(gdb) Hangup detected on fd 0
Error detected on fd 0
error detected on stdin
Last edit: 04 Oct 2017 06:29 by JTP.

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

More
06 Oct 2017 14:36 #6964 by JTP
Replied by JTP on topic Portal as a skill problems
Hope someone can help make this work, im being deployed to iraq next week on a training mission.

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

More
06 Oct 2017 14:49 #6965 by zusuk
Replied by zusuk on topic Portal as a skill problems
Hey bro if no one can help you by sunday ill gladly help by then :)

Shoot me an email: moshehwebservices<at>live.com

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

More
08 Oct 2017 10:10 - 08 Oct 2017 21:36 #6967 by zusuk
Replied by zusuk on topic Portal as a skill problems
This is just how I would do it, adjust as needed :)

First I would set up a testing function that will make sure the destination is valid, so I can share it with other teleportation type spells/skills such as 'word of recall' or 'summon' etc...
Code:
/* this function takes a real number for a room and returns: FALSE - mortals shouldn't be able to teleport to this destination TRUE - mortals CAN teleport to this destination * accepts NULL ch data */ int valid_mortal_tele_dest(struct char_data *ch, room_rnum dest, bool dim_lock) { if (dest == NOWHERE) return FALSE; if (ch && IS_AFFECTED(ch, AFF_DIM_LOCK) && dim_lock) return FALSE; /* this function needs a vnum, not rnum */ if (ch && !House_can_enter(ch, GET_ROOM_VNUM(dest))) return FALSE; if (ZONE_FLAGGED(GET_ROOM_ZONE(dest), ZONE_NOASTRAL)) return FALSE; if (ROOM_FLAGGED(dest, ROOM_PRIVATE)) return FALSE; if (ROOM_FLAGGED(dest, ROOM_DEATH)) return FALSE; if (ROOM_FLAGGED(dest, ROOM_STAFFROOM)) return FALSE; if (ZONE_FLAGGED(GET_ROOM_ZONE(dest), ZONE_CLOSED)) return FALSE; if (ZONE_FLAGGED(GET_ROOM_ZONE(dest), ZONE_NOASTRAL)) return FALSE; if (ROOM_FLAGGED(dest, ROOM_NOTELEPORT)) return FALSE; //passed all tests! return TRUE; }

I am writing this off the top of my head so fix any errors ;p next i would just write a function that is the engine
for actually moving a character from one room to the destination, since we are going to be doing it for a whole group
Code:
void char_tele_to_room(struct char_data *ch, room_rnum to_room) { send_to_char(ch, "You slowly fade out of existence...\r\n"); 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); send_to_char(ch, "You slowly fade back into existence...\r\n"); look_at_room(ch, 0); entry_memory_mtrigger(ch); greet_mtrigger(ch, -1); greet_memory_mtrigger(ch); }

And then this is how I would code a group teleport skill itself:
Code:
ACMD(do_teleport) { char arg[MAX_INPUT_LENGTH] = { '\0' }; struct char_data *tch = NULL, *victim = NULL, *i = NULL; room_rnum to_room = NOWHERE; if (ch == NULL) return; /* parse argument */ one_argument(argument, arg); if (!*arg) { send_to_char(ch, "Your skill requires a target!\r\n"); return; } /* valid victim? */ if ((victim = get_char_vis(ch, arg, NULL, FIND_CHAR_WORLD)) == NULL) { send_to_char(ch, "You can not seem to find your target!\r\n"); return; } if (AFF_FLAGGED(victim, AFF_NOTELEPORT)) { send_to_char(ch, "Your skill fails to target that victim!\r\n"); return; } to_room = IN_ROOM(victim); if (!valid_mortal_tele_dest(ch, to_room, TRUE)) { send_to_char(ch, "A bright flash prevents your skill from working!"); return; } if (!valid_mortal_tele_dest(ch, IN_ROOM(ch), TRUE)) { send_to_char(ch, "A bright flash prevents your skill from working!"); return; } send_to_char(ch, "Using your skill you form a portal...\r\n"); act("$n skillfully forms a portal.", FALSE, ch, 0, 0, TO_ROOM); /* first, take care of the group, since we want to make sure they are all in the same room as the caster */ if (GROUP(ch) != NULL) { /* caster groupped? */ while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) { /* iterate through group */ if (tch == ch) continue; if (IN_ROOM(tch) != IN_ROOM(ch)) /* in same room? */ continue; /* we are in the same room, and groupped with caster, time to teleport */ send_to_char(tch, "You step through the portal...\r\n"); act("$n steps through the portal....", FALSE, tch, 0, 0, TO_ROOM); char_tele_to_room(tch, to_room); } } /* finally lets bring the caster */ send_to_char(ch, "You step through the portal...\r\n"); act("$n steps through the portal...", FALSE, ch, 0, 0, TO_ROOM); char_tele_to_room(ch, to_room); }

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100
Last edit: 08 Oct 2017 21:36 by zusuk. Reason: fix errors, change from spell to skill, remove 'fat', tch == ch check

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

More
08 Oct 2017 11:01 - 08 Oct 2017 11:10 #6968 by JTP
Replied by JTP on topic Portal as a skill problems
Ok i entered your void, and cut the following from your spell, into my skill:
Code:
/* first, take care of the group, since we want to make sure they are all in the same room as the caster */ if (GROUP(ch) != NULL) { /* caster groupped? */ while ((tch = (struct char_data *) simple_list(GROUP(ch)->members)) != NULL) { /* iterate through group */ if (IN_ROOM(tch) != IN_ROOM(ch)) /* in same room? */ continue; /* we are in the same room, and groupped with caster, time to teleport */ char_tele_to_room(tch, to_room); } } /* finally lets bring the caster */ char_tele_to_room(ch, to_room);


But the follower isnt moved unless its the leader. So if user of the skill is the leader he dont bring the followers, but if user is just a a follower, then he brings the leader ?

And it appears user still see the room desc twice ?

Good thing though user can portal alone without crashing the mud. 1
Last edit: 08 Oct 2017 11:10 by JTP.

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

More
08 Oct 2017 11:04 #6969 by zusuk
Replied by zusuk on topic Portal as a skill problems
The follower is groupped and in same room as the caster?

I will double-check the code and respond shortly :)

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

Time to create page: 0.309 seconds