Attribute of custom type? (Weapon with bullets as Objects)

Stardog
The only thing stopping me using Quest is that Attributes seem like they can only be one of these:

String
Boolean
Integer
Double
Script
String List
Object
Command Pattern
String dictionary
Script dictionary
Null

How do I choose a custom "Object Type" from here?

I'm looking to make a Gun (inherited type Weapon), with attribute AmmoSlot (needs to be type Ammo, but isn't allowed).

It seems like we can't do basic subclassing for some reason. How do I do this? I need this structure:

Base types/classes
Weapon (Object Type)
- AmmoSlot (Attribute type Ammo)

Ammo (Object Type)

AmmoShell (Object Type - inherited type Ammo)

Objects
Shotgun (inherited type Weapon)
ShotgunShells (inherited type AmmoShell)

magano
First off, attributes are not object types, but attributes are derived from its object type
The String, Integer thingy are attribute types and that you can't modify (well, at least for me)
However, you can configure new object types (Like Gun, Ammo) and assign an object to inherit from the type (like shotguns, which has a Gun type)

For a long time I haven't opened Quest, but you can start off in Create - Object Types

HegemonKhan
in quest, the Classes~Groups, are called:

Object Types (or it's shortened form of ' Type ' which gets a bit confusing as there's the Attribute~Data Types, and etc general usages of 'types' too)

---------

in GUI~Editor: Advanced -> Object Types -> (Add ~ create ~ set up)

--------

Object Types can hold Attributes AND OTHER OBJECT TYPES (multiple layers~nesting of Inherited Attributes via multiple layers~nesting of Object Types)

--------

to add the Object Types to your individual Objects:

'whatever' Object -> 'Attributes' Tab -> Inherited Attributes -> add -> (type in the name of your Object Type)

--------

http://docs.textadventures.co.uk/quest/
VVVVVVV
http://docs.textadventures.co.uk/quest/elements/
VVVVVVV
http://docs.textadventures.co.uk/quest/ ... /type.html
VVVVVVV
http://docs.textadventures.co.uk/quest/ ... /type.html

http://docs.textadventures.co.uk/quest/types.html
http://docs.textadventures.co.uk/quest/ ... herit.html

http://docs.textadventures.co.uk/quest/ ... types.html
http://docs.textadventures.co.uk/quest/ ... types.html

-------------------

examples:

<object name="orc_1">
<inherit name="orc_object_type"
</object>

<object name="orc_2">
<inherit name="orc_object_type"
</object>

<type name="orc_object_type">
<alias>orc</alias>
<description>Orcs are ugly, green, and stupid, but they're strong.</description>
<attr name="condition" type="simplestringlist">normal</attr>
<attr name="locomotion" type="simplestringlist">bipedal;walking</attr>
<attr name="race" type="string">orc</attr>
<attr name="current_life" type="int">100</attr>
<attr name="maximum_life" type="int">100</attr>
<attr name="strength" type="int">25
<attr name="endurance" type="int">25
<attr name="dexterity" type="int">25
<attr name="agility" type="int">25
<attr name="speed" type="int">25
<attr name="luck" type="int">25
<attr name="fight" type="script">
// blah combat scripting
</attr>
</type>


and here's an example of Object Types within Object Types (though it's actualy probably better not to put the Object Types inside of other Object Types with this design I'm using as an example):

<type name="equipment_object_type">
<attr name="equipable" type="boolean">true</attr>
<attr name="unequipable" type="boolean">true</attr>
<attr name="equipped" type="boolean">false</attr>
<attr name="weight" type="int">0</attr>
<attr name="price" type="int">0</attr>
<attr name="slot" type="simplestringlist">unknown</attr>
<attr name="layer" type="int">0</attr>
<attr name="durability" type="int">100</attr>
// etc Attributes
</type>

<type name="weapon_object_type">
<inherit name="equipment_object_type" />
<attr name="physical_damage" type="int">0</attr>
<attr name="fire_damage" type="int">0</attr>
<attr name="water_damage" type="int">0</attr>
<attr name="air_damage" type="int">0</attr>
<attr name="earth_damage" type="int">0</attr>
<attr name="light_damage" type="int">0</attr>
<attr name="dark_damage" type="int">0</attr>
<attr name="holy_damage" type="int">0</attr>
<attr name="unholy_damage" type="int">0</attr>
// etc Attributes
</type>

<type name="one_handed_object_type">
<inherit name="weapon_object_type" />
<attr name="two_handed" type="boolean">false</attr>
<attr name="slots" type="simplestringlist">right_hand</attr>
// etc Attributes
</type>

<type name="two_handed_object_type">
<inherit name="weapon_object_type" />
<attr name="two_handed" type="boolean">true</attr>
<attr name="slots" type="simplestringlist">right_hand; left_hand</attr>
// etc Attributes
</type>

<type name="melee_object_type">
<inherit name="weapon_object_type" />
<attr name="attack_range" type="int">0</attr>
<attr name="attack_speed" type="int">0</attr>
// etc Attributes
</type>

<type name="sword_object_type">
</type>

<type name="axe_object_type">
</type>

<type name="ranged_object_type">
<inherit name="weapon_object_type" />
<attr name="range" type="int">1</attr>
<attr name="rate_of_fire" type="int">0</attr>
<attr name="recoil_force" type="int">0</attr>
<attr name="recoil_time" type="int">0</attr>
<attr name="reload_time" type="int">0</attr>
<attr name="maximum_rounds" type="int">1</attr>
<attr name="current_rounds" type="int">0</attr>
// etc Attributes
</type>

<type name="armor_object_type">
<inherit name="equipment_object_type" />
<attr name="physical_resistance" type="int">0</attr>
<attr name="fire_resistance" type="int">0</attr>
<attr name="water_resistance" type="int">0</attr>
<attr name="air_resistance" type="int">0</attr>
<attr name="earth_resistance" type="int">0</attr>
<attr name="light_resistance" type="int">0</attr>
<attr name="dark_resistance" type="int">0</attr>
<attr name="holy_resistance" type="int">0</attr>
<attr name="unholy_resistance" type="int">0</attr>
// etc Attributes
</type>

<type name="clothing_object_type">
<inherit name="equipment_object_type" />
// etc Attributes
</type>


hopefully, you get the idea... :D

---------------------------

An Object's Attributes will over-ride the Inherited Attributes that it gets from an Object Type:

What is the 'orc_king' Object's 'strength' Integer Attribute's Value and its 'alias' String Attribute's Value?

Alias: 'orc' or 'orc king' ???
Strength: '25' or '75' ???

<object name="orc_king">
<inherit name="orc_object_type" />
<alias>orc king</attr>
<attr name="strength" type="int">75</attr>
</object>

<type name="orc_object_type">
<alias>orc</alias>
<attr name="strength" type="int">25</attr>
</type>


Answer:

Alias: 'orc king'
Strength: '75'

--------------------------

also:

viewforum.php?f=18

see Pixie's Simple Combat Lbrary (it includes equipment)
see Chase's Wearables (Equipment) Library
see Pertex' Combat Library (it includes equipment)

see Pixie's Spell Library (it uses Object Types):

(I think it is combined into Pixie's Simple Combat Library now)

http://docs.textadventures.co.uk/quest/ ... types.html
http://docs.textadventures.co.uk/quest/ ... nced_.html
http://docs.textadventures.co.uk/quest/ ... nced_.html
http://docs.textadventures.co.uk/quest/ ... nced_.html

Watcher55
I'm not entirely sure what you are trying to achieve, but a possible solution is this. You can give any object any attribute you like; and you can give any object which is ammunition a boolean "ammo". Then say you are handling the command:
load #object1# with #object2#

Then after testing whether object1 is a gun, you can do:
if (GetBoolean(object2,"ammo")) {
msg ("Your " + GetDisplayAlias(object1) + " is now loaded!")
}
else {
msg ("You can only load a gun with ammunition.")

The Pixie
Stardog wrote:The only thing stopping me using Quest is that Attributes seem like they can only be one of these:

String
Boolean
Integer
Double
Script
String List
Object
Command Pattern
String dictionary
Script dictionary
Null

How do I choose a custom "Object Type" from here?

Object includes any custom object type.

I'm looking to make a Gun (inherited type Weapon), with attribute AmmoSlot (needs to be type Ammo, but isn't allowed).


Set it to be an object, and then check the type in a script when appropriate. You can use the DoesInherit function to test if your object is of any type in the inheritance tree.

It seems like we can't do basic subclassing for some reason. How do I do this? I need this structure:

Base types/classes
Weapon (Object Type)
- AmmoSlot (Attribute type Ammo)

Ammo (Object Type)

AmmoShell (Object Type - inherited type Ammo)

Objects
Shotgun (inherited type Weapon)
ShotgunShells (inherited type AmmoShell)


Create a new object type. In the GUI you will see a textfield for name, and below that two big boxes. The top one allows you to assign a type to this type. That will make your new type inherit from the type (or types) you specify. If you look at the attributes tab of an object, you can see where attributes have been inherited from under "source".

All this assumes you are editing off-line. If you are working on-line, some of this may not be possible.

TinFoilMkIV
What I would do is to create an attribute that is a string which contains a value for the type of ammunition your gun will use, or if you want to get fancy a stringlist to allow multiple types. Then as Pixie described above, use DoesInherit when attempting to load to check that your ammo is the correct type for the weapon. If the ammo is allowed I would set its parent to the actual weapon, this puts the ammo object inside of the weapon object, which ends up logically following the sort of interaction you want to create anyways. So from there the weapon will need an attribute to track the amount of ammunition loaded.

A basic way to track your ammo is to start at 0 and just increase it whenever you load and decrease when you unload or fire. You can however perform a check to read the exact number of ammo objects the weapon contains if needed, by using GetDirectChildren combined with ListCount, and use a DoesInherit check if there are cases where the weapon may contain non-ammo objects to ensure an accurate count.

For the weapon functionality you'll likely want to use an object list attribute on the weapon populated with GetDirectChildren anyways to help keep ammo organized and to have a more controlled method of determining which ammo object is first in the clip and such. That would also technically allow loading a single clip with different types of ammo if you wish to allow it.

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums