This is OSentry.m in view mode; [Download] [Up]
// // $Id: OSentry.m,v 1.1 1997/10/28 05:11:42 nygard Exp $ // // // This file is a part of Empire, a game of exploration and conquest. // Copyright (C) 1996 Steve Nygard // // 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. // // You may contact the author by: // e-mail: nygard@telusplanet.net // #import "Empire.h" RCSID ("$Id: OSentry.m,v 1.1 1997/10/28 05:11:42 nygard Exp $"); #import "OSentry.h" #import "Unit.h" //====================================================================== // // This makes a unit wait for enemy activity, or to be loaded on a ship, // so the user doesn't have to deal with the unit each turn. The unit // will "wake up" when it encounters an enemy unit, allowing the player // to give new orders. This doesn't make sense for fighters unless they // are within a city or on board a ship, since they will run out of fuel, // but it tries not to crash them. // // A sentried unit doesn't use up it's movement points until the end of // the turn, so that they can be reactivated during survey mode if // desired. // //====================================================================== #define OSentry_VERSION 1 @implementation OSentry + (void) initialize { if (self == [OSentry class]) { [self setVersion:OSentry_VERSION]; } } //---------------------------------------------------------------------- - initForUnit:(Unit *)aUnit { [super initForUnit:aUnit]; return self; } //---------------------------------------------------------------------- - (void) dealloc { [super dealloc]; } //---------------------------------------------------------------------- - (NSString *) orderText { return @"Sentry"; } //---------------------------------------------------------------------- - (void) aboutToMove { // Try not to crash fighters. if ([unit unitType] != u_fighter || [unit currentRange] > 10 || [unit isOnBoardShip] == YES || [unit isInCity] == YES) [unit skipMove]; } //---------------------------------------------------------------------- - (Direction) nextMove { // Skip move... return d_none; } //---------------------------------------------------------------------- - (BOOL) wasBlocked { return NO; } //---------------------------------------------------------------------- - (BOOL) isSentried { return YES; } @end
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.