Official Soldat Forums

Server Talk => Scripting Releases => Topic started by: DorkeyDear on August 13, 2007, 06:55:03 pm

Title: Health Regeneration Around Medic
Post by: DorkeyDear on August 13, 2007, 06:55:03 pm
Script Name: Health Regeneration Around Medic
Script Description: First player to do !medic becomes the medic. Anybody around the medic will be healed at a specified rate. When the map changes, medic is replaced, and may be reclaimed by anybody. There is a limitation of 1 medic per team. The script is designed for CTF mode, although may be easily modified for team match.
Original Author: Curt (DorkeyDear)
Core Version: 2.6.1b
Code:
Code: [Select]
const
  Color = $FFFFFFFF;
  MaxDist = 65;
  MaxHealth = 65;
  HealRate = 8;

var
  Medic: array[1..2] of byte;

procedure AppOnIdle(Ticks: integer);
var
  i,j: byte;
  X,Y: single;
begin
  for i := 1 to 2 do begin
    GetPlayerXY(Medic[i],X,Y);
    if Medic[i] <> 0 then if GetPlayerStat(Medic[i],'Alive') = true then for j := 1 to 32 do if (GetPlayerStat(j,'Active') = true) and (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
      if GetPlayerStat(j,'Health') + HealRate > MaxHealth then DoDamage(j,GetPlayerStat(j,'Health') - MaxHealth) else DoDamage(j,-HealRate);
    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;
    WriteConsole(0,'Medic for team #' + InttoStr(Team) + ' is up for grabs. Type !medic to claim it.',Color);
  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
  Team: byte;
begin
  if (Text = '!medic') then begin
    Team := GetPlayerStat(ID,'Team');
    if Medic[Team] = 0 then begin
      Medic[Team] := ID;
      WriteConsole(ID,GetPlayerStat(ID,'Name') + ' has claimed medic for team #' + InttoStr(Team) + '.',Color);
    end else WriteConsole(ID,'Medic has already been claimed by ' + GetPlayerStat(Medic[Team],'Name') + '.',Color);
  end;
end;
In request from Amida
Title: Re: Health Regeneration Around Medic
Post by: XfalconX on August 13, 2007, 07:26:06 pm
Didn't work  ???

http://img532.imageshack.us/my.php?image=clip0002if2.flv
Title: Re: Health Regeneration Around Medic
Post by: DorkeyDear on August 13, 2007, 07:47:47 pm
Didn't seem to give me errors back in 2.6.1b that I can remember of.
Does it at least still work?
Title: Re: Health Regeneration Around Medic
Post by: XfalconX on August 13, 2007, 07:57:36 pm
found out that it does run but will it be a problem infinitaly repeating the error on the cmd screen?
Title: Re: Health Regeneration Around Medic
Post by: DorkeyDear on August 13, 2007, 08:18:37 pm
I fixed it, with a little help from EagleEye.
Title: Re: Health Regeneration Around Medic
Post by: XfalconX on August 13, 2007, 08:23:06 pm
Thank you very much, and if it is too much to ask for, any chance you can make a script that u can login like leo's servers or give me a link to an existing one, or try to answer more of my questions in http://forums.soldat.pl/index.php?topic=18758.0
Title: Re: Health Regeneration Around Medic
Post by: miketh2005 on August 15, 2007, 12:18:27 pm
I fixed it, with a little help from EagleEye.

Same thing happens with Admin invinibility, it's annoying and it causes....... sh@@ It happened just now.....FIXED ARSSE always messes up saying out of memory and I have to Force CLose
Title: Re: Health Regeneration Around Medic
Post by: DorkeyDear on August 15, 2007, 01:45:16 pm
I fixed it, with a little help from EagleEye.

Same thing happens with Admin invinibility, it's annoying and it causes....... sh@@ It happened just now.....FIXED ARSSE always messes up saying out of memory and I have to Force CLose
I just checked to see if it works with this version, and I see no errors in the Command Prompt console.
Title: Re: Health Regeneration Around Medic
Post by: -Aaron- on November 01, 2007, 04:06:16 pm
How close does the player have to be to the medic? I think I might use this.
Title: Re: Health Regeneration Around Medic
Post by: DorkeyDear on July 29, 2008, 02:16:27 pm
How close does the player have to be to the medic? I think I might use this.
You have to do a little experiementing to figure that out...
Change "  MaxDist = 65;", the 65 in it to a larger number for a larger range, smaller for smaller.

Date Posted: November 01, 2007, 06:19:27 pm
Sombody requested that it doesn't heal the medic:
Code: [Select]
const
  Color = $FFFFFFFF;
  MaxDist = 65;
  MaxHealth = 65;
  HealRate = 8;

var
  Medic: array[1..2] of byte;

procedure AppOnIdle(Ticks: integer);
var
  i,j: byte;
  X,Y: single;
begin
  for i := 1 to 2 do begin
    GetPlayerXY(Medic[i],X,Y);
    if Medic[i] <> 0 then if GetPlayerStat(Medic[i],'Alive') = true then for j := 1 to 32 do if (GetPlayerStat(j,'Active') = true) and (GetPlayerStat(j,'Alive') = true) and (GetPlayerStat(Medic[i],'Team') = GetPlayerStat(j,'Team')) and (Medic[i] <> j) and (Distance(X,Y,GetPlayerStat(j,'X'),GetPlayerStat(j,'Y')) <= MaxDist) and (GetPlayerStat(j,'Health') < MaxHealth) then begin
      if GetPlayerStat(j,'Health') + HealRate > MaxHealth then DoDamage(j,GetPlayerStat(j,'Health') - MaxHealth) else DoDamage(j,-HealRate);
    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;
    WriteConsole(0,'Medic for team #' + InttoStr(Team) + ' is up for grabs. Type !medic to claim it.',Color);
  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
  Team: byte;
begin
  if (Text = '!medic') then begin
    Team := GetPlayerStat(ID,'Team');
    if Medic[Team] = 0 then begin
      Medic[Team] := ID;
      WriteConsole(ID,GetPlayerStat(ID,'Name') + ' has claimed medic for team #' + InttoStr(Team) + '.',Color);
    end else WriteConsole(ID,'Medic has already been claimed by ' + GetPlayerStat(Medic[Team],'Name') + '.',Color);
  end;
end;
was just a quick change
Title: Re: Health Regeneration Around Medic
Post by: blackdevil0742 on July 29, 2008, 03:31:06 pm
I believe it was me who wanted that ;)
Thank you so much for this DorkeyDear <3

Edit: I'm getting an error when I use the changed script.
Title: Re: Health Regeneration Around Medic
Post by: DorkeyDear on July 29, 2008, 05:18:51 pm
Try now
Title: Re: Health Regeneration Around Medic
Post by: blackdevil0742 on July 30, 2008, 03:40:50 am
It works now :=)
Title: Re: Health Regeneration Around Medic
Post by: zop on July 31, 2008, 12:06:54 am
thx Curt I can use it too.
Title: Re: Health Regeneration Around Medic
Post by: preli on January 04, 2009, 08:07:50 am
hi.
i'm new here and i don't know rly, very much about scripts. i have arsse, and i converted this file to .pas, and recompiled it, but it still don't work ;/.
If you know what i am doing wrong, please tell me.
Title: Re: Health Regeneration Around Medic
Post by: iDante on January 04, 2009, 08:40:24 am
hi.
i'm new here and i don't know rly, very much about scripts. i have arsse, and i converted this file to .pas, and recompiled it, but it still don't work ;/.
If you know what i am doing wrong, please tell me.
This is a script for the soldat dedicated server. For instructions on installing it, go here. (http://forums.soldat.pl/index.php?topic=21468.0)
Title: Re: Health Regeneration Around Medic
Post by: preli on January 09, 2009, 12:17:03 pm
thank you for your help. now i can recompile it, but it still doesn't work ;/. everything looks as if it rly works, but it doesn't.
i can write: !medic, and i can see replay: xXx have been claimed medic..., but when i got injured, it doesn't regenerate my HP :/. Does anybody knows why it doesn't works? Pls help me.
Title: Re: Health Regeneration Around Medic
Post by: JotEmI on January 09, 2009, 01:41:19 pm
If you are a medic then you can heal other players, not yourself. Someone else would have to be a medic to heal you. But you could easily modify this script so it'd also heal the medic. If you don't know how then I can do it (I assume Dorkey allows other users to modify this script)
Title: Re: Health Regeneration Around Medic
Post by: DorkeyDear on January 09, 2009, 03:47:50 pm
I assume Dorkey allows other users to modify this script
sure
just as long as you don't say its urs :P
Title: Re: Health Regeneration Around Medic
Post by: JotEmI on January 09, 2009, 07:20:51 pm
Did you Dorkey uploaded a new version? Cause the script I've just downloaded heals medics too. preli I don't know why it doesnt work for you. Maybe you played nonrealistic and forgot to set MaxHealth=150? But even then you should be able to heal almost 1/2 of your HP.
Title: Re: Health Regeneration Around Medic
Post by: DorkeyDear on January 09, 2009, 08:04:50 pm
He must have used the source I posted here (http://forums.soldat.pl/index.php?topic=18764#msg343611) where as you got it from the main topic.
Title: Re: Health Regeneration Around Medic
Post by: preli on January 10, 2009, 05:24:58 am
I didn't forgot about it. I change it for 150, and eventhough it wasn't working. JotEmI if you could change this srcipt, just like u said, i would be very thankful to you for it.
Title: Re: Health Regeneration Around Medic
Post by: JotEmI on January 10, 2009, 07:13:46 am
Just download this version -> link (http://forums.soldat.pl/index.php?action=dlattach;topic=18764.0;attach=9325) It works fine for me.
Title: Re: Health Regeneration Around Medic
Post by: preli on January 10, 2009, 09:17:45 am
Thank you very much. It works now :)