r70 - in trunk/src: . objects

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Sun Oct 3 06:56:52 EDT 2004


Author: jonas
Date: 2004-10-03 06:56:52 -0400 (Sun, 03 Oct 2004)
New Revision: 70

Added:
   trunk/src/objects/plant.cpp
   trunk/src/objects/plant.h
Modified:
   trunk/src/monsters_common.cpp
   trunk/src/objectpools.cpp
   trunk/src/objects/Makefile
   trunk/src/objects/baleog.cpp
   trunk/src/objects/fang.cpp
   trunk/src/players_common.cpp
   trunk/src/weapons.h
Log:
added plant, modified some event settings, monster and players are no longer dense to each other

Modified: trunk/src/monsters_common.cpp
===================================================================
--- trunk/src/monsters_common.cpp	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/monsters_common.cpp	2004-10-03 10:56:52 UTC (rev 70)
@@ -18,7 +18,6 @@
     maxspeedy=0;
     state=STATE_FALL;
     otype|=OTYPE_MONSTER;
-    dense_types|=OTYPE_PLAYER;
     enemy_types|=OTYPE_PLAYER;
     im_left=animation;
     im_right=animation;

Modified: trunk/src/objectpools.cpp
===================================================================
--- trunk/src/objectpools.cpp	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/objectpools.cpp	2004-10-03 10:56:52 UTC (rev 70)
@@ -4,6 +4,7 @@
 #include "sndcache.h"
 #include "objectpools.h"
 //HACK!!!!!!
+#include "monsters_common.h"
 #include "objects/baleog.h"
 #include "objects/bomb.h"
 #include "objects/door.h"
@@ -18,6 +19,7 @@
 #include "objects/teleport.h"
 #include "objects/trigger.h"
 #include "objects/triggered_bomb.h"
+#include "objects/plant.h"
 #include "objects/wall.h"
 #include "objects/water.h"
 #include "objects/wind.h"
@@ -37,7 +39,7 @@
     string name=obj;
     if (arg1!="0") {
         //one additional parameter
-        if (name=="Trigger" || name=="Door" || name=="Bomb" || name=="TriggeredBomb" || name=="Geyser" || name=="Wind") {
+        if (name=="Trigger" || name=="Door" || name=="Bomb" || name=="TriggeredBomb" || name=="Plant" || name=="Geyser" || name=="Wind") {
             if (arg2!="0") name=arg2;
         //two additional parameter
         } else if (name=="Teleporter") {
@@ -63,6 +65,7 @@
 
     //normal characters
     else if (obj=="TriggeredBomb") return (addCharacter(new TriggeredBomb(image,x,y,atoi(arg1.c_str()),name)));
+
     //Players
     else if (obj=="Eric")    return (addPlayer(new Eric(image,x,y,name)));
     else if (obj=="Olaf")    return (addPlayer(new Olaf(image,x,y,name)));
@@ -71,6 +74,7 @@
     else if (obj=="Scorch")  return (addPlayer(new Scorch(image,x,y,name)));
 
     //Monsters
+    else if (obj=="Plant")   return (addMonster(new Plant(image,x,y,atoi(arg1.c_str()),name)));
     else if (obj=="Zombie")  return (addMonster(new Zombie(image,x,y,name)));
 
     //not recognized

Modified: trunk/src/objects/Makefile
===================================================================
--- trunk/src/objects/Makefile	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/objects/Makefile	2004-10-03 10:56:52 UTC (rev 70)
@@ -9,7 +9,7 @@
 
 OBJS  = baleog.o bomb.o door.o eric.o exit.o fang.o geyser.o heart.o\
         key.o olaf.o scorch.o teleport.o trigger.o triggered_bomb.o\
-        wall.o water.o wind.o zombie.o
+        wall.o water.o wind.o zombie.o plant.o
 PLUGS = ../objects.a
 
 

Modified: trunk/src/objects/baleog.cpp
===================================================================
--- trunk/src/objects/baleog.cpp	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/objects/baleog.cpp	2004-10-03 10:56:52 UTC (rev 70)
@@ -34,5 +34,5 @@
     if (dt < 0) return;
     input->unsetState(INPUT_SP1);
 
-    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,5,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? im_sword_left : im_sword_right));
+    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? im_sword_left : im_sword_right));
 }

Modified: trunk/src/objects/fang.cpp
===================================================================
--- trunk/src/objects/fang.cpp	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/objects/fang.cpp	2004-10-03 10:56:52 UTC (rev 70)
@@ -84,7 +84,7 @@
     if (dt < 0) return;
     input->unsetState(INPUT_SP2);
 
-    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,5,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? im_claw_left : im_claw_right));
+    setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? im_claw_left : im_claw_right));
 }
 
 void Fang::crash(Uint16 dir) {

Added: trunk/src/objects/plant.cpp
===================================================================
--- trunk/src/objects/plant.cpp	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/objects/plant.cpp	2004-10-03 10:56:52 UTC (rev 70)
@@ -0,0 +1,52 @@
+#include "common.h"
+#include "sndcache.h"
+#include "sfxeng.h"
+#include "weapons.h"
+#include "players_common.h"
+#include "monsters_common.h"
+#include "map.h"
+#include "plant.h"
+
+Plant::Plant(string imagename, Sint16 xcord, Sint16 ycord, Uint16 trecover, string cname):
+  Monster(imagename,xcord,ycord,cname),
+  recover(trecover),
+  tcur(trecover) {
+    maxhealth=1;
+    weapon=Weapon(-1,W_TOUCH);
+    au_hit=sndcache->loadWAV("creeper.wav");
+    au_recover=au_hit;
+    enemy_types|=(OTYPE_PLAYER);
+}
+Plant::~Plant() { }
+
+void Plant::touch(Object* obj) {
+    if (health==0) return;
+    if(Player* ptr = dynamic_cast<Player*>(obj)) {
+        Uint16 adir=(DIR_UP|curmap->getDirection(getCenter(),ptr->getCenter()));
+        if (!(adir&DIR_LR)) adir|=DIR_LEFT;
+        ptr->hit(adir,weapon);
+    }
+}
+
+void Plant::idle(Uint16 dt) {
+    if (health==0) {
+        tcur-=dt;
+        if (tcur<=0) {
+            sfxeng->playWAV(au_recover);
+            tcur=recover;
+            setHealth(maxhealth);
+            std::set<Character *> cset=curmap->getCharactersIn(enemy_types,pos,true);
+            character_iterator cit=cset.begin();
+            while (cit!=cset.end()) {
+                (*cit)->hit(curmap->getDirection(pos,*(*cit)->getPos()),weapon);
+                ++cit;
+            }
+        }
+    }
+}
+
+Uint16 Plant::hit(Uint16, Weapon& weap) {
+    if (health==0) return health;
+    sfxeng->playWAV(au_hit);
+    return addHealth(weap.getDamage());
+}

Added: trunk/src/objects/plant.h
===================================================================
--- trunk/src/objects/plant.h	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/objects/plant.h	2004-10-03 10:56:52 UTC (rev 70)
@@ -0,0 +1,17 @@
+#include "characters_common.h"
+
+/** \brief Regrowing plant
+
+*/
+class Plant : public Monster {
+    public:
+        Plant(string imagename, Sint16 xpos=0, Sint16 ypos=0, Uint16 dleft=3000, string name="Plant");
+        virtual ~Plant();
+        virtual void touch(Object*);
+        virtual void idle(Uint16);
+        virtual Uint16 hit(Uint16 dir, Weapon& weap);
+    private:
+        Uint16 recover;
+        Sint16 tcur;
+        Mix_Chunk* au_recover;
+};

Modified: trunk/src/players_common.cpp
===================================================================
--- trunk/src/players_common.cpp	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/players_common.cpp	2004-10-03 10:56:52 UTC (rev 70)
@@ -22,7 +22,6 @@
     }
     state=STATE_FALL;
     otype|=OTYPE_PLAYER;
-    dense_types|=OTYPE_MONSTER;
     enemy_types|=OTYPE_MONSTER;
     im_left=animation;
     im_right=animation;
@@ -353,8 +352,8 @@
             case W_TOUCH: {
                 //TODO: play animations (make new Event for this)
                 if (direction&(DIR_UP|DIR_DOWN)) sfxeng->playWAV(aud_hit);
-                if (direction&DIR_LEFT) setEvent(new ESpeed(this,TSTRIKE,-200,-DSTRIKE,0,ESTATE_BUSY,aud_hit));
-                else setEvent(new ESpeed(this,TSTRIKE,-200,DSTRIKE,0,ESTATE_BUSY,aud_hit));
+                if (direction&DIR_LEFT) setEvent(new ESpeed(this,TSTRIKE,-200,-400,0,ESTATE_BUSY,aud_hit));
+                else setEvent(new ESpeed(this,TSTRIKE,-200,400,0,ESTATE_BUSY,aud_hit));
                 break;
             }
             case W_WATER: {

Modified: trunk/src/weapons.h
===================================================================
--- trunk/src/weapons.h	2004-10-02 23:00:47 UTC (rev 69)
+++ trunk/src/weapons.h	2004-10-03 10:56:52 UTC (rev 70)
@@ -22,7 +22,6 @@
 #define WS_PRESSURE      0x00000010
 #define WS_HEAL          0x00000020
 
-#define DSTRIKE          200
 #define TSTRIKE          600
 
 /** \brief Weapons




More information about the lostpenguins-commits mailing list