Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Discussion on ID vs DISPID (OOP)
Author Message
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #1
Discussion on ID vs DISPID (OOP)
Alright I'd like to discuss the differences in ID and DISPID.
There seems to be a lot of confusion in the forums of the properties and their use. Now this discussion will have meaning if the reader has a programming background else it will probably only confuse you.

It's my observation that DISPID has no OOP (object oriented programming) functionality. It only effects the appearance of the object.
Example-
make a shovel -> .add i_shovel
change it's appearance -> .set DISPID i_barrel
update to show change -> .update
Now the shovel appears as a barrel, but any and all queries on the object will display i_shovel properties.
So the shovel looks like a barrel but remains to be a shovel.
So queries on the shovel return shovel properties (though it looks like a barrel) and it sill behaves like a shovel.

Now ID seems to use basic inheritance (a shallow, single level is-a OOP principle). Meaning that by assigning an ID to an object, the object will now behave like the new ID. Meaning old object is-a new object. But seems to be restricted to a single level of heritance not multiple inheritance. Also it does not retain it's base class (as in normal OOP). So it's no longer the old object.
Example-
make a shovel -> .add i_shovel
change it's id -> .set ID i_dagger
update to show change -> .update
The shovel is in fact a dagger now with all the dagger properties.
That's because shovel is-a dagger now with everything relating to a dagger. All things shovel are gone.


Hope that helps!
Feel free to correct me here or add to this discussion!

Thanks
Capes
(This post was last modified: 04-14-2018 11:58 PM by Capes.)
04-14-2018 10:54 PM
Find all posts by this user Like Post Quote this message in a reply
Capes
Journeyman
*

Posts: 57
Likes Given: 0
Likes Received: 4 in 4 posts
Joined: Mar 2018
Reputation: 0



Post: #2
RE: Discussion on ID vs DISPID (OOP)
Id also like to add that in a item definition (0.56d) sphere won't let you use both ID & DISPID together you have to add DISPID in the on=@create.
DUPEITEM seems to be a combination of ID & DISPID except allowing the new Object to keep all behaviors of old object.
So DUPEITEM does not remove the base behaviors of the original object it retains them.
Basically DUPEITEM is the same as defining an object using both ID & DISPID where ID is the old objects behaviors/properties and DISPID is the new appearance.

Summary
DISPID -> changes only the appearance of the object (all old behavior's remain)
ID -> change all aspects of old object to new object
DUPEITEM -> acts like an object with ID & DISPID set to separate objects, where ID defines behaviors and DISPID is the appearance.

DUPEITEM example-
[ITEMDEF 01041]
DEFNAME=i_pie_baked
TYPE=t_food
//bla bla bla

[ITEMDEF 0dc0] //fishing pole
DEFNAME=fishing_pole_acts_like_baked_pie
DUPEITEM=i_pie_baked

Same example using ID & DISPID
[ITEMDEF fishing_pole_acts_like_baked_pie]
ID=i_pie_baked
ON=@Create
DISPID=i_fishing_pole


The reason for me posting this is because I spent literally days trying to debug why certain things didn't work. Only to find out that I didn't really understand how ID, DISPID & DUPEITEM worked.

Thanks
Capes
04-15-2018 01:01 AM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)