0 Members and 1 Guest are viewing this topic.
const Color = $EE30DDEE; MaxDist = 65; MaxHealth = 150; HealRate = 8; AutoRelinquish = true; // once the medic heals completely or is dead, medic becomes unclaimedvar Medic: array[1..2] of byte;procedure AppOnIdle(Ticks: integer);var Relinquish: boolean; i,j: byte; X,Y: single;begin for i := 1 to 2 do begin GetPlayerXY(Medic[i],X,Y); if Medic[i] <> 0 then begin Relinquish := true; if GetPlayerStat(Medic[i],'Alive') = true then for j := 1 to 32 do if (GetPlayerStat(j,'Active') = true) then if (GetPlayerStat(j,'Alive') = true) and (GetPlayerStat(Medic[i],'Team') = GetPlayerStat(j,'Team')) and (Distance(X,Y,GetPlayerStat(j,'X'),GetPlayerStat(j,'Y')) <= MaxDist) and (GetPlayerStat(j,'Health') < MaxHealth) then begin Relinquish := false; if GetPlayerStat(j,'Health') + HealRate > MaxHealth then DoDamage(j,GetPlayerStat(j,'Health') - MaxHealth) else DoDamage(j,-HealRate); end; if (Relinquish) then begin Medic[i] := 0; end; end; end;end;procedure OnJoinGame(ID, Team: byte);begin if Medic[Team] = 0 then WriteConsole(ID,'Medic is up for grabs on your team. Type !medic to claim it.',Color);end;procedure OnJoinTeam(ID, Team: byte);var OTeam: byte;begin if Team = 1 then OTeam := 2 else OTeam := 1; if Medic[OTeam] = ID then begin Medic[OTeam] := 0; WriteConsole(0,'Medic for team #' + InttoStr(OTeam) + ' is up for grabs. Type !medic to claim it.',Color); end;end;procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);begin if Medic[Team] = ID then begin Medic[Team] := 0; end;end;procedure OnMapChange(NewMap: string);var i: byte;begin for i := 1 to 2 do Medic[i] := 0; WriteConsole(0,'Medic is now up for grabs for both teams. Type !medic to claim it.',Color);end;procedure OnPlayerSpeak(ID: byte; Text: string);var Hurt: boolean; Team, i: byte; X, Y: single;begin if RegExpMatch('^!(medic|med|medi|Medic|Nurse|nurse)$',LowerCase(Text)) then begin Team := GetPlayerStat(ID,'Team'); if Medic[Team] = 0 then begin Hurt := not AutoRelinquish; if (AutoRelinquish) then begin GetPlayerXY(ID,X,Y); for i := 1 to 32 do if (GetPlayerStat(i, 'Active') = true) then if (GetPlayerStat(i,'Alive') = true) and (Team = GetPlayerStat(i,'Team')) and (Distance(X,Y,GetPlayerStat(i,'X'),GetPlayerStat(i,'Y')) <= MaxDist) and (GetPlayerStat(i,'Health') < MaxHealth) then begin Hurt := true; break; end; end; if (Hurt) then begin Medic[Team] := ID; WriteConsole(ID,GetPlayerStat(ID,'Name') + ' has claimed medic for team #' + InttoStr(Team) + '.',Color); end else WriteConsole(ID,'You cannot claim medic because you and those near you are not hurt.',Color); end else WriteConsole(ID,'Medic has already been claimed by ' + GetPlayerStat(Medic[Team],'Name') + '.',Color); end;end;
const HpHealed= 6; HealForPoint= 65; HealDistance= 60; Color= $EE00FF00; Red = $FF0000; Blue = $0000FF;var Medic: array[1..2] of byte; Healed: array[1..2] of integer; MaxHP: byte;procedure Reset;begin if Command('/realistic') = 1 then MaxHP:= 65 else MaxHP:= 150; Medic[1]:= 0; Medic[2]:= 0; Healed[1]:= 0; Healed[2]:= 0;end;procedure ActivateServer();begin Reset;end;procedure OnMapChange(NewMap: string);vari: byte;begin Reset; WriteConsole(0,'Medic position is now free. Write !medic to apply.',Color);end;procedure MedicQuit(Team: byte);begin WriteConsole(0,IDToName(Medic[Team])+' is no longer the '+iif(Team=1,'alpha','bravo')+' team''s medic!',iif(Team=1,Red,Blue)); Medic[Team]:= 0; Healed[Team]:= 0;end;procedure Heal(Team: byte);var HP: integer; i: byte;begin for i:= 1 to 32 do if GetPlayerStat(i,'Active') = true then if GetPlayerStat(i,'Alive') = true then if GetPlayerStat(i,'Health') < MaxHP then if Team = GetPlayerStat(i,'Team') then if Distance(GetPlayerStat(Medic[Team],'X'),GetPlayerStat(Medic[Team],'Y'),GetPlayerStat(i,'X'),GetPlayerStat(i,'Y')) <= HealDistance then begin if GetPlayerStat(i,'Health') <= (MaxHP-HpHealed) then HP:= 5 else HP:= MaxHP-GetPlayerStat(i,'Health'); DoDamage(i,-HP); if Medic[Team] <> i then begin inc(Healed[Team],HP); if Healed[Team] > HealForPoint then begin WriteConsole(Medic[Team],'You got 1 point for healing.',Color); SetScore(Medic[Team],GetPlayerStat(Medic[Team],'Kills')+1); Healed[Team]:= 0; end; end; end;end;function OnPlayerCommand(ID: Byte; Text: string): boolean;var T: byte;begin if RegExpMatch('^/(medic|med|medi)$',LowerCase(Text)) then if (GetPlayerStat(ID,'Team')=1) or (GetPlayerStat(ID,'Team')=2) then begin T:= GetPlayerStat(ID,'Team'); if Medic[T]=0 then begin WriteConsole(0,IDToName(ID)+' is now the '+iif(T=1,'alpha','bravo')+' team''s medic!',iif(T=1,Red,Blue)); Medic[T]:= ID; end else if Medic[T] = ID then begin MedicQuit(T); end else WriteConsole(ID,IDToName(Medic[T])+' is already your team''s medic!',Color);end;Result := false;end;procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);begin if (Team = 1) or (Team = 2) then if ID = Medic[Team] then MedicQuit(Team);end;procedure OnJoinTeam(ID, Team: byte);begin if (Medic[1]=ID) or (Medic[2]=ID) then MedicQuit(iif(Medic[1]=ID,1,2)); if (Team = 1) or (Team = 2) then if Medic[Team]=0 then WriteConsole(ID,'Medic position is free. Write !medic to apply.',Color) else WriteConsole(ID,IDToName(Medic[Team]) + ' is your team''s medic.',Color);end;procedure AppOnIdle(Ticks: integer);vari, T: byte;beginfor i:= 1 to 32 do if GetPlayerStat(i,'Active') = true then begin if (Medic[1]=i) or (Medic[2]=i) then if GetPlayerStat(i,'Health') > 0 then Heal(iif(Medic[1]=i,1,2));end;end;
const HpHealed= 6; HealForPoint= 65; HealDistance= 60; Color= $EE00FF00; Red = $FF0000; Blue = $0000FF;var Medic: array[1..2] of byte; Healed: array[1..2] of integer; MaxHP: byte; Timer: array [1..2] of integer; startTimer: array [1..2] of integer;procedure Reset;begin if Command('/realistic') = 1 then MaxHP:= 65 else MaxHP:= 150; Medic[1]:= 0; Medic[2]:= 0; Healed[1]:= 0; Healed[2]:= 0;end;procedure ActivateServer();begin Reset;end;procedure OnMapChange(NewMap: string);vari: byte;begin Reset; WriteConsole(0,'Medic position is now free. Write !medic to apply.',Color); for i:= 1 to 32 do begin if GetPlayerStat(i,'Active') = true then begin end; end;end;procedure MedicQuit(Team: byte);begin WriteConsole(0,IDToName(Medic[Team])+' is no longer the '+iif(Team=1,'alpha','bravo')+' team''s medic!',iif(Team=1,Red,Blue)); Medic[Team]:= 0; Healed[Team]:= 0;end;procedure Heal(Team: byte);var HP: integer; i: byte;begin for i:= 1 to 32 do if GetPlayerStat(i,'Active') = true then if GetPlayerStat(i,'Alive') = true then if GetPlayerStat(i,'Health') < MaxHP then if Team = GetPlayerStat(i,'Team') then if Distance(GetPlayerStat(Medic[Team],'X'),GetPlayerStat(Medic[Team],'Y'),GetPlayerStat(i,'X'),GetPlayerStat(i,'Y')) <= HealDistance then begin if GetPlayerStat(i,'Health') <= (MaxHP-HpHealed) then HP:= 5 else HP:= MaxHP-GetPlayerStat(i,'Health'); DoDamage(i,-HP); if Medic[Team] <> i then begin inc(Healed[Team],HP); if Healed[Team] > HealForPoint then begin WriteConsole(Medic[Team],'You got 1 point for healing.',Color); SetScore(Medic[Team],GetPlayerStat(Medic[Team],'Kills')+1); Healed[Team]:= 0; end; end; end;end;function OnPlayerCommand(ID: Byte; Text: string): boolean;var T: byte;begin if RegExpMatch('^!(medic|med|medi)$',LowerCase(Text)) then if (GetPlayerStat(ID,'Team')=1) or (GetPlayerStat(ID,'Team')=2) then begin T:= GetPlayerStat(ID,'Team'); if Medic[T]=0 then begin WriteConsole(0,IDToName(ID)+' is now the '+iif(T=1,'alpha','bravo')+' team''s medic!',iif(T=1,Red,Blue)); Medic[T]:= ID; startTimer[ID] := 1; Timer[ID] := 30; end else if Medic[T] = ID then begin MedicQuit(T); end else WriteConsole(ID,IDToName(Medic[T])+' is already your team''s medic!',Color);end else WriteConsole(ID,'You were already a medic on the map!',Color);end;Result := false;end;procedure OnLeaveGame(ID, Team: byte; Kicked: boolean);begin if (Team = 1) or (Team = 2) then if ID = Medic[Team] then MedicQuit(Team);end;procedure OnJoinTeam(ID, Team: byte);begin if (Medic[1]=ID) or (Medic[2]=ID) then MedicQuit(iif(Medic[1]=ID,1,2)); if (Team = 1) or (Team = 2) then if Medic[Team]=0 then WriteConsole(ID,'Medic position is free. Write !medic to apply.',Color) else WriteConsole(ID,IDToName(Medic[Team]) + ' is your team''s medic.',Color);end;procedure AppOnIdle(Ticks: integer);vari, T: byte;beginfor i:= 1 to 2 do beginif startTimer[i] = 1 then begin Timer[i] := Timer[i] - 1; if Timer[i] = 0 then begin if(GetPlayerStat(i,'Active')=true) then begin T:= GetPlayerStat(i,'Team'); MedicQuit(T); startTimer[i] := 0; end; end;end;end;for i:= 1 to 32 do if GetPlayerStat(i,'Active') = true then begin if (Medic[1]=i) or (Medic[2]=i) then if GetPlayerStat(i,'Health') > 0 then Heal(iif(Medic[1]=i,1,2));end;end;