Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Classes & dbPickObject

Author
Message
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 17th May 2009 13:02
Heya. Me again. Maybe someone can explain how this is accomplished, or if there are better ways to accomplish this.

Heres what I have, I have a NPC class which holds, for now, some basic variables like int health and int modelnum.

When called, this class creates an object in the game, currently a square it holds the model number and passed to it the health.

I was wondering if I could use dbPickObject and through some means determine which class that object is part of, since dbPickObject returns an object number and the classes all store model numbers that this could be possible.

My brain is racking on this, i cant figure it out, there must be an easier way to do what im trying to do.
jezza
16
Years of Service
User Offline
Joined: 8th Mar 2008
Location: Bham, UK
Posted: 17th May 2009 16:26
inside all the classes could be a var of say an enum called Type.
if you had a void * array where the index is the model number, using dbPickObject you could do something like this:


AndrewT
17
Years of Service
User Offline
Joined: 11th Feb 2007
Location: MI, USA
Posted: 17th May 2009 16:36
Or you could reserve objects, say, 101 through 200 for a certain class, 201 through 300 for another, etc. and when you use pick object, you just check which range it is in and you know the class.

i like orange
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 17th May 2009 23:31
Alright! Perfect! =]

Thanks so much!
kklouzal
15
Years of Service
User Offline
Joined: 15th May 2009
Location: Arizona
Posted: 18th May 2009 02:51
Alright, I thought I understood how to use classes, let me show you what i'm doing:

NPC Class:


Now i'm trying to print something from the class:


Well I get a few errors when I try to compile:

Login to post a reply

Server time is: 2024-11-05 18:57:20
Your offset time is: 2024-11-05 18:57:20