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
➜ Programming
➜ General
➜ Logical thinking, not a huge prob, just ignorance
Logical thinking, not a huge prob, just ignorance
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Trom
(82 posts) Bio
|
Date
| Sat 10 Apr 2004 03:55 AM (UTC) 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. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #1 on Sat 10 Apr 2004 04:58 AM (UTC) |
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 | Top |
|
Posted by
| Trom
(82 posts) Bio
|
Date
| Reply #2 on Sat 10 Apr 2004 05:08 AM (UTC) |
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. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sat 10 Apr 2004 07:30 AM (UTC) |
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 | Top |
|
Posted by
| Trom
(82 posts) Bio
|
Date
| Reply #4 on Sat 10 Apr 2004 04:03 PM (UTC) |
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. | Top |
|
Posted by
| Trom
(82 posts) Bio
|
Date
| Reply #5 on Sat 10 Apr 2004 04:59 PM (UTC) |
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. | Top |
|
Posted by
| Nick Gammon
Australia (23,140 posts) Bio
Forum Administrator |
Date
| Reply #6 on Sat 10 Apr 2004 10:49 PM (UTC) |
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 | 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.
18,635 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top