Page 1 of 1

Doors (widgets) Discoveries

Posted: Sun Mar 22, 2009 10:27 am
by John Adams
Before we begin: The Content Team only deals with data collected from the Live game, and so far we have never created in-game spawns (npcs, objects, widgets or signs) "from scratch". Our goal is to mimic Live as close as possible, and if we're missing data, we go collect it.

Someone on the team asked how we can manually create a door that does not yet exist in the database. I've done some experiments with this before, but never succeeded; the end result always being a "little pink box" which functions and sounds just like a door, yet does not look like one.
door-box.jpg
In this write up I will attempt to explain how do "hang a door" manually, and why manually creating widgets is likely not possible (at this time) without first knowing the widget_id. I'll start with the bad news first.

So what is a widget_id?
Best we can tell, this is the ID of an object (or location of an object) inside the clients Zone files. You need to tell the World this ID so the World can send that ID to the client so the Client knows what to spawn at the given spot, and how it behaves. In the case of a Door, depending on the widget_id the client sees the world telling it that in a specific x,y,z pop this "generic wooden door". Without the widget_id, the client does not know what object in it's local VPK to pull up, and you end up getting a pink box - which if you are into 3D Animation and graphics design you probably recognize. :)

To sum up: Without the widget_id, you will not get a door to show up.

Here is a sample of creating the door widget and what minimal data is required:

Code: Select all

insert into `spawn`(`id`,`name`,`sub_title`,`race`,`model_type`,`size`,`targetable`,`show_name`,`command_primary`,`command_secondary`,`visual_state`,`attackable`,`show_level`,`show_command_icon`,`display_hand_icon`,`faction_id`,`collision_radius`,`hp`,`power`,`merchant_id`,`transport_id`) values 
( '1','wooden_door_widget',NULL,'0','49','32','0','0','4','0','0','0','0','1','0','0','64','0','0','0','0');
First, of course, you need the `spawn` record. Everything that spawns In-Game needs this parent record, and these are the basic "door" values throughout all our collected data. Some doors vary in size or collision_radius, but not by much.

Code: Select all

insert into `spawn_widgets`(`id`,`spawn_id`,`widget_id`,`widget_x`,`widget_y`,`widget_z`,`include_heading`,`include_location`,`icon`,`type`,`open_heading`,`closed_heading`,`open_y`,`action_spawn_id`,`open_sound_file`,`close_sound_file`,`open_duration`,`close_y`,`linked_spawn_id`) values 
( NULL,'1','0','0.094344','-4.97873','10.0875','1','1','0','Door','0','0','-1','0','sounds/widgets/doors/door_genericwood_open004.wav','sounds/widgets/doors/door_genericwood_close003.wav','10','-1','0');
This is the magic record - the one that makes the spawn appear as a door. Note that in this current setup, I did not know the widget_id, so I set it to 0 (zero). This makes the door appear as a little pink box (placeholder, anchor, whatever). This is all I will get until I find the widget_id for this particular door.

Code: Select all

insert into `zonespawngroup`(`id`,`name`) values ( NULL,'Door_Test');
Next, we need to build the zonespawn info, starting with the zonespawngroup. Every location where a spawn (or it's placeholders) may spawn uses a unique zonespawngroup ID. So if you have a single x,y,z where 5 possible spawns may pop, they still use ONE zonespawngroup ID - since it's the same x,y,z.

After you insert your zonespawngroup, note the ID because you will need it in the next two inserts.

Code: Select all

-- use new zonespawngroup.id value for the next two inserts
insert into `zonespawnentry`(`id`,`spawn_id`,`spawngroupid`,`spawnpercentage`) values 
( NULL,'1','<zonespawngroup.id>','100');
This is the table the spawns/placeholders are defined in. Since doors do not have placeholders, I won't describe that here. But taking the zonespawngroup.id from the last step, insert a new zonespawnentry record for the new door widget, zonespawngroup.id, and 100% chance to spawn.

Code: Select all

insert into `zonespawns`(`id`,`zone_id`,`spawngroup_id`,`x`,`y`,`z`,`x_offset`,`y_offset`,`z_offset`,`heading`,`respawn`,`location_id`) values 
( NULL,'283','<zonespawngroup.id>','0.094344','-4.97873','10.0875','0','0','0','270','3600','973606217');
Lastly, you enter the zonespawns (location) where that spawngroup is supposed to appear. You can get a close proximity by entering the game, positioning your character near the exact spot you wish to pop the door, and doing a /loc. The x,y,z values that appear are what you are looking for.


SPECIAL NOTE ABOUT location_id!!!
This one will get you every time if you do not set the proper location_id. The game zones are divided up into "grids", and each grid has an ID. The World needs to know what location/grid ID to pop something into, without this, your stuff ends up off the grid somewhere and you cannot see it.

To find the location_id, simply walk into the area you are trying to spawn something into. The World console notifies when a player leaves one area and enters another:
World wrote:Left Grid 4294967295 and Entered Grid 1698999948
These numbers are not sequential, so you cannot guess.


Getting back to the "bad news" real quick. After all this work is done, you enter your zone and go to the door you set up, and all you see is the pink box... However, in my example, I have another tradeskill instance that DOES have a door here, so I just used it's widget_id and got my door to function as desired.
door-good.jpg
Last note on Widget ID's... if you have a Widget ID of another wooden door and try to use it, the zone will still not know what to do with it. Sure you will get a solid, swinging door - but the client will not know what "background" to display if you use the wrong widget_Id!
door-bad.jpg
In this second, bad example, I only changed the spawn_widgets.widget_id value from the known good door to another door in the same zone, and the door broke. :(

So, in conclusion - Don't try and build your zones by hand. Collect the data from Live, parse it, use it. Or, if you cannot do this, wait til the Content Team releases a zone, and you can hack it to bits making your custom zones. But doors, signs, and some objects? They need to be where they need to be due to some connection inside the client we have no control over.

Yet. :evil: