/* Weapon.m Class definition. Copyright (C) 1995 David Flater. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include "cheezmud.h" @implementation Weapon + new { self=[super new]; [self describe: "club": "a club": "the club": "This is a chunk of wood that you can use to clobber someone."]; strcpy (youhit, "clobber"); strcpy (hehit, "clobbers"); strcpy (hitwith, " with the club"); [self setspeeddamage: 4: 4]; return self; } - kill: who: dobj { if ([dobj isdead]) return self; /* We have to prevent people from getting in extra hits by typing kill */ /* over and over. We only really want to hit if this function was called */ /* by the heartbeat. The heartbeat is nice enough to set a flag for us, */ /* since otherwise it would be hard to tell. */ if ([who checkkillflag]) { id owner_location; if (dobj == who) { [who clue: who]; return self; } if (++beatcount == speed) { beatcount = 0; owner_location = [who getlocation]; [owner_location emote: who: youhit: hehit: dobj: hitwith]; [dobj hit: who: (float) (random() % (damage+1))]; [owner_location theres_a_fight_going_on]; } } else { if (dobj == who) { [who echo: "If you want to delete your account, e-mail the mud admin!"]; [who clue: who]; return self; } [[who enemies] addIfAbsent: dobj]; } return self; } - (void) setspeeddamage: (int) s: (int) d { float tspeed; speed = s; damage = d; tspeed = ((float)s / 4.0 - 1.0) * 0.5 + 1.0; prio = (float)damage / tspeed; } - (float) priority: (char *) action: (int) numargs { if (numargs == 2) { if (!strcmp (action, "kill")) return prio; } /* Not supported */ return -1.0; } @end