git » fp-git.git » commit 10427ca

Added potions

author ecalot
2005-02-22 02:14:24 UTC
committer ecalot
2005-02-22 02:14:24 UTC
parent d428d7eca70d5356e37ef817fca6fefa682d6a65

Added potions

FP/src/conf/states/main.conf +9 -0
FP/src/conf/tiles.conf +26 -2
FP/src/include/kid.h +2 -2
FP/src/ker/kernel.c +1 -1
FP/src/ker/kid.c +14 -6
FP/src/ker/object.c +4 -4
FP/src/ker/room.c +3 -3

diff --git a/FP/src/conf/states/main.conf b/FP/src/conf/states/main.conf
index 5ed39cd..4b4efa8 100644
--- a/FP/src/conf/states/main.conf
+++ b/FP/src/conf/states/main.conf
@@ -214,6 +214,15 @@ normal:
 #			relative  0
 #		animation
 #			15 fh $2
+	action            Drink potion
+		conditions
+			MapOn                  potion
+			KeyShift               pressed
+		animation
+			193-206 p
+			207 pd
+		next
+			normal
 
 	action            If there aren't more actions then the normal state is kept
 		conditions
diff --git a/FP/src/conf/tiles.conf b/FP/src/conf/tiles.conf
index 35018cf..188417a 100644
--- a/FP/src/conf/tiles.conf
+++ b/FP/src/conf/tiles.conf
@@ -29,10 +29,10 @@
 #
 
 tile EMPTY 0 free
-dangerous space bricke1@0 bricke2@1 bricke3@2
+dangerous space bricke1@1 bricke2@2 window@3
 
 tile FLOOR 1 free
-walkable floor brickf1@0 brickf2@1 
+walkable floor brickf1@1 brickf2@2
 
 tile SPIKES 2 spike
 walkable dangerous spikes chopper_spike
@@ -59,6 +59,30 @@ tile BP_TOP 9 none
 
 tile POTION 10 potion
 walkable potion floor
+#by effect
+hitpoint@1
+life@2
+featherfall@3
+invert@4
+poison@5
+open@6
+
+#by size
+smallpotion@0
+smallpotion@1
+bigpotion@2
+bigpotion@3
+bigpotion@4
+smallpotion@5
+smallpotion@6
+
+#by colour
+redpotion@1
+redpotion@2
+greenpotion@3
+greenpotion@4
+bluepotion@5
+bluepotion@6
 
 tile LOOSE 11 none
 #it has floor and is walkable only if it is not down
diff --git a/FP/src/include/kid.h b/FP/src/include/kid.h
index 0cbb0a0..12d6a66 100644
--- a/FP/src/include/kid.h
+++ b/FP/src/include/kid.h
@@ -39,12 +39,12 @@ kid.h: Free Prince : Kid object
 #include "types.h"
 
 void kidDrawLives(tObject *kid);
-void kidGetLive(tObject *kid);
+void kidGetLife(tObject *kid);
 void kidGetHitPoint(tObject *kid);
 int kidTakeHitPoint(tObject *kid);
 int kidMove(tObject* kid,short flags,tRoom* room);
 void kidKillHim(tObject *kid);
-void kidDrinkPotion(tObject* object,tTile tile);
+int kidDrinkPotion(tObject* object,tTile tile); /* 0 if died */
 
 #endif
 
diff --git a/FP/src/ker/kernel.c b/FP/src/ker/kernel.c
index 5f15197..bde9873 100644
--- a/FP/src/ker/kernel.c
+++ b/FP/src/ker/kernel.c
@@ -151,7 +151,7 @@ int playgame(int optionflag,int level) {
 					notReset=0;
 					break;
 				case addLive:
-					kidGetLive(&kid);
+					kidGetLife(&kid);
 					break;
 				case addHitPoint:
 					kidGetHitPoint(&kid);
diff --git a/FP/src/ker/kid.c b/FP/src/ker/kid.c
index 32972bd..8f4e082 100644
--- a/FP/src/ker/kid.c
+++ b/FP/src/ker/kid.c
@@ -41,11 +41,6 @@ kid.c: Free Prince : Kid object
 #define KID_LIVE_FILL 216
 #define KID_LIVE_EMPTY 217
 
-void kidDrinkPotion(tObject* object,tTile tile) {
-
-
-}
-
 void kidDrawLives(tObject *kid) {
 	int i;
 	static int blink=0;
@@ -59,7 +54,7 @@ void kidDrawLives(tObject *kid) {
 	}
 }
 
-void kidGetLive(tObject *kid) {
+void kidGetLife(tObject *kid) {
 	kid->hitPoints=++kid->lives;
 }
 
@@ -78,6 +73,19 @@ void kidKillHim(tObject *kid) {
 	kid->hitPoints=0;
 }				
 
+int kidDrinkPotion(tObject* kid,tTile tile) {
+	/* returns 0 if died */
+	if (isIn(tile,TILE_SWORD)) {
+	} else if (isIn(tile,TILES_HITPOINT)) {
+		kidGetHitPoint(kid);
+	} else if (isIn(tile,TILES_LIFE)) {
+		kidGetLife(kid);
+	} else if (isIn(tile,TILES_POISON)) {
+		return kidTakeHitPoint(kid);
+	}
+	return 1;	
+}
+
 /* Room stuff */
 				
 int kidVerifyRoom(tObject *kid,tRoom *room,int refresh) {
diff --git a/FP/src/ker/object.c b/FP/src/ker/object.c
index f9c93a1..d596696 100644
--- a/FP/src/ker/object.c
+++ b/FP/src/ker/object.c
@@ -95,14 +95,14 @@ int objectMove(tObject* object,tKey key,tRoom* room) {
 		case oKid:
 			refresh=kidMove(object,flags,room);
 			if (flags&STATES_FLAG_H) {
-				if (!kidTakeHitPoint(object)) { /* take a hit point */
+				if (!kidTakeHitPoint(object)) /* loose a hit point */
 					/* the kid has died! */
 					flags=STATE_EXIT_CODE_SPLASH;
-				}
 			}
 			if (flags&STATES_FLAG_D) {
-				tTile tile=roomGetTile(room,object->location/TILE_W,object->floor);
-				kidDrinkPotion(object,tile);
+				tTile tile=roomGetTile(room,object->location/TILE_W+1,object->floor+1);
+				if (!kidDrinkPotion(object,tile)) /* drink the potion */
+					flags=STATE_EXIT_CODE_SPLASH;
 				/* TODO: transform the tile into floor */
 			}
 			break;
diff --git a/FP/src/ker/room.c b/FP/src/ker/room.c
index e0d3a86..f7bacab 100644
--- a/FP/src/ker/room.c
+++ b/FP/src/ker/room.c
@@ -309,11 +309,11 @@ void drawBackPanel(tRoom* room,int x, int y) {
 		drawChopper((x-1)*TILE_W+0,y*TILE_H,chopperGetFrame(tile),layCBack);
 	/* empty_bricks/this */
 	if (isIn(tile,TILES_BRICKE1)) 
-		e(51,x*TILE_W+0,y*TILE_H-18);
-	if (isIn(tile,TILES_BRICKE2)) 
 		e(52,x*TILE_W+0,y*TILE_H-18);
-	if (isIn(tile,TILES_BRICKE3)) 
+	if (isIn(tile,TILES_BRICKE2)) 
 		e(53,x*TILE_W+0,y*TILE_H-18);
+	if (isIn(tile,TILES_WINDOW)) 
+		e(54,x*TILE_W+0,y*TILE_H-18);
 	/* floor_bricks/this */
 	if (isIn(tile,TILES_BRICKF1)) 
 		e(12,x*TILE_W+0,y*TILE_H-18);