ftp.nice.ch/pub/next/games/action/xox/XoxWars94.NI.bs.tar.gz#/pack/XoxWars.bproj/CrazyMander.m

This is CrazyMander.m in view mode; [Download] [Up]

#import "CrazyMander.h"
#import "XoxWars.h"
#import "XWShip.h"

@implementation CrazyMander

- resetShip:ship
{
     [ship setThrusting:NO time:0];
     [ship setShields:YES];
     return ship;
}

- oneStep:scenario
{
#define HALF() (randBetween(0.0,1.0)<0.5)
  extern float randBetween(float a, float b);
     int n = [ships count];
     while (n--) {
          id ship = [ships objectAt:n];
          int flag = randBetween(0.0, 4.0);

          switch(flag)     {
               case 0:          // change rotation
                    if (HALF()) {
                         int LR = (HALF()) ? LEFT : RIGHT;
                         [ship setTurning:LR down:YES time:0];
                    } else {
                         [ship setTurning:LEFT down:NO time:0];
                         [ship setTurning:RIGHT down:NO time:0];
                    }
                    break;
               case 1:          // fire - need shields off!
                    if ([scenario hasBullets:alliance]) {
                       [ship setShields:NO];
                       [ship fire];
                    }
                    break;
               case 2:          // thrust
                    [ship setThrusting:YES time:0];
                    break;
           default:
               case 3:          // shields
                    [ship setShields:YES];
                    break;
         }
     }     // next ship
  return self;
}

@end

These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.