The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

Object Progs

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » 1.69s Beta4
View previous topic :: View next topic  
Author Message
osiris



Joined: 31 Oct 2008
Posts: 32
Location: North Carolina

PostPosted: Sat Feb 28, 2009 6:25 am    Post subject: Object Progs Reply with quote

I could have sworn I saw Kal say 1.69S had obj progs but I can't find it now. I breezed through the change file and didn't see it either (although I wasn't very thorough so I may have missed it). So does S have obj progs or not? If it does does that mean I can create a ring and set it so that the ring object casts heal and acid blast? I remember reading something on this a while back and there was talk of using mob progs to accomplish this which seemed a bit "hacky". If obj progs are in S can someone give a breakdown of how it works?

Osiris


Back to top
View user's profile Send private message Send e-mail
Daos



Joined: 29 Jan 2003
Posts: 1211
Location: United States

PostPosted: Sat Feb 28, 2009 6:47 am    Post subject: Re: Object Progs Reply with quote

osiris wrote:
I could have sworn I saw Kal say 1.69S had obj progs but I can't find it now. I breezed through the change file and didn't see it either (although I wasn't very thorough so I may have missed it). So does S have obj progs or not? If it does does that mean I can create a ring and set it so that the ring object casts heal and acid blast? I remember reading something on this a while back and there was talk of using mob progs to accomplish this which seemed a bit "hacky". If obj progs are in S can someone give a breakdown of how it works?

Osiris


To briefly summarize the way the new engine is designed; the mudprog system emulates a virtual mobile to take on the shape of the object performing the mudprogged function. This is actually a very safe and unique way of designing the mudprog engine because it can handle mobs, objects, & eventually rooms.

Code:
char_data *objectmudprog_generate_mobified_object(obj_data *obj, char_data * ch, int otrig)


That is the actual function that generates the mobile to run the object program, puts it in the room of the object, transfers the objects contained by the object into its inventory, returns the newly created mob, returns NULL if there was a problem creating the mob, and returns NULL if there was a problem finding somewhere to put the mob. All in one funtion Wink

If you want to create a mudprog within an object; you simply set it up no differently than if you were setting it on a mob.

Arrow Type mpedit create <new mudprog vnum>.
Arrow Edit your new mudprog through mpedit olc interface.
Arrow Once finished, enter oedit to edit the object that will have the mudprog function.
Arrow Type addmprog <mudprog vnum> <trigger> <phrase>.

Then you're done. The triggers for objects are different than those for mobiles. Here is a list of object triggers:

Code:
#define OTRIG_GET_PRE      (A)
#define OTRIG_GET_POST      (B)
#define OTRIG_DROP_PRE      (C)
#define OTRIG_DROP_POST      (D)
#define OTRIG_PUT_PRE      (E)
#define OTRIG_PUT_POST      (F)
#define OTRIG_WEAR_PRE      (G)
#define OTRIG_WEAR_MID      (H)
#define OTRIG_WEAR_POST      (I)
#define OTRIG_LOOKAT_PRE   (J)
#define OTRIG_LOOKAT_POST   (K)
#define OTRIG_LOOKIN_PRE   (L)
#define OTRIG_LOOKIN_POST   (M)
#define OTRIG_CONTAINER_GET_PRE      (N)
#define OTRIG_CONTAINER_GET_POST   (O)
#define OTRIG_CONTAINER_PUTIN_PRE   (P)
#define OTRIG_CONTAINER_PUTIN_POST   (Q)


I am working on a detailed document file regarding mudprogs. I'll post an announcement upon its completion.



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
osiris



Joined: 31 Oct 2008
Posts: 32
Location: North Carolina

PostPosted: Sat Feb 28, 2009 7:07 am    Post subject: Reply with quote

Daos, I gotta say you are a total asset to these forums. Your code knowledge is valuable beyond measure.

Ok, we have obj progs... that are still handled by a mobile? Am I understanding you right? Let's use my previous ring example. So I have a ring that heals and casts acid blast. If my ring is going to heal, the mudprog system creates a mobile, gives it the ability to heal, puts the mobile in the same room as my ring, and casts heal on me? That seems like a lot of overhead to keep up with. What if my ring heals me 4 times and casts acid blast 5 times during the course of one fight? That means I have 9 created virtual mobiles sitting in the room? What happens to the mobiles? Do they purge once you leave? How hard would it be to implement a stand alone obj prog system that would, upon object creation, assign whatever progs you want added to the object itself and the object handles any progs itself?

Osiris


Back to top
View user's profile Send private message Send e-mail
Daos



Joined: 29 Jan 2003
Posts: 1211
Location: United States

PostPosted: Sat Feb 28, 2009 1:36 pm    Post subject: Reply with quote

osiris wrote:
Ok, we have obj progs... that are still handled by a mobile? Am I understanding you right? Let's use my previous ring example. So I have a ring that heals and casts acid blast. If my ring is going to heal, the mudprog system creates a mobile, gives it the ability to heal, puts the mobile in the same room as my ring, and casts heal on me? That seems like a lot of overhead to keep up with. What if my ring heals me 4 times and casts acid blast 5 times during the course of one fight? That means I have 9 created virtual mobiles sitting in the room? What happens to the mobiles? Do they purge once you leave? How hard would it be to implement a stand alone obj prog system that would, upon object creation, assign whatever progs you want added to the object itself and the object handles any progs itself?


To answer your question, yes & no. Yes, the system will generate/emulate a virtual mobile for every object program that will operate based upon however the program was triggered. No, the system will not create multiple mobiles. If the system were designed that way, it would eat up memory REAL fast.

Here is the general code design for the virtual mobile creation:

Code:
// create the objectmudprog_mob
   objectmudprog_mob= new_char();
   objectmudprog_mob->pIndexData   = pMobIndex;
   objectmudprog_mob->name         = str_dup( obj->name);   
   objectmudprog_mob->short_descr   = str_dup( obj->short_descr);   
   objectmudprog_mob->long_descr   = str_dup( pMobIndex->long_descr);     
   objectmudprog_mob->description   = str_dup( obj->description );
   objectmudprog_mob->level      = obj->level;
   objectmudprog_mob->player_id   = obj->pIndexData->vnum;
   objectmudprog_mob->uid         = obj->uid;
   objectmudprog_mob->language      = language_native;
   objectmudprog_mob->running_mudprog_for_object=obj;
   SET_BIT(objectmudprog_mob->dyn,DYN_MOB_SEE_ALL);


As you can see, the emulated mobile takes on the shape, the name, description, and various other specs of the object the program is on.

Now to answer the second part of your question. Once the virtual mobile does its job (performs the object program) - the virtual mobile is unloaded from the system through this function:

Code:
void objectmudprog_degenerate_mobified_object(char_data *objectmudprog_mob)


One of the functions this performs prior to unloading is to transfer any objects from within a container from the mobile back to the original object. This prevents data loss or corruption.

Code:
if(obj && IS_VALID(obj)){
         obj->contains=objectmudprog_mob->carrying;
         objectmudprog_mob->carrying=NULL;

         for(obj_data *o=obj->contains; o; o=o->next_content){
            o->in_obj      = obj;
            o->carried_by   = NULL;
         }
      }


The final part is to in fact unload the emulated mobile itself:

Code:
char_from_room(objectmudprog_mob);
      free_char(objectmudprog_mob);


So as you can see from the design of the code, the mobile is created & loaded for every object program call, then unloaded at the end of the object program. Even if you run several simultaneous progs, because of the queue system - it will still only utilize one virtual mobile. I hope this serves a better explanation Smile



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
osiris



Joined: 31 Oct 2008
Posts: 32
Location: North Carolina

PostPosted: Sun Mar 01, 2009 2:04 am    Post subject: Reply with quote

Ok, that makes a bit more sense. But what about my second question? Why not just have it so that the object handles the program/s itself. The whole process would seem more... streamlined, I guess, if progs were handled in house rather than depending on outside assistance. Couldn't we just implement the process within the object creation code? That way any progs associated with the obj are handled by the object itself. Don't get me wrong, the correct process you just explained obviously gets the job done but humor me if you would. If I wanted to code this up as a "project" how hard would it be? Could you point me in the right direction?

Osiris


Back to top
View user's profile Send private message Send e-mail
Daos



Joined: 29 Jan 2003
Posts: 1211
Location: United States

PostPosted: Tue Mar 10, 2009 3:40 pm    Post subject: Reply with quote

osiris wrote:
Ok, that makes a bit more sense. But what about my second question? Why not just have it so that the object handles the program/s itself. The whole process would seem more... streamlined, I guess, if progs were handled in house rather than depending on outside assistance. Couldn't we just implement the process within the object creation code? That way any progs associated with the obj are handled by the object itself. Don't get me wrong, the correct process you just explained obviously gets the job done but humor me if you would. If I wanted to code this up as a "project" how hard would it be? Could you point me in the right direction?

Osiris


Having entity_data as a super class makes the system far more streamlined than designing something where mobs, objects, rooms, etc handle the programs themselves. In an essence though; the object does handle the program itself. It houses the trigger & the actual mpcode. The only thing the object doesn't do is the actual function of the mpcode - that is when of course the objmobile is created and handles that function itself - then is purged once completed.

I once sought out to design an object program system which is similar to what you're describing; and after several months of work - I wasn't getting anywhere because of how obj_data is classed. Kalahn's design is far cleaner and more flexible. The current design allows expansion to other types of mpcode.

If you want to try and pioneer on a new design, I support you - but I cannot give an honest answer of where to start.



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
osiris



Joined: 31 Oct 2008
Posts: 32
Location: North Carolina

PostPosted: Wed Mar 11, 2009 5:21 am    Post subject: Reply with quote

Quote:
One of the functions this performs prior to unloading is to transfer any objects from within a container from the mobile back to the original object. This prevents data loss or corruption.


Can you give me an example of what you mean here? What kind of objects would be transferred back and forth?

Osiris


Back to top
View user's profile Send private message Send e-mail
Parsival



Joined: 04 Feb 2009
Posts: 30

PostPosted: Wed Mar 18, 2009 4:24 am    Post subject: Reply with quote

Quote:
Quote:
One of the functions this performs prior to unloading is to transfer any objects from within a container from the mobile back to the original object. This prevents data loss or corruption.


Can you give me an example of what you mean here? What kind of objects would be transferred back and forth?


Please correct me if I'm wrong here, but I think what he means is that, when an objprog is performed by the virtual mobile, the mobile ends up 'carrying' the items that were within the container (if, in fact, the original object with the objprog was a container of some sort), then, when the virtual mob finishes execution of the prog, the items it is carrying are put back into the container before deallocating the mobile.

Code:

if(obj && IS_VALID(obj)){
         obj->contains=objectmudprog_mob->carrying;
         objectmudprog_mob->carrying=NULL;

         for(obj_data *o=obj->contains; o; o=o->next_content){
            o->in_obj      = obj;
            o->carried_by   = NULL;
         }
      }


Hope that helps!

Steve-o


Back to top
View user's profile Send private message
Daos



Joined: 29 Jan 2003
Posts: 1211
Location: United States

PostPosted: Tue Mar 24, 2009 4:10 pm    Post subject: Reply with quote

Here is a sample object program I wrote for a player in their area:

Dawn Output:
=============================================================================
Vnum: 500607     Area[40]: dragca.are
Title: key blows up - damage  Author(s): Daos
Last editor: Daos on Fri Dec 26 05:47:12 2008 (2 months, 3 weeks, 6 days, 22 hours, 13 minutes, 40 seconds ago)
Code:
mp seeall
mq1 mp echoat $n As you look at the key, it shatters into thousand pieces and pierces your skin.
mq2 mp damage $n 300 600 1000
mq3 mp echoat $n The shattered pieces of the key mold back together into its original shape.

=============================================================================
Currently no mobiles directly use this program.
Note that the code could still be accessed via the 'mp call' command...
e.g. mp force inventor mp call 500607 $n
Objects that use mudprog 500607 follow:
500604 a key of rock - lookat_post (100).
500606 a tiny golden key - lookat_post (100).
=============================================================================


As you can see, the mpcode makes use of the queue system and performs the very basic functions of echoat & damage when a player looks at the key. I also use the seeall function so invisible players cannot bypass the set of mp functions in the code.



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Naylor



Joined: 03 Dec 2012
Posts: 95

PostPosted: Fri Jan 04, 2013 3:04 pm    Post subject: Reply with quote

this would be rather helpful.... but I can't seem to make it work.. there is no addmprog in oedit that I can see

nvm... found my mistake, I was using q not s.... OOPS!
now to port over the changes i did in q and try to get working with s.. lol


Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » 1.69s Beta4 All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin