ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/server/time.C
(Generate patch)

Comparing deliantra/server/server/time.C (file contents):
Revision 1.44 by root, Sat Apr 21 22:01:57 2007 UTC vs.
Revision 1.46 by root, Sat Apr 28 21:34:38 2007 UTC

87 } 87 }
88 88
89 op->destroy (); 89 op->destroy ();
90} 90}
91 91
92static void 92void
93generate_monster_tail (object *gen, object *op) 93generate_monster (object *gen)
94{ 94{
95 if (!gen->map)
96 return;
97
98 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1))
99 return;
100
101 object *op;
102
103 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN))
104 {
105 // either copy one item form the inventory...
106 if (!gen->inv)
107 return;
108
109 // first select one item from the inventory
110 int index = 0;
111 for (object *tmp = gen->inv; tmp; tmp = tmp->below)
112 if (!rndm (++index))
113 op = tmp;
114
115 op = object_create_clone (op);
116
117 CLEAR_FLAG (op, FLAG_IS_A_TEMPLATE);
118 unflag_inv (op, FLAG_IS_A_TEMPLATE);
119 }
120 else
121 {
122 // ...or use other_arch
123 if (archetype *at = gen->other_arch)
124 op = arch_to_object (at);
125 else
126 return;
127 }
128
95 op->expand_tail (); 129 op->expand_tail ();
96 130
97 int i = find_free_spot (op, gen->map, gen->x, gen->y, 1, 9); 131 int i = find_free_spot (op, gen->map, gen->x, gen->y, 1, 9);
98 if (i >= 0) 132 if (i >= 0)
99 { 133 {
108 return; 142 return;
109 } 143 }
110 } 144 }
111 145
112 op->destroy (); 146 op->destroy ();
113}
114
115/* Will generate a monster according to content
116 * of generator.
117 */
118static void
119generate_monster_inv (object *gen)
120{
121 if (!gen->inv)
122 return;
123
124 /* First count number of objects in inv */
125 int index = 0;
126 object *op;
127 for (object *tmp = gen->inv; tmp; tmp = tmp->below)
128 if (!rndm (++index))
129 op = tmp;
130
131 op = object_create_clone (op);
132
133 CLEAR_FLAG (op, FLAG_IS_A_TEMPLATE);
134 unflag_inv (op, FLAG_IS_A_TEMPLATE);
135
136 generate_monster_tail (gen, op);
137}
138
139static void
140generate_monster_arch (object *gen)
141{
142 if (archetype *at = gen->other_arch)
143 generate_monster_tail (gen, arch_to_object (at));
144}
145
146void
147generate_monster (object *gen)
148{
149 if (!gen->map)
150 return;
151
152 if (GENERATE_SPEED (gen) && rndm (0, GENERATE_SPEED (gen) - 1))
153 return;
154
155 if (QUERY_FLAG (gen, FLAG_CONTENT_ON_GEN))
156 generate_monster_inv (gen);
157 else
158 generate_monster_arch (gen);
159
160} 147}
161 148
162void 149void
163remove_force (object *op) 150remove_force (object *op)
164{ 151{
233} 220}
234 221
235 222
236void 223void
237move_gate (object *op) 224move_gate (object *op)
238{ /* 1 = going down, 0 = goind up */ 225{ /* 1 = going down, 0 = going up */
239 object *tmp; 226 object *tmp;
240 227
241 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op)) 228 if (op->stats.wc < 0 || (int) op->stats.wc >= NUM_ANIMATIONS (op))
242 { 229 {
243 LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op)); 230 LOG (llevError, "Gate error: animation was %d, max=%d\n", op->stats.wc, NUM_ANIMATIONS (op));
315 */ 302 */
316 if ((int) op->stats.wc >= NUM_ANIMATIONS (op) / 2) 303 if ((int) op->stats.wc >= NUM_ANIMATIONS (op) / 2)
317 { 304 {
318 /* Halfway or further, check blocks */ 305 /* Halfway or further, check blocks */
319 /* First, get the top object on the square. */ 306 /* First, get the top object on the square. */
320 for (tmp = op->above; tmp != NULL && tmp->above != NULL; tmp = tmp->above); 307 for (tmp = op->above; tmp && tmp->above; tmp = tmp->above)
308 ;
321 309
322 if (tmp != NULL) 310 if (tmp)
323 { 311 {
324 if (QUERY_FLAG (tmp, FLAG_ALIVE)) 312 if (QUERY_FLAG (tmp, FLAG_ALIVE))
325 { 313 {
326 hit_player (tmp, random_roll (1, op->stats.dam, tmp, PREFER_LOW), op, AT_PHYSICAL, 1); 314 hit_player (tmp, random_roll (0, op->stats.dam, tmp, PREFER_LOW), op, AT_PHYSICAL, 1);
315
327 if (tmp->type == PLAYER) 316 if (tmp->type == PLAYER)
328 new_draw_info_format (NDI_UNIQUE, 0, tmp, "You are crushed by the %s!", &op->name); 317 new_draw_info_format (NDI_UNIQUE, 0, tmp, "You are crushed by the %s!", &op->name);
329 } 318 }
330 else 319 else
331 /* If the object is not alive, and the object either can 320 /* If the object is not alive, and the object either can

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines