hedgewars/uGears.pas
changeset 14472 8d5034f7cc19
parent 14410 e72ffa27492d
child 14564 599f136d4f32
equal deleted inserted replaced
14471:c5033a95fd7b 14472:8d5034f7cc19
  1080     end;
  1080     end;
  1081 end;}
  1081 end;}
  1082 
  1082 
  1083 
  1083 
  1084 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content, cnt: Longword): PGear;
  1084 function SpawnCustomCrateAt(x, y: LongInt; crate: TCrateType; content, cnt: Longword): PGear;
  1085 begin
  1085 var gear: PGear;
  1086     FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0);
  1086 begin
       
  1087     gear := AddGear(x, y, gtCase, 0, _0, _0, 0);
       
  1088     if(FinishedTurnsTotal > -1) then
       
  1089         FollowGear:= gear;
  1087     cCaseFactor := 0;
  1090     cCaseFactor := 0;
  1088 
  1091 
  1089     if (crate <> HealthCrate) and (content > ord(High(TAmmoType))) then
  1092     if (crate <> HealthCrate) and (content > ord(High(TAmmoType))) then
  1090         content := ord(High(TAmmoType));
  1093         content := ord(High(TAmmoType));
  1091 
  1094 
  1092     FollowGear^.Power:= cnt;
  1095     gear^.Power:= cnt;
  1093 
  1096 
  1094     case crate of
  1097     case crate of
  1095         HealthCrate:
  1098         HealthCrate:
  1096             begin
  1099             begin
  1097             FollowGear^.Pos := posCaseHealth;
  1100             gear^.Pos := posCaseHealth;
  1098             // health crate is smaller than the other crates
  1101             // health crate is smaller than the other crates
  1099             FollowGear^.Radius := cCaseHealthRadius;
  1102             gear^.Radius := cCaseHealthRadius;
  1100             FollowGear^.Health := content;
  1103             gear^.Health := content;
  1101             AddCaption(GetEventString(eidNewHealthPack), capcolDefault, capgrpAmmoInfo);
  1104             if(FinishedTurnsTotal > -1) then
       
  1105                 AddCaption(GetEventString(eidNewHealthPack), capcolDefault, capgrpAmmoInfo);
  1102             end;
  1106             end;
  1103         AmmoCrate:
  1107         AmmoCrate:
  1104             begin
  1108             begin
  1105             FollowGear^.Pos := posCaseAmmo;
  1109             gear^.Pos := posCaseAmmo;
  1106             FollowGear^.AmmoType := TAmmoType(content);
  1110             gear^.AmmoType := TAmmoType(content);
  1107             AddCaption(GetEventString(eidNewAmmoPack), capcolDefault, capgrpAmmoInfo);
  1111             if(FinishedTurnsTotal > -1) then
       
  1112                 AddCaption(GetEventString(eidNewAmmoPack), capcolDefault, capgrpAmmoInfo);
  1108             end;
  1113             end;
  1109         UtilityCrate:
  1114         UtilityCrate:
  1110             begin
  1115             begin
  1111             FollowGear^.Pos := posCaseUtility;
  1116             gear^.Pos := posCaseUtility;
  1112             FollowGear^.AmmoType := TAmmoType(content);
  1117             gear^.AmmoType := TAmmoType(content);
  1113             AddCaption(GetEventString(eidNewUtilityPack), capColDefault, capgrpAmmoInfo);
  1118             if(FinishedTurnsTotal > -1) then
       
  1119                 AddCaption(GetEventString(eidNewUtilityPack), capColDefault, capgrpAmmoInfo);
  1114             end;
  1120             end;
  1115     end;
  1121     end;
  1116 
  1122 
  1117     if ( (x = 0) and (y = 0) ) then
  1123     if ( (x = 0) and (y = 0) ) then
  1118         FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1124         FindPlace(gear, true, 0, LAND_WIDTH);
  1119 
  1125 
  1120     SpawnCustomCrateAt := FollowGear;
  1126     SpawnCustomCrateAt := gear;
  1121 end;
  1127 end;
  1122 
  1128 
  1123 function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean): PGear;
  1129 function SpawnFakeCrateAt(x, y: LongInt; crate: TCrateType; explode: boolean; poison: boolean): PGear;
  1124 begin
  1130 var gear: PGear;
  1125     FollowGear := AddGear(x, y, gtCase, 0, _0, _0, 0);
  1131 begin
       
  1132     gear := AddGear(x, y, gtCase, 0, _0, _0, 0);
       
  1133     if(FinishedTurnsTotal > -1) then
       
  1134         FollowGear:= gear;
  1126     cCaseFactor := 0;
  1135     cCaseFactor := 0;
  1127     FollowGear^.Pos := posCaseDummy;
  1136     gear^.Pos := posCaseDummy;
  1128 
  1137 
  1129     if explode then
  1138     if explode then
  1130         FollowGear^.Pos := FollowGear^.Pos + posCaseExplode;
  1139         gear^.Pos := gear^.Pos + posCaseExplode;
  1131     if poison then
  1140     if poison then
  1132         FollowGear^.Pos := FollowGear^.Pos + posCasePoison;
  1141         gear^.Pos := gear^.Pos + posCasePoison;
  1133 
  1142 
  1134     case crate of
  1143     case crate of
  1135         HealthCrate:
  1144         HealthCrate:
  1136             begin
  1145             begin
  1137             FollowGear^.Pos := FollowGear^.Pos + posCaseHealth;
  1146             gear^.Pos := gear^.Pos + posCaseHealth;
  1138             // health crate is smaller than the other crates
  1147             // health crate is smaller than the other crates
  1139             FollowGear^.Radius := cCaseHealthRadius;
  1148             gear^.Radius := cCaseHealthRadius;
  1140             AddCaption(GetEventString(eidNewHealthPack), capcolDefault, capgrpAmmoInfo);
  1149             if(FinishedTurnsTotal > -1) then
       
  1150                 AddCaption(GetEventString(eidNewHealthPack), capcolDefault, capgrpAmmoInfo);
  1141             end;
  1151             end;
  1142         AmmoCrate:
  1152         AmmoCrate:
  1143             begin
  1153             begin
  1144             FollowGear^.Pos := FollowGear^.Pos + posCaseAmmo;
  1154             gear^.Pos := gear^.Pos + posCaseAmmo;
  1145             AddCaption(GetEventString(eidNewAmmoPack), capcolDefault, capgrpAmmoInfo);
  1155             if(FinishedTurnstotal > -1) then
       
  1156                 AddCaption(GetEventString(eidNewAmmoPack), capcolDefault, capgrpAmmoInfo);
  1146             end;
  1157             end;
  1147         UtilityCrate:
  1158         UtilityCrate:
  1148             begin
  1159             begin
  1149             FollowGear^.Pos := FollowGear^.Pos + posCaseUtility;
  1160             gear^.Pos := gear^.Pos + posCaseUtility;
  1150             AddCaption(GetEventString(eidNewUtilityPack), capcolDefault, capgrpAmmoInfo);
  1161             if(FinishedTurnsTotal > -1) then
       
  1162                 AddCaption(GetEventString(eidNewUtilityPack), capcolDefault, capgrpAmmoInfo);
  1151             end;
  1163             end;
  1152     end;
  1164     end;
  1153 
  1165 
  1154     if ( (x = 0) and (y = 0) ) then
  1166     if ( (x = 0) and (y = 0) ) then
  1155         FindPlace(FollowGear, true, 0, LAND_WIDTH);
  1167         FindPlace(gear, true, 0, LAND_WIDTH);
  1156 
  1168 
  1157     SpawnFakeCrateAt := FollowGear;
  1169     SpawnFakeCrateAt := gear;
  1158 end;
  1170 end;
  1159 
  1171 
  1160 procedure StartSuddenDeath();
  1172 procedure StartSuddenDeath();
  1161 begin
  1173 begin
  1162     if SuddenDeath then
  1174     if SuddenDeath then