Howdy yall, I'm not the best of coders(really poor) so I'm requesting that if you reply you explain your answers thoroughly please. Thanks!
1. Is is possible to skin corpses? I feel certain there is a way to do this, but I have only had Smaug for a little while.
2. Is it possible to make objects out of other objects? For example, if I had a flour obj and a waterskin obj and I wanted to type bake/cook/make bread, how would I go about turning it into a bread object? The same question applies to making clothing out of cloth.
3. Everytime I aassign myself an area and savearea in it, it erases all my work when I reboot the MUD. Why is this happening?
4. I want to make a fishing program where there is a random chance of a fish passing by(ie a message telling you that you see a fish swimming by), and when that message occurs if you type catch there will be a chance you will catch the fish, thus adding a fish obj to your inventory.
5. I want a turn-based combat system(ie, One player attacks and then the battle stops. Then the other person attacks, and so forth.), but I'm not sure about what to remove. I still have to make it so that after a period of time a NPC will attack since unlike players they have no one to type in attacks. I saw an article somewhere in this forum about it but the coding is over my head.
I may add more questions later but enough for now. If you can only answer one or two of them that's fine, I will be glad for the help.
1. yes, there is a skin command in smaug already, which is used by PK's to skin each other as trophies.
2. yes, there are a number of ways you can achieve this, how you would do it would depend on the outcome you want. For your baking example you would check in the baking function that the player had the objects needed to bake a cake, remove the objects from their inventory and then put a cake object in.
3. If you have aassigned an area to yourself you cannot savearea, you must use foldarea to save changes. savea only works on prototype area's, not ones that are live and in the game.
4. WHat is it with fishing, i have been asked to add fishing into my mud by another imm, read about it in a thread oon mudconnect,, was asked to code it for another mud and now we have it again. Below sudo code by me LOL.
check they entered the command and any paramiters correct
check they can use the skill/ if its a skill
check they are in the right place to fish/ cant fish in the city huh
check they have the right objects/ bait and tackle
bailout if if any of these fail
remove bait / 1 bait 1 cast
roll dice to see of there is a fish
if no fish, wait till they retrieve line then end.
if fish is there, wait till they pull the line,
% chance of catching based on gear used and type of fish.
if no catch wait till they retrieve line then end
if caught fish, load fish object to room, end
That would cover most of what you would need to d for fishing.
5. this is way over my head, if your struggeling with some of the easy things then i would wait on this for a long time to come.
The skill do_skin is in skills.c, if you dont have it, here is the code for it, it doesnt need many changed to make it skin mobs.
void do_skin( CHAR_DATA *ch, char *argument)
{
OBJ_DATA *korps;
OBJ_DATA *corpse;
OBJ_DATA *obj;
OBJ_DATA *skin;
bool found;
char *name;
char buf[MAX_STRING_LENGTH];
found = FALSE;
if ( !IS_PKILL(ch) && !IS_IMMORTAL(ch) )
{
send_to_char( "Leave the hideous defilings to the killers!\n", ch );
return;
}
if ( argument[0] == '\0' )
{
send_to_char( "Whose corpse do you wish to skin?\n\r", ch );
return;
}
if ( (corpse=get_obj_here(ch, argument)) == NULL )
{
send_to_char( "You cannot find that here.\n\r", ch );
return;
}
if ( (obj=get_eq_char(ch, WEAR_WIELD)) == NULL )
{
send_to_char( "You have no weapon with which to perform this deed.\n\r", ch );
return;
}
if ( corpse->item_type != ITEM_CORPSE_NPC )
{
send_to_char( "You can only skin the bodies of player characters.\n\r", ch);
return;
}
/* if ( obj->value[3] != 1
&& obj->value[3] != 2
&& obj->value[3] != 3
&& obj->value[3] != 11 )
{
send_to_char( "There is nothing you can do with this corpse.\n\r", ch );
return;
} */
if ( get_obj_index( OBJ_VNUM_SKIN ) == NULL )
{
bug( "Vnum 23 (OBJ_VNUM_SKIN) not found for do_skin!", 0);
return;
}
korps = create_object( get_obj_index(OBJ_VNUM_CORPSE_PC), 0 );
skin = create_object( get_obj_index(OBJ_VNUM_SKIN), 0 );
name = IS_NPC(ch) ? korps->short_descr : corpse->short_descr;
sprintf( buf, skin->short_descr, name );
STRFREE( skin->short_descr );
skin->short_descr = STRALLOC( buf );
sprintf( buf, skin->description, name );
STRFREE( skin->description );
skin->description = STRALLOC( buf );
act( AT_BLOOD, "$n strips the skin from $p.", ch, corpse, NULL, TO_ROOM);
act( AT_BLOOD, "You strip the skin from $p.", ch, corpse, NULL, TO_CHAR);
act( AT_MAGIC, "\nThe skinless corpse is dragged through the ground by a strange force...", ch, corpse, NULL, TO_CHAR);
act( AT_MAGIC, "\nThe skinless corpse is dragged through the ground by a strange force...", ch, corpse, NULL, TO_ROOM);
extract_obj( corpse );
obj_to_char( skin, ch );
return;
}
Dont forget to make the required entries in tables.c and mud.h, and then, when cleaned and made, cedit the command.
As for what file to put your baking command in, it is realy a matter of choice, tho, as it is a skill(if your making it a skill that a class receives) and not a command, you could put it in skills.c with all the other skills.
On the other hand, if your going to be making a lot of new skills that are all related, (baking, fishing, mining, chop_trees_down, ect) you might want to start a new C file, crafting.c where all the crafting related skills are kept. Ultimately its up to you to place the functions in a place that is easy to find them later.
Ok with the skin code this is what you want to look at and change to suit how you want it to work.
if ( !IS_PKILL(ch) && !IS_IMMORTAL(ch) )
{
send_to_char( "Leave the hideous defilings to the killers!\n", ch );
return;
}
In this section you have to be a Pkiller or an Immortal to skin
if ( corpse->item_type != ITEM_CORPSE_NPC )
Hmmm guess i changed this already so that you can skin the corpses of Mobiles instead of Players. Yours will read ITEM_CORPSE_PC.
I dont know about a simple way to add more than one type of money. There is a snippet out there that adds in Silver and Bronze. It was written by Sadiq, i think you can find it on Samsons snippet site.
I just looked through it, seems to be a lot of aditions there, i wouldnt say that it is a simple snippet to add tho.
1. ITEM_CORPSE_NPC is defined in mud.h, the actual items vnum is a part of limbo.are, tho i cannot think of hand what the vnum is. So no you dont need to make an object for this as it is already a part of limbo.are
2. It www.afkmud.com its in the download section under sadiq's stuff, its called alternate currency system.
3. If you have a look in the area file you should find the mobile, that you created there, as long as you have created one within the vnum range of the area file.
When you make a mobile, you also have to create a reset for the mobile to make it come into the area when the area resets.
There are a number of ways to acheive this. Instaroom, Instazone, and Reset are all commands that can be used to make a reset. Read the help files on them to become more familure with them.
On another note, if your having trouble understanding the whole building process, there is an exelent website that i learned much from. I cannot think of the address offhand, but do a google for Herne's Smaug Building Guide. Its the most comprehensive builders guide that i know of.
What is it with fishing, i have been asked to add fishing into my mud by another imm, read about it in a thread oon mudconnect,, was asked to code it for another mud and now we have it again.
Some MMORPGs have fishing (eg. World Of Warcraft), maybe the idea is spilling across to text MUDs.
It is a way of gathering food (and occasionally treasure, like a message in a bottle).
Final Fantasy XI has fishing as well. A fairly good way to make some money, if I remember right. Lots of gear and stuff for it (some tackle that would allow you to catch 4-5 fish at once or something).
It adds another thing for players to do besides killing mobs, and is, as Nick said, a source of food. Both the Muds I've played on had fishing, and that was long before the high-falootin' MMORPG craze. =)
To add a new command (SKILL??) you would follow the following, not exactly in that order, but this pretty much covers it. I will assume that its a skill (fishing) as that has a few more parts to do with GSN's that a command doesnt.
1. Write the code for fishing skill, Will leave this upto you for now, if you cannot get it to work, post what you have and i will help you from there.
2. Add entries in tables.c there are 2 massive tables, where everything is ment to be in alphabetical order. You need to add entries that are the same as below, where do_fish replace do_fixed.
if ( !str_cmp( name, "do_fixed" ))
return do_fixed;
AND..... further down
if ( skill == do_fixed )
return "do_fixed";
IN mud.h you have this to add.
DECLARE_DO_FUN( do_fixed );
and for the gsn(global skill number)
extern sh_int gsn_fixed
Next part goes in db.c
sh_int gsn_fixed;
Lastly we know that our coding skills are the best, and it all compiles cleanly, the mud starts up and there is no crash(Tm), we sset the command in if we are suckers for punishment, or we open skills.dat and add in somthing that looks like this,
#SKILL
Name fish~
Type Skill
Info 0
Flags 0
Minpos 110
Slot 550
Rounds 8
Code do_fish
Dammsg ~
Misschar You are a tops fisher person.~
Minlevel 1
End
I think that just about covers it all, hope that helps some.
Ok, I don't understand the commands for adding the code for a new skill. I'm quite willing to try it myself but I don't know how to check if I'm in a room where you can fish or how to check the bait on my pole or your skill or anything. Could somebody give me a list of commands for writing code?
Also, does anyone know how to change the desc color in room descs? And what kind of food CAN you cook, it says you can only cook certain types of food.
Thanks for your patience, I really wish I knew some coding skills but I'm picking up a bit.
Ok, I went and examined my do_skin bit, and I found that there wasn't a skill even using it, so no wonder it never worked. So I made a new skill(following the steps of Kevin London's tutorial, http://www.cs.utk.edu/~london/smaug/SMAUGDOC.html#spells)
I assigned the do_skin command to the skill, but it still says the same thing: "huh?"
HUH? WHY DOES IT SAY HUH? I killed a deer(npc) and typed skin corpse, and it says "huh?".
if ( !IS_PKILL(ch) && !IS_IMMORTAL(ch) )
{
send_to_char( "Leave the hideous defilings to the killers!\n", ch );
return;
}
if ( argument[0] == '\0' )
{
send_to_char( "Whose corpse do you wish to skin?\n\r", ch );
return;
}
if ( (corpse=get_obj_here(ch, argument)) == NULL )
{
send_to_char( "You cannot find that here.\n\r", ch );
return;
}
if ( (obj=get_eq_char(ch, WEAR_WIELD)) == NULL )
{
send_to_char( "You have no weapon with which to perform this deed.\n\r", ch );
return;
}
if ( corpse->item_type != ITEM_CORPSE_NPC )
{
send_to_char( "You can only skin the bodies of player characters.\n\r", ch);
return;
}
if ( obj->value[3] != 1
&& obj->value[3] != 2
&& obj->value[3] != 3
&& obj->value[3] != 11 )
{
send_to_char( "There is nothing you can do with this corpse.\n\r", ch );
return;
}
if ( get_obj_index( OBJ_VNUM_SKIN ) == NULL )
{
bug( "Vnum 23 (OBJ_VNUM_SKIN) not found for do_skin!", 0);
return;
}
korps = create_object( get_obj_index(OBJ_VNUM_CORPSE_PC), 0 );
skin = create_object( get_obj_index(OBJ_VNUM_SKIN), 0 );
name = IS_NPC(ch) ? korps->short_descr : corpse->short_descr;
sprintf( buf, skin->short_descr, name );
STRFREE( skin->short_descr );
skin->short_descr = STRALLOC( buf );
sprintf( buf, skin->description, name );
STRFREE( skin->description );
skin->description = STRALLOC( buf );
act( AT_BLOOD, "$n strips the skin from $p.", ch, corpse, NULL, TO_ROOM);
act( AT_BLOOD, "You strip the skin from $p.", ch, corpse, NULL, TO_CHAR);
/* act( AT_MAGIC, "\nThe skinless corpse is dragged through the ground by a strange force...", ch, corpse, NULL, TO_CHAR);
act( AT_MAGIC, "\nThe skinless corpse is dragged through the ground by a strange force...", ch, corpse, NULL, TO_ROOM);
extract_obj( corpse ); */
obj_to_char( skin, ch );
return;
}
Ok, I don't understand the commands for adding the code for a new skill. I'm quite willing to try it myself but I don't know how to check if I'm in a room where you can fish or how to check the bait on my pole or your skill or anything. Could somebody give me a list of commands for writing code?
Whenever i face these problems, i look to other sections of code that might hopefully do simular things to what i want to acheive.
1. Am i in the right type of room to fish.
What i would do is grep for a sector type and hope that something looks to do what i need. grep SECT_ *.c, what i found thats usefull is this, in magic.c in the spell plant pass.
So if a Chariter is in a room with the sector type equalling forest, it would then execute the next line/few lines of code contained in the {}, else execute the code in this section {}
2. Does charicter have bait or a pole.
A fishing pole would be held, right? So we can then check to see what the player has in the WEAR_HOLD location. Lots of other things need to be held to use, so grep WEAR_HOLD *.c and there i found this example in do_scribe, to scribe you need to be holding a blanc scroll.
I this get_eq_char checks to see whats in WEAR_HOLD and if there is nothing (NULL) then it executes whats in the {}, if there is something in WEAR_HOLD, then scroll gets given all the data for that object(dont know if i said that right) so we can then check values of scroll to see if its that right type to do what we want.
if ( scroll->item_type == ITEM_SCROLL )
A check like this would be used to see of the oject is the right item_type.
I have assumed that you would be creating a new item type.
There is some parts to get you thinking, you will also need to work out how to remove and object from a player, to take away a lost or stolen bait, load an object into a room to give the player a fish if one is caught.
Good luck, if your still stuck, post what you have written and we can help you out further, the most important part here is having a go at it, dont worry if it doesnt work right or even compile first time, its all a part of the learning.
The good thing here is once you have the first one done, you will have a frame work to continue on to make baking and the other sumular skills with.
Alright, I figgered out what my skin problem was. I had to practice the skill. :D Yes, go ahead and laugh...
Whenever I kill an animal it says:
Log: [*****] BUG: death_cry: invalid vnum. As a result I don't get a deathcry from anything. What's up with that?
Edit: ugh, now it's gone away. But I can skin the same corpse as many times as I want! I want it to die when it has been skinned once! Grrr...
Also, the whole point of the skin command for me was to make it possible to sell animal skins. Will it automatically tell the difference between the skins? Somehow I doubt that, so how do I define what kind of skin it should be so I can sell it?
Thanks for that last post Robert Powell, I'll take a try at it and see what I can come up with.
The part get_obj_index looks to see if the variable vnum is a valid one, if it isnt valid then you get that error. So looking deeper into the deadth_cry function you need to find out where vnum is being givin its value to see what the heck it does.
Vnum equals parts_vnums which atleast means something, its the vnum of a body part that is left over when you kill a mobile. So i would say in limbo.are your missing a bodypart, as for what one i dont know. LOL
Peace.
Now i think i need some of this explained to me also, but i will have a crack, & has a number of uses, the most used one that i can think of is in this situation
if ( this && that ) which should mean if this and that is true.
The pipe | if ( this || that ) is if this or that is true.
-> now i dont realy know how to explain this, but has to do with referencing parts of structures(with pointers??, im not realy up on pointer theory.
CHAR_DATA *ch; declares a pointer ch that points to the CHAR_DATA structure in mud.h, so you can then reference part of the structure, ch->name, would give you the name element from the structure.
Im sure someone else could explain that way better than i have.
Ok, I've got a bit going now. Now how does one add a new obj_type? I want to add several new ones.
Also, I'm trying to change the various combat messages, such as "MOB scratches you" but I can't seem to find the right file to edit. Which would it be please?
Grep for stuff you know, ITEM_SHOVEL and shovel, scratches you.
Make grep your friend and you will never be lost, well not very lost anyway, heh.
The reason for ITEM_SHOVEL and shovel, (it could be any item type you can think of) is because in some of the lists you need to add to it is ITEM_ and in others its just the name. Take a look you will see, after adding it in all the places you can find, if something doesnt work then post again, so you can be shown what you missed.
Ok, I put in a new skill that I got from some snippet place for "charge", and I followed all the steps exactly, but when I try to compile it gives me about a bazillion errors in mud.h saying stuff has been called before or something or other. It's about every line in mud.h I think that calls an error. What's up with that and how do I fix it?
Also, what do you do to an object to make it cookable?
And more critically, how do you set a player's Pkill flag on and off? I want to allow folks to kill each other right off the bat, none of this level 5 baloney. :)
Can you post a few lines of the errors your getting, that will help in working out whats going on.
For the pkill stuff, being pk PK is just means you have the PCFLAG_DEADLY flag set on them, if you want that set on everyone, the best place to set it would be in comm.c in the nanny function, just look for where the auto's(auto exits i think in stock) are set and put it there.
For cooking, look in skills.c in the function do_cook.
K, I'll post some lines of that later, I don't have time now.
More critical at the moment is the fact that shopkeepers won't buy anything. I followed the guide on Herne's Smaug Page but we still can't get the shops to say anything other then, "Looks uninterested in the item". What could be wrong? We set the shop buy1, 2 and 3 values, and it is open.
Like i have said a few times befor, most times you can work out whats going on, by grepping your source for either the error, or responce your being given. The code above is in shop.c.
Ok, I'm not sure how to call a dice sequence to check for success. This would also apply to my fishing code, but at the moment it has to do with chopping wood. My current code is as follows:
void do_chop (CHAR_DATA *ch, char *argument)
{
if (ch->in_room->sector_type == SECT_FOREST)
{
if ( ( shovel = get_eq_char(ch, WEAR_HOLD) ) == NULL)
{
send_to_char( "You don't have an axe! \n\r", ch );
}
if (shovel->item_type ==ITEM_SHOVEL)
{
act(AT_ACTION, "$n chops at the trees with their axe.", NULL, NULL, TO_ROOM);
}
}
}
I'd appreciate help with the dice, and any comments on the code would be nice. Thanks for all the help! I feel I might actually be learning something from all this. :)
Make sure you use the code tags so it's easier to read. You need a return in parts where you want the code to stop, say after the "You do not have an axe".
The random number check is used much through the code. It's called rand_num or something of the sort.
Ahhhh, now I understand. I want a dice sequence such as if it equals 1 something happens, and 2 then something else happens(or the same, it could be a range), etc.
Here are a few bits of information you might need, number_range is what you want to use to determine a number value between 2 numbers. learn_from_failure and learn_from_sucess are 2 other functions you might like to use. Grep them out to see how to use them, Your on the right track so far.
Ahh my favorite Haha.. I am very ... protestant... against certainty in a mud world.. I've got number_range cases everywhere.
And yes.. that's perfect.. but you might want to add a default: case there just incase something very weird happens that causes "rand" to become corrupted/changed
A default in a switch will be used any time nothing else matches.
Well the trip function is for mobs to use. What you want to do is create a new function, do_trip for the trip skill, that has checks etc and calls the trip function.
Ok, suddenly I cannot see action descs and the like(ie, if something happens in the room a blank black line appears) and it is messing up my MUD. I first noticed it after I put in the bank code located at AFKmud's homepage(www.afkmud.com) and it is driving me up the wall. What might cause this? I'd rather not go back and delete the bank code(took a lot of time to put in) but rather I'd like to just fix the problem. Any ideas?
Sounds to me liek the mobile has the secritive flag set on it, i remember running about for hours trying to workout why then hell my shops wouldnt work, and it ws because of the secritive flag being set on a couple in the area i was working in.
Ok, I got that fixed. Thanks. Now another question. I'm trying to extend the time it takes to get hungry, as it is really getting on my nerves with the continuous feeding process. However I cannot seem to find out which variable to change. I grepped hunger_mod but it doesn't seem to be the right one. Which variable would it be?
More critically, I keep getting a segmentation fault(core dumped) message that crashes the mud. It always seems to come after wildlands.are is reset but it resets that area at other times without problem. Why is this?
It all happens in a function called gain_condition, as for a suitable way to modify it im at a loss without reading throught it and all the places it is called.
Like grep to find things you need to make GDB your friend, gdb will help you in most cases pinpoint where a problem is occuring.
Nicks tutorial is fantastic but when i first read it i was overwelmed by the amount of detail he gave and was in some ways lost in all the details.
There are 2 main ways you can use it, by having it analize a core file, or by running the program within gdb while debuging, this is my preference while working on my local machine because for some unknown reason i donot make core files localy.
cd into your area directory,
run gdb
type file ../src/smaug (or the path to your executable)
type run
You now have smaug running in gdb, login to the mud and cause it to crash.
Go back into gdb,
Type bt (backtrace will show you the last bunch of functions called befor the crash)
frame <number> will take you to function you think caused the crash.
then you can type LIST to see the section of code.
Print <variable name> will show you what the variable contains.
Ok thanks guys. It appears to be fixed. Now I went to put in the slice skill(it came with Smaug) and everytime I try to slice something it says:
"Can not find mob for value[2] of corpse, do_slice".
Now how would one fix that? I know that it needs to be set to a value of two, but how do I do that? Newbish question I know, but I'm getting there. :)
From my quick read of do_slice, v2 is used to determine a food value for the mob corpse in question, beacuse if slice is successfull you end up with vnum 24 and i think thats a chunk of meat.
Now if you look through the code you will see that V2 never gets used at all within the function, but V3 does.
ALso if you kill something and ostat the corpse object you will find that V2 is set on the object but not in the index object and its checking the index value.
I would just remove the whole V2 check as its there for no reason that i can tell, and posibly change the values in v3 as 75 seems a little high when i got a value of 1 for the biggest mob in my game.
I've tried deleting it but when I make it says it may be called anyway or something like that. Running the game and trying to slice the corpse results in a crash by a segmentation fault. What would one to do delete that function, or what could I change the command to so that it does something useless but thinks it's doing something?
Sorry guys, I'm kinda boggled. What should I do since I can't delete the line of code? It's still calling from somewhere so it crashes when I run it. What could I set that command to so it will never be called?
There are some other changes that need to be made in order to make it work right. It uses pMobindex->blaa its trying to set values on a mobile when it should be setting them on an object, corpse->blaa, the other change is slice->value3 = this makes the food item poison so delete it and set values for v0 (food value) and v1 (condition).
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;
}
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] = 25;
slice->value[0] = 13;
obj_to_char(slice, ch);
learn_from_success(ch, gsn_slice);
return;
}
There is one other thing you might want to do and thats remove the corpse after the meat has been sliced, otherwise you could slice meat for all eternity.
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.)?
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
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.
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.
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;
}
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.
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 ( (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;
}
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. :)
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.
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? :)
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;
}
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.
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.
case 1
found stuff message
case default
didnt find stuff message
Tends to be easier to read when you have all but 1 result with the same message. There's also the built in safety net of not crashing with a default if you somehow get a result not specified in your case struct.
if ( result == 1 )
// found something
else
// found nothing
The point of the case statement is really to save you from having to write out lots of if/else if/else if/... if you're just using two alternatives you may as well just use if/else. The compiler should be smart enough to not generate a jump table with a two-branch case statement but it doesn't hurt to help it out.