0 Members and 2 Guests are viewing this topic.
//Made by D4NG3R for the zombie survival server, based on the codec of the origional author://Shantecfunction OnPlayerDamage(Victim, Shooter: byte; Damage: integer): integer;var Vx,Vy,Sx,Sy: single;begin if (IdToName(victim) = 'Witch') and (IdToName(shooter) <> 'Witch') then begin Vx := GetPlayerStat(Victim,'X'); Vy := GetPlayerStat(Victim,'Y'); Sx := GetPlayerStat(Shooter,'X'); Sy := GetPlayerStat(Shooter,'Y'); If (Distance(Vx,Vy,Sx,Sy) < 180) and (GetPlayerStat(victim,'Alive') = true) then begin //Here needs to bee the bot start part WriteConsole(ID,'You startled a Witch!',RGB(200,200,200)) end; end;end;procedure OnPlayerKill(Killer, Victim: byte; Weapon: string);begin if (IdToName(victim) = 'Witch') and (IdToName(killer) <> 'Witch') then begin WriteConsole(ID,'You killed the Witch.',RGB(200,200,200)) end;end;
using Avarax's SpawnBot
First you must to do is dummy bot, named witch (is it possible? or does the name need to be "dummy"?), i think you want to make LeftForDead alike witch, amirite?Then, if the distance is small enough, kick the dummy named witch, and spawn "living" witch botQuote using Avarax's SpawnBot
//Witch Testing script based on some codec of: Shantec's "Taliban" scriptfunction PlaceBot(botname: string; team: byte; X,Y: single): byte;function OnPlayerDamage(Witch, Player: byte; Damage: integer): integer;var Wx,Wy,Px,Py: single;beginif (IdToName(Witch) = 'Dummy') and (IdToName(Player) <> 'Witch') then begin Wx := GetPlayerStat(Witch,'X'); Wy := GetPlayerStat(Witch,'Y'); Px := GetPlayerStat(Player,'X'); Py := GetPlayerStat(Player,'Y'); If (Distance(Wx,Wy,Px,Py) < 180) and (GetPlayerStat(Witch,'Alive') = true) then begin Command('/kick Dummy') PlaceBot('Witch',GetPlayerStat(Dummy,'Team'),GetPlayerStat(Dummy,'X'),GetPlayerStat(Dummy,'Y')); WriteConsole(ID, 'You startled the witch!', $FFFFFF); end;end;procedure OnPlayerKill(Witch: byte; Weapon: string);begin if (IdToName(Witch) = 'Witch') then begin Command('/kick Witch') Command('/Addbot2 Dummy) end;end;
function PlaceBot(botname: string; team: byte; X,Y: single): byte;function OnPlayerDamage(Witch, Player: byte; Damage: integer): integer;var Wx,Wy,Px,Py: single;begin;
function PlaceBot(botname: string; team: byte; X,Y: single): byte;begin//actual placebot stuff hereend;function OnPlayerDamage(Witch, Player: byte; Damage: integer): integer;var Wx,Wy,Px,Py: single;begin;
fu >n< ction OnPlayerDamage(Witch, Player: byte; Damage: integer): integer;
function OnPlayerDamage(Witch, Player: byte; Damage: integer): integer;...WriteConsole(ID, 'You startled the witch!', $FFFFFF);
function PlaceBot(botname: string; team: byte; X,Y: single): byte;var i,n,tempType: byte; spawn: array of byte; tempX,tempY: single;begin SetArrayLength(spawn,0); n:=0; for i:=1 to 254 do If GetSpawnStat(i,'Active') = true then If GetSpawnStat(i,'Style') = team then begin n:=n + 1; SetArrayLength(spawn,n); spawn[n-1]:=i; SetSpawnStat(i,'Active',false); end; for i:=1 to 254 do If GetSpawnStat(i,'Active') = false then begin SetSpawnStat(i,'Active',true); tempType:=GetSpawnStat(i,'Style'); tempX:=GetSpawnStat(i,'X'); tempY:=GetSpawnStat(i,'Y'); SetSpawnStat(i,'Style',team); SetSpawnStat(i,'X',X); SetSpawnStat(i,'Y',Y); break; end; result:=Command('/addbot' + inttostr(team) + ' ' + botname); SetSpawnStat(i,'Active',false); SetSpawnStat(i,'Style',tempType); SetSpawnStat(i,'X',tempX); SetSpawnStat(i,'Y',tempY); If n > 0 then for i:=0 to n-1 do SetSpawnStat(spawn[i],'Active',true);end;
In AppOnIdle check everyone's distance to the bot using the Distance function in the scriptcore.
Quote from: iDante on May 16, 2009, 02:17:11 pmIn AppOnIdle check everyone's distance to the bot using the Distance function in the scriptcore.If the script constantly checks the player positions wouldn't it make lag?
const Distance = 150.0;var Distance2: double;procedure ActivateServer();begin Distance2 := Distance * Distance;end;procedure AppOnIdle(Ticks: cardinal);begin if (GetPlayerStat(__, 'X') * GetPlayerStat(__, 'X') + GetPlayerStat(__, 'Y') * GetPlayerStat(__, 'Y') < Distance2) then begin // ... end;end;
const Distance = 150.0; BOTID = 1;var Distance2: single;procedure ActivateServer;begin Distance2 := Distance * Distance;end;procedure AppOnIdle(Ticks: cardinal);var i: integer; wx,wy,x,y: single;begin GetPlayerXY(BOTID, wx, wy); for i := 1 to 32 do begin GetPlayerXY(i, x, y); if ( ( (x-wx)*(x-wx) + (y-wy)*(y-wy) ) < Distance2 ) AND ( i <> BOTID ) then begin { It is close enough, do stuff } end; end;end;
const Dist = 150; Max_Players = 20; Distance2 = Dist*Dist;procedure AppOnIdle(Ticks: cardinal);var i: byte; x,y,x2,y2: single;begin GetPlayerXY(BOTID, x, y); for i := 1 to Max_Players do if GetPlayerStat(i,'Active') then if i <> BOTID then begin GetPlayerXY(i, x2, y2); x2:=x2-x; y2:=y2-y; if x2*x2 + y2*y2 < Distance2 then begin { It is close enough, do stuff } end; end;end;
Faster and working version:Code: [Select]const Dist = 150; Max_Players = 20; Distance2 = Dist*Dist;procedure AppOnIdle(Ticks: cardinal);var i: byte; x,y,x2,y2: single;begin GetPlayerXY(BOTID, x, y); for i := 1 to Max_Players do if GetPlayerStat(i,'Active') then if i <> BOTID then begin GetPlayerXY(i, x2, y2); x2:=x2-x; y2:=y2-y; if x2*x2 + y2*y2 < Distance2 then begin { It is close enough, do stuff } end; end;end;
Last year, I dreamt I was pissing at a restroom, but I missed the urinal and my penis exploded.
GetPlayerXY(BOTID, x, y); for i := 1 to Max_Players do if GetPlayerStat(i,'Active') then if i <> BOTID then
const Dist = 150.0; Dist2 = Dist * Dist;function PlaceBot(botname: string; team: byte; X,Y: single): byte;var i,n,tempType: byte; spawn: array of byte; tempX,tempY: single;begin SetArrayLength(spawn,0); n:=0; for i:=1 to 254 do If GetSpawnStat(i,'Active') = true then If GetSpawnStat(i,'Style') = team then begin n:=n + 1; SetArrayLength(spawn,n); spawn[n-1]:=i; SetSpawnStat(i,'Active',false); end; for i:=1 to 254 do If GetSpawnStat(i,'Active') = false then begin SetSpawnStat(i,'Active',true); tempType:=GetSpawnStat(i,'Style'); tempX:=GetSpawnStat(i,'X'); tempY:=GetSpawnStat(i,'Y'); SetSpawnStat(i,'Style',team); SetSpawnStat(i,'X',X); SetSpawnStat(i,'Y',Y); break; end; result:=Command('/addbot' + inttostr(team) + ' ' + botname); SetSpawnStat(i,'Active',false); SetSpawnStat(i,'Style',tempType); SetSpawnStat(i,'X',tempX); SetSpawnStat(i,'Y',tempY); If n > 0 then for i:=0 to n-1 do SetSpawnStat(spawn[i],'Active',true);end;procedure AppOnIdle(Ticks: cardinal);var i, j: byte; X1, Y1, X2, Y2, DX, DY: single;begin for i := 1 to 32 do if (GetPlayerStat(i, 'Active') = true) then if (GetPlayerStat(i, 'Human') = true) then begin GetPlayerXY(i, X1, Y1); for j := 1 to 32 do if ((i <> j) and (GetPlayerStat(j, 'Active') = true)) then if ((GetPlayerStat(j, 'Human') = false) and (GetPlayerStat(j, 'Name') = 'Dummy') and (GetPlayerStat(i, 'Team') <> GetPlayerStat(j, 'Team'))) then begin GetPlayerXY(j, X2, Y2); DX := X2 - X1; DY := Y2 - Y1; if (DX * DX + DY * DY < Dist2) then begin PlaceBot('Witch', GetPlayerStat(j, 'Team'), X2, Y2); KickPlayer(j); end; end; end;end;