Fixed configurable max mana.
This commit is contained in:
parent
c74d6ef010
commit
fd082c0e36
7 changed files with 33 additions and 895 deletions
|
@ -191,7 +191,7 @@ local int AiEyeOfVisionSpell(Unit* unit)
|
|||
r=SyncRand();
|
||||
/* s0m3body: each unit can have different MaxMana, the original condition is testing MaxMana-10,
|
||||
* so let's take unit's maxmana * 245/255 as a new treshold */
|
||||
if( unit->Mana>((unit->Type->Magic * 245 ) / 255) && !(r%32) ) {
|
||||
if( unit->Mana>((unit->Type->_MaxMana * 245 ) / 255) && !(r%32) ) {
|
||||
if( unit->Mana>AiEyeOfVision->ManaCost ) {
|
||||
DebugLevel0Fn("`%s' cast eye of vision\n"
|
||||
_C_ unit->Type->Ident);
|
||||
|
@ -244,7 +244,7 @@ local int AiHolyVisionSpell(Unit* unit)
|
|||
/* s0m3body: each unit can have different MaxMana, the original condition is testing MaxMana-10,
|
||||
* * so let's take unit's maxmana * 245/255 as a new treshold */
|
||||
|
||||
if( unit->Mana>((unit->Type->Magic * 245)/255) && !(r%32) ) {
|
||||
if( unit->Mana>((unit->Type->_MaxMana * 245)/255) && !(r%32) ) {
|
||||
if( unit->Mana>AiHolyVision->ManaCost ) {
|
||||
int x;
|
||||
int y;
|
||||
|
|
|
@ -130,9 +130,13 @@
|
|||
**
|
||||
** Maximum hit points
|
||||
**
|
||||
** UnitType::_MaxMana
|
||||
**
|
||||
** Maximum mana points
|
||||
**
|
||||
** UnitType::Magic
|
||||
**
|
||||
** Unit can cast spells
|
||||
** Unit is a mage
|
||||
**
|
||||
** UnitType::_Costs[::MaxCosts]
|
||||
**
|
||||
|
@ -483,6 +487,7 @@ struct _unit_type_ {
|
|||
Construction*Construction; /// What is shown in construction phase
|
||||
int _SightRange; /// Sight range
|
||||
unsigned _HitPoints; /// Maximum hit points
|
||||
int _MaxMana; /// Maximum mana points
|
||||
// FIXME: only flag
|
||||
int Magic; /// Unit can cast spells
|
||||
|
||||
|
|
|
@ -116,8 +116,8 @@ local void UiDrawManaBar(const Unit* unit,int x,int y)
|
|||
VideoFillRectangleClip(ColorBlack,x,y+3,ICON_WIDTH+7,4);
|
||||
if( unit->HP ) {
|
||||
/* s0m3body: mana bar should represent proportional value of Mana with respect to
|
||||
* MaxMana (unit->Type->Magic) for the unit */
|
||||
f=(100*unit->Mana)/unit->Type->Magic;
|
||||
* MaxMana (unit->Type->_MaxMana) for the unit */
|
||||
f=(100*unit->Mana)/unit->Type->_MaxMana;
|
||||
f=(f*(ICON_WIDTH+5))/100;
|
||||
VideoFillRectangleClip(ColorBlue,x+1,y+3+1,f,2);
|
||||
}
|
||||
|
@ -529,7 +529,7 @@ global void DrawUnitInfo(const Unit* unit)
|
|||
VideoDrawText(x+59,y+8+140+1,GameFont,"Magic:");
|
||||
VideoDrawRectangleClip(ColorGray,x+108,y+8+140,61,14);
|
||||
VideoDrawRectangleClip(ColorBlack,x+108+1,y+8+140+1,61-2,14-2);
|
||||
i=(100*unit->Mana)/unit->Type->Magic;
|
||||
i=(100*unit->Mana)/unit->Type->_MaxMana;
|
||||
i=(i*(61-4))/100;
|
||||
VideoFillRectangleClip(ColorBlue,x+108+2,y+8+140+2,i,14-4);
|
||||
|
||||
|
@ -539,7 +539,7 @@ global void DrawUnitInfo(const Unit* unit)
|
|||
/* s0m3body: fix to display mana bar properly for any maxmana
|
||||
value */
|
||||
/* s0m3body: max mana can vary for the unit */
|
||||
i=(100*unit->Mana)/unit->Type->Magic;
|
||||
i=(100*unit->Mana)/unit->Type->_MaxMana;
|
||||
i=(i*w)/100;
|
||||
VideoDrawRectangleClip(ColorGray, x+16, y+8+140, w+4, 16 );
|
||||
VideoDrawRectangleClip(ColorBlack,x+16+1,y+8+140+1,w+2,16-2);
|
||||
|
@ -1112,7 +1112,7 @@ global void DrawInfoPanel(void)
|
|||
|| Selected[0]->Orders[0].Action==UnitActionUpgradeTo
|
||||
|| Selected[0]->Orders[0].Action==UnitActionTrain) ) {
|
||||
i=3;
|
||||
} else if( Selected[0]->Type->Magic ) {
|
||||
} else if( Selected[0]->Type->_MaxMana ) {
|
||||
i=2;
|
||||
} else {
|
||||
i=1;
|
||||
|
|
|
@ -65,7 +65,7 @@ local long SiodUnitTypeTag; /// siod unit-type object
|
|||
**
|
||||
** @param list List describing the unit-type.
|
||||
*/
|
||||
local SCM CclDefineNewUnitType(SCM list)
|
||||
local SCM CclDefineUnitType(SCM list)
|
||||
{
|
||||
SCM value;
|
||||
SCM sublist;
|
||||
|
@ -169,12 +169,15 @@ local SCM CclDefineNewUnitType(SCM list)
|
|||
} else if( gh_eq_p(value,gh_symbol2scm("hit-points")) ) {
|
||||
type->_HitPoints=gh_scm2int(gh_car(list));
|
||||
list=gh_cdr(list);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("max-mana")) ) {
|
||||
type->_MaxMana=gh_scm2int(gh_car(list));
|
||||
if( type->_MaxMana>MaxMana ) {
|
||||
DebugLevel0Fn("Too much mana %d\n" _C_ type->_MaxMana);
|
||||
type->_MaxMana=MaxMana;
|
||||
}
|
||||
list=gh_cdr(list);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("magic")) ) {
|
||||
type->Magic=gh_scm2int(gh_car(list));
|
||||
if( type->Magic>MaxMana ) {
|
||||
DebugLevel0Fn("Too much mana %d\n" _C_ type->Magic);
|
||||
type->Magic=MaxMana;
|
||||
}
|
||||
list=gh_cdr(list);
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("tile-size")) ) {
|
||||
sublist=gh_car(list);
|
||||
|
@ -381,586 +384,6 @@ local SCM CclDefineNewUnitType(SCM list)
|
|||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
/**
|
||||
** Parse unit-type.
|
||||
**
|
||||
** @note FIXME: This should be changed to a more readable and useable
|
||||
** format. I thinking of an tagged format 'size and this should be
|
||||
** parsed by a general parser.
|
||||
**
|
||||
** @param list List describing the unit-type.
|
||||
*/
|
||||
local SCM CclDefineOldUnitType(SCM list)
|
||||
{
|
||||
SCM value;
|
||||
SCM temp;
|
||||
char* str;
|
||||
UnitType* type;
|
||||
int i;
|
||||
int j;
|
||||
int n;
|
||||
|
||||
DebugLevel0Fn("This version will be soon removed.\n");
|
||||
|
||||
// Slot identifier
|
||||
|
||||
value=gh_car(list);
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
IfDebug( i=NoWarningUnitType; NoWarningUnitType=1; );
|
||||
type=UnitTypeByIdent(str);
|
||||
IfDebug( NoWarningUnitType=i; );
|
||||
if( type ) {
|
||||
DebugLevel0Fn("Redefining unit-type `%s'\n" _C_ str);
|
||||
free(str);
|
||||
} else {
|
||||
type=NewUnitTypeSlot(str);
|
||||
}
|
||||
|
||||
// Name
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
DebugLevel3("\tName: %s\n" _C_ str);
|
||||
free(type->Name);
|
||||
type->Name=str;
|
||||
|
||||
// Graphic
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
if( gh_symbol_p(value) || gh_string_p(value) ) {
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
DebugLevel3("\tSame-Sprite: %s\n" _C_ str);
|
||||
free(type->SameSprite);
|
||||
type->SameSprite=str;
|
||||
free(type->File[0]);
|
||||
type->File[0]=NULL;
|
||||
free(type->File[1]);
|
||||
type->File[1]=NULL;
|
||||
free(type->File[2]);
|
||||
type->File[2]=NULL;
|
||||
free(type->File[3]);
|
||||
type->File[3]=NULL;
|
||||
} else {
|
||||
if( gh_vector_length(value)!=4 ) {
|
||||
fprintf(stderr,"Wrong vector length\n");
|
||||
}
|
||||
free(type->SameSprite);
|
||||
type->SameSprite=NULL;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(0));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
DebugLevel3("\tFile-0: %s\n" _C_ str);
|
||||
free(type->File[0]);
|
||||
type->File[0]=str;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(1));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
DebugLevel3("\tFile-1: %s\n" _C_ str);
|
||||
free(type->File[1]);
|
||||
type->File[1]=str;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(2));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
DebugLevel3("\tFile-2: %s\n" _C_ str);
|
||||
free(type->File[2]);
|
||||
type->File[2]=str;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(3));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
DebugLevel3("\tFile-3: %s\n" _C_ str);
|
||||
free(type->File[3]);
|
||||
type->File[3]=str;
|
||||
}
|
||||
|
||||
// Graphic Size
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
|
||||
temp=gh_car(value);
|
||||
type->Width=gh_scm2int(temp);
|
||||
temp=gh_car(gh_cdr(value));
|
||||
type->Height=gh_scm2int(temp);
|
||||
DebugLevel3("\tGraphic: %d,%d\n" _C_ type->Width _C_ type->Height);
|
||||
|
||||
// Animations
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
type->Animations=AnimationsByIdent(str);
|
||||
free(str);
|
||||
|
||||
// Icon
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
DebugLevel3("\tIcon: %s\n" _C_ str);
|
||||
|
||||
free(type->Icon.Name);
|
||||
type->Icon.Name=str;
|
||||
|
||||
// Speed
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tSpeed: %d\n" _C_ i);
|
||||
type->_Speed=i;
|
||||
|
||||
// Overlay frame
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tOverlay frame: %d\n" _C_ i);
|
||||
type->Construction=ConstructionByWcNum(i);
|
||||
|
||||
// Sight range
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tSight range: %d\n" _C_ i);
|
||||
type->_SightRange=i;
|
||||
|
||||
// Hitpoints
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tHitpoints: %d\n" _C_ i);
|
||||
type->_HitPoints=i;
|
||||
|
||||
// Magic
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tMagic: %d\n" _C_ i);
|
||||
type->Magic=i;
|
||||
|
||||
// Costs
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
n=gh_vector_length(value);
|
||||
if( n<4 || n>MaxCosts ) {
|
||||
fprintf(stderr,"Wrong vector length\n");
|
||||
if( n>MaxCosts ) {
|
||||
n=MaxCosts;
|
||||
}
|
||||
}
|
||||
|
||||
for( j=0; j<n; ++j ) {
|
||||
temp=gh_vector_ref(value,gh_int2scm(j));
|
||||
i=gh_scm2int(temp);
|
||||
type->_Costs[j]=i;
|
||||
}
|
||||
while( j<MaxCosts ) {
|
||||
type->_Costs[j++]=0;
|
||||
}
|
||||
|
||||
DebugLevel3("\tCosts: %d,%d,%d,%d\n"
|
||||
_C_ type->_Costs[TimeCost] _C_ type->_Costs[GoldCost]
|
||||
_C_ type->_Costs[WoodCost] _C_ type->_Costs[OilCost]);
|
||||
|
||||
// Tile Size
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
|
||||
temp=gh_car(value);
|
||||
type->TileWidth=gh_scm2int(temp);
|
||||
temp=gh_car(gh_cdr(value));
|
||||
type->TileHeight=gh_scm2int(temp);
|
||||
DebugLevel3("\tTile: %d,%d\n" _C_ type->TileWidth _C_ type->TileHeight);
|
||||
|
||||
// Box Size
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
|
||||
temp=gh_car(value);
|
||||
type->BoxWidth=gh_scm2int(temp);
|
||||
temp=gh_car(gh_cdr(value));
|
||||
type->BoxHeight=gh_scm2int(temp);
|
||||
DebugLevel3("\tBox: %d,%d\n" _C_ type->BoxWidth _C_ type->BoxHeight);
|
||||
|
||||
// Minimal attack range
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tMinimal AttackRange: %d\n" _C_ i);
|
||||
type->MinAttackRange=i;
|
||||
|
||||
// Attack range
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tAttackRange: %d\n" _C_ i);
|
||||
type->_AttackRange=i;
|
||||
|
||||
// Reaction range computer
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tReaction range computer: %d\n" _C_ i);
|
||||
type->ReactRangeComputer=i;
|
||||
|
||||
// Reaction range player
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tReaction range player: %d\n" _C_ i);
|
||||
type->ReactRangePerson=i;
|
||||
|
||||
// Armor
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tArmor: %d\n" _C_ i);
|
||||
type->_Armor=i;
|
||||
|
||||
// Priority
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tPriority: %d\n" _C_ i);
|
||||
type->Priority=i;
|
||||
|
||||
// Basic damage
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tBasic damage: %d\n" _C_ i);
|
||||
type->_BasicDamage=i;
|
||||
|
||||
// Piercing damage
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tPiercing damage: %d\n" _C_ i);
|
||||
type->_PiercingDamage=i;
|
||||
|
||||
// Weapons upgradable
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tWeaponsUpgradable: %d\n" _C_ i);
|
||||
type->WeaponsUpgradable=i;
|
||||
|
||||
// Armor upgradable
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tArmorUpgradable: %d\n" _C_ i);
|
||||
type->ArmorUpgradable=i;
|
||||
|
||||
// Decay rate
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tDecay rate: %d\n" _C_ i);
|
||||
type->DecayRate=i;
|
||||
|
||||
// Annoy computer factor
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tAnnoy computer factor: %d\n" _C_ i);
|
||||
type->AnnoyComputerFactor=i;
|
||||
|
||||
// Points
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tPoints: %d\n" _C_ i);
|
||||
type->Points=i;
|
||||
|
||||
// Food demand
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tFood demand: %d\n" _C_ i);
|
||||
type->Demand=i;
|
||||
|
||||
// Food supply
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
i=gh_scm2int(value);
|
||||
DebugLevel3("\tFood supply: %d\n" _C_ i);
|
||||
type->Supply=i;
|
||||
|
||||
// Missile
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
DebugLevel3("\tMissile: %s\n" _C_ str);
|
||||
|
||||
free(type->Missile.Name);
|
||||
type->Missile.Name=str;
|
||||
|
||||
// Corpse
|
||||
|
||||
list=gh_cdr(list);
|
||||
temp=gh_car(list);
|
||||
|
||||
free(type->CorpseName);
|
||||
type->CorpseName=NULL;
|
||||
type->CorpseType=NULL;
|
||||
type->CorpseScript=0;
|
||||
if( !gh_null_p(temp) ) {
|
||||
value=gh_car(temp);
|
||||
temp=gh_cdr(temp);
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
DebugLevel3("\tCorpse: %s\n" _C_ str);
|
||||
type->CorpseName=str;
|
||||
|
||||
value=gh_car(temp);
|
||||
i=gh_scm2int(value);
|
||||
type->CorpseScript=i;
|
||||
}
|
||||
|
||||
// Flags
|
||||
type->UnitType=0; // reset all
|
||||
type->MouseAction=0;
|
||||
type->CanTarget=0;
|
||||
type->LandUnit=0;
|
||||
type->AirUnit=0;
|
||||
type->SeaUnit=0;
|
||||
type->ExplodeWhenKilled=0;
|
||||
type->Critter=0;
|
||||
type->Building=0;
|
||||
type->Submarine=0;
|
||||
type->CanSeeSubmarine=0;
|
||||
type->CowerWorker=0;
|
||||
type->Tanker=0;
|
||||
type->Transporter=0;
|
||||
type->GivesOil=0;
|
||||
type->StoresGold=0;
|
||||
type->Vanishes=0;
|
||||
type->GroundAttack=0;
|
||||
type->IsUndead=0;
|
||||
type->ShoreBuilding=0;
|
||||
type->CanCastSpell=0;
|
||||
type->StoresWood=0;
|
||||
type->CanAttack=0;
|
||||
type->Tower=0;
|
||||
type->OilPatch=0;
|
||||
type->GoldMine=0;
|
||||
type->Hero=0;
|
||||
type->StoresOil=0;
|
||||
type->Volatile=0;
|
||||
type->CowerMage=0;
|
||||
type->Organic=0;
|
||||
type->SelectableByRectangle=0;
|
||||
type->Teleporter=0;
|
||||
|
||||
while( !gh_null_p(list) ) {
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
if( gh_vector_p(value) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
if( gh_eq_p(value,gh_symbol2scm("type-land")) ) {
|
||||
type->UnitType=UnitTypeLand;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("type-fly")) ) {
|
||||
type->UnitType=UnitTypeFly;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("type-naval")) ) {
|
||||
type->UnitType=UnitTypeNaval;
|
||||
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("right-none")) ) {
|
||||
type->MouseAction=MouseActionNone;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("right-attack")) ) {
|
||||
type->MouseAction=MouseActionAttack;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("right-move")) ) {
|
||||
type->MouseAction=MouseActionMove;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("right-harvest")) ) {
|
||||
type->MouseAction=MouseActionHarvest;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("right-haul-oil")) ) {
|
||||
type->MouseAction=MouseActionHaulOil;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("right-demolish")) ) {
|
||||
type->MouseAction=MouseActionDemolish;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("right-sail")) ) {
|
||||
type->MouseAction=MouseActionSail;
|
||||
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("can-target-land")) ) {
|
||||
type->CanTarget|=CanTargetLand;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("can-target-sea")) ) {
|
||||
type->CanTarget|=CanTargetSea;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("can-target-air")) ) {
|
||||
type->CanTarget|=CanTargetAir;
|
||||
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("land-unit")) ) {
|
||||
type->LandUnit=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("air-unit")) ) {
|
||||
type->AirUnit=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("sea-unit")) ) {
|
||||
type->SeaUnit=1;
|
||||
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("explode-when-killed")) ) {
|
||||
type->ExplodeWhenKilled=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("critter")) ) {
|
||||
type->Critter=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("building")) ) {
|
||||
type->Building=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("submarine")) ) {
|
||||
type->Submarine=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("can-see-submarine")) ) {
|
||||
type->CanSeeSubmarine=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("cower-worker")) ) {
|
||||
type->CowerWorker=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("tanker")) ) {
|
||||
type->Tanker=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("transporter")) ) {
|
||||
type->Transporter=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("gives-oil")) ) {
|
||||
type->GivesOil=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("stores-gold")) ) {
|
||||
type->StoresGold=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("vanishes")) ) {
|
||||
type->Vanishes=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("can-ground-attack")) ) {
|
||||
type->GroundAttack=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("isundead")) ) {
|
||||
type->IsUndead=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("shore-building")) ) {
|
||||
type->ShoreBuilding=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("can-cast-spell")) ) {
|
||||
type->CanCastSpell=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("stores-wood")) ) {
|
||||
type->StoresWood=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("can-attack")) ) {
|
||||
type->CanAttack=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("tower")) ) {
|
||||
type->Tower=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("oil-patch")) ) {
|
||||
type->OilPatch=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("gives-gold")) ) {
|
||||
type->GoldMine=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("hero")) ) {
|
||||
type->Hero=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("stores-oil")) ) {
|
||||
type->StoresOil=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("volatile")) ) {
|
||||
type->Volatile=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("cower-mage")) ) {
|
||||
type->CowerMage=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("organic")) ) {
|
||||
type->Organic=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("selectable-by-rectangle")) ) {
|
||||
type->SelectableByRectangle=1;
|
||||
} else if( gh_eq_p(value,gh_symbol2scm("teleporter")) ) {
|
||||
type->Teleporter=1;
|
||||
|
||||
} else {
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
fprintf(stderr,"Unsupported flag %s\n",str);
|
||||
free(str);
|
||||
}
|
||||
}
|
||||
|
||||
// Sounds
|
||||
|
||||
if( gh_vector_length(value)!=5 ) {
|
||||
fprintf(stderr,"Wrong vector length\n");
|
||||
}
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(0));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
free(type->Sound.Selected.Name);
|
||||
type->Sound.Selected.Name=str;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(1));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
free(type->Sound.Acknowledgement.Name);
|
||||
type->Sound.Acknowledgement.Name=str;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(2));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
free(type->Sound.Ready.Name);
|
||||
type->Sound.Ready.Name=str;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(3));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
free(type->Sound.Help.Name);
|
||||
type->Sound.Help.Name=str;
|
||||
|
||||
temp=gh_vector_ref(value,gh_int2scm(4));
|
||||
if( gh_null_p(temp) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(temp,NULL);
|
||||
}
|
||||
free(type->Sound.Dead.Name);
|
||||
type->Sound.Dead.Name=str;
|
||||
|
||||
list=gh_cdr(list);
|
||||
value=gh_car(list);
|
||||
|
||||
if( gh_null_p(value) ) {
|
||||
str=NULL;
|
||||
} else {
|
||||
str=gh_scm2newstr(value,NULL);
|
||||
}
|
||||
free(type->Weapon.Attack.Name);
|
||||
type->Weapon.Attack.Name=str;
|
||||
|
||||
return SCM_UNSPECIFIED;
|
||||
}
|
||||
|
||||
/**
|
||||
** Parse unit-stats.
|
||||
**
|
||||
|
@ -1335,8 +758,7 @@ local SCM CclDefineAnimations(SCM list)
|
|||
*/
|
||||
global void UnitTypeCclRegister(void)
|
||||
{
|
||||
//gh_new_procedureN("define-old-unit-type",CclDefineOldUnitType);
|
||||
gh_new_procedureN("define-new-unit-type",CclDefineNewUnitType);
|
||||
gh_new_procedureN("define-unit-type",CclDefineUnitType);
|
||||
gh_new_procedureN("define-unit-stats",CclDefineUnitStats);
|
||||
|
||||
SiodUnitTypeTag=allocate_user_tc();
|
||||
|
|
|
@ -291,7 +291,7 @@ global void InitUnit(Unit* unit, UnitType* type)
|
|||
}
|
||||
|
||||
if (type->CanCastSpell) {
|
||||
unit->Mana = (type->Magic * MAGIC_FOR_NEW_UNITS) / 100;
|
||||
unit->Mana = (type->_MaxMana * MAGIC_FOR_NEW_UNITS) / 100;
|
||||
}
|
||||
unit->Active = 1;
|
||||
|
||||
|
@ -1425,7 +1425,7 @@ global void UnitIncrementMana(void)
|
|||
--unit->Blink;
|
||||
}
|
||||
|
||||
if( unit->Type->CanCastSpell && unit->Mana!=unit->Type->Magic ) {
|
||||
if( unit->Type->CanCastSpell && unit->Mana!=unit->Type->_MaxMana ) {
|
||||
unit->Mana++;
|
||||
|
||||
// some frames delayed done my color cycling
|
||||
|
|
|
@ -1006,9 +1006,9 @@ local void DrawDecoration(const Unit* unit,const UnitType* type,int x,int y)
|
|||
// Mana bar on right side of unit. FIXME: combine bar and sprite
|
||||
//
|
||||
if( ShowManaBar ) {
|
||||
/* s0m3body: mana bar should display man proportionally to unit's max mana (unit->Type->Magic) */
|
||||
if( type->CanCastSpell && !(ShowNoFull && unit->Mana==unit->Type->Magic) ) {
|
||||
DrawManaBar(x,y,type,unit->Type->Magic,unit->Mana);
|
||||
/* s0m3body: mana bar should display man proportionally to unit's max mana (unit->Type->_MaxMana) */
|
||||
if( type->CanCastSpell && !(ShowNoFull && unit->Mana==unit->Type->_MaxMana) ) {
|
||||
DrawManaBar(x,y,type,unit->Type->_MaxMana,unit->Mana);
|
||||
} else if( type->GivesOil || type->GoldMine || type->OilPatch ) {
|
||||
DrawManaBar(x,y,type,655350,unit->Value);
|
||||
}
|
||||
|
@ -1070,9 +1070,9 @@ local void DrawDecoration(const Unit* unit,const UnitType* type,int x,int y)
|
|||
// Mana dot on right side of unit.
|
||||
//
|
||||
if( ShowManaDot ) {
|
||||
/* s0m3body: MaxMana can vary for each unit, it is stored in unit->Type->Magic */
|
||||
if( type->CanCastSpell && !(ShowNoFull && unit->Mana==unit->Type->Magic) ) {
|
||||
DrawManaSprite(x,y,type,unit->Type->Magic,unit->Mana);
|
||||
/* s0m3body: MaxMana can vary for each unit, it is stored in unit->Type->_MaxMana */
|
||||
if( type->CanCastSpell && !(ShowNoFull && unit->Mana==unit->Type->_MaxMana) ) {
|
||||
DrawManaSprite(x,y,type,unit->Type->_MaxMana,unit->Mana);
|
||||
} else if( type->GivesOil || type->GoldMine || type->OilPatch ) {
|
||||
DrawManaSprite(x,y,type,655350,unit->Value);
|
||||
}
|
||||
|
|
|
@ -272,9 +272,6 @@ global void ParsePudUDTA(const char* udta,int length __attribute__((unused)))
|
|||
for( i=0; i<110; ++i ) { // Flag if unit is magic
|
||||
unittype=UnitTypeByWcNum(i);
|
||||
v=Fetch8(udta);
|
||||
if( v==1 ) {
|
||||
v=255; // Compatibility hack 1 = FULL
|
||||
}
|
||||
unittype->Magic=v;
|
||||
}
|
||||
for( i=0; i<110; ++i ) { // Build time * 6 = one second FRAMES
|
||||
|
@ -649,6 +646,9 @@ local void NewSaveUnitType(FILE* file,const UnitType* type,int all)
|
|||
}
|
||||
fprintf(file," 'speed %d\n",type->_Speed);
|
||||
fprintf(file," 'hit-points %d\n",type->_HitPoints);
|
||||
if( all || type->_MaxMana ) {
|
||||
fprintf(file," 'magic %d\n",type->_MaxMana);
|
||||
}
|
||||
if( all || type->Magic ) {
|
||||
fprintf(file," 'magic %d\n",type->Magic);
|
||||
}
|
||||
|
@ -894,295 +894,6 @@ local void NewSaveUnitType(FILE* file,const UnitType* type,int all)
|
|||
fprintf(file,")\n\n");
|
||||
}
|
||||
|
||||
#if 0
|
||||
/**
|
||||
** Save state of an unit-type to file.
|
||||
**
|
||||
** @param type Unit-type to save.
|
||||
** @param file Output file.
|
||||
*/
|
||||
local void OldSaveUnitType(const UnitType* type,FILE* file)
|
||||
{
|
||||
int i;
|
||||
const UnitType* temp;
|
||||
|
||||
fprintf(file,"(define-unit-type \"%s\"",type->Ident);
|
||||
if( strlen(type->Ident)<12 ) {
|
||||
fputs("\t\t",file);
|
||||
} else if( strlen(type->Ident)<20 ) {
|
||||
fputc('\t',file);
|
||||
}
|
||||
fprintf(file,"\t\"%s\"\n",type->Name);
|
||||
fputs(" ;; graphic data\n ",file);
|
||||
if( type->SameSprite ) {
|
||||
fprintf(file,"\"%s\"",type->SameSprite);
|
||||
} else {
|
||||
fprintf(file,"#(");
|
||||
for( i=0; i<4; ++i ) {
|
||||
if( i ) {
|
||||
fputs("\n ",file);
|
||||
}
|
||||
if( type->File[i] ) {
|
||||
fprintf(file,"\"%s\"",type->File[i]);
|
||||
} else {
|
||||
fprintf(file,"()");
|
||||
}
|
||||
}
|
||||
fprintf(file," )");
|
||||
}
|
||||
fprintf(file,"\n '( %3d %3d )\t\t\t;; graphic size\n"
|
||||
,type->Width,type->Height);
|
||||
|
||||
//fprintf(file," \"animations-%s\"\t;; animations\n",type->Ident+5);
|
||||
|
||||
for( temp=UnitTypes; temp->OType && temp!=type ; ++temp ) {
|
||||
if( temp->Animations==type->Animations ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
fprintf(file," \"animations-%s\"\n",temp->Ident+5);
|
||||
|
||||
fprintf(file," \"%s\"\n",IdentOfIcon(type->Icon.Icon));
|
||||
|
||||
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->Construction->Nr
|
||||
,type->_SightRange
|
||||
,type->_HitPoints
|
||||
,type->Magic
|
||||
,type->_Costs[TimeCost]
|
||||
,type->_Costs[GoldCost]
|
||||
,type->_Costs[WoodCost]
|
||||
,type->_Costs[OilCost]
|
||||
,type->_Costs[OreCost]
|
||||
,type->_Costs[StoneCost]
|
||||
,type->_Costs[CoalCost]);
|
||||
|
||||
fprintf(file," ;;Tile Box Size >Attack <Attack ReactC ReactH\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->ReactRangePerson);
|
||||
|
||||
fprintf(file," ;;Armor Prior Damage Pierc WUpgr AUpgr\n");
|
||||
fprintf(file," %6d %5d %6d %6d %7d %7d\n"
|
||||
,type->_Armor
|
||||
,type->Priority
|
||||
,type->_BasicDamage
|
||||
,type->_PiercingDamage
|
||||
,type->WeaponsUpgradable
|
||||
,type->ArmorUpgradable);
|
||||
|
||||
fprintf(file," ;;Decay Annoy\tPoints Food - +\n");
|
||||
fprintf(file," %5d %6d %7d %5d %5d\n"
|
||||
,type->DecayRate
|
||||
,type->AnnoyComputerFactor
|
||||
,type->Points
|
||||
,type->Demand
|
||||
,type->Supply);
|
||||
|
||||
fprintf(file," \"%s\"\n",type->Missile.Name);
|
||||
if( type->CorpseName ) {
|
||||
fprintf(file," '(\"%s\" %d)\n",type->CorpseName,type->CorpseScript);
|
||||
} else {
|
||||
fprintf(file," '()\n");
|
||||
}
|
||||
|
||||
fprintf(file," ");
|
||||
switch( type->UnitType ) {
|
||||
case UnitTypeLand:
|
||||
fprintf(file,"'type-land");
|
||||
break;
|
||||
case UnitTypeFly:
|
||||
fprintf(file,"'type-fly");
|
||||
break;
|
||||
case UnitTypeNaval:
|
||||
fprintf(file,"'type-naval");
|
||||
break;
|
||||
default:
|
||||
fprintf(file,"'type-unknown");
|
||||
break;
|
||||
}
|
||||
fprintf(file,"\n");
|
||||
|
||||
fprintf(file," ");
|
||||
switch( type->MouseAction ) {
|
||||
case MouseActionNone:
|
||||
fprintf(file,"'right-none");
|
||||
break;
|
||||
case MouseActionAttack:
|
||||
fprintf(file,"'right-attack");
|
||||
break;
|
||||
case MouseActionMove:
|
||||
fprintf(file,"'right-move");
|
||||
break;
|
||||
case MouseActionHarvest:
|
||||
fprintf(file,"'right-harvest");
|
||||
break;
|
||||
case MouseActionHaulOil:
|
||||
fprintf(file,"'right-haul-oil");
|
||||
break;
|
||||
case MouseActionDemolish:
|
||||
fprintf(file,"'right-demolish");
|
||||
break;
|
||||
case MouseActionSail:
|
||||
fprintf(file,"'right-sail");
|
||||
break;
|
||||
default:
|
||||
fprintf(file,"'right-unknown");
|
||||
break;
|
||||
}
|
||||
fprintf(file,"\n");
|
||||
|
||||
if( type->CanTarget ) {
|
||||
fprintf(file," ");
|
||||
if( type->CanTarget&CanTargetLand ) {
|
||||
fprintf(file,"'can-target-land ");
|
||||
}
|
||||
if( type->CanTarget&CanTargetSea ) {
|
||||
fprintf(file,"'can-target-sea ");
|
||||
}
|
||||
if( type->CanTarget&CanTargetAir ) {
|
||||
fprintf(file,"'can-target-air ");
|
||||
}
|
||||
if( type->CanTarget&~7 ) {
|
||||
fprintf(file,"'can-target-other ");
|
||||
}
|
||||
fprintf(file,"\n");
|
||||
}
|
||||
|
||||
fprintf(file," ;; flags\n");
|
||||
if( type->LandUnit ) {
|
||||
fprintf(file," 'land-unit\n");
|
||||
}
|
||||
if( type->AirUnit ) {
|
||||
fprintf(file," 'air-unit\n");
|
||||
}
|
||||
if( type->SeaUnit ) {
|
||||
fprintf(file," 'sea-unit\n");
|
||||
}
|
||||
if( type->ExplodeWhenKilled ) {
|
||||
fprintf(file," 'explode-when-killed\n");
|
||||
}
|
||||
if( type->Critter ) {
|
||||
fprintf(file," 'critter\n");
|
||||
}
|
||||
if( type->Building ) {
|
||||
fprintf(file," 'building\n");
|
||||
}
|
||||
if( type->Submarine ) {
|
||||
fprintf(file," 'submarine\n");
|
||||
}
|
||||
if( type->CanSeeSubmarine ) {
|
||||
fprintf(file," 'can-see-submarine\n");
|
||||
}
|
||||
if( type->CowerWorker ) {
|
||||
fprintf(file," 'cower-worker\n");
|
||||
}
|
||||
if( type->Tanker ) {
|
||||
fprintf(file," 'tanker\n");
|
||||
}
|
||||
if( type->Transporter ) {
|
||||
fprintf(file," 'transporter\n");
|
||||
}
|
||||
if( type->GivesOil ) {
|
||||
fprintf(file," 'gives-oil\n");
|
||||
}
|
||||
if( type->StoresGold ) {
|
||||
fprintf(file," 'stores-gold\n");
|
||||
}
|
||||
if( type->Vanishes ) {
|
||||
fprintf(file," 'vanishes\n");
|
||||
}
|
||||
if( type->GroundAttack ) {
|
||||
fprintf(file," 'can-ground-attack\n");
|
||||
}
|
||||
if( type->IsUndead ) {
|
||||
fprintf(file," 'isundead\n");
|
||||
}
|
||||
if( type->ShoreBuilding ) {
|
||||
fprintf(file," 'shore-building\n");
|
||||
}
|
||||
if( type->CanCastSpell ) {
|
||||
fprintf(file," 'can-cast-spell\n");
|
||||
}
|
||||
if( type->StoresWood ) {
|
||||
fprintf(file," 'stores-wood\n");
|
||||
}
|
||||
if( type->CanAttack ) {
|
||||
fprintf(file," 'can-attack\n");
|
||||
}
|
||||
if( type->Tower ) {
|
||||
fprintf(file," 'tower\n");
|
||||
}
|
||||
if( type->OilPatch ) {
|
||||
fprintf(file," 'oil-patch\n");
|
||||
}
|
||||
if( type->GoldMine ) {
|
||||
fprintf(file," 'gives-gold\n");
|
||||
}
|
||||
if( type->Hero ) {
|
||||
fprintf(file," 'hero\n");
|
||||
}
|
||||
if( type->StoresOil ) {
|
||||
fprintf(file," 'stores-oil\n");
|
||||
}
|
||||
if( type->Volatile ) {
|
||||
fprintf(file," 'volatile\n");
|
||||
}
|
||||
if( type->CowerMage ) {
|
||||
fprintf(file," 'cower-mage\n");
|
||||
}
|
||||
if( type->Organic ) {
|
||||
fprintf(file," 'organic\n");
|
||||
}
|
||||
if( type->SelectableByRectangle ) {
|
||||
fprintf(file," 'selectable-by-rectangle\n");
|
||||
}
|
||||
if( type->Teleporter ) {
|
||||
fprintf(file," 'teleporter\n");
|
||||
}
|
||||
|
||||
fprintf(file," ;; sounds\n");
|
||||
if( type->Sound.Selected.Name ) {
|
||||
fprintf(file," #(\"%s\"\n",type->Sound.Selected.Name);
|
||||
} else {
|
||||
fprintf(file," #( ()\n");
|
||||
}
|
||||
if( type->Sound.Acknowledgement.Name ) {
|
||||
fprintf(file," \"%s\"\n",type->Sound.Acknowledgement.Name);
|
||||
} else {
|
||||
fprintf(file," ()\n");
|
||||
}
|
||||
if( type->Sound.Ready.Name ) {
|
||||
fprintf(file," \"%s\"\n",type->Sound.Ready.Name);
|
||||
} else {
|
||||
fprintf(file," ()\n");
|
||||
}
|
||||
if( type->Sound.Help.Name ) {
|
||||
fprintf(file," \"%s\"\n",type->Sound.Help.Name);
|
||||
} else {
|
||||
fprintf(file," ()\n");
|
||||
}
|
||||
if( type->Sound.Dead.Name ) {
|
||||
fprintf(file," \"%s\" )\n",type->Sound.Dead.Name);
|
||||
} else {
|
||||
fprintf(file," () )\n");
|
||||
}
|
||||
if( type->Weapon.Attack.Name ) {
|
||||
fprintf(file," \"%s\" )\n",type->Weapon.Attack.Name);
|
||||
} else {
|
||||
fprintf(file," () )\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
** Save state of an unit-stats to file.
|
||||
**
|
||||
|
|
Loading…
Add table
Reference in a new issue