From c2d992c8f0bd0127b271743bc3d1209621788918 Mon Sep 17 00:00:00 2001 From: nkorslund Date: Mon, 17 Nov 2008 11:29:18 +0000 Subject: [PATCH] More work on the scripts (just playing around) git-svn-id: https://openmw.svn.sourceforge.net/svnroot/openmw/trunk@71 ea6a568a-9f4f-0410-981a-c910a81bb256 --- mscripts/{cellobjects => gameobjects}/door.mn | 0 mscripts/gameobjects/equipitem.mn | 27 +++++++++++++ .../gameobject.mn} | 15 +++++-- mscripts/gameobjects/inventoryitem.mn | 28 +++++++++++++ .../{cellobjects => gameobjects}/light.mn | 2 +- .../lockedobject.mn | 2 +- mscripts/gameobjects/weapon.mn | 31 ++++++++++++++ mscripts/object.d | 2 +- scene/celldata.d | 40 +++++++++---------- 9 files changed, 121 insertions(+), 26 deletions(-) rename mscripts/{cellobjects => gameobjects}/door.mn (100%) create mode 100644 mscripts/gameobjects/equipitem.mn rename mscripts/{cellobjects/cellobject.mn => gameobjects/gameobject.mn} (73%) create mode 100644 mscripts/gameobjects/inventoryitem.mn rename mscripts/{cellobjects => gameobjects}/light.mn (96%) rename mscripts/{cellobjects => gameobjects}/lockedobject.mn (96%) create mode 100644 mscripts/gameobjects/weapon.mn diff --git a/mscripts/cellobjects/door.mn b/mscripts/gameobjects/door.mn similarity index 100% rename from mscripts/cellobjects/door.mn rename to mscripts/gameobjects/door.mn diff --git a/mscripts/gameobjects/equipitem.mn b/mscripts/gameobjects/equipitem.mn new file mode 100644 index 000000000..0565e3eae --- /dev/null +++ b/mscripts/gameobjects/equipitem.mn @@ -0,0 +1,27 @@ +/* + OpenMW - The completely unofficial reimplementation of Morrowind + Copyright (C) 2008 Nicolay Korslund + Email: < korslund@gmail.com > + WWW: http://openmw.snaptoad.com/ + + This file (equipitem.mn) is part of the OpenMW package. + + OpenMW is distributed as free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + version 3, as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + version 3 along with this program. If not, see + http://www.gnu.org/licenses/ . + + */ + +// Anything that can be equiped, like clothes, armor and weapons. +class EquipItem : InventoryItem; + +int enchant; diff --git a/mscripts/cellobjects/cellobject.mn b/mscripts/gameobjects/gameobject.mn similarity index 73% rename from mscripts/cellobjects/cellobject.mn rename to mscripts/gameobjects/gameobject.mn index 25873997f..5122ac951 100644 --- a/mscripts/cellobjects/cellobject.mn +++ b/mscripts/gameobjects/gameobject.mn @@ -4,7 +4,7 @@ Email: < korslund@gmail.com > WWW: http://openmw.snaptoad.com/ - This file (cellobject.mn) is part of the OpenMW package. + This file (gameobject.mn) is part of the OpenMW package. OpenMW is distributed as free software: you can redistribute it and/or modify it under the terms of the GNU General Public License @@ -23,9 +23,18 @@ // An object that exists inside a cell. All cell objects must have a // position in space. -class CellObject : Object; +class GameObject : Object; -// Position and rotation in space +// Is this object placed in a cell? isPlaced is true if the object is +// displayed inside a cell with a mesh and given 3D coordinates, and +// false otherwise (eg. if it is part of the player's inventory or in +// a container.) + +// TODO: This will change to an actual cell reference later on, and be +// null if the object is not placed. +bool isPlaced; + +// Position and rotation in space (only valid if isPlaced is true.) float x, y, z; float r1, r2, r3; diff --git a/mscripts/gameobjects/inventoryitem.mn b/mscripts/gameobjects/inventoryitem.mn new file mode 100644 index 000000000..728f49c16 --- /dev/null +++ b/mscripts/gameobjects/inventoryitem.mn @@ -0,0 +1,28 @@ +/* + OpenMW - The completely unofficial reimplementation of Morrowind + Copyright (C) 2008 Nicolay Korslund + Email: < korslund@gmail.com > + WWW: http://openmw.snaptoad.com/ + + This file (inventoryitem.mn) is part of the OpenMW package. + + OpenMW is distributed as free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + version 3, as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + version 3 along with this program. If not, see + http://www.gnu.org/licenses/ . + + */ + +class InventoryItem : GameObject; + +float weight; +int value; + diff --git a/mscripts/cellobjects/light.mn b/mscripts/gameobjects/light.mn similarity index 96% rename from mscripts/cellobjects/light.mn rename to mscripts/gameobjects/light.mn index fd2a5007d..924703c90 100644 --- a/mscripts/cellobjects/light.mn +++ b/mscripts/gameobjects/light.mn @@ -21,7 +21,7 @@ */ -class Light : CellObject; +class Light : InventoryItem; // Time left in seconds (for carried lights) float lifetime; diff --git a/mscripts/cellobjects/lockedobject.mn b/mscripts/gameobjects/lockedobject.mn similarity index 96% rename from mscripts/cellobjects/lockedobject.mn rename to mscripts/gameobjects/lockedobject.mn index 0fccdd9a8..51d091607 100644 --- a/mscripts/cellobjects/lockedobject.mn +++ b/mscripts/gameobjects/lockedobject.mn @@ -22,7 +22,7 @@ */ // Objects that can have a lock level and a trap -class LockedObject : CellObject; +class LockedObject : GameObject; // ID of key and trap type. char[] key, trap; diff --git a/mscripts/gameobjects/weapon.mn b/mscripts/gameobjects/weapon.mn new file mode 100644 index 000000000..19da4455c --- /dev/null +++ b/mscripts/gameobjects/weapon.mn @@ -0,0 +1,31 @@ +/* + OpenMW - The completely unofficial reimplementation of Morrowind + Copyright (C) 2008 Nicolay Korslund + Email: < korslund@gmail.com > + WWW: http://openmw.snaptoad.com/ + + This file (weapon.mn) is part of the OpenMW package. + + OpenMW is distributed as free software: you can redistribute it + and/or modify it under the terms of the GNU General Public License + version 3, as published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + version 3 along with this program. If not, see + http://www.gnu.org/licenses/ . + + */ + +// Weapons (This is just an example, it's not used for anything yet.) +class Weapon : EquipItem; + +float speed, reach; + +bool magical, silver; +bool isTwohanded; + diff --git a/mscripts/object.d b/mscripts/object.d index 27b21c2e4..6e9ed2c3f 100644 --- a/mscripts/object.d +++ b/mscripts/object.d @@ -35,7 +35,7 @@ void initMonsterScripts() { // Add the script directories MonsterClass.addPath("mscripts/"); - MonsterClass.addPath("mscripts/cellobjects/"); + MonsterClass.addPath("mscripts/gameobjects/"); MonsterClass.addPath("mscripts/sound/"); // Make sure the Object class is loaded diff --git a/scene/celldata.d b/scene/celldata.d index 6fcb01e82..3de23504b 100644 --- a/scene/celldata.d +++ b/scene/celldata.d @@ -42,7 +42,7 @@ import scene.player; // Generic version of a "live" object struct GenLive(T) { - // Instance of class CellObject or a derived class (depending on + // Instance of class GameObject or a derived class (depending on // object type) MonsterObject *obj; T *m; @@ -259,13 +259,13 @@ class CellData private: static - MonsterClass cellObjC, doorC, lightC, lockedC; + MonsterClass gameObjC, doorC, lightC, lockedC; void setup() { - if(cellObjC !is null) return; + if(gameObjC !is null) return; - cellObjC = new MonsterClass("CellObject"); + gameObjC = new MonsterClass("GameObject"); doorC = new MonsterClass("Door"); lightC = new MonsterClass("Light"); lockedC = new MonsterClass("LockedObject"); @@ -310,7 +310,7 @@ class CellData { LiveStatic ls; ls.m = s; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; statics.insert(ls); stat = true; @@ -320,7 +320,7 @@ class CellData { LiveMisc ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; miscItems.insert(ls); } @@ -366,7 +366,7 @@ class CellData { LiveActivator ls; ls.m = a; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; activators.insert(ls); activator = true; @@ -376,7 +376,7 @@ class CellData { LiveNPC ls; ls.m = n; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; npcs.insert(ls); } @@ -384,7 +384,7 @@ class CellData { LivePotion ls; ls.m = p; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; potions.insert(ls); } @@ -392,7 +392,7 @@ class CellData { LiveApparatus ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; appas.insert(ls); } @@ -400,7 +400,7 @@ class CellData { LiveIngredient ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; ingredients.insert(ls); } @@ -408,7 +408,7 @@ class CellData { LiveArmor ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; armors.insert(ls); } @@ -416,7 +416,7 @@ class CellData { LiveWeapon ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; weapons.insert(ls); } @@ -424,7 +424,7 @@ class CellData { LiveBook ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; books.insert(ls); } @@ -432,7 +432,7 @@ class CellData { LiveClothing ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; clothes.insert(ls); } @@ -440,7 +440,7 @@ class CellData { LiveTool ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; tools.insert(ls); } @@ -448,7 +448,7 @@ class CellData { LiveTool ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; tools.insert(ls); } @@ -456,7 +456,7 @@ class CellData { LiveTool ls; ls.m = m; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; tools.insert(ls); } @@ -464,7 +464,7 @@ class CellData { LiveCreature ls; ls.m = c; - ls.obj = cellObjC.createObject; + ls.obj = gameObjC.createObject; mo = ls.obj; creatures.insert(ls); } @@ -475,7 +475,7 @@ class CellData ls.m = l.instCreature(playerData.level); if(ls.m != null) { - ls.obj = cellObjC.createObject; mo = ls.obj; + ls.obj = gameObjC.createObject; mo = ls.obj; creatures.insert(ls); } }