27 |
27 |
28 procedure initModule; |
28 procedure initModule; |
29 procedure freeModule; |
29 procedure freeModule; |
30 |
30 |
31 function AddTeam(TeamColor: Longword): PTeam; |
31 function AddTeam(TeamColor: Longword): PTeam; |
|
32 function SetMissionTeam(TeamColor: Longword): PTeam; |
32 procedure SwitchHedgehog; |
33 procedure SwitchHedgehog; |
33 procedure AfterSwitchHedgehog; |
34 procedure AfterSwitchHedgehog; |
34 procedure InitTeams; |
35 procedure InitTeams; |
35 function TeamSize(p: PTeam): Longword; |
36 function TeamSize(p: PTeam): Longword; |
36 procedure RecountTeamHealth(team: PTeam); |
37 procedure RecountTeamHealth(team: PTeam); |
472 begin |
473 begin |
473 AddVoice(sndHmm, CurrentTeam^.voicepack) |
474 AddVoice(sndHmm, CurrentTeam^.voicepack) |
474 end; |
475 end; |
475 ReadyTimeLeft:= 0 |
476 ReadyTimeLeft:= 0 |
476 end; |
477 end; |
|
478 end; |
|
479 |
|
480 function SetMissionTeam(TeamColor: Longword): PTeam; |
|
481 var team: PTeam; |
|
482 begin |
|
483 New(team); |
|
484 if checkFails(team <> nil, 'AddTeam: team = nil', true) then exit(nil); |
|
485 FillChar(team^, sizeof(TTeam), 0); |
|
486 team^.HedgehogsNumber:= 0; |
|
487 |
|
488 CurrentTeam:= team; |
|
489 MissionTeam:= team; |
|
490 SetMissionTeam:= team; |
477 end; |
491 end; |
478 |
492 |
479 function AddTeam(TeamColor: Longword): PTeam; |
493 function AddTeam(TeamColor: Longword): PTeam; |
480 var team: PTeam; |
494 var team: PTeam; |
481 c: LongInt; |
495 c: LongInt; |
677 Gear^.State:= (Gear^.State or gstHHGone) and (not gstHHDriven) |
691 Gear^.State:= (Gear^.State or gstHHGone) and (not gstHHDriven) |
678 end |
692 end |
679 end |
693 end |
680 end; |
694 end; |
681 |
695 |
|
696 procedure chAddMissionHH(var id: shortstring); |
|
697 var s: shortstring; |
|
698 Health: LongInt; |
|
699 begin |
|
700 s:= ''; |
|
701 if (not isDeveloperMode) then |
|
702 exit; |
|
703 if checkFails((CurrentTeam <> nil), 'Can''t add hedgehogs yet, add a team first!', true) then exit; |
|
704 with CurrentTeam^ do |
|
705 begin |
|
706 if checkFails(HedgehogsNumber<=cMaxHHIndex, 'Can''t add hedgehog to "' + TeamName + '"! (already ' + intToStr(HedgehogsNumber) + ' hogs)', true) then exit; |
|
707 SplitBySpace(id, s); |
|
708 CurrentHedgehog:= @Hedgehogs[HedgehogsNumber]; |
|
709 CurrentHedgehog^.BotLevel:= StrToInt(id); |
|
710 CurrentHedgehog^.Team:= CurrentTeam; |
|
711 SplitBySpace(s, id); |
|
712 Health:= StrToInt(s); |
|
713 if checkFails((Health > 0) and (Health <= cMaxHogHealth), 'Invalid hedgehog health (must be between 1 and '+IntToStr(cMaxHogHealth)+')', true) then exit; |
|
714 CurrentHedgehog^.Name:= id; |
|
715 CurrentHedgehog^.InitialHealth:= Health; |
|
716 inc(HedgehogsNumber) |
|
717 end |
|
718 end; |
|
719 |
682 procedure chAddHH(var id: shortstring); |
720 procedure chAddHH(var id: shortstring); |
683 var s: shortstring; |
721 var s: shortstring; |
684 Gear: PGear; |
722 Gear: PGear; |
685 begin |
723 begin |
686 s:= ''; |
724 s:= ''; |
742 Color:= StrToInt(cs); |
780 Color:= StrToInt(cs); |
743 |
781 |
744 // color is always little endian so the mask must be constant also in big endian archs |
782 // color is always little endian so the mask must be constant also in big endian archs |
745 Color:= Color or $FF000000; |
783 Color:= Color or $FF000000; |
746 AddTeam(Color); |
784 AddTeam(Color); |
747 |
785 |
748 if CurrentTeam <> nil then |
786 if CurrentTeam <> nil then |
749 begin |
787 begin |
750 CurrentTeam^.TeamName:= ts; |
788 CurrentTeam^.TeamName:= ts; |
751 CurrentTeam^.PlayerHash:= s; |
789 CurrentTeam^.PlayerHash:= s; |
752 loadTeamBinds(ts); |
790 loadTeamBinds(ts); |
753 |
791 |
754 if GameType in [gmtDemo, gmtSave, gmtRecord] then |
792 if GameType in [gmtDemo, gmtSave, gmtRecord] then |
755 CurrentTeam^.ExtDriven:= true; |
793 CurrentTeam^.ExtDriven:= true; |
756 |
794 |
|
795 CurrentTeam^.voicepack:= AskForVoicepack('Default') |
|
796 end |
|
797 end |
|
798 end; |
|
799 |
|
800 procedure chSetMissionTeam(var s: shortstring); |
|
801 var Color: Longword; |
|
802 ts, cs: shortstring; |
|
803 begin |
|
804 cs:= ''; |
|
805 ts:= ''; |
|
806 if isDeveloperMode then |
|
807 begin |
|
808 SplitBySpace(s, cs); |
|
809 SplitBySpace(cs, ts); |
|
810 Color:= StrToInt(cs); |
|
811 |
|
812 // color is always little endian so the mask must be constant also in big endian archs |
|
813 Color:= Color or $FF000000; |
|
814 SetMissionTeam(Color); |
|
815 |
|
816 if CurrentTeam <> nil then |
|
817 begin |
|
818 CurrentTeam^.TeamName:= ts; |
|
819 CurrentTeam^.PlayerHash:= s; |
757 CurrentTeam^.voicepack:= AskForVoicepack('Default') |
820 CurrentTeam^.voicepack:= AskForVoicepack('Default') |
758 end |
821 end |
759 end |
822 end |
760 end; |
823 end; |
761 |
824 |
939 end; |
1002 end; |
940 |
1003 |
941 procedure initModule; |
1004 procedure initModule; |
942 begin |
1005 begin |
943 RegisterVariable('addhh', @chAddHH, false); |
1006 RegisterVariable('addhh', @chAddHH, false); |
|
1007 RegisterVariable('addmisshh', @chAddMissionHH, false); |
944 RegisterVariable('addteam', @chAddTeam, false); |
1008 RegisterVariable('addteam', @chAddTeam, false); |
|
1009 RegisterVariable('setmissteam', @chSetMissionTeam, false); |
945 RegisterVariable('hhcoords', @chSetHHCoords, false); |
1010 RegisterVariable('hhcoords', @chSetHHCoords, false); |
946 RegisterVariable('bind', @chBind, true ); |
1011 RegisterVariable('bind', @chBind, true ); |
947 RegisterVariable('teamgone', @chTeamGone, true ); |
1012 RegisterVariable('teamgone', @chTeamGone, true ); |
948 RegisterVariable('teamback', @chTeamBack, true ); |
1013 RegisterVariable('teamback', @chTeamBack, true ); |
949 RegisterVariable('fort' , @chFort , false); |
1014 RegisterVariable('fort' , @chFort , false); |