making a new kind of thing template

I am working on a prototype for Stellarscape 3500, which will eventually be a massive game. I’m trying to see how well inform can handle this sort of thing. One thing I want, are various “templates” I can use and slightly alter for different things. One such template I need is a spaceship. I’m going to make probably 50 different kinds of spaceship, with their own stats and stuff, which will be used for a sort of DnD style space combat from time to time. I think it would be easiest if I made the different kinds of spaceship have their own templates, which I could call at random. I want you to randomly encounter things like pirate gangs, and so spaceships will have to be generated on the fly.

Hmmm in Inform 6, I used a modified version of the bubble example to generate NPCs. Then I only had to make as many as might show up in a single room at the start and modify their traits when needed before bringing them on stage. I haven’t figured out how to do this in Inform 7 yet though.

firthworks.com/roger/informfaq/oo.html (and scroll down to the generated bubbles examples)

edit: I think the Uptown Girls example might be useful for this in Inform 7: dhayton.haverford.edu/wp-content … ex169.html

You can do this. In Inform 7, you can create kinds of thing.

[code]A spacecraft is a kind of vehicle. A spacecraft has a number called speed. A spacecraft has a number called shield. A spacecraft has a number called offense. The description of a spacecraft is usually “You call up this model on your trusty Wikitablet. Apparently this model has a max speed of [speed of the noun], a defense rating of [shield of the noun]/100, and weapons capability rated at [offense of the noun]% of the norm.”. The speed of a spacecraft is usually 50. The shield of a spacecraft is usually 50. The offense of a spacecraft is usually 50. Understand “ship/craft/spaceship” as a spacecraft.

Hangar Bay is a room.

A used SV 9000 B-Wing is a spacecraft in Hangar Bay. A slightly damaged Tugport RS7 is a spacecraft in Hangar Bay. A sleek, new-looking BanGatolista Mark5 is a spacecraft in hangar bay.

When play begins:
repeat with vessel running through spacecrafts:
if a random chance of 1 in 2 succeeds:
increase speed of vessel by a random number between 5 and 20;
otherwise:
decrease speed of vessel by a random number between 5 and 20;
if a random chance of 1 in 2 succeeds:
increase shield of vessel by a random number between 5 and 20;
otherwise:
decrease shield of vessel by a random number between 5 and 20;
if a random chance of 1 in 2 succeeds:
increase offense of vessel by a random number between 5 and 20;
otherwise:
decrease offense of vessel by a random number between 5 and 20;

Test me with “x sv/x rs7/x mark5”[/code]

You can’t so much “create things” on the fly without some advanced fudgery, but you can have a gallery of potential spacecraft offstage, and then modify their stats (and even the descriptions with some clever text variations) when brought onstage and re-use them as necessary.

I was originally going to make my own IF engine, but I am becoming so impressed with Inform7, I might not. This is my code so far if your curious.

[code]“Stellarscape 3500” by Daniel Valcour

Section 1 - Definitions

Color is a kind of value. Red, green, blue, orange, yellow, purple, violet, gray, white, tan, khaki, teal, cyan, lime, black, silver, navy, maroon, goldenrod, gold, pink, magenta, brown, mint, alabaster, almond, amber, amethyst, brass yellow, ruby, fuschsia, bronze brown, apricot, aqua, aquamarine, azure, baby blue, beige, bisque, blond, blood orange, blue-green, light blue, dark blue, lilac, turquoise, bubble-gum, cadet blue, cadmium blue, caramel, canary, camouflage green, chamoisee, champagne, cherry, rose, chocolate, citron green, claret, coconut brown, coffee brown, cream, cornsilk, dark coral, dandelion yellow, imperial blue, dark lavender, dark goldenrod, carmine, taupe, terra cotta, vanilla, tuscan red, denim, deep violet, diamond blue, ebony black, eggplant purple, ultramarine, vermillion, eucalyptus, fallow brown, and peach are colors.

Material is a kind of value. Iron, steel, galvanized-steel, copper, plastic, aerogel, kevlar, spider cloth, carbon nano-metal, ampherous metal, glass, and brass are materials.

A corporation is a kind of value. Farseeker Systems, Conglomerated Corporation, Feltfire Ballistics, Centrari Federal Armory, and Sagitarus Shielding are corporations.

An ammo type is a kind of value. Misiles, torpedos, heavy rounds, and light rounds are ammo types.

An outfit type is a kind of value. Engine outfit, shields outfit, hull plating outfit, weapons outfit, sensors outfit, anti-sensors outfit, anti-weapons outfit, hacking systems outfit, anti-hacking systems outfit, power systems outfit, coolant systems outfit, health systems outfit, repair systems outfit, bunk rooms outfit, entertainment outfit, sliding doors outfit, and stealth outfit systems are outfit types.

An outfit is a kind of thing. An outfit has a number called space. An outfit has an outfit type called outtype. An outfit has a corporation called manufacturer. An outfit has a number called price. An outfit has a text called description.

An electronic outfit is a kind of outfit. An electronic outfit has a number called power usage rating. An electronic outfit has a number called heat rating. An electronic outfit has a number called emp protection.

An engine system is a kind of electronic outfit. An engine system has a number called thrust. An engine system has a number called manuverability.

A shield is a kind of electronic outfit. A shield has a number called defense rating. A shield has a number called recharge rating.

A hull plating is a kind of outfit. A hull plating has a number called defense rating.

A weapon system is a kind of electronic outfit. A weapon system has a number called damage rating. A weapon system has a number called shield damage rating. A weapon system has a number called heat damage rating. A weapon system has a number called power damage rating. A weapon system has a number called emp ability. A weapon system has a number called shield ignorance. A weapon system has a number called power usage rating. A weapon system has an ammo type called ammo. A weapon system has a number called range. A weapon system has a number called manuverability. A weapon system has a number called recharge speed.

A sensory system is a kind of electronic outfit. A sensory system has a number called sensory power. A sensory system has a number called range.

An anti-sensory system is a kind of electronic outfit. An anti-sensory system has a number called blockage power.

An anti-weapons system is a kind of electronic outfit. An anti-weapons system has an ammo type called speciality. An anti-weapons system has a number called blockage.

A hacking system is a kind of electronic outfit. A hacking system has a number called infiltration ability. A hacking system has a number called secrecy. A hacking system has a number called range.

An anti-hacking system is a kind of electronic outfit. An anti-hacking system has a number called antivirus power.

A power system is a kind of electronic outfit. A power system has number called power output.

A coolant system is a kind of electronic outfit. A coolant system has a number called cooling power.

A health system is a kind of electronic outfit. A health system has a number called capacity. A health system has a number called curing power. A health system has a number called research power.

A repair system is a kind of electronic outfit. A repair system has a number called repair power.

A bunk room is a kind of outfit. A bunk room has a number called capacity.

An entertainment center is a kind of electronic outfit. An entertainment center has a number called happiness generation.

A sliding doors system is a kind of electronic outfit. A sliding doors system has a number called defense rating.

A stealth system is a kind of electronic outfit. A stealth system has a number called stealth rating. A stealth system has a number called stealth period. A stealth system has a number called recharge period.

A spaceship is a kind of vehicle. A spaceship has a number called max shields. A spaceship has a number called current shields. A spaceship has a number called max speed. A spaceship has a number called current speed. A spaceship has a number called max armor. A spaceship has a number called current armor. A spaceship has a number called evasion percentage. A spaceship has a color called hull color. A spaceship has a list of outfits called outfits. A spaceship has a corporation called manufacturer. A spaceship has a number called price.

Section 2 - Specific Definitions

[engines]

A CFA 3120 Ion Engine is a kind of engine system. The space of a CFA 3120 Ion Engine is 10. The outtype of a CFA 3120 Ion Engine is an engine outfit. The thrust of an CFA 3120 Ion Engine is 5. The manuverability of a CFA 3120 Ion Engine is 3. The price of a CFA 3120 Ion Engine is 12000. The description of a CFA 3120 Ion Engine is “This engine is an old piece of technology, using rays of ion particles to provide thrust for a starship. Ion beam engines were invented by humanity before the discovery of FTL, and were used for ships to get around the Solar System. They are still used today, though they are not very powerful. Though this variant was developed in the year 3120, it is still considered to be the top of the line for its kind, as not much progress has been made in the field of ion radiation since its invention.”

A CFA 3045 Ion Engine is a kind of engine system. The space of a CFA 3045 Ion Engine is 10. The outtype of a CFA 3045 Ion Engine is an engine outfit. The thrust of an CFA 3045 Ion Engine is 3. The manuverability of a CFA 3045 Ion Engine is 3. The price of a CFA 3045 Ion Engine is 5980. The description of a CFA 3045 Ion Engine is “This is an extremely old ion engine variant, which has been replaced with the more recent 2120 series. Though the 2120 series is more powerful and takes up the same amount of space, this older variant is still avaliable on the marketplace for people who can’t afford it.”

Section 3 - Game

Test room is a room.

The engine is a CFA 3120 Ion Engine. The engine is in the test room.
[/code]

Thanks!

Oof! :slight_smile:

What’s gonna help is if you, say, make classes of engine and use the word “usually” to make all the variables set to a default.

A supreme engine system is a kind of engine system. The space of a supreme engine system is usually 10. The shields of a supreme engine is usually 15. [and so on] A CFA 3120 Ion Engine is a kind of supreme engine system.

That way all your “supreme” variables will transfer over to every CFA 3120 you make, and you can tweak just a few variables by hand instead of having to set every single one each time you create one of them.

Old Reliable is A CFA 3120 Ion Engine. It is part of the S3702 HiPointe Spacecraft. The space of Old Reliable is 30. [this overrides the "usually" default.]

Good luck!

You might also look at this Procedurally generated wilderness example which you could get ideas from for generated space in your game.

sibylmoon.com/a-procedurally … ilderness/

One thing is that Inform games can get very unwieldy if they have lots of objects–there are a fair number of routines that involve looping over objects. (I think; I’m not sure of the details.) So you might find it beneficial to make only a few ships, and as it were “repaint” them with new specifications when you need them.

Here’s an example of how that might work with monsters–there’s only one monster, but because I keep renaming it and redefining the values, it seems like there’s more than one. (Hanon will make fun of me for using tables again, but honestly no matter how you do this you’re going to have to define your kinds with a table, so you don’t have to write a massive paragraph for everything you define.)

[code]A die roll is a kind of value. 9d20+10 specifies a die roll.

A monster is a kind of person. A monster has a number called hit points. A monster has a number called armor class. A monster has a die roll called damage.

A monster species is a kind of value. The monster species are defined by the Table of Monster Manual.

A monster has a monster species. Understand the monster species property as describing a monster. [This lets “x dragon” work when the monster species is “dragon.”]

Table of Monster Manual
monster species hit points armor class damage description
kobold 4 10 1d4+0 “Sneaky but ineffective in combat.”
orc 8 7 1d6+1 “The plainest of vanilla monsters.”
dragon 200 -4 4d20+10 “Uh oh.”

To initialize (creature - a monster) as (type - a monster species):
now the monster species of the creature is the type;
now the hit points of the creature is the hit points of the type;
now the armor class of the creature is the armor class of the type;
now the damage of the creature is the damage of the type;
now the description of the creature is the description of the type;
now the printed name of the creature is “[monster species of the creature]”.

Dungeon is a room. A generic monster is a monster in Dungeon. [I call it “a generic monster” as opposed to “generic monster” so Inform will know it’s not proper-named.]
When play begins: initialize generic monster as a random monster species.

Instead of going in Dungeon:
say “You bravely run away from [the generic monster].”;
initialize generic monster as a random monster species;
say “You encounter [a generic monster]!”[/code]

Also, just as a piece of advice, it might be a good idea to get a general idea of your “game engine” in place before you try putting in all the detail–you have an immense amount of detail there, which is cool, but this could lead you to trouble if when you go to implement it you find out it doesn’t work; or you could find making changes unwieldy; or if someone on the internet says “Hey, you should use tables for that” you might find yourself retyping a lot of stuff.

(I mean, I never do that. I always just type my stuff straight into the IDE. But I hear that starting small and scaling up is a good idea.)