[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  Programming
. -> [Folder]  General
. . -> [Subject]  Logical thinking, not a huge prob, just ignorance
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Logical thinking, not a huge prob, just ignorance

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page


Posted by Trom   (82 posts)  [Biography] bio
Date Sat 10 Apr 2004 03:55 AM (UTC)  quote  ]

Amended on Sat 10 Apr 2004 03:57 AM (UTC) by Trom

Message
I've been approaching a new type of assemble system were items are combined to create another item. This exists on many muds already, but i'm taking a shot at coding it on my own. So far i've got it done and working great, but now i've come across the difficulty of coding it so it can be used for QUEST ASSEMBLES.

Now a quest assemble is a bit more work since all the pieces and the result piece have to be quest pieces, so i've figured out most of it, all the dirty work is done.. the problem i've run into is when the player types 'quest info' it should display what mobs have recieved the quest pieces and what room their in.

I've come up with an idea to add questmob to ch->pcdata which would be of CHAR_DATA * structure.

Now this is the problem, how can i add an unknown amount of mobs to ch->pcdata->questmob.

So when quest info is typed, it would cycle through that list and display all their info (because it would be a pointer to the target mobs).

I don't think this can be anymore descriptive.


BTW:
I have a vague idea of how it works, it would be like assigning mobs to questmob then doing something like questmob = questmob->next, then assigning the mob to questmob again, the only prob with that is getting back to the start and keeping the new mobs at the same time.
[Go to top] top

Posted by Nick Cash   USA  (626 posts)  [Biography] bio
Date Reply #1 on Sat 10 Apr 2004 04:58 AM (UTC)  quote  ]
Message
Perhaps a linked list would be best. I was thinking of using an array, but I guess thats not really possible.

~Nick Cash
http://www.nick-cash.com
[Go to top] top

Posted by Trom   (82 posts)  [Biography] bio
Date Reply #2 on Sat 10 Apr 2004 05:08 AM (UTC)  quote  ]
Message
I plan to use a link list, but don't know how to keep adding to the end of the list without losing the whole list.
[Go to top] top

Posted by Nick Gammon   Australia  (19,473 posts)  [Biography] bio   Forum Administrator
Date Reply #3 on Sat 10 Apr 2004 07:30 AM (UTC)  quote  ]
Message
Do you want a different list per player?

You may need a separate structure, something like this:


struct  questmob_type
{
    questmob_type *        next;
    int  vnum;
};


Then in your pcdata you would put the *first* questmob (which might be NULL), and then you add them by putting the first mob as "first" and then next is linked onto the last one in the list.

There are plenty of examples of that in SMAUG, look at the macros LINK, UNLINK etc. in mud.h.



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Trom   (82 posts)  [Biography] bio
Date Reply #4 on Sat 10 Apr 2004 04:03 PM (UTC)  quote  ]
Message
I've download smaug 1.4 and checked mud.h but didn't see much more than what rot/rom had.

Could you give me an example of adding to a link list ( to the start or end, order doesn't matter ).

I plan to have the following variables.

/*
struct pc_data
{
LIST_DATA *list;
}
*/
//Main list - ch->pcdata->list

typedef structure list_data_type LIST_DATA;
struct list_data_type
{
CHAR_DATA *mob;
LIST_DATA *next;
}

The above code is the type of code i want to use to store a temporary list in memory. How would i add like say 5 mobs to the list 'ch->pcdata->list'. I'm hoping the above code is at least a start to the right path.
[Go to top] top

Posted by Trom   (82 posts)  [Biography] bio
Date Reply #5 on Sat 10 Apr 2004 04:59 PM (UTC)  quote  ]
Message
nevermind, i figured it out. Basically i setup a function which creates a newnode, then assigns the existing list to the newnode->next. Then assigned the new values to newnode itself then in that function returned newnode so the new data would be at the top of the list. Then assigned the new list to the ch->pcdata->list directly.
[Go to top] top

Posted by Nick Gammon   Australia  (19,473 posts)  [Biography] bio   Forum Administrator
Date Reply #6 on Sat 10 Apr 2004 10:49 PM (UTC)  quote  ]
Message
Yes, that is about it. The linked-list macros in mud.h do that and more for you, and if you happen to have converted it to C++ you can use STL which greatly simplifies things like keeping lists.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


2,701 views.

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Web site powered by FutureQuest.Net]