1 | /* |
1 | /* |
2 | * static char *rcsid_spell_attack_c = |
2 | * static char *rcsid_spell_attack_c = |
3 | * "$Id: spell_attack.c,v 1.2 2006/02/21 11:00:07 root Exp $"; |
3 | * "$Id: spell_attack.c,v 1.3 2006/03/15 15:35:52 elmex Exp $"; |
4 | */ |
4 | */ |
5 | |
5 | |
6 | |
6 | |
7 | /* |
7 | /* |
8 | CrossFire, A Multiplayer game for X-windows |
8 | CrossFire, A Multiplayer game for X-windows |
… | |
… | |
114 | void forklightning(object *op, object *tmp) { |
114 | void forklightning(object *op, object *tmp) { |
115 | int new_dir=1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
115 | int new_dir=1; /* direction or -1 for left, +1 for right 0 if no new bolt */ |
116 | int t_dir; /* stores temporary dir calculation */ |
116 | int t_dir; /* stores temporary dir calculation */ |
117 | mapstruct *m; |
117 | mapstruct *m; |
118 | sint16 sx,sy; |
118 | sint16 sx,sy; |
|
|
119 | object *new_bolt; |
119 | |
120 | |
120 | /* pick a fork direction. tmp->stats.Con is the left bias |
121 | /* pick a fork direction. tmp->stats.Con is the left bias |
121 | * i.e., the chance in 100 of forking LEFT |
122 | * i.e., the chance in 100 of forking LEFT |
122 | * Should start out at 50, down to 25 for one already going left |
123 | * Should start out at 50, down to 25 for one already going left |
123 | * down to 0 for one going 90 degrees left off original path |
124 | * down to 0 for one going 90 degrees left off original path |
… | |
… | |
129 | /* check the new dir for a wall and in the map*/ |
130 | /* check the new dir for a wall and in the map*/ |
130 | t_dir = absdir(tmp->direction + new_dir); |
131 | t_dir = absdir(tmp->direction + new_dir); |
131 | |
132 | |
132 | if(get_map_flags(tmp->map,&m, tmp->x + freearr_x[t_dir],tmp->y + freearr_y[t_dir], |
133 | if(get_map_flags(tmp->map,&m, tmp->x + freearr_x[t_dir],tmp->y + freearr_y[t_dir], |
133 | &sx, &sy) & P_OUT_OF_MAP) |
134 | &sx, &sy) & P_OUT_OF_MAP) |
134 | return; |
135 | return; |
135 | |
136 | |
136 | if (OB_TYPE_MOVE_BLOCK(tmp, GET_MAP_MOVE_BLOCK(m, sx, sy))) |
137 | if (OB_TYPE_MOVE_BLOCK(tmp, GET_MAP_MOVE_BLOCK(m, sx, sy))) |
137 | return; |
138 | return; |
138 | |
139 | |
139 | /* OK, we made a fork */ |
140 | /* OK, we made a fork */ |
140 | object *new_bolt = get_object(); |
141 | new_bolt = get_object(); |
141 | |
142 | |
142 | copy_object(tmp,new_bolt); |
143 | copy_object(tmp,new_bolt); |
143 | |
144 | |
144 | /* reduce chances of subsequent forking */ |
145 | /* reduce chances of subsequent forking */ |
145 | new_bolt->stats.Dex -= 10; |
146 | new_bolt->stats.Dex -= 10; |