Author Topic: Events  (Read 2824 times)

Offline saquivor

  • BFF
  • ***
  • Posts: 111
    • View Profile
Events
« on: September 09, 2007, 01:07:01 am »
Today's meanderings have taken me to look at events relating to LIB_SENTIENT ie eventReceiveEmote, eventReceiveCommand ,etc.

It has given me an idea that I would like to create  sentient style room and objects. So on my initial musings it would appear that eventReceiveEmote has links to
  • lib/sentient.c
  • daemon/soul.c
  • daemon/services/emoteto.c
  • daemon/intermud.c

It is possible that rooms already have eventReceiveObject. But I am looking for something like eventReceiveRace that would gas an orc for entering the room/trigger an object in a room.

Are there any other files I need to look at in relation to creating a sentient lib for objects and rooms that would allow reactions to events.

I will carry on with my experiments, but would be grateful for any pointers.

Thanks,

Saquivor

Offline cratylus

  • Your favorite and best
  • Administrator
  • ***
  • Posts: 1024
  • Cratylus@Dead Souls <ds> np
    • View Profile
    • About Cratylus
Re: Events
« Reply #1 on: September 09, 2007, 07:42:50 am »
Quote
It is possible that rooms already have eventReceiveObject. But I am looking for something like eventReceiveRace that would gas an orc for entering the room/trigger an object in a room.

I don't think you need to code an entirely new lib function
like that, unless rooms behaving differently for different
races is a very common thing.

In general I'd just add it to the specific room that needs it
this way:

Code: [Select]
int eventReceiveObject(object ob){
    string race = ob->GetRace();
    if(race && race == "orc"){
        ob->eventPrint("Welcome to our inclusive halls, proud orc!");
    }
    return ::eventReceiveObject(ob);
}

Quote
Are there any other files I need to look at in relation to creating a sentient lib for objects and rooms that would allow reactions to events.

I think LIB_SENTIENT should just about cover it. The other
files you listed wouldn't have much to do with the room
functionality you seek.

Quote
I will carry on with my experiments, but would be grateful for any pointers.

http://lpmuds.net/pointers.png

-Crat

Offline saquivor

  • BFF
  • ***
  • Posts: 111
    • View Profile
Re: Events
« Reply #2 on: September 09, 2007, 08:31:34 am »
I am working on building an area that is uber interactive
and want nearly all rooms and objects to have some form
of interaction with both players,npc,seasons and daylight.

Race was just one example. I want certain objects/room to
inherit types of behaviour relating to players and npcs :)

Thanks for the pointers :P

Saquivor

Offline JohnOC

  • Acquaintance
  • *
  • Posts: 10
    • View Profile
Re: Events
« Reply #3 on: September 09, 2007, 01:01:08 pm »
Quote
I will carry on with my experiments, but would be grateful for any pointers.

http://lpmuds.net/pointers.png

-Crat

xkcd is awesome. 

Offline memrosh

  • Acquaintance
  • *
  • Posts: 20
    • View Profile
Re: Events
« Reply #4 on: September 09, 2007, 10:19:22 pm »
Hiya,
In a previous mud I worked on we had 'world wide events' for things like 'drop', 'death', etc.
and each object could 'listen' for specific event classes. I miss that, kinda, sorta. But I think it
really ate up the processing.

Anyway-

in /lib/std/room.c
  Function eventHearTalk()
  Here is where all talking is 'caught' that occurs in a room.
  You will find that on most of them that the objects are filtered by living etc.
  For your domain (area) you could create a 'class' file that inherits the
  lib/std/room and all your area rooms will inherit your 'class'.
  Basically 'overwrite' this function:
  varargs mixed eventHearTalk(...
    //call short delay to a sorting function to let the lib room do its thing first?
    call_out("VoiceSorter",1, who, targ, msg);
    return room::eventHearTalk(...
   
    In your VoiceSorter function you can make whatever checks and actions you
    need, including calling specific functions in objects in the local room.
Note- I have not tested this yet.
   
eventRecieveObject()... yup like Crat suggests. Though if you have something
going on different in each room you might put it in your 'class' file and have
it call a 'local' function in each room file outside of the eventRecieveObject()

In both these instances you will know 'who' or what, so within your sorting or local
functions you can check for player/npc, race, profession, vision, thirst level,
time of day, season, if in combat, special property, specific id, and on and on...
to decide what responce action you want to initiate.
Plus you will preserve the Lib.

But- remember there is quite a bit of interactive ability already in stock DS.
Such as 'functionals' for the setlong, setshort, and descrips of dummy items.
There are functions such as CanGet() that gives you the chance to insert checks
in the specific objects in the room. Browsing through the inherit list of
/lib/std/item.c could give some ideas on whats possible for special physical
interactions.

Memrosh

Offline saquivor

  • BFF
  • ***
  • Posts: 111
    • View Profile
Re: Events
« Reply #5 on: September 10, 2007, 02:27:28 pm »
Thanks for the feedback everyone.

I have still look at dummy objects and should take the time to see how they work.