100 function CheckGearDrowning(Gear: PGear): boolean; |
100 function CheckGearDrowning(Gear: PGear): boolean; |
101 var |
101 var |
102 skipSpeed, skipAngle, skipDecay: hwFloat; |
102 skipSpeed, skipAngle, skipDecay: hwFloat; |
103 i, maxDrops: LongInt; |
103 i, maxDrops: LongInt; |
104 particle: PVisualGear; |
104 particle: PVisualGear; |
105 begin |
105 isSubmersible: boolean; |
|
106 begin |
|
107 isSubmersible:= (Gear = CurrentHedgehog^.Gear) and (CurAmmoGear <> nil) and (CurAmmoGear^.AmmoType = amJetpack); |
106 // probably needs tweaking. might need to be in a case statement based upon gear type |
108 // probably needs tweaking. might need to be in a case statement based upon gear type |
107 if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then |
109 if cWaterLine < hwRound(Gear^.Y) + Gear^.Radius then |
108 begin |
110 begin |
109 skipSpeed := _0_25; |
111 skipSpeed := _0_25; |
110 skipAngle := _1_9; |
112 skipAngle := _1_9; |
119 CheckGearDrowning := false; |
121 CheckGearDrowning := false; |
120 PlaySound(sndSkip) |
122 PlaySound(sndSkip) |
121 end |
123 end |
122 else |
124 else |
123 begin |
125 begin |
124 CheckGearDrowning := true; |
126 if not isSubmersible then |
125 Gear^.State := gstDrowning; |
127 begin |
126 Gear^.RenderTimer := false; |
128 CheckGearDrowning := true; |
127 if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
129 Gear^.State := gstDrowning; |
128 if Gear^.Kind = gtHedgehog then begin |
130 Gear^.RenderTimer := false; |
129 if PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] then begin |
131 if (Gear^.Kind <> gtSniperRifleShot) and (Gear^.Kind <> gtShotgunShot) and (Gear^.Kind <> gtDEagleShot) and (Gear^.Kind <> gtSineGunShot) then |
130 ResurrectHedgehog(Gear); |
132 if Gear^.Kind = gtHedgehog then |
131 end else begin |
133 begin |
132 Gear^.doStep := @doStepDrowningGear; |
134 if PHedgehog(Gear^.Hedgehog)^.Effects[heResurrectable] then |
133 Gear^.State := Gear^.State and (not gstHHDriven); |
135 ResurrectHedgehog(Gear) |
134 AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage); |
136 else |
135 end; |
137 begin |
136 end else begin |
138 Gear^.doStep := @doStepDrowningGear; |
137 Gear^.doStep := @doStepDrowningGear; |
139 Gear^.State := Gear^.State and (not gstHHDriven); |
138 end; |
140 AddCaption(Format(GetEventString(eidDrowned), PHedgehog(Gear^.Hedgehog)^.Name), cWhiteColor, capgrpMessage); |
139 if hwRound(Gear^.Y) < cWaterLine + 64 + Gear^.Radius then |
141 end |
|
142 end |
|
143 else |
|
144 Gear^.doStep := @doStepDrowningGear |
|
145 end; |
|
146 if ((not isSubmersible) and (hwRound(Gear^.Y) < cWaterLine + 64 + Gear^.Radius)) or |
|
147 (isSubmersible and (hwRound(Gear^.Y) < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01))) then |
140 // don't play splash if they are already way past the surface |
148 // don't play splash if they are already way past the surface |
141 PlaySound(sndSplash) |
149 PlaySound(sndSplash) |
142 end; |
150 end; |
143 |
151 |
144 if ((cReducedQuality and rqPlainSplash) = 0) and (hwRound(Gear^.Y) < cWaterLine + 64 + Gear^.Radius) then |
152 if ((cReducedQuality and rqPlainSplash) = 0) and |
|
153 (((not isSubmersible) and (hwRound(Gear^.Y) < cWaterLine + 64 + Gear^.Radius)) or |
|
154 (isSubmersible and (hwRound(Gear^.Y) < cWaterLine + 2 + Gear^.Radius) and ((CurAmmoGear^.Pos = 0) and (CurAmmoGear^.dY < _0_01)))) then |
145 begin |
155 begin |
146 AddVisualGear(hwRound(Gear^.X), cWaterLine, vgtSplash); |
156 AddVisualGear(hwRound(Gear^.X), cWaterLine, vgtSplash); |
147 |
157 |
148 maxDrops := (Gear^.Radius div 2) + hwRound(Gear^.dX * Gear^.Radius * 2) + hwRound(Gear^. |
158 maxDrops := (Gear^.Radius div 2) + hwRound(Gear^.dX * Gear^.Radius * 2) + hwRound(Gear^. |
149 dY * Gear^.Radius * 2); |
159 dY * Gear^.Radius * 2); |
155 particle^.dX := particle^.dX - (Gear^.dX.QWordValue / 42949672960); |
165 particle^.dX := particle^.dX - (Gear^.dX.QWordValue / 42949672960); |
156 particle^.dY := particle^.dY - (Gear^.dY.QWordValue / 21474836480) |
166 particle^.dY := particle^.dY - (Gear^.dY.QWordValue / 21474836480) |
157 end |
167 end |
158 end |
168 end |
159 end; |
169 end; |
|
170 if isSubmersible and (CurAmmoGear^.Pos = 0) then CurAmmoGear^.Pos := 1000 |
160 end |
171 end |
161 else |
172 else |
162 CheckGearDrowning := false |
173 CheckGearDrowning := false; |
163 end; |
174 end; |
164 |
175 |
165 procedure CheckCollision(Gear: PGear); |
176 procedure CheckCollision(Gear: PGear); |
166 begin |
177 begin |
167 if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y) |
178 if TestCollisionXwithGear(Gear, hwSign(Gear^.X)) or TestCollisionYwithGear(Gear, hwSign(Gear^.Y) |
2949 var |
2960 var |
2950 HHGear: PGear; |
2961 HHGear: PGear; |
2951 fuel: LongInt; |
2962 fuel: LongInt; |
2952 move: hwFloat; |
2963 move: hwFloat; |
2953 begin |
2964 begin |
|
2965 if Gear^.Pos > 0 then dec(Gear^.Pos); |
2954 AllInactive := false; |
2966 AllInactive := false; |
2955 HHGear := PHedgehog(Gear^.Hedgehog)^.Gear; |
2967 HHGear := PHedgehog(Gear^.Hedgehog)^.Gear; |
2956 //dec(Gear^.Timer); |
2968 //dec(Gear^.Timer); |
2957 move := _0_1; |
2969 move := _0_2; |
2958 fuel := 50; |
2970 fuel := 50; |
2959 (*if (HHGear^.Message and gmPrecise) <> 0 then |
2971 (*if (HHGear^.Message and gmPrecise) <> 0 then |
2960 begin |
2972 begin |
2961 move:= _0_02; |
2973 move:= _0_02; |
2962 fuel:= 5; |
2974 fuel:= 5; |
2963 end;*) |
2975 end;*) |
2964 |
2976 |
2965 if (HHGear^.Message and gmUp) <> 0 then |
2977 if Gear^.Health > 0 then |
2966 begin |
2978 begin |
2967 if (not HHGear^.dY.isNegative) or (HHGear^.Y > -_256) then |
2979 if (HHGear^.Message and gmUp) <> 0 then |
2968 HHGear^.dY := HHGear^.dY - move; |
2980 begin |
2969 HHGear^.dY := HHGear^.dY - move; |
2981 if (not HHGear^.dY.isNegative) or (HHGear^.Y > -_256) then |
2970 dec(Gear^.Health, fuel); |
2982 HHGear^.dY := HHGear^.dY - move; |
2971 Gear^.MsgParam := Gear^.MsgParam or gmUp; |
2983 dec(Gear^.Health, fuel); |
2972 Gear^.Timer := GameTicks |
2984 Gear^.MsgParam := Gear^.MsgParam or gmUp; |
2973 end; |
2985 Gear^.Timer := GameTicks |
2974 if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true; |
2986 end; |
2975 if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then |
2987 if (HHGear^.Message and gmLeft) <> 0 then move.isNegative := true; |
2976 begin |
2988 if (HHGear^.Message and (gmLeft or gmRight)) <> 0 then |
2977 HHGear^.dX := HHGear^.dX + (move * _0_2); |
2989 begin |
2978 dec(Gear^.Health, fuel div 5); |
2990 HHGear^.dX := HHGear^.dX + (move * _0_1); |
2979 Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight)); |
2991 dec(Gear^.Health, fuel div 5); |
2980 Gear^.Timer := GameTicks |
2992 Gear^.MsgParam := Gear^.MsgParam or (HHGear^.Message and (gmLeft or gmRight)); |
2981 end; |
2993 Gear^.Timer := GameTicks |
|
2994 end |
|
2995 end; |
2982 |
2996 |
2983 // erases them all at once :-/ |
2997 // erases them all at once :-/ |
2984 if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then |
2998 if (Gear^.Timer <> 0) and (GameTicks - Gear^.Timer > 250) then |
2985 begin |
2999 begin |
2986 Gear^.Timer := 0; |
3000 Gear^.Timer := 0; |
2987 Gear^.MsgParam := 0 |
3001 Gear^.MsgParam := 0 |
2988 end; |
3002 end; |
2989 |
3003 |
2990 if Gear^.Health < 0 then Gear^.Health := 0; |
3004 if Gear^.Health < 0 then Gear^.Health := 0; |
2991 if (GameTicks and $3F) = 0 then |
3005 if (GameTicks and $3F) = 0 then |
2992 begin |
3006 begin |
2993 //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate); |
3007 //AddCaption('Fuel: '+inttostr(round(Gear^.Health/20))+'%', cWhiteColor, capgrpAmmostate); |
2994 if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); |
3008 if Gear^.Tex <> nil then FreeTexture(Gear^.Tex); |
2995 Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + |
3009 Gear^.Tex := RenderStringTex(trmsg[sidFuel] + ': ' + inttostr(round(Gear^.Health / 20)) + |
2996 '%', cWhiteColor, fntSmall) |
3010 '%', cWhiteColor, fntSmall) |
2997 end; |
3011 end; |
2998 |
3012 |
2999 if HHGear^.Message and (gmAttack or gmUp or gmPrecise or gmLeft or gmRight) <> 0 then Gear^ |
3013 if HHGear^.Message and (gmAttack or gmUp or gmPrecise or gmLeft or gmRight) <> 0 then Gear^ |
3000 .State := Gear^.State and not gsttmpFlag; |
3014 .State := Gear^.State and not gsttmpFlag; |
3001 HHGear^.Message := HHGear^.Message and not (gmUp or gmPrecise or gmLeft or gmRight); |
3015 HHGear^.Message := HHGear^.Message and not (gmUp or gmPrecise or gmLeft or gmRight); |
3002 HHGear^.State := HHGear^.State or gstMoving; |
3016 HHGear^.State := HHGear^.State or gstMoving; |
3006 // For some reason I need to reapply followgear here, something else grabs it otherwise. |
3020 // For some reason I need to reapply followgear here, something else grabs it otherwise. |
3007 if not bShowAmmoMenu then FollowGear := HHGear; |
3021 if not bShowAmmoMenu then FollowGear := HHGear; |
3008 |
3022 |
3009 if ((Gear^.State and gsttmpFlag) = 0) or (HHGear^.dY < _0) then doStepHedgehogMoving(HHGear); |
3023 if ((Gear^.State and gsttmpFlag) = 0) or (HHGear^.dY < _0) then doStepHedgehogMoving(HHGear); |
3010 |
3024 |
3011 if (Gear^.Health = 0) |
3025 if // (Gear^.Health = 0) |
3012 or (HHGear^.Damage <> 0) |
3026 (HHGear^.Damage <> 0) |
3013 or CheckGearDrowning(HHGear) |
3027 //or CheckGearDrowning(HHGear) |
3014 or (TurnTimeLeft = 0) |
3028 or (cWaterLine + 512 < hwRound(HHGear^.Y)) |
3015 // allow brief ground touches - to be fair on this, might need another counter |
3029 or (TurnTimeLeft = 0) |
3016 or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and TestCollisionYwithGear( |
3030 // allow brief ground touches - to be fair on this, might need another counter |
3017 HHGear, 1)) |
3031 or (((GameTicks and $1FF) = 0) and (not HHGear^.dY.isNegative) and TestCollisionYwithGear( |
3018 or ((Gear^.Message and gmAttack) <> 0) then |
3032 HHGear, 1)) |
3019 begin |
3033 or ((Gear^.Message and gmAttack) <> 0) then |
|
3034 begin |
3020 with HHGear^ do |
3035 with HHGear^ do |
3021 begin |
3036 begin |
3022 Message := 0; |
3037 Message := 0; |
3023 Active := true; |
3038 Active := true; |
3024 State := State or gstMoving |
3039 State := State or gstMoving |