Zippy-Egoboo Home EgoWiki > Documentation > PortingObjectsGuide ( vs. r1.1) EgoWiki webs:
Main | TWiki | Know | Sandbox
Documentation . { Changes | Index | Search | Go }
 <<O>>  Difference Topic PortingObjectsGuide (r1.1 - 11 Nov 2004 - ArakoN)
Added:
>
>

%META:TOPICINFO{author="ArakoN" date="1100210729" format="1.0" version="1.1"}% %META:TOPICPARENT{name="MakingZippyObjects"}% This section is under contruction, and some information may be inaccurate. I'll announce when this is ready to go on the boards when I feel it's reliable

This is a begining guide to help those familiar with Egoboo 2.22 in porting objects to Zippy. A lot of information given here may be a bit of review of other documentation for Zippy already.

Suggested Reading

I highly suggest reading the ZippyScriptingIntro section before continuing. Specifically the Rock example. If you don't understand all of it, don't worry. Consider it a "first pass" to familiarize yourself with some of it. It really sounds more complicated then it is.

Overview

Objects come in a large variety. There are weapons, items, shields, treasure chests, etc. Each one will eventually have it's own little topic. This section specifically focuses on getting the object to appear in game. It does not yet address making a weapon do damage, or shields protecting. That's a slightly more complicated topic, and will require use of a base class (which may or may not yet exist).

Still, getting an object to appear in game is worthy of a topic in itself, since something must appear in game before you can experiment with all of the other scripting coolness!

Step One: File placement

First, lets find an object to port. The Spiked Mace from the 2.22 Healer module is a good choice, since we need to make it appear in game before it can be turned into a dangerous weapon. It's also simple, in that it does not have a lot that needs to be done.

The object directory is originally located in the Healer module, along with a few others. Remember that Egoboo 2.22 needed each object to be placed in a module's object directory in order for it to be used. This is not the case with Zippy. Zippy allows for shared objects.

Zippy's shared objects are stored in the "objects" directory (off of the root of the Zippy directory tree). Zippy not only allows for shared objects, but it allows for organizing them by category to make it easier to find what you need.

To begin, create a directory in "objects", named "spikedmace.obj". The .obj is not actually required by the engine, but it is considered good form.

The next step is to copy the assets that are specific to the mace into this directory. In this case, it's the models (md2's), skins & icons (bmp's), and sounds (wav's). Notice this does not include the data.txt file, message.txt file, or the particle effect files. These are not needed for Zippy.

*_At a later point the media will be in a different shared directory in order to help separate things even more. This will be updated at that time_.

Step Two: Creating the character file

Zippy uses Lua script files for defining a character. You should be somewhat familiar with this from reading ZippyScriptingIntro. In the new spikedmace.obj directory a "script.lua" file needs to be created. Edit this file with a text editor (I prefer SciTE in Windows-land).

This file is basically going to look like the Rock example. The names are basically different, and some of the other attributes will be different, though that will be addressed in a weapon-specific guide.

register_type{
  name = "SpikedMace",
  namespace = Default,    -- IMPORTANT!  This is not in the rock example at moment!
  profile = {
    invincible = 1,
    weight = 40,
    bump_size = 45,     -- this is how wide the model is, in 256ths of a map tile
    bump_dampen = 0.25, -- this means the rock is fairly difficult to move (lower is more difficult)
    model = "tris.md2", -- the name of the model file, this will usually be in a common directory
    skins = {
      normal = Skin{
        name = "SpikedMace",
        texture = "tris0.bmp",  -- these will usually be in a common directory also
        icon = "icon.bmp"
      }
    }
  }
}

Save this file - the object is now pretty much ready for Zippy. Only problem is that Zippy does not yet know about it.

Step Three: Telling Zippy about the object

At this stage, we have a Spiked Mace, with all of the right definitions, but Zippy still isn't aware of it. This is because Zippy does not have the limits on objects that 2.22 has.

In order to add the file to the index, you must open the make_namespaces.lua file from the objects directory. You'll see in this file two separate Namespace sections: Default, and Basic. Default holds most of the objects, and Basic is used mostly for support objects. Default is where the Spiked Mace belongs.

Add a line at the end of the table section. Remember, tables start with { and end with }. These are the squiggily brackets, and should not be confused with brackets or paranethes.

This line should look like the following: SpikedMace = in_file("objects/spikedmace.obj/script.lua")

Make sure there is a comma at the end of the above "in_file". This line is basically telling Zippy that when a module is looking to spawn a SpikedMace where to find it.

Step Four: Spawning the item

For this, we need to edit two files. Choose the module in which you want the spawn to take place. In this case, I will use Zippy City as an example.

First, open the file: modules/zippy.mod/objects/loadai.lua

This file contains a line-by-line list of objects that will be spawned in the spawn file. Since a Spiked Mace is now needed, it needs to be entered into here for that to happen. Somewhere near the bottom of the list, add:

Require(Default.SpikedMace)

Save the file, and close.

Now, open the file: modules/zippy.mod/gamedat/spawn.lua

Somewhere near the bottom, add the line to actually spawn the item: Default.SpikedMace(15, 18, 4, "SpikedMace", GoodTeam?, "normal", -1, nil)

The first "Default" is the name of the namespace. The first three parameters are x, y, and z. More information on this can be found in ZippyCharacterType.

Now, if everything went well, the mace will spawn when Zippy City is opened up. The object is now usable in game! Of course, it doesn't actually do anything yet, but it does show up in the game. Turning it into an actually weapon requires modifying the script.lua file and responding to ZippyAlerts, and setting a base class for the object. This will be discussed in a later guide.

Conclusion

Making Zippy objects that appear in the game requires a few steps, but overall the process is about as simple as it was in 2.22. The massive data.txt file is replaced with a structured script.lua. Unlike the data.txt file, only those values that are important need to be defined, making it much easier to view and edit.

The namespace system may be difficult to understand at first, but it provides a large amount of expandability. Modules will be able to be smaller since all of the objects will be shared internally.

The actual spawn file will be more structured in the future, but at moment is rather free form.

More guides will be created as weapon base classes are finished, and other base classes are added for shields, monsters, etc.

-- ArakoN - 11 Nov 2004


Topic PortingObjectsGuide . { View | Diffs | r1.1 | More }
Revision -
Revision r1.1 - 11 Nov 2004 - 22:05 GMT - ArakoN
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding EgoWiki? Send feedback.