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 ➜ Newish to coding, brand new to Smaug coding

Newish to coding, brand new to Smaug coding

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


Pages: 1 2  

Posted by Sanus   (7 posts)  Bio
Date Tue 20 Jan 2009 06:32 PM (UTC)
Message
Before you read any of this, you should know I'm using Lands of Pabulum code distribution, which was built off of SMAUG 1.7 FUSS, which in turn was off of SMAUG 1.4, and you guys know the rest.

(Lands of Pabulum distros can be found at Smaugmuds.org, kinda obscure)

I'm just starting to get the hang of things, doing more than changing level caps now, or adding snippets, and I've been messing around with a little bit of everything, though no major achievements yet.

So, while doing some building today, I was getting rather frustrated with this program, and everything looked like it would check out OK, but it didn't seem to be working.

After an hour of work making 100% SURE that the damn program wasn't too complicated, and checked out with allllll the rules, I still couldn't get it to go through.

Right about then I noticed that OBJprogs didn't have the fight trigger. And then I noticed that there were a couple triggers I was used to missing (the mud I used to build at must've spoiled the hell out of me).

I know better than to think that there are snippets out there for progtriggers (cause I've looked!), so I want to know how I can make my own. I tried copying the format of the other ones, but something just didn't come out right. Any help would be appreciated.
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 20 Jan 2009 07:38 PM (UTC)
Message
You might get a more detailed response if you explain what the problem is exactly.

You said "I still couldn't get it to go through" and "something just didn't come out right".

Are we talking about compiler errors, runtime errors (ie. crashes) or is it just not doing the right thing?

With a bit more detail someone may be able to help. Detail like the code you added, and what errors, if any, you got.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Sanus   (7 posts)  Bio
Date Reply #2 on Tue 20 Jan 2009 07:58 PM (UTC)
Message
Eh, sorry, I tend to be a bit vague when it's my first post at a new forum. Always gives a bad impression >.>.

I tried to add a fight prog to an object, but it just wouldn't let me, I'm rather newish to coding, and had trouble trying to add something like "void objtrigger_fight" etc. to mud_progs.c. I want to know how to make triggers and such, for programs. I've looked through the files, and it doesn't make much sense to me, so I came here to ask for a little help :P.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #3 on Tue 20 Jan 2009 08:11 PM (UTC)
Message
When you say "newish to coding", what exactly do you mean? Would you know how to write a "hello world" program, or one that reads and writes values from standard in and out? It's important for people to have an idea of where you stand in order to give an answer appropriate for you.

The high-level answer here is that if objects can't have 'fight' triggers, you need to:
(1) change the OLC to allow you to add 'fight' triggers;
(2) find the fight code that is meant to trigger these mudprogs, and actually make it do the triggering -- this will look quite similar to triggering the mob fight progs;
(3) implement the trigger code, which will look similar again to the mob fight triggers.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Sanus   (7 posts)  Bio
Date Reply #4 on Tue 20 Jan 2009 08:22 PM (UTC)
Message
OLC already allows it to have fight progs for pretty much everything, but it doesn't seem to connect when I add the objtrigger, think you would know where that would connect?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #5 on Tue 20 Jan 2009 08:38 PM (UTC)
Message
What exactly do you mean by "it doesn't seem to connect"?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Sanus   (7 posts)  Bio
Date Reply #6 on Tue 20 Jan 2009 09:22 PM (UTC)
Message
OLC lets me give objs a fight_prog, and I can set up the stuff in mud_prog, but whenit gets to programming, it can't tell that it's there, I guess I didn't add something right...
Top

Posted by Sanus   (7 posts)  Bio
Date Reply #7 on Wed 21 Jan 2009 01:26 AM (UTC)

Amended on Wed 21 Jan 2009 01:59 AM (UTC) by Sanus

Message
First off, if mud_prog.c isn't included in regular smaug, or smaug fuss, and you have no idea what I'm talking about, please tell me, so that I know that my problem is uncommon ;)

Okay, in mud_prog.c I've got

"_" = " "

void oprog_fight_trgger( CHAR_DATA 8mob, OBJ_DATA *obj, CHAR_DATA *ch )
{
___if( HAS_PROG( obj->pIndexData, FIGHT_PROG ) )
___{
______set_supermob( obj );
______oprog_percent_check( supermob, mob, obj, ch, FIGHT_PROG );
______release_supermob() );
___}
}

in mud.h, under void oprog_close_trigger, I have

void oprog_fight_trigger( CHAR_DATA *mob, OBJ_DATA *obj, CHAr_DATA *ch );

This compiles, but it doesn't... do... anything...So, I'm probably missing something, could someone please point me in the right direction?
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #8 on Wed 21 Jan 2009 03:47 AM (UTC)

Amended on Wed 21 Jan 2009 03:48 AM (UTC) by Nick Gammon

Message
What's with all the underscores? Are you retyping all this code? It seems to have errors in it, like "oprog_fight_trgger" (missing "i") and "CHAr_DATA" (lower-case "r").

Why not copy and paste? That way we can see what the code really is. To preserve spacing use the [code] tag (see What Are Forum Codes).

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #9 on Wed 21 Jan 2009 03:21 PM (UTC)
Message
I think I might need to repeat my previous question :-)
Quote:
When you say "newish to coding", what exactly do you mean? Would you know how to write a "hello world" program, or one that reads and writes values from standard in and out? It's important for people to have an idea of where you stand in order to give an answer appropriate for you.

If you just added a function, but don't ever call it anywhere, what do you expect to happen?

Let's look at this:

#include <stdio.h>
void f()
{
  printf("hello world\n");
}

int main()
{
  return 0;
}


Do you expect this program to do anything? How do you make it print "hello world"?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Sanus   (7 posts)  Bio
Date Reply #10 on Wed 21 Jan 2009 04:03 PM (UTC)
Message
I did indeed re-write this code from my laptop, which doesn't have internet capabilties at the moment. I'm not exactly sure where to call this one, I didn't find anything in fight.c except something to get the program to continue if the victim or the char died from the fight prog, though it seems I was unable to add in a value for the oprog version of it. How exactly do I get it to call the trigger, and where should I get it to call it?
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #11 on Wed 21 Jan 2009 04:06 PM (UTC)
Message
Find how it calls the fight progs for mobs, and then emulate it for objects. It is in fight.c if memory serves, but grep will help you find it.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Sanus   (7 posts)  Bio
Date Reply #12 on Thu 22 Jan 2009 12:34 PM (UTC)
Message
oi, added in the call for it, as soon as it was called it crashed the mud, soI removed that piece of code, and reverted the two files back to their original states, and then I found out that mprog_give_trigger doesn't work, I checked where it called, and checked it's code out in mud_progs, as well as checked it's entry in mud.h, and all seems to be well... Doesn't work though, checked that too.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #13 on Thu 22 Jan 2009 05:51 PM (UTC)
Message
You'll have to compare your code against what it was before to find out exactly what changed. Clearly you didn't revert exactly to original status because something isn't working anymore. ;-) Hopefully you either have backups, or haven't changed it too much from stock so that you can compare against a fresh archive.

To debug a crash, use gdb. Nick has written a very good guide to gdb available here: http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=3653

The entry in mud.h has no effect; its presence is for compilation, not runtime. See the "hello world" example/question I posted earlier that went unanswered.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Nick Gammon   Australia  (23,173 posts)  Bio   Forum Administrator
Date Reply #14 on Thu 22 Jan 2009 07:42 PM (UTC)

Amended on Thu 22 Jan 2009 07:45 PM (UTC) by Nick Gammon

Message
Quote:

oi, added in the call for it, as soon as it was called it crashed the mud, soI removed that piece of code


I think we aren't getting far here. You are asking general questions about code which you don't post, or if you do post it you are retyping it, making typing errors.

If you want help we have to move on from posts like "I made an (unspecified) change and got an (unspecified) error message, or an (unspecified) crash."

I agree with David, read the post about gdb, and find the exact spot it crashed (ie. the line number, and the context). Also post (copy and paste) the changes you made, and how they are called.

I don't wish to be unkind, but if this is your first C coding project, you are tackling something very complex (a MUD server which has complex interactions of many objects over time) when you really need to master the C fundamentals, or the whole thing will seem like gibberish.

You will find it much more satisfying to do some tutorial projects on C (there will be many examples on the Web), and clarify the difference between declaring a function and calling it, and the reason for using function prototypes (in this case, in mud.h).

You would also need to look into memory allocation issues (like malloc and free), and the way strings are handled in C. For example, it may surprise you to know that in this code:


char * a = "Nick Gammon";
char * b = "Nick Gammon";

if (a == b)
  printf ("true");
else
  printf ("false");


This prints "false", not "true" as you may expect.


A shorter link to the gdb page I wrote is this:

http://www.mushclient.com/gdb

However that is the same page David mentioned (it just is an HTML redirect).


- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


58,295 views.

This is page 1, subject is 2 pages long: 1 2  [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.