Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ A few questions.

A few questions.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2  3  4  5 6  

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #60 on Wed 18 May 2005 09:31 AM (UTC)

Amended on Wed 18 May 2005 09:32 AM (UTC) by Robert Powell

Message
Sorry its a typo, the second one should be slice->value[1] = 13;

v1 being for condition. ))

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #61 on Mon 23 May 2005 09:25 PM (UTC)
Message
Ok, now I want to make it so when you skin certain animals you get a differant pelt object(this is so you can sell the pelts and get differant values for them) but I need to know how to call the various pelts. Could I set a value on each one and if that value is such and such then such and such an object is loaded?
Also, could I make it so the various objects can be sliced a certain amount of times off the corpse(1 meat object for rabbit, 2 for deer, etc.)?

Thanks and Godbless,
Longbow
Top

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #62 on Mon 23 May 2005 11:21 PM (UTC)
Message
Take a look at the existing skin code in skills.c. This code is used by Deadlies to skin there pk oponent and keep as a trophy.

With some simple modification it will skin the corpse of NPC instead of PC.

Now to make it give different skins for different mobs, the way the code works it already will name each skin the name of the mobile/corpse name, so you dont realy need to have lots of different skin objects. So the simplest way would be to apply the cost value either randomly so each skin has a different value.

{
range = number_range(1, 2)
  if range == 1
     skin->cost == ch->level * 4;
  if range == 2
     skin->cost == ch->level * 8;
}


Another way would be to look at the name of the corpse object, and if it contains a key word then apply a value based on that.

Now im not sure on propper syntax here as i have never realy used strstr, but this might work

if (strstr(corpse->name, "deer"))
 {
    skin->cost = 500;
 }
else if (strstr(corpse->name, "rabbit"))
 {
    skin->cost = 100;
 }
else
    skin->cost = 50; 



Hope that is some help and not more confusion, if you get stuck post again and we will see what we can do.

Peace

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #63 on Tue 24 May 2005 04:46 PM (UTC)
Message
Ok that looks really helpful so I'll give it a try. But what about setting how many meat objects can be sliced off of the obj?

Thanks and Godbless,
Longbow
Top

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #64 on Wed 25 May 2005 12:47 AM (UTC)
Message
Just remove the corpse object from the room once they have sliced off the meat. If you want them to slice more than 1 meat from a corpse befor the object is removes, just ad in a counter and increment it everytime the meat is sliced from a coprse, when it reaches the max they can slice, remove the corpse object from the room.

Peace.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #65 on Wed 25 May 2005 11:18 PM (UTC)
Message
How would one add a counter and a percent?

Also, I'm trying to transfer spells to skills. I transferred detect poison but and I don't get any errors compiling except it says the obj may not be called. The data starts with

OBJ_DATA *obj;

When I type the commmand ingame it says nothing, just adds a blank line.


Thanks and Godbless!
Longbow
Top

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #66 on Thu 26 May 2005 06:16 AM (UTC)
Message
A simple counter would be a variable that you increment every time a particular action has taken place, then you can use an if statement to see if come condition is true to do something else.

int meat_counter;

 meat_counter ++;

 if meat_counter == 5;
   {
     extract_obj( corpse );
     return;
   }



Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #67 on Sat 28 May 2005 05:48 PM (UTC)
Message
This is the code for spell_detect_poison, which I transferred to be a skill. I only changed the AT_MAGIC to AT_SKILL.

ch_ret spell_detect_poison( int sn, int level, CHAR_DATA *ch, void *vo )
{
OBJ_DATA *obj = (OBJ_DATA *) vo;

set_char_color( AT_SKILL, ch);
if ( obj->item_type == ITEM_DRINK_CON || obj->item_type == ITEM_FOOD
|| obj->item_type == ITEM_COOK)
{
if ( obj->item_type == ITEM_COOK && obj->value[2] == 0 )
send_to_char( "It looks undercooked.\n\r", ch );
else if ( obj->value[3] != 0 )
send_to_char( "You smell poisonous fumes.\n\r", ch );
else
send_to_char( "It looks very delicious.\n\r", ch );
}
else
{
send_to_char( "It doesn't look poisoned.\n\r", ch );
}

return rNONE;
}

Now I have never transferred a spell to a skill before, so what would I need to do to make this work? When I get ingame and try the skill it just brings up a blank line, but my proficiency goes up.

Thanks and Godbless,
Longbow
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #68 on Sat 28 May 2005 06:13 PM (UTC)
Message
This is my do_slice code:

void do_slice( CHAR_DATA *ch, char *argument )
{
OBJ_DATA *corpse;
OBJ_DATA *obj;
OBJ_DATA *slice;
bool found;
char buf[MAX_STRING_LENGTH];
char buf1[MAX_STRING_LENGTH];
found = FALSE;

if ( !IS_NPC(ch) && !IS_IMMORTAL(ch)
&& ch->level < skill_table[gsn_slice]->skill_level[ch->class] )
{
send_to_char("You are not learned in this skill.\n\r", ch );
return;
}

if ( argument[0] == '\0' )
{
send_to_char("From what do you wish to slice meat?\n\r", ch);
return;
}

int meat_counter;

meat_counter ++;

if meat_counter == 5;
{
extract_obj( corpse );
return;
}

if ( ( obj = get_eq_char( ch, WEAR_WIELD ) ) == NULL
|| ( obj->value[3] != 1 && obj->value[3] != 2 && obj->value[3] != 3
&& obj->value[3] != 11) )
{
send_to_char( "You need to wield a sharp weapon.\n\r", ch);
return;
}

if ( (corpse = get_obj_here( ch, argument )) == NULL)
{
send_to_char("You can't find that here.\n\r", ch);
return;
}

if (corpse->item_type != ITEM_CORPSE_NPC )
{
send_to_char("That is not a suitable source of meat.\n\r", ch);
return;
}
if ( get_obj_index(OBJ_VNUM_SLICE) == NULL )
{
bug("Vnum 24 not found for do_slice!", 0);
return;
}

if ( !can_use_skill(ch, number_percent(), gsn_slice ) && !IS_IMMORTAL(ch))
{
send_to_char("You fail to slice the meat properly.\n\r", ch);
learn_from_failure(ch, gsn_slice); /* Just in case they die :> */
if ( number_percent() + (get_curr_dex(ch) - 13) < 10)
{
act(AT_BLOOD, "You cut yourself!", ch, NULL, NULL, TO_CHAR);
damage(ch, ch, ch->level, gsn_slice);
}
return;
}

slice = create_object( get_obj_index(OBJ_VNUM_SLICE), 0 );

sprintf(buf, "meat fresh slice %s", corpse->name);
STRFREE(slice->name);
slice->name = STRALLOC(buf);

sprintf(buf, "a slice of raw meat from %s", corpse->short_descr);
STRFREE(slice->short_descr);
slice->short_descr = STRALLOC(buf);

sprintf(buf1, "A slice of raw meat from %s lies on the ground.", corpse->short_descr);
STRFREE(slice->description);
slice->description = STRALLOC(buf1);

act( AT_BLOOD, "$n cuts a slice of meat from $p.", ch, corpse, NULL, TO_ROOM);
act( AT_BLOOD, "You cut a slice of meat from $p.", ch, corpse, NULL, TO_CHAR);
slice->value[0] = 13;
obj_to_char(slice, ch);

learn_from_success(ch, gsn_slice);
return;
}

I'm getting a parse error before "meat counter" and I don't quite know how one goes about adding an increment to the counter, but other then that it's good. :)

Thanks and Godbless.

Longbow
Top

Posted by Gatewaysysop2   USA  (146 posts)  Bio
Date Reply #69 on Sat 28 May 2005 06:15 PM (UTC)
Message
The AT_SKILL versus AT_MAGIC thing is only for coloration purposes. AT_MAGIC is dark blue I think, AT_SKILL I believe is bright green. Has no effect beyond that.


"The world of men is dreaming, it has gone mad in its sleep, and a snake is strangling it, but it can't wake up." -D.H. Lawrence
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #70 on Wed 01 Jun 2005 12:02 AM (UTC)
Message
Anybody got an idea about my code, in particular for my slice code? I want to get this fixed pretty soon and I think I'm almost there.

Thanks, Godbless,
Longbow
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #71 on Wed 01 Jun 2005 10:38 PM (UTC)
Message
I've been trying to change how long each hour in a day is. Time is traveling waaaaay to fast so I want to slow it down. Now I've found the code for time in db.c around line 515, but I don't know how to read what does what. I can play around and see but I'd like to know what it might affect if I make hours longer? And can I make the hours longer by increasing the big number in line 519?
Also, there is a bit of code that seems to deal with weather that is commented out below the time code. Is this unfinished or buggy code and if not can I uncommment it and what will it do? :)

Thanks for helping me out!
Godbless,
Longbow
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #72 on Mon 13 Jun 2005 12:25 AM (UTC)
Message
Ok folks, this is some code I'd like help with. It is the first piece I've come near completing on my own! Praise the Lord and pass the help! Now it gives me a number of errors when compiling, along the lines of "case label not within a switch statement" and BV32 not undeclared"(which is the ORE flag) and so on. Could yall help me fix my bugs por favor?
Gracias!

/* This is my mining code. I hope it works! --Longbow */

void do_mine (CHAR_DATA *ch, char *argument)
{
if ( ( shovel = get_eq_char(ch, WEAR_HOLD) ) == NULL)
{
send_to_char( "You don't have anything to mine with! \n\r", ch);
return;
}
if (shovel->item_type ==ITEM_SHOVEL)
{
act(AT_ACTION, "%n mines furiously. \n\r", ch, NULL, TO_ROOM);
return;
if ( IS_SET(pRoomIndex->room_flags, ROOM_ORE) )
rand = number_range( 1, 6 )
switch(rand)
case 1:
mine = create_object( get_obj_index(OBJ_VNUM_ORE), 0 );
send_to_char("You mined a chunk of ore! \n\r", ch);
break;
case 2:
send_to_char("You failed to mine anything useful. \n\r", ch);
break;
case 3:
send_to_char("You failed to mine anything useful. \n\r", ch);
break;
case 4:
send_to_char("You failed to mine anything useful. \n\r", ch);
break;
case 5:
send_to_char("You failed to mine anything useful. \n\r", ch);
break;
case 6:
send_to_char("You failed to mine anything useful. \n\r", ch);
break;
}



Godbless,
Longbow
Top

Posted by Robert Powell   Australia  (367 posts)  Bio
Date Reply #73 on Mon 13 Jun 2005 11:52 AM (UTC)

Amended on Mon 13 Jun 2005 12:04 PM (UTC) by Robert Powell

Message
Whats problems are you getting??

Firstly there are no variables defined, your missing a some important code that should be under void do_mining(CHAR_DATA *ch) I dont think the char *argument is needed as your not accepting any imput from the char in this function.


 if (shovel->item_type ==ITEM_SHOVEL)
{
act(AT_ACTION, "%n mines furiously. \n\r", ch, NULL, TO_ROOM);
return; 


This should be (in sudo code)

if ch->wield != ITEM_SHOVEL
send ( you cannot mine without a shovel or a miners pick )
return.

I'm guessing that this next part needs to know which room and who is in it.

 if ( IS_SET(pRoomIndex->room_flags, ROOM_ORE) )
rand = number_range( 1, 6 )
switch(rand)


should look something like this. of cource use your own room_flag and variables

if (xIS_SET(ch->in_room->room_flags,ROOM_MINE))
    {
      switch(range = number_range( 1, 6 ))


Ok in this part, you have a sucessfull mine, you have created an object, but what you going to do with it, there is a set missing in there. The ore object needs to either be loaded into the pc's inv or into the room, or some other option.

 case 1:
mine = create_object( get_obj_index(OBJ_VNUM_ORE), 0 );
send_to_char("You mined a chunk of ore! \n\r", ch);
break;

Keep plugging away at this, your very close to having a working function there, Then i will bombard you with a few other things to take into concideration. HEH, like wait states or even better a substate, so if they use another command while mining they stop mining all together.

Just a guy having a bit of fun. Nothing more, nothing less, I do not need I WIN to feel validated.
Top

Posted by Longbow   (102 posts)  Bio
Date Reply #74 on Sat 25 Jun 2005 02:50 PM (UTC)
Message
Ok, Teacher, I've got my homework here. *Grins like a schoolboy*:

 void do_mine (CHAR_DATA *ch,)
 {
	char arg[MAX_INPUT_LENGTH]
	
 if ( ( shovel = get_eq_char(ch, WEAR_HOLD) ) == NULL)
 	{
	send_to_char( "You don't have anything to mine with! \n\r", ch);
	return;
	}
 if (ch->item_type ==ITEM_SHOVEL)
 	{
	act(AT_ACTION, "%n mines furiously. \n\r", ch, NULL, TO_ROOM);
	return;	
 if ( xIS_SET(ch->in_room->room_flags, ROOM_ORE) )
 	{
  switch( range = number_range( 1, 6 ) )
 	case 1:
	mine                = create_object( get_obj_index(OBJ_VNUM_ORE), 0 );
	obj_to_char(mine, ch);
    send_to_char("You mined a chunk of ore! \n\r", ch);
	break;
	case 2:
	send_to_char("You failed to mine anything useful. \n\r", ch);
	break;
	case 3:
	send_to_char("You failed to mine anything useful. \n\r", ch);
	break;
    case 4:
    send_to_char("You failed to mine anything useful. \n\r", ch);
	break;
    case 5:
	send_to_char("You failed to mine anything useful. \n\r", ch);
	break;
	case 6:
	send_to_char("You failed to mine anything useful. \n\r", ch);
	break;
	}
  }	

Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


222,514 views.

This is page 5, subject is 6 pages long:  [Previous page]  1  2  3  4  5 6  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.