Load node objects from code instead of zedit

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 week 4 days ago #10109 by Nero
I have added fishing, mining, and wood cutting to my game. I created a 'node' that is an object from oedit that loads into the room.
For example, I have created a school of fish that loads into a water room, only when that node exists in the room can you actually cast your rod and fish.
The reason I did this was to force exploration instead of people cramming into one room to fish all day.
My question though is how do I force that object to load randomly in the water rooms on a zone reset instead of using zedit?
The reason why I don't want to use zedit is one, I will have to go through every water room in the game and edit in zedit to get the object to load which will take a lot of work and two the object only maxes at 100 which I feel my be too scarce given the size of the game. Is there an easier way to do this in code to accomplish what I want? Say, the object has a 30% chance to load in any given water room in the game when the zone(s) reset?
/*Fishing code*/
ACMD(do_castout)
{
  struct obj_data *obj, *pole, *next, *pool = world[IN_ROOM(ch)].contents;
  int fail, pool_vnum = 307, extract;

  if (!can_see_room(ch, IN_ROOM(ch))) {
      send_to_char(ch, "It's too dark for you to castout here!\r\n");
      return;
    }

/* No fishing while fighting */
  if (IS_FIGHTING(ch)) {
    send_to_char(ch, "You are too busy fighting to fish right now!\r\n");
    return;
  }

  if (PLR_FLAGGED(ch, PLR_FISHING)) {
    send_to_char(ch, "You are already fishing!\r\n");
    return;
  }

  if (!(pole = GET_EQ(ch, WEAR_HOLD)) ||
      (GET_OBJ_TYPE(pole) != ITEM_POLE)) {
    send_to_char(ch, "You need to be holding a fishing pole first.\r\n");
    return;
  }

  if (!ROOM_FLAGGED(IN_ROOM(ch), ROOM_SALTWATER_FISH) && !ROOM_FLAGGED(IN_ROOM(ch), ROOM_FRESHWATER_FISH)) {
    send_to_char(ch, "This is not a good place to fish, you'll want to find a better spot.\r\n");
    return;
  }

while (pool != NULL && GET_OBJ_VNUM(pool) != pool_vnum)
       pool = pool->next_content;

 if (!pool) {
    send_to_char(ch, "This is not a good place to fish, you'll want to find a better spot that has a school of fish.\r\n");
    GET_WAIT_STATE(ch) = (2 RL_SEC);
    return;
 }


  fail = rand_number(1, 10);
  if (fail <= 3) {
    send_to_char(ch, "You pull your arm back and try to cast out your line, but it gets all tangled up.\r\nTry again.\r\n");
    act("$n pulls $s arm back, trying to cast $s fishing line out into the water, but ends up just a bit tangled.", FALSE, ch, 0, 0, TO_ROOM);
    GET_WAIT_STATE(ch) = (2 RL_SEC);
    return;
  }

  /* Ok, now they've gone through the checks, now set them fishing */
  extract = rand_number(1, 4);
  if (extract == 1) {
  extract_obj(pool);
  }
  SET_BIT_AR(PLR_FLAGS(ch), PLR_FISHING);
  send_to_char(ch, "You cast your line out into the water, hoping for a bite.\r\n");
  act("$n casts $s line out into the water, hoping to catch some food.", FALSE, ch, 0, 0, TO_ROOM);
  return;
}

/* Fish on? Reelin! */
ACMD(do_reelin)
{
  int success, f_num, fish_num;
  struct obj_data *fish;
  char buf[MAX_STRING_LENGTH];

  if (!PLR_FLAGGED(ch, PLR_FISHING)) {
    send_to_char(ch, "You aren't even fishing!\r\n");
    return;
  }
  if (!PLR_FLAGGED(ch, PLR_FISH_ON)) {
    send_to_char(ch, "You reel in your line, but alas... nothing on the end.\r\nBetter luck next time.\r\n");
    REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_FISHING);
    act("$n reels $s line in, but with nothing on the end.", FALSE, ch, 0, 0, TO_ROOM);
    return;
  }

  /* Ok, they are fishing and have a fish on */
  success = rand_number(1, 10);

  REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_FISHING);
  REMOVE_BIT_AR(PLR_FLAGS(ch), PLR_FISH_ON);

  if (success <= 6) {
    send_to_char(ch, "You reel in your line, putting up a good fight, but you lose it!\r\nTry again?\r\n");
    act("$n reels $s line in, fighting with whatever is on the end, but loses the catch.", FALSE, ch, 0, 0, TO_ROOM);
    GET_WAIT_STATE(ch) = (2 RL_SEC);
    return;
  }

  /* We used object vnums 300 for our fish that people could
   * catch. The below numbers reflect that use. If you wish to change
   * the vnums of the fish, just change the numbers below. You can
   * see that we seperated the type of fish by freshwater and salt
   * water.
   */
  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_SALTWATER_FISH)) {
    fish_num = rand_number(114,116);
    f_num = real_object(fish_num);
    fish = read_object(f_num, REAL);
    send_to_char(ch, "You reel in %s! Nice catch!\r\n", fish->short_description);
    obj_to_char(fish, ch);
    act("Wow! $n reels in a nice catch! Looks like $p!", FALSE, ch, fish, 0, TO_ROOM);
    return;
  } else
  if (ROOM_FLAGGED(IN_ROOM(ch), ROOM_FRESHWATER_FISH)) {
    fish_num = rand_number(300,306);
    f_num = real_object(fish_num);
    fish = read_object(f_num, REAL);
    send_to_char(ch, "You reel in %s! Nice catch!\r\n", fish->short_description);
    obj_to_char(fish, ch);
    act("Wow! $n reels in a nice catch! Looks like $p!", FALSE, ch, fish, 0, TO_ROOM);
    return;
  } else
  send_to_char(ch, "You should never see this message, please report it.\r\n");
  return;
}

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

  • zusuk
  • zusuk's Avatar
  • Offline
  • Elite Member
  • Elite Member
  • LuminariMUD Developer
More
1 week 4 days ago #10110 by zusuk
Would you also want those nodes to reset/respawn in-game on a timer or as they are farmed? Or just load once per boot/copyover? There is a version of this on LuminariMUD (github.com/LuminariMUD/Luminari-Source), but I don't have the code in front of me :)

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

  • Nero
  • Nero's Avatar Topic Author
  • Offline
  • Premium Member
  • Premium Member
More
1 week 4 days ago #10112 by Nero
I think either would work for me as long as I don't have to go to every room and zedit. I will take a look at this thanks!

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

Time to create page: 0.138 seconds