Skill tan wont load objects

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 6 days ago - 10 months 6 days ago #7113 by JTP
Skill tan wont load objects was created by JTP
Hi

Im trying to make a tan skill, but it wont load the objects iwe set.
And if i try to tan corpse ring, that isnt on my define list, it still says i make the obj, but should get the Illigal object message.
#define TAN_SHIELD   3095
#define TAN_JACKET   3043
#define TAN_BOOTS    3084
#define TAN_GLOVES   3071
#define TAN_LEGGINGS 3081
#define TAN_SLEEVES  3086
#define TAN_HELMET   3076
#define TAN_BAG	     3032



.....


else  if (!strcmp(itemtype, "bag"))
    	{
	if ((r_num = real_object(TAN_BAG)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
	 }
    	}  else  {
    	 send_to_char("Illegal type of equipment!\n\r",ch);
    	 return;
       }
}

Anyone know why ?
Last edit: 10 months 6 days ago by JTP.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 5 days ago - 10 months 5 days ago #7115 by JTP
Replied by JTP on topic Skill tan wont load objects
#define TAN_SHIELD   3095
#define TAN_JACKET   3043
#define TAN_BOOTS    3084
#define TAN_GLOVES   3071
#define TAN_LEGGINGS 3081
#define TAN_SLEEVES  3086
#define TAN_HELMET   3076
#define TAN_BAG	     3032

ACMD(do_tan)
{
 struct obj_data *corpse, *hide;
 char buf[MAX_STRING_LENGTH];
 char itemname[MAX_INPUT_LENGTH], itemtype[MAX_INPUT_LENGTH];
 int r_num = 0;

if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_TAN)) {
        send_to_char(ch, "You haven't learned how to tan.\r\n");
        return;
}

  two_arguments(argument, itemname, itemtype);

if (!*itemname) {
 send_to_char(ch, "Tan what?\r\n");
 return;
}

if (!*itemtype) {
 send_to_char(ch, "I see that, but what do you wanna make?\r\n");
 return;
}

   if (!(corpse = get_obj_in_list_vis(ch, itemname, NULL, world[IN_ROOM(ch)].contents)))
    {
      send_to_char(ch, "Where did that corpse go?\r\n");
      return;
   } else {

   if(rand_number(1,150) > GET_SKILL(ch, SKILL_TAN)) {

   sprintf(buf, "You hack at %s but manage to only destroy the hide.\r\n", corpse->short_description);
   send_to_char(ch, buf);

   sprintf(buf,"%s tries to skins %s for it's hide, but destroys it.", GET_NAME(ch), corpse->short_description);
   act(buf, TRUE, ch, 0, 0, TO_ROOM);     
   improve_skill(ch, SKILL_TAN);
   extract_obj(corpse);
   WAIT_STATE(ch, PULSE_VIOLENCE*3);                
  return;
 } else {
	sprintf(buf, "You hack at the %s and finally make the %s.\r\n", corpse->short_description, itemtype);
	send_to_char(ch, buf);

	sprintf(buf, "%s skins %s for it's hide.", GET_NAME(ch), corpse->short_description);
	act(buf, TRUE, ch, 0, 0, TO_ROOM);

	extract_obj(corpse);
       	WAIT_STATE(ch, PULSE_VIOLENCE*1); 
        return;
        }
if (!strcmp(itemtype, "shield"))
	{
	if ((r_num = real_object(TAN_SHIELD)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
   	  }
	}
else if (!strcmp(itemtype, "jacket"))
          {
	if ((r_num = real_object(TAN_JACKET)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
            }	
	}
 else if (!strcmp(itemtype, "boots"))
      	 {
	if ((r_num = real_object(TAN_BOOTS)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
   	    }	
	}
 else if (!strcmp(itemtype, "gloves"))
      	{
	if ((r_num = real_object(TAN_GLOVES)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
   	  }	
	}
else if (!strcmp(itemtype, "leggings"))
     	{
	if ((r_num = real_object(TAN_LEGGINGS)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
   	  }	
	}
else if (!strcmp(itemtype, "sleeves"))
    	{
	if ((r_num = real_object(TAN_SLEEVES)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
   	  }	
	}
else  if (!strcmp(itemtype, "helmet"))
    	{
	if ((r_num = real_object(TAN_HELMET)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
	  }	
	}
else  if (!strcmp(itemtype, "bag"))
    	{
	if ((r_num = real_object(TAN_BAG)) >= 0)
	{
    	    hide = read_object(r_num, VIRTUAL);
    	    obj_to_char(hide, ch); 
	 }
    	}  else  {
    	 send_to_char(ch, "Illegal type of equipment!\r\n");
    	 return;
       }
    }
}

This attempt still tries to make an item name not in list:
You hack at the the corpse of a little white mouse and finally make the
necklace.
Illegal type of equipment!

And if i try with one of the names from the list, it now loads a letter.

Think brackets are wrongly placed, but not my strong side, might also just be something else that i cant see...Any idea ?

File error shows: Nov 18 20:06:11 :: SYSERR: NULL obj ((nil)) or char (0x9c34958) passed to obj_to_char.
Last edit: 10 months 5 days ago by JTP.

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

More
10 months 5 days ago #7118 by WhiskyTest
Replied by WhiskyTest on topic Skill tan wont load objects
There isn't any way for us to tell without seeing the whole function.

From what you've posted there are too many brackets and an old send_to_char which wouldn't even compile

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 5 days ago #7119 by JTP
Replied by JTP on topic Skill tan wont load objects
Had changed the last send_to when i compiled, just forgot to update here.

Updated above post with entire code

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

More
10 months 4 days ago - 10 months 4 days ago #7122 by WhiskyTest
Replied by WhiskyTest on topic Skill tan wont load objects
Cool thanks.
You've done some good work there.

I've corrected a couple of problems with the flow, which is why we were getting unexpected messages and the objects not loading in.

Rather than using an ever growing collection of 'if-else' statements, I've put the names and vnmus into a table. To add items just add a new entry in the table and increase the NUM_TAN_TYPES. If the object doesn't exist in-game the player will get an error message. Maybe change that to be a syslog call?

Oh and one other thing - there is no checks to see if the target object is actually a corpse. And I couldn't see any obvious way to do it. You may need to add a new object flag into the game via the make_corpse() function or something like that.
struct tan_data
{
    const char *name;
    int vnum;
};

struct tan_data tan_table[] = {
  /* Name, VNUM  */
    {"shield", 3095}, 
    {"jacket", 3043}, 
    {"boots", 3084}, 
    {"gloves", 3071}, 
    {"leggings", 3081}, 
    {"sleeves", 3086}, 
    {"helmet", 3076}, 
    {"bag", 3032},
};

#define NUM_TAN_TYPES 8

  
ACMD(do_tan)
{
 struct obj_data *corpse, *hide;
 char buf[MAX_STRING_LENGTH];
 char itemname[MAX_INPUT_LENGTH], itemtype[MAX_INPUT_LENGTH];
 obj_rnum r_num = 0;
 int i;
 bool found = FALSE;

if (IS_NPC(ch) || !GET_SKILL(ch, SKILL_TAN)) {
        send_to_char(ch, "You haven't learned how to tan.\r\n");
        return;
    }

 two_arguments(argument, itemname, itemtype);

    if (!*itemname) {
        send_to_char(ch, "Tan what?\r\n");
        return;
    }

    if (!*itemtype) {
        send_to_char(ch, "I see that, but what do you wanna make?\r\n");
        return;
    }

    corpse = get_obj_in_list_vis(ch, itemname, NULL, world[IN_ROOM(ch)].contents);

    if (!corpse)
    {
      send_to_char(ch, "Where did that corpse go?\r\n");
      return;
    }

  /* Insert check here to see if the object is actually a corpse - not just any object */
    

 /* Check the tan_table to see if this is a valid item the player is attempting to make (abbreviations OK) */
    for (i = 0; !found && i < NUM_TAN_TYPES; i++)
        if (is_abbrev(itemtype, tan_table[i].name))
        {
            if ((r_num = real_object(tan_table[i].vnum)) == NOTHING) {
                send_to_char(ch, "Error: There is no object with that number.\r\n");
                return;
            }
            found = TRUE;
        }


  /* If the player didn't make a valid entry from the tan_table OR they fail their skill test */
   if(!found || rand_number(1,150) > GET_SKILL(ch, SKILL_TAN) )
   {

    snprintf(buf, sizeof(buf), "You hack at %s but manage to only destroy the hide.\r\n", corpse->short_description);
    send_to_char(ch, buf);

    snprintf(buf, sizeof(buf), "%s tries to skins %s for it's hide, but destroys it.", GET_NAME(ch), corpse->short_description);
    act(buf, TRUE, ch, 0, 0, TO_ROOM);     
   improve_skill(ch, SKILL_TAN);
    extract_obj(corpse);
   WAIT_STATE(ch, PULSE_VIOLENCE*3);                
    return;
    }
    
  /* Player is successful */
    hide = read_object(r_num, REAL);
    snprintf(buf, sizeof(buf), "You hack at the %s and finally make the %s.\r\n", corpse->short_description, hide->short_description);
    send_to_char(ch, buf);
    snprintf(buf, sizeof(buf),  "%s skins %s for it's hide.", GET_NAME(ch), corpse->short_description);
    act(buf, TRUE, ch, 0, 0, TO_ROOM);
    obj_to_char(hide, ch);
    extract_obj(corpse);
    WAIT_STATE(ch, PULSE_VIOLENCE*1); 
    return;
    
}
Last edit: 10 months 4 days ago by WhiskyTest. Reason: formatting

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 4 days ago #7124 by JTP
Replied by JTP on topic Skill tan wont load objects
Thanks, i did my best.

There is a !corpse part in the code to check for no corpse it works.

Your Line: send_to_char(ch, "Error: There is no object with that number.\r\n");

I cant Seem to get that in game ?

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 4 days ago #7126 by JTP
Replied by JTP on topic Skill tan wont load objects
Oh and any ideas for imprevements such as better gear as high level, right now its mostly a low lvl skill

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

More
10 months 4 days ago #7127 by WhiskyTest
Replied by WhiskyTest on topic Skill tan wont load objects
That error message will only appear if the in-game object VNUM doesn't exist.
Eg: if you deleted object 3095 and then tried to tan a shield, it would alert you that object 3095 isn't there.

The !corpse checks for a visible object in the room that matches 'itemname', it doesn't check if that object is a corpse. Like you can drop your sword and tan that at the moment :D

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 4 days ago - 10 months 4 days ago #7128 by JTP
Replied by JTP on topic Skill tan wont load objects
Oh crap, that is bad, how can i prevent that
Last edit: 10 months 4 days ago by JTP.

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

More
10 months 4 days ago #7130 by WhiskyTest
Replied by WhiskyTest on topic Skill tan wont load objects
I think the best way is to create a new item flag.
Eg: ITEM_IS_CORPSE or ITEM_IS_TANNABLE

Before you do though, have a think about whether all corpses should be tannable, or only some, and whether there will be any other uses for corpses (reanimation, skinning, cooking, ? ). Perhaps you only want certain corpses to be used for crafting.

Find the make_corpse() function and set your new flag in there. Add a check for the flag in do_tan and you're done.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 4 days ago #7131 by JTP
Replied by JTP on topic Skill tan wont load objects
Hmmm damn, thought it worked as it should...

corpses is also needed for animate dead. But makes sense that not all is tannable

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 4 days ago #7132 by JTP
Replied by JTP on topic Skill tan wont load objects
Could it be possible to check if anything else then corpse is typed as itemname, then return ?

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 4 days ago - 10 months 4 days ago #7133 by JTP
Replied by JTP on topic Skill tan wont load objects
Ok, for a short moment i thought i had it fixed by changing the get_obj_in_list_vis itemname to "corpse" and change the otder of ifs:
    corpse = get_obj_in_list_vis(ch, "corpse", NULL, world[IN_ROOM(ch)].contents);

    if (!corpse)
    {
      send_to_char(ch, "Where did that corpse go?\r\n");
      return;
    }
    if (!*itemname) {
        send_to_char(ch, "Tan what?\r\n");
        return;
    }

    if (!*itemtype) {
        send_to_char(ch, "I see that, but what do you wanna make?\r\n");
        return;
    }

It worked as long as there was no corpse in the room.

But

if there was both a lets say shield and a corpse

tan shield boots, would turn the corpse into boots. Im sooo lost :/
Last edit: 10 months 4 days ago by JTP.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 4 days ago #7134 by JTP
Replied by JTP on topic Skill tan wont load objects
Ok fixed with new ITEM_ flag, and alittle add on to do_tan....Looks like its done for now...but yea not all corpses should be able to be tanned...have mob races in, so maybe i can use that so undead cant be skinned in make_corpse() ?

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

More
10 months 3 days ago #7135 by WhiskyTest
Replied by WhiskyTest on topic Skill tan wont load objects
Nice work.
Yeah put some conditions into make_corpse so only certain mobs corpses become tannable. Using race for this is a good way to do it.
The following user(s) said Thank You: JTP

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 2 days ago - 10 months 2 days ago #7144 by JTP
Replied by JTP on topic Skill tan wont load objects
Ok im trying this:
  if (!(GET_CLASS(vict) == CLASS_NPC_UNDEAD))
  SET_BIT_AR(GET_OBJ_EXTRA(corpse), ITEM_TANNABLE);


But compiling it says:
fight.c: In function ‘raw_kill’:
fight.c:209: warning: ‘vict’ is used uninitialized in this function

How do i get it to work ?
Last edit: 10 months 2 days ago by JTP.

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

More
10 months 1 day ago - 10 months 1 day ago #7145 by WhiskyTest
Replied by WhiskyTest on topic Skill tan wont load objects
Change "vict" to "ch"
Ps: do this in make_corpse() not in raw_kill()
Last edit: 10 months 1 day ago by WhiskyTest.

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

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
10 months 1 day ago #7149 by JTP
Replied by JTP on topic Skill tan wont load objects
Wierd because it is under make_corpse hmmmm

Ok changed to ch it compiles and Will test now

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

Time to create page: 1.986 seconds