Portal as a skill problems

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 2 weeks ago - 7 months 2 weeks ago #6961 by JTP
JTP created the topic: Portal as a skill problems
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.
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: 7 months 2 weeks ago by JTP.

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

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 1 week ago #6964 by JTP
JTP replied the 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.

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
7 months 1 week ago #6965 by zusuk
zusuk replied the 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.

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
7 months 1 week ago - 7 months 1 week ago #6967 by zusuk
zusuk replied the 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...
/* 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
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:
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: 7 months 1 week ago 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.

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 1 week ago - 7 months 1 week ago #6968 by JTP
JTP replied the topic: Portal as a skill problems
Ok i entered your void, and cut the following from your spell, into my skill:
  /* 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: 7 months 1 week ago by JTP.

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

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
7 months 1 week ago #6969 by zusuk
zusuk replied the 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.

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 1 week ago #6970 by JTP
JTP replied the topic: Portal as a skill problems
Iwe updated the post alittle

But yes they were both in same room, didnt test yet if they were in different rooms.


Also seems to be some odd with messages:

Tester slowly fades into existence.
Tester slowly fades out of existence and is gone.
Tester slowly fades into existence.

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

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
7 months 1 week ago #6971 by zusuk
zusuk replied the topic: Portal as a skill problems
You need to be in the same group as caster... following is not necessary, make sure both the caster and the person you want to travel with the caster are in the same room and groupped together. If that does not work, please let me know.

To fix the double message, look for this 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);
    }
  }

change it to:
  /* 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 */
      char_tele_to_room(tch, to_room);
    }
  }

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100
The following user(s) said Thank You: JTP

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

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 1 week ago #6972 by JTP
JTP replied the topic: Portal as a skill problems
if (tch == ch)
continue;

Seems to fix everything...i will test further.

User now only see one room desc. And it now doesnt matter if user is leader or follower, all come.

And if leader and user is in two different rooms, only user goes to target :)

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

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 1 week ago #6973 by JTP
JTP replied the topic: Portal as a skill problems
In your void:
  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");

2 send_to_char(ch,
2 act with FALSE, ch

Any of those that should be tch ??

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

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
7 months 1 week ago #6974 by zusuk
zusuk replied the topic: Portal as a skill problems
That how you want it to work or did you desire something different?

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

  • zusuk
  • zusuk's Avatar
  • Offline
  • Gold Boarder
  • Gold Boarder
  • LuminariMUD Developer
More
7 months 1 week ago #6975 by zusuk
zusuk replied the topic: Portal as a skill problems
nope, when the function is called for tch it gets changed to ch in that function

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 1 week ago #6976 by JTP
JTP replied the topic: Portal as a skill problems
Testing so far seem that the skill itself works.

But seen from the follower:
You slowly fade out of existence...
You slowly fade back into existence...
Then room description.
Tester slowly fades into existence. <<-- The user of the portal skill.
---
Might be missing a message saying something like Tester opens a portal....then everyone enters.





Seen from the user of the skill:
Tester2 slowly fades out of existence and is gone. <<-- The follower
You slowly fade out of existence...
You slowly fade back into existence...
Then room description.
---
Again here before follower and then user of the skill goes there would be cool with a message saying Tester opens a portal.

Maybe even a message where the portal closes.

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

  • JTP
  • JTP's Avatar Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
7 months 1 week ago - 7 months 1 week ago #6977 by JTP
JTP replied the topic: Portal as a skill problems
Like message to user, You open a portal B steps through, you step through and close the portal
Then again what if your alone, then You open a portal and step through and close the portal

message to follower, A opens a portal, you step through.

and message room, like A opens a portal B enters, A enters and portal dissapears
And again if user is alone, A opens a portal and enters and it dissapears.



We are down to message handling, rest works brilliantly.
Last Edit: 7 months 1 week ago by JTP.

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

Time to create page: 1.552 seconds