65 if AliveCount = 0 then |
66 if AliveCount = 0 then |
66 begin // draw |
67 begin // draw |
67 AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); |
68 AddCaption(trmsg[sidDraw], cWhiteColor, capgrpGameState); |
68 SendStat(siGameResult, trmsg[sidDraw]); |
69 SendStat(siGameResult, trmsg[sidDraw]); |
69 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
70 AddGear(0, 0, gtATFinishGame, 0, _0, _0, 3000) |
70 end else // win |
71 end |
|
72 else // win |
71 with AliveClan^ do |
73 with AliveClan^ do |
72 begin |
74 begin |
73 if TeamsNumber = 1 then |
75 if TeamsNumber = 1 then |
74 s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName) // team wins |
76 s:= Format(shortstring(trmsg[sidWinner]), Teams[0]^.TeamName) // team wins |
75 else |
77 else |
183 var i, t: LongInt; |
189 var i, t: LongInt; |
184 CurWeapon: PAmmo; |
190 CurWeapon: PAmmo; |
185 |
191 |
186 begin |
192 begin |
187 if PlacingHogs then |
193 if PlacingHogs then |
188 begin |
194 begin |
189 PlacingHogs:= false; |
195 PlacingHogs:= false; |
190 for t:= 0 to Pred(TeamsCount) do |
196 for t:= 0 to Pred(TeamsCount) do |
191 for i:= 0 to cMaxHHIndex do |
197 for i:= 0 to cMaxHHIndex do |
192 if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then |
198 if (TeamsArray[t]^.Hedgehogs[i].Gear <> nil) and (TeamsArray[t]^.Hedgehogs[i].Unplaced) then |
193 PlacingHogs:= true; |
199 PlacingHogs:= true; |
194 |
200 |
195 if not PlacingHogs then // Reset various things I mucked with |
201 if not PlacingHogs then // Reset various things I mucked with |
196 begin |
202 begin |
197 for i:= 0 to ClansCount do |
203 for i:= 0 to ClansCount do |
198 if ClansArray[i] <> nil then ClansArray[i]^.TurnNumber:= 0; |
204 if ClansArray[i] <> nil then |
199 ResetWeapons |
205 ClansArray[i]^.TurnNumber:= 0; |
200 end |
206 ResetWeapons |
201 end; |
207 end |
|
208 end; |
202 |
209 |
203 inc(CurrentTeam^.Clan^.TurnNumber); |
210 inc(CurrentTeam^.Clan^.TurnNumber); |
204 |
211 |
205 CurWeapon:= GetAmmoEntry(CurrentHedgehog^); |
212 CurWeapon:= GetAmmoEntry(CurrentHedgehog^); |
206 if CurWeapon^.Count = 0 then CurrentHedgehog^.CurAmmoType:= amNothing; |
213 if CurWeapon^.Count = 0 then |
|
214 CurrentHedgehog^.CurAmmoType:= amNothing; |
207 |
215 |
208 with CurrentHedgehog^ do |
216 with CurrentHedgehog^ do |
209 begin |
217 begin |
210 with Gear^ do |
218 with Gear^ do |
211 begin |
219 begin |
233 AddFileLog('Wind = '+FloatToStr(cWindSpeed)); |
241 AddFileLog('Wind = '+FloatToStr(cWindSpeed)); |
234 end; |
242 end; |
235 |
243 |
236 ApplyAmmoChanges(CurrentHedgehog^); |
244 ApplyAmmoChanges(CurrentHedgehog^); |
237 |
245 |
238 if (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then SetBinds(CurrentTeam^.Binds); |
246 if (not CurrentTeam^.ExtDriven) and (CurrentHedgehog^.BotLevel = 0) then |
|
247 SetBinds(CurrentTeam^.Binds); |
239 |
248 |
240 bShowFinger:= true; |
249 bShowFinger:= true; |
241 |
250 |
242 if PlacingHogs then |
251 if PlacingHogs then |
243 begin |
252 begin |
244 if CurrentHedgehog^.Unplaced then TurnTimeLeft:= 15000 |
253 if CurrentHedgehog^.Unplaced then |
|
254 TurnTimeLeft:= 15000 |
245 else TurnTimeLeft:= 0 |
255 else TurnTimeLeft:= 0 |
246 end |
256 end |
247 else if ((GameFlags and gfTagTeam) <> 0) and (not NextClan) then |
257 else if ((GameFlags and gfTagTeam) <> 0) and (not NextClan) then |
248 begin |
258 begin |
249 if TagTurnTimeLeft <> 0 then TurnTimeLeft:= TagTurnTimeLeft; |
259 if TagTurnTimeLeft <> 0 then |
|
260 TurnTimeLeft:= TagTurnTimeLeft; |
250 TagTurnTimeLeft:= 0; |
261 TagTurnTimeLeft:= 0; |
251 end |
262 end |
252 else |
263 else |
253 begin |
264 begin |
254 TurnTimeLeft:= cHedgehogTurnTime; |
265 TurnTimeLeft:= cHedgehogTurnTime; |
259 begin |
270 begin |
260 if CurrentTeam^.ExtDriven then |
271 if CurrentTeam^.ExtDriven then |
261 AddVoice(sndIllGetYou, CurrentTeam^.voicepack) |
272 AddVoice(sndIllGetYou, CurrentTeam^.voicepack) |
262 else |
273 else |
263 AddVoice(sndYesSir, CurrentTeam^.voicepack); |
274 AddVoice(sndYesSir, CurrentTeam^.voicepack); |
264 if PlacingHogs or (cHedgehogTurnTime < 1000000) then ReadyTimeLeft:= cReadyDelay; |
275 if PlacingHogs or (cHedgehogTurnTime < 1000000) then |
|
276 ReadyTimeLeft:= cReadyDelay; |
265 AddCaption(Format(shortstring(trmsg[sidReady]), CurrentTeam^.TeamName), cWhiteColor, capgrpGameState) |
277 AddCaption(Format(shortstring(trmsg[sidReady]), CurrentTeam^.TeamName), cWhiteColor, capgrpGameState) |
266 end |
278 end |
267 else |
279 else |
268 begin |
280 begin |
269 if TurnTimeLeft > 0 then |
281 if TurnTimeLeft > 0 then |
342 LocalAmmo:= Hedgehogs[0].AmmoStore |
355 LocalAmmo:= Hedgehogs[0].AmmoStore |
343 end; |
356 end; |
344 th:= 0; |
357 th:= 0; |
345 for i:= 0 to cMaxHHIndex do |
358 for i:= 0 to cMaxHHIndex do |
346 if Hedgehogs[i].Gear <> nil then |
359 if Hedgehogs[i].Gear <> nil then |
347 inc(th, Hedgehogs[i].Gear^.Health); |
360 inc(th, Hedgehogs[i].Gear^.Health); |
348 if th > MaxTeamHealth then MaxTeamHealth:= th; |
361 if th > MaxTeamHealth then |
|
362 MaxTeamHealth:= th; |
349 // Some initial King buffs |
363 // Some initial King buffs |
350 if (GameFlags and gfKing) <> 0 then |
364 if (GameFlags and gfKing) <> 0 then |
351 begin |
365 begin |
352 Hedgehogs[0].King:= true; |
366 Hedgehogs[0].King:= true; |
353 Hedgehogs[0].Hat:= 'crown'; |
367 Hedgehogs[0].Hat:= 'crown'; |
405 TeamHealth:= NewTeamHealthBarWidth; |
422 TeamHealth:= NewTeamHealthBarWidth; |
406 if NewTeamHealthBarWidth > MaxTeamHealth then |
423 if NewTeamHealthBarWidth > MaxTeamHealth then |
407 begin |
424 begin |
408 MaxTeamHealth:= NewTeamHealthBarWidth; |
425 MaxTeamHealth:= NewTeamHealthBarWidth; |
409 RecountAllTeamsHealth; |
426 RecountAllTeamsHealth; |
410 end else if NewTeamHealthBarWidth > 0 then NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
427 end else if NewTeamHealthBarWidth > 0 then |
|
428 NewTeamHealthBarWidth:= (NewTeamHealthBarWidth * cTeamHealthWidth) div MaxTeamHealth |
411 end; |
429 end; |
412 |
430 |
413 RecountClanHealth(team^.Clan); |
431 RecountClanHealth(team^.Clan); |
414 |
432 |
415 AddVisualGear(0, 0, vgtTeamHealthSorter) |
433 AddVisualGear(0, 0, vgtTeamHealthSorter) |
443 |
461 |
444 procedure chAddHH(var id: shortstring); |
462 procedure chAddHH(var id: shortstring); |
445 var s: shortstring; |
463 var s: shortstring; |
446 Gear: PGear; |
464 Gear: PGear; |
447 begin |
465 begin |
448 s:= ''; |
466 s:= ''; |
449 if (not isDeveloperMode) or (CurrentTeam = nil) then exit; |
467 if (not isDeveloperMode) or (CurrentTeam = nil) then |
450 with CurrentTeam^ do |
468 exit; |
451 begin |
469 with CurrentTeam^ do |
452 SplitBySpace(id, s); |
470 begin |
453 CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
471 SplitBySpace(id, s); |
454 val(id, CurrentHedgehog^.BotLevel); |
472 CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
455 Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
473 val(id, CurrentHedgehog^.BotLevel); |
456 SplitBySpace(s, id); |
474 Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0); |
457 val(s, Gear^.Health); |
475 SplitBySpace(s, id); |
458 TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
476 val(s, Gear^.Health); |
459 Gear^.Hedgehog^.Team:= CurrentTeam; |
477 TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true); |
460 if (GameFlags and gfSharedAmmo) <> 0 then CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex |
478 Gear^.Hedgehog^.Team:= CurrentTeam; |
461 else if (GameFlags and gfPerHogAmmo) <> 0 then |
479 if (GameFlags and gfSharedAmmo) <> 0 then |
462 begin |
480 CurrentHedgehog^.AmmoStore:= Clan^.ClanIndex |
463 AddAmmoStore; |
481 else if (GameFlags and gfPerHogAmmo) <> 0 then |
464 CurrentHedgehog^.AmmoStore:= StoreCnt - 1 |
482 begin |
465 end |
483 AddAmmoStore; |
466 else CurrentHedgehog^.AmmoStore:= TeamsCount - 1; |
484 CurrentHedgehog^.AmmoStore:= StoreCnt - 1 |
467 CurrentHedgehog^.Gear:= Gear; |
|
468 CurrentHedgehog^.Name:= id; |
|
469 CurrentHedgehog^.InitialHealth:= Gear^.Health; |
|
470 CurrHedgehog:= HedgehogsNumber; |
|
471 inc(HedgehogsNumber) |
|
472 end |
485 end |
|
486 else CurrentHedgehog^.AmmoStore:= TeamsCount - 1; |
|
487 CurrentHedgehog^.Gear:= Gear; |
|
488 CurrentHedgehog^.Name:= id; |
|
489 CurrentHedgehog^.InitialHealth:= Gear^.Health; |
|
490 CurrHedgehog:= HedgehogsNumber; |
|
491 inc(HedgehogsNumber) |
|
492 end |
473 end; |
493 end; |
474 |
494 |
475 procedure chAddTeam(var s: shortstring); |
495 procedure chAddTeam(var s: shortstring); |
476 var Color: Longword; |
496 var Color: Longword; |
477 ts, cs: shortstring; |
497 ts, cs: shortstring; |
478 begin |
498 begin |
479 cs:= ''; |
499 cs:= ''; |
480 ts:= ''; |
500 ts:= ''; |
481 if isDeveloperMode then |
501 if isDeveloperMode then |
482 begin |
502 begin |
483 SplitBySpace(s, cs); |
503 SplitBySpace(s, cs); |
484 SplitBySpace(cs, ts); |
504 SplitBySpace(cs, ts); |
485 val(cs, Color); |
505 val(cs, Color); |
486 TryDo(Color <> 0, 'Error: black team color', true); |
506 TryDo(Color <> 0, 'Error: black team color', true); |
487 |
507 |
488 // color is always little endian so the mask must be constant also in big endian archs |
508 // color is always little endian so the mask must be constant also in big endian archs |
489 Color:= Color or $FF000000; |
509 Color:= Color or $FF000000; |
490 |
510 AddTeam(Color); |
491 AddTeam(Color); |
511 CurrentTeam^.TeamName:= ts; |
492 CurrentTeam^.TeamName:= ts; |
512 CurrentTeam^.PlayerHash:= s; |
493 CurrentTeam^.PlayerHash:= s; |
513 if GameType in [gmtDemo, gmtSave] then |
494 if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true; |
514 CurrentTeam^.ExtDriven:= true; |
495 |
515 |
496 CurrentTeam^.voicepack:= AskForVoicepack('Default') |
516 CurrentTeam^.voicepack:= AskForVoicepack('Default') |
497 end |
517 end |
498 end; |
518 end; |
499 |
519 |
500 procedure chSetHHCoords(var x: shortstring); |
520 procedure chSetHHCoords(var x: shortstring); |
501 var y: shortstring; |
521 var y: shortstring; |
502 t: Longint; |
522 t: Longint; |
503 begin |
523 begin |
504 y:= ''; |
524 y:= ''; |
505 if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then exit; |
525 if (not isDeveloperMode) or (CurrentHedgehog = nil) or (CurrentHedgehog^.Gear = nil) then |
|
526 exit; |
506 SplitBySpace(x, y); |
527 SplitBySpace(x, y); |
507 val(x, t); |
528 val(x, t); |
508 CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
529 CurrentHedgehog^.Gear^.X:= int2hwFloat(t); |
509 val(y, t); |
530 val(y, t); |
510 CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
531 CurrentHedgehog^.Gear^.Y:= int2hwFloat(t) |
513 procedure chBind(var id: shortstring); |
534 procedure chBind(var id: shortstring); |
514 var s: shortstring; |
535 var s: shortstring; |
515 b: LongInt; |
536 b: LongInt; |
516 begin |
537 begin |
517 s:= ''; |
538 s:= ''; |
518 if CurrentTeam = nil then exit; |
539 if CurrentTeam = nil then |
|
540 exit; |
519 SplitBySpace(id, s); |
541 SplitBySpace(id, s); |
520 if s[1]='"' then Delete(s, 1, 1); |
542 if s[1]='"' then |
521 if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1); |
543 Delete(s, 1, 1); |
|
544 if s[byte(s[0])]='"' then |
|
545 Delete(s, byte(s[0]), 1); |
522 b:= KeyNameToCode(id); |
546 b:= KeyNameToCode(id); |
523 if b = 0 then OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
547 if b = 0 then |
524 else CurrentTeam^.Binds[b]:= s |
548 OutError(errmsgUnknownVariable + ' "' + id + '"', false) |
|
549 else |
|
550 CurrentTeam^.Binds[b]:= s |
525 end; |
551 end; |
526 |
552 |
527 procedure chTeamGone(var s:shortstring); |
553 procedure chTeamGone(var s:shortstring); |
528 var t: LongInt; |
554 var t: LongInt; |
529 begin |
555 begin |
530 t:= 0; |
556 t:= 0; |
531 while (t < cMaxTeams) |
557 while (t < cMaxTeams) and (TeamsArray[t] <> nil) and (TeamsArray[t]^.TeamName <> s) do |
532 and (TeamsArray[t] <> nil) |
558 inc(t); |
533 and (TeamsArray[t]^.TeamName <> s) do inc(t); |
559 if (t = cMaxTeams) or (TeamsArray[t] = nil) then |
534 if (t = cMaxTeams) or (TeamsArray[t] = nil) then exit; |
560 exit; |
535 |
561 |
536 with TeamsArray[t]^ do |
562 with TeamsArray[t]^ do |
537 begin |
563 begin |
538 AddChatString('** '+ TeamName + ' is gone'); |
564 AddChatString('** '+ TeamName + ' is gone'); |
539 hasGone:= true |
565 hasGone:= true |
560 RecountAllTeamsHealth(); |
586 RecountAllTeamsHealth(); |
561 end; |
587 end; |
562 |
588 |
563 procedure initModule; |
589 procedure initModule; |
564 begin |
590 begin |
565 RegisterVariable('addhh', vtCommand, @chAddHH, false); |
591 RegisterVariable('addhh', vtCommand, @chAddHH, false); |
566 RegisterVariable('addteam', vtCommand, @chAddTeam, false); |
592 RegisterVariable('addteam', vtCommand, @chAddTeam, false); |
567 RegisterVariable('hhcoords', vtCommand, @chSetHHCoords, false); |
593 RegisterVariable('hhcoords', vtCommand, @chSetHHCoords, false); |
568 RegisterVariable('bind', vtCommand, @chBind, true ); |
594 RegisterVariable('bind', vtCommand, @chBind, true ); |
569 RegisterVariable('teamgone', vtCommand, @chTeamGone, true ); |
595 RegisterVariable('teamgone', vtCommand, @chTeamGone, true ); |
570 RegisterVariable('finish', vtCommand, @chFinish, true ); // all teams gone |
596 RegisterVariable('finish', vtCommand, @chFinish, true ); // all teams gone |
571 |
597 |
572 CurrentTeam:= nil; |
598 CurrentTeam:= nil; |
573 PreviousTeam:= nil; |
599 PreviousTeam:= nil; |
574 CurrentHedgehog:= nil; |
600 CurrentHedgehog:= nil; |
575 TeamsCount:= 0; |
601 TeamsCount:= 0; |
576 ClansCount:= 0; |
602 ClansCount:= 0; |
577 LocalClan:= -1; |
603 LocalClan:= -1; |
578 LocalTeam:= -1; |
604 LocalTeam:= -1; |
579 LocalAmmo:= -1; |
605 LocalAmmo:= -1; |
580 GameOver:= false; |
606 GameOver:= false; |
581 NextClan:= true; |
607 NextClan:= true; |
582 end; |
608 end; |
583 |
609 |
584 procedure freeModule; |
610 procedure freeModule; |
585 var i, h: LongWord; |
611 var i, h: LongWord; |
586 begin |
612 begin |
587 if TeamsCount > 0 then |
613 if TeamsCount > 0 then |
588 begin |
614 begin |
589 for i:= 0 to Pred(TeamsCount) do |
615 for i:= 0 to Pred(TeamsCount) do |
590 begin |
616 begin |
591 for h:= 0 to cMaxHHIndex do |
617 for h:= 0 to cMaxHHIndex do |
592 if TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil then |
618 if TeamsArray[i]^.Hedgehogs[h].GearHidden <> nil then |
593 Dispose(TeamsArray[i]^.Hedgehogs[h].GearHidden); |
619 Dispose(TeamsArray[i]^.Hedgehogs[h].GearHidden); |
594 Dispose(TeamsArray[i]); |
620 Dispose(TeamsArray[i]); |
595 end; |
621 end; |
596 for i:= 0 to Pred(ClansCount) do Dispose(ClansArray[i]); |
622 for i:= 0 to Pred(ClansCount) do |
597 end; |
623 Dispose(ClansArray[i]); |
598 TeamsCount:= 0; |
624 end; |
599 ClansCount:= 0; |
625 TeamsCount:= 0; |
|
626 ClansCount:= 0; |
600 end; |
627 end; |
601 |
628 |
602 end. |
629 end. |