Crossfire Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
CF: Pet-monsters improvement patch
- To: crossfire (at) ifi.uio.no
- Subject: CF: Pet-monsters improvement patch
- From: "Jacek Konieczny" <>
- Date: Sat, 26 Dec 1998 19:01:01 +0100
- Mail-Followup-To:
- Sender:
Hi,
Summoning pet-monsters are not very usable now, because they block you,
so you have to kill them sometimes to be able to move.
I have attached a small fix - patch for the server, which make you swap-places
with your pet instead of attacking it, when you move on it.
It doesn't work well for big (multipart) pets. But multipart pets
don't function well even without this patch.
I hope you will like it.
And if anybody could help me with fixing it for big pets support it
would be great.
Another problem about pets is the fact, that they prefer attacking doors
than monsters. And they even attack passable (not locked) doors.
I will probably fix it too.
Maybe we some way of giving orders to pets should be implemented.
For example commands like:
tellpets attack monsters
tellpets attack door
tellpets follow me
tellpets run away
Greets,
Jacek
--
+---------+--------------------------------------------------------+
! , ! Jacek Konieczny, Gliwice, Poland !
! Jajcus ! email: , !
! ! ICQ# 7149127 WWW: none (yet) !
+---------+--------------------------------------powered-by-Linux--+
diff -durN crossfire-0.95.1.orig/server/move.c crossfire-0.95.1/server/move.c
--- crossfire-0.95.1.orig/server/move.c Mon Nov 30 03:09:13 1998
+++ crossfire-0.95.1/server/move.c Sat Dec 26 13:09:55 1998
@@ -337,3 +337,51 @@
}
return 1;
}
+
+/*
+ * swap_objects(): swap places of two objects.
+ * returns 1 when successful
+ * WARNING: although I tried, this doesn't work well with
+ * multipart objects
+ */
+
+int swap_objects(object *op1,object *op2) {
+
+ object *tmp;
+ int x1,y1,x2,y2;
+
+ x1=op2->x; y1=op2->y;
+ x2=op1->x; y2=op1->y;
+
+ /* We must remove objects first to find a free space */
+ if(op1->head!=NULL)
+ op1=op1->head;
+ remove_ob(op1);
+ if(op2->head!=NULL)
+ op2=op2->head;
+ remove_ob(op2);
+
+ if (arch_blocked(op1->arch,op1->map,x1,y1)){
+ insert_ob_in_map(op1,op1->map);
+ insert_ob_in_map(op2,op2->map);
+ return 0;
+ }
+
+ if (arch_blocked(op2->arch,op2->map,x2,y2)){
+ insert_ob_in_map(op1,op1->map);
+ insert_ob_in_map(op2,op2->map);
+ return 0;
+ }
+
+ for(tmp=op1;tmp!=NULL;tmp=tmp->more)
+ tmp->x=x1+(tmp->arch==NULL?0:tmp->arch->clone.x),
+ tmp->y=y1+(tmp->arch==NULL?0:tmp->arch->clone.y);
+ insert_ob_in_map(op1,op1->map);
+
+ for(tmp=op2;tmp!=NULL;tmp=tmp->more)
+ tmp->x=x2+(tmp->arch==NULL?0:tmp->arch->clone.x),
+ tmp->y=y2+(tmp->arch==NULL?0:tmp->arch->clone.y);
+ insert_ob_in_map(op2,op2->map);
+
+ return 1;
+}
diff -durN crossfire-0.95.1.orig/server/player.c crossfire-0.95.1/server/player.c
--- crossfire-0.95.1.orig/server/player.c Mon Nov 30 03:09:13 1998
+++ crossfire-0.95.1/server/player.c Sat Dec 26 14:53:08 1998
@@ -1207,6 +1207,14 @@
if(action_makes_visible(op)) make_visible(op);
}
+
+ /* if it is our pet monster we don't want to kill it,
+ so just swap places*/
+ if ((tmp->owner==op && QUERY_FLAG(tmp,FLAG_FRIENDLY)) &&
+ (!op->contr->braced)){
+ swap_objects(op,tmp);
+ }
+
/* The following deals with possibly attacking peaceful
* or frienddly creatures. Basically, all players are considered
* unaggressive. If the moving player has peaceful set, then the
@@ -1215,7 +1223,7 @@
* and thus will not push them.
*/
- if ((tmp->type==PLAYER || tmp->enemy != op) &&
+ else if ((tmp->type==PLAYER || tmp->enemy != op) &&
(tmp->type==PLAYER || QUERY_FLAG(tmp,FLAG_UNAGGRESSIVE)
|| QUERY_FLAG(tmp, FLAG_FRIENDLY)) &&
op->contr->peaceful && (!op->contr->braced)) {