From 09ba91c708de23e26d04ff45b15d23a3c86cdee9 Mon Sep 17 00:00:00 2001 From: johns <> Date: Sun, 11 Jun 2000 19:30:25 +0000 Subject: [PATCH] Minimal attack range added. --- src/stratagus/oldmissile.cpp | 25 +++++++++++++----- src/unit/script_unittype.cpp | 12 +++++++-- src/unit/unittype.cpp | 50 +++++++++++++++++++++--------------- 3 files changed, 58 insertions(+), 29 deletions(-) diff --git a/src/stratagus/oldmissile.cpp b/src/stratagus/oldmissile.cpp index 810d1cbf7..82a57fcf0 100644 --- a/src/stratagus/oldmissile.cpp +++ b/src/stratagus/oldmissile.cpp @@ -598,8 +598,10 @@ global void FireMissile(Unit* unit) DebugLevel3Fn("\n"); + // + // None missile hits immediately! + // if( ((MissileType*)unit->Type->Missile.Missile)->Class==MissileClassNone ) { - // Hit immediately if( !(goal=unit->Command.Data.Move.Goal) ) { dx=unit->Command.Data.Move.DX; dy=unit->Command.Data.Move.DY; @@ -621,6 +623,7 @@ global void FireMissile(Unit* unit) } // FIXME: make sure thats the correct unit. + // Check if goal is correct unit. if( goal->Destroyed ) { DebugLevel0Fn("destroyed unit\n"); @@ -668,13 +671,23 @@ global void FireMissile(Unit* unit) // Fire to nearest point of unit! NearestOfUnit(goal,unit->X,unit->Y,&dx,&dy); DebugLevel3Fn("Fire to unit at %d,%d\n",dx,dy); - dx=dx*TileSizeX+TileSizeX/2; - dy=dy*TileSizeY+TileSizeY/2; } else { - dx=unit->Command.Data.Move.DX*TileSizeX+TileSizeX/2; - dy=unit->Command.Data.Move.DY*TileSizeY+TileSizeY/2; + dx=unit->Command.Data.Move.DX; + dy=unit->Command.Data.Move.DY; } + // + // Moved out of attack range? + // + if( MapDistance(unit->X,unit->Y,dx,dy)<=unit->Type->MinAttackRange ) { + DebugLevel0Fn("Missile target too near %d,%d\n" + ,MapDistance(unit->X,unit->Y,dx,dy),unit->Type->MinAttackRange); + // FIXME: do something other? + return; + } + + dx=dx*TileSizeX+TileSizeX/2; + dy=dy*TileSizeY+TileSizeY/2; missile=MakeMissile(unit->Type->Missile.Missile,x,y,dx,dy); // // Damage of missile @@ -950,7 +963,7 @@ global void MissileHit(const Missile* missile) } return; } - DebugLevel0Fn("Oops nothing to hit (%d,%d)?\n",x,y); + DebugLevel3Fn("Oops nothing to hit (%d,%d)?\n",x,y); return; } diff --git a/src/unit/script_unittype.cpp b/src/unit/script_unittype.cpp index 35156db60..e36c77cae 100644 --- a/src/unit/script_unittype.cpp +++ b/src/unit/script_unittype.cpp @@ -217,9 +217,9 @@ local SCM CclDefineUnitType(SCM list) list=gh_cdr(list); value=gh_car(list); n=gh_vector_length(value); - if( n<4 || n>6 ) { + if( n<4 || n>MaxCosts ) { fprintf(stderr,"Wrong vector length\n"); - if( n>6 ) { + if( n>MaxCosts ) { n=MaxCosts; } } @@ -259,6 +259,14 @@ local SCM CclDefineUnitType(SCM list) type->BoxHeight=gh_scm2int(temp); DebugLevel3("\tBox: %d,%d\n",type->BoxWidth,type->BoxHeight); + // Minimal attack range + + list=gh_cdr(list); + value=gh_car(list); + i=gh_scm2int(value); + DebugLevel3("\tMinimal AttackRange: %d\n",i); + type->MinAttackRange=i; + // Attack range list=gh_cdr(list); diff --git a/src/unit/unittype.cpp b/src/unit/unittype.cpp index 667e1f754..c590d7d59 100644 --- a/src/unit/unittype.cpp +++ b/src/unit/unittype.cpp @@ -9,11 +9,10 @@ // FreeCraft - A free fantasy real time strategy game engine // /**@name unittype.c - The unit types. */ -/* -** (c) Copyright 1998-2000 by Lutz Sammer -** -** $Id$ -*/ +// +// (c) Copyright 1998-2000 by Lutz Sammer +// +// $Id$ //@{ @@ -225,7 +224,7 @@ local const char* UnitTypeNames[] = { "KurdanAndSky_ree", "Dentarg", "Khadgar", - "GnomHellscream", + "GromHellscream", "TankerHuman", "TankerOrc", "TransportHuman", @@ -365,7 +364,7 @@ global void PrintUnitTypeTable(void) printf(" ,%3d,%3d\t\t\t// graphic size\n" ,type->Width,type->Height); - printf(" ,_%sAnimations\t// animations\n",UnitTypeNames[i]); + printf(" ,%sAnimations\t// animations\n",UnitTypeNames[i]); printf(" ,{ \"%s\" }\n",IdentOfIcon(type->Icon.Icon)); printf(" ,{ \"%s\" }\t\t// Missile\n",type->Missile.Name); @@ -376,25 +375,30 @@ global void PrintUnitTypeTable(void) } else { printf(" ,NULL, NULL, 0\n"); } - break; - printf("\t//Speed\tOvFrame\tSightR\tHitpnt\tMagic\tBTime\tGold\tWood\tOil\n"); - printf("\t,%6d,%7d,%6d,%7d,%6d, {%5d,%6d,%7d,%6d }\n" + printf("\t//Speed\tOverlay\tSightR\tHitpnt\tMagic\n"); + printf("\t,%6d,%7d,%6d,%7d,%6d\n" ,type->_Speed ,type->OverlapFrame ,type->_SightRange ,type->_HitPoints - ,type->Magic + ,type->Magic); + printf("\t// BTime Gold Wood Oil Ore Stone Coal\n"); + printf("\t,{%5d,%5d,%5d,%5d,%5d,%5d,%5d }\n" ,type->_Costs[TimeCost] ,type->_Costs[GoldCost] ,type->_Costs[WoodCost] - ,type->_Costs[OilCost]); - printf("\t//TileW\tTileH\tBoxW\tBoxH\tAttack\tReactC\tReactH\n"); - printf("\t,%6d,%5d,%6d,%7d,%9d,%7d,%7d\n" + ,type->_Costs[OilCost] + ,type->_Costs[OreCost] + ,type->_Costs[StoneCost] + ,type->_Costs[CoalCost]); + printf("\t//TileW\tTileH\tBoxW\tBoxH\t>Attack\t<Attack\tReactC\tReactHuman\n"); + printf("\t,%6d,%5d,%6d,%7d,%9d,%7d,%6d,%7d\n" ,type->TileWidth ,type->TileHeight ,type->BoxWidth ,type->BoxHeight + ,type->MinAttackRange ,type->_AttackRange ,type->ReactRangeComputer ,type->ReactRangeHuman); @@ -537,7 +541,7 @@ global void ParsePudUDTA(const char* udta,int length) IfDebug( if( length!=5694 && length!=5948 ) { DebugLevel0("\n"__FUNCTION__": ***\n"__FUNCTION__": %d\n",length); - DebugLevel0(__FUNCTION__": ***\n\n"); + DebugLevel0Fn("***\n\n"); } ) start=udta; @@ -780,8 +784,8 @@ global void SaveUnitType(const UnitType* type,FILE* file) fprintf(file," \"animations-%s\"\t;; animations\n",type->Ident+5); fprintf(file," \"%s\"\n",IdentOfIcon(type->Icon.Icon)); - fprintf(file," ;;Speed OvFrame SightR Hitpnt Magic BTime\tGold\tWood\tOil\n"); - fprintf(file," %6d %7d %6d %6d %6d #(%5d %6d %7d %6d )\n" + fprintf(file," ;;Speed Constr SightR Hitpnt Magic BTime Gold Wood Oil Ore Stone Coal\n"); + fprintf(file," %6d %6d %6d %6d %5d #(%4d %5d %5d %5d %5d %5d %5d)\n" ,type->_Speed ,type->OverlapFrame ,type->_SightRange @@ -790,13 +794,17 @@ global void SaveUnitType(const UnitType* type,FILE* file) ,type->_Costs[TimeCost] ,type->_Costs[GoldCost] ,type->_Costs[WoodCost] - ,type->_Costs[OilCost]); - fprintf(file," ;;Tile Box Size Attack\tReactC\tReactH\n"); - fprintf(file," '( %d %d ) '( %3d %3d ) %5d %7d %7d\n" + ,type->_Costs[OilCost] + ,type->_Costs[OreCost] + ,type->_Costs[StoneCost] + ,type->_Costs[CoalCost]); + fprintf(file," ;;Tile Box Size >Attack\t<Attack\tReactC\tReactH\n"); + fprintf(file," '( %d %d ) '( %3d %3d ) %6d %7d %6d %7d\n" ,type->TileWidth ,type->TileHeight ,type->BoxWidth ,type->BoxHeight + ,type->MinAttackRange ,type->_AttackRange ,type->ReactRangeComputer ,type->ReactRangeHuman); @@ -1021,7 +1029,7 @@ global UnitType* UnitTypeByIdent(const char* ident) return *type; } - DebugLevel0(__FUNCTION__": Name %s not found\n",ident); + DebugLevel0Fn("Name %s not found\n",ident); return NULL; }