Crossfire Server, Trunk
peacemaker.cpp
Go to the documentation of this file.
1 /*
2  CrossFire, A Multiplayer game for X-windows
3 
4  Copyright (C) 2007 Mark Wedel & Crossfire Development Team
5  Copyright (C) 1992 Frank Tore Johansen
6 
7  This program is free software; you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation; either version 2 of the License, or
10  (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21  The authors can be reached via e-mail at crossfire-devel@real-time.com
22 */
23 
28 #include <global.h>
29 #include <ob_methods.h>
30 #include <ob_types.h>
31 #include <sounds.h>
32 #include <sproto.h>
33 
34 static method_ret peacemaker_type_process(object *op);
35 
41 }
42 
50  object *owner;
51 
52  owner = object_get_owner(op);
53  if (owner == NULL) {
54  LOG(llevError, "peacemaker_type_process: peacemaker object %s has no owner\n", op->name);
56  object_free(op, 1);
57  return METHOD_OK;
58  }
59 
60  FOR_MAP_PREPARE(op->map, op->x, op->y, tmp) {
61  int atk_lev, def_lev;
62  object *victim;
63 
64  victim = HEAD(tmp);
66  continue;
68  continue;
69  if (victim->stats.exp == 0)
70  continue;
71 
72  def_lev = MAX(1, victim->level);
73  atk_lev = MAX(1, op->level);
74 
75  if (rndm(0, atk_lev-1) > def_lev) {
76  /* make this sucker peaceful. */
77 
78  change_exp(owner, victim->stats.exp, op->skill, 0);
79  victim->stats.exp = 0;
80  victim->attack_movement = RANDO2;
85  if (victim->name) {
87  "%s no longer feels like fighting.",
88  victim->name);
89  }
90  }
91  } FOR_MAP_FINISH();
92  return METHOD_OK;
93 }
object_get_owner
object * object_get_owner(object *op)
Definition: object.cpp:804
global.h
FOR_MAP_FINISH
#define FOR_MAP_FINISH()
Definition: define.h:730
peacemaker_type_process
static method_ret peacemaker_type_process(object *op)
Definition: peacemaker.cpp:49
llevError
@ llevError
Definition: logger.h:11
LOG
void LOG(LogLevel logLevel, const char *format,...)
Definition: logger.cpp:51
SET_FLAG
#define SET_FLAG(xyz, p)
Definition: define.h:224
QUERY_FLAG
#define QUERY_FLAG(xyz, p)
Definition: define.h:226
init_type_peacemaker
void init_type_peacemaker(void)
Definition: peacemaker.cpp:39
METHOD_OK
#define METHOD_OK
Definition: ob_methods.h:15
draw_ext_info_format
void draw_ext_info_format(int flags, int pri, const object *pl, uint8_t type, uint8_t subtype, const char *format,...) PRINTF_ARGS(6
Ice.tmp
int tmp
Definition: Ice.py:207
rndm
int rndm(int min, int max)
Definition: utils.cpp:162
register_process
void register_process(int ob_type, process_func method)
Definition: ob_types.cpp:71
MAX
#define MAX(x, y)
Definition: compat.h:24
MSG_TYPE_SPELL_SUCCESS
#define MSG_TYPE_SPELL_SUCCESS
Definition: newclient.h:635
FLAG_RUN_AWAY
#define FLAG_RUN_AWAY
Definition: define.h:280
HEAD
#define HEAD(op)
Definition: object.h:596
PEACEMAKER
@ PEACEMAKER
Definition: object.h:167
object_free
void object_free(object *ob, int flags)
Definition: object.cpp:1592
change_exp
void change_exp(object *op, int64_t exp, const char *skill_name, int flag)
Definition: living.cpp:2166
FLAG_UNAGGRESSIVE
#define FLAG_UNAGGRESSIVE
Definition: define.h:272
sproto.h
MSG_TYPE_SPELL
#define MSG_TYPE_SPELL
Definition: newclient.h:411
FLAG_MONSTER
#define FLAG_MONSTER
Definition: define.h:245
FLAG_RANDOM_MOVE
#define FLAG_RANDOM_MOVE
Definition: define.h:309
FOR_MAP_PREPARE
#define FOR_MAP_PREPARE(map_, mx_, my_, it_)
Definition: define.h:723
method_ret
char method_ret
Definition: ob_methods.h:14
ob_types.h
sounds.h
NDI_UNIQUE
#define NDI_UNIQUE
Definition: newclient.h:262
reputation.victim
victim
Definition: reputation.py:14
give.op
op
Definition: give.py:33
CLEAR_FLAG
#define CLEAR_FLAG(xyz, p)
Definition: define.h:225
object_remove
void object_remove(object *op)
Definition: object.cpp:1833
ob_methods.h
RANDO2
#define RANDO2
Definition: define.h:523