Official Soldat Forums
Server Talk => Scripting Discussions and Help => Topic started by: frosty on June 28, 2010, 07:21:34 pm
-
title says it all, if i spawnBullet (or whatever it is) on someone it doesnt do any damage, i could do 100 bullets and it still hasnt done any damage,
although my wep mod is set to 999999 damage, which works fine when actually using the weapons,
i want to move away from using explosive rounds as its causing MASSIVE lag issues on my server so, how do i do it?
i know that Dodamage results in a selfkill which isnt what i want
i also want to set up like a turret that auto fires, but how do i get the angle of direction from turret to target and Createbullet with that angle info?
-
You need to get angle between turret and player:
function arctan2(X, Y: single): single;
begin
if X < 0 then Result := arctan(Y/X) + Pi else
if X > 0 then Result := arctan(Y/X) else
if Y > 0 then Result := 1.5707 else
Result := -1.5707;
end;
a:= arctan(X2-X1,Y2-Y1);
*arctan2() made by tk.
vX:= cos(a)*velocity;
vY:= sin(a)*velocity;
CreateBullet(TurretX,TurretY,vX,vY,Power,Style,ID);
This will create a bullet going from turret to player, you need to find some angle adjustments though if you want low velocity bullets to hit.
-
CreateBullet function doesn't use any values from weapon mod, you need to manually specify bullet power (~10000 for sure kill). Also resulting damage will be effected by the speed of the bullet. So don't set speed to 0 if bullet is spawned just inside the player.
-
CreateBullet function doesn't use any values from weapon mod, you need to manually specify bullet power (~10000 for sure kill). Also resulting damage will be effected by the speed of the bullet. So don't set speed to 0 if bullet is spawned just inside the player.
Aswell don't place bullets with rapid speed near players because they will just fly through them.
function arctan2(X, Y: single): single;
begin
if X < 0 then Result := arctan(Y/X) + Pi else
if X > 0 then Result := arctan(Y/X) else
if Y > 0 then Result := 1.5707 else
Result := -1.5707;
end;
<3 :P
-
uhh how exactly do i set bullet "speed" in CreateBullet? someone give me an example plz
theres no "speed" var in the syntax, only VelX and VelY, tried 1000 VelY with HitMultiplier as 10000 and it doesnt kill, so how exactly do i set the speed?
-
1000 for a sold at velocity is ungodly. The bullet would span the entire map in a second.... Try 1.
-
Well.. speed would be sqrt(VelX * VelX + VelY * VelY)
And if you don't understand what VelX and VelY means you kinda did miss something..
CreateBullet(x, y, -10, 0, 100, 14, owner); Bullet flys straight up.
CreateBullet(x, y, -10, 10, 100, 14, owner); Would create a bullet which starting angle is 45° (flys ^>)
CreateBullet(x, y, 0, 10, 100, 14, owner); Flys to the right of it's spawning position.
I think this should be enough so you get the idea.
-
1 VelY doest kill, even with a hit multiplier of 100000, for a kill i need a minimum of 1000 VelY coupled with hitM of 100000
idk wtfh is going on here, but it is irritating
also, VelX and VelY isnt explained in the doc at all if anything so its a bit confusing
and also i need to use GetPlayerStat in VelX and VelY for it to even work
makes more sense now tho but my problem with Vely is an issue :S
-
You don't need GetPlayerStat..
Negative VelY: Bullets move up.
Positive VelY: Bullets move down.
The point (0|-5) would be over the point (0|5), it's just how MM coded it.
Hope that's what you wanted to know.
Also why don't you just use DoDamage() >_>'
-
Because Dodamage results in selfkill of target, like i said earlier, that is not what i wanted
thanks swompie for the explanation, explains a few things that have happened (somewhat randomly(ugh! silly me)) :D
-
Because Dodamage results in selfkill of target, like i said earlier, that is not what i wanted
DoDamageBy()
-
thanks Gizd :), im guessing the syntax is DoDamageBy(Target,Owner) ?
also where did you get that function? it isnt on:
http://enesce.com/help/ (http://enesce.com/help/) or http://devs.soldat.pl/wiki/index.php?title=Server_Scripting (http://devs.soldat.pl/wiki/index.php?title=Server_Scripting)
-
thanks Gizd :), im guessing the syntax is DoDamageBy(Target,Owner) ?
also where did you get that function? it isnt on:
http://enesce.com/help/ (http://enesce.com/help/) or http://devs.soldat.pl/wiki/index.php?title=Server_Scripting (http://devs.soldat.pl/wiki/index.php?title=Server_Scripting)
I believe it's DoDamageBy(Victim, Shooter, Damage);
-
thanks squiddy :D
hmm ill have to stick with CreateBullet, DoDamageBy with 99 set as damage causes way worse lag than createbullet and actually continuosly causes the script to crash and the server to completely hang, hmm
From: July 02, 2010, 01:43:54 am
edit: wtf is going on? if i remove the GetplayerStat from VelY in CreateBullet it doesnt kill!! wtf!!!!!!!!
-
also where did you get that function? it isnt on:
http://enesce.com/help/ (http://enesce.com/help/) or http://devs.soldat.pl/wiki/index.php?title=Server_Scripting (http://devs.soldat.pl/wiki/index.php?title=Server_Scripting)
NOTE: If you wish to be able to specify a player ID doing damage, use DoDamageBy:
procedure DoDamageBy(ID,Shooter: Byte; Damage: Integer);
hmm ill have to stick with CreateBullet, DoDamageBy with 99 set as damage causes way worse lag than createbullet and actually continuosly causes the script to crash and the server to completely hang, hmm
Lies! Code please.
-
nevermind, got CreateBullet to work fine, dont need DoDamageBy
-
nevermind, got CreateBullet to work fine, dont need DoDamageBy
If player is close to wall it might change.
-
ok if thats the case
this is in OnPlayerKill, all Vars have been declared, dont understand why this causes the server to hang when this weapon is used, this ONLY started hanging after i put in DoDamageBy (was using the commented out CreateBullet)
if Weapon = 'Barrett M82A1' then begin
for i := 1 to 32 do
begin
x := GetPlayerStat(Victim,'x');
y := GetPlayerStat(Victim,'y');
x2 := GetPlayerStat(i,'x');
y2 := GetPlayerStat(i,'y');
if RayCast(x,y,x2,y2,Dist,400) then begin
if i <> Killer then begin
if GetPlayerStat(i,'Alive') = true then begin
//WriteLn(IDtoName(i)+' is in range of Raycast');
//CreateBullet(GetPlayerStat(i,'x'), GetPlayerStat(i,'y') - 0, 0,-1000,100, 3, Killer);
DoDamageBy(i, Killer, 99);
BioKills[Killer]:=BioKills[Killer]+1;
end;
end;
end;
end;
WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills[Killer]),$EE81FAA1);
BioKills[Killer]:=BioKills[Killer]*0;
end;
this is the only part of the script that has the DoDamageBy
i dont get it, why the hell is it hanging the server? why is it the CreateBullet works fine with barely any lag yet DoDamageBy hangs the server? i dont get it :S also the script crashes 20 times in a row, then i get a crapload of access violations in Panel Log resulting in me needing to reset the server
If player is close to wall it might change.
has now, now that you mention it, i just found that out while in my server
edit: i dont get why the forum has indented DoDamageBy so far to the right....
-
Can you show OnPlayerDamage? Before doing so check if it's making an Infinite damage loop.
-
I would need the whole script to find the problem, because of Weapon and similar stuff.
Also, i cant remember that DoDamageBy exists, it isnt even in the scripting manual. :\
Did you try DoDamage(i, Killer, 4000)
Also, what is the script supposed to do, or at least this fragment?
Kill the enemy if he is inside a 400 radius while the victim has barrett?
I think you would need to assign with AppOnIdle the weapon check to each player, something like this (youll need to adopt it to the overall script:
procedure AppOnIdle(Ticks: integer);
var
i: integer;
Weapon: array[1..255] of array[1..32];
begin
for i:= 1 to 32 do Weapon[GetPlayerStat(i, 'Primary')][i];
end;
end;
//and then instead of
if Weapon = 'Barrett M82A1' then begin
for i := 1 to 32 do
//place
for i: 1 to 32 do if Weapon[8][i] then begin
// or something like that. again, i would need to see the whole script
Also, im not sure if i can assign the double array like that, but i always failed with x[y][z] := x[1][2] and similar, can someone recheck that part?
-
Also, i cant remember that DoDamageBy exists, it isnt even in the scripting manual. :\
Did you try DoDamage(i, Killer, 4000)
In 2.7.0 DoDamage replaces DoDamageBy.
And the problem is that you don't check for activeness of player(player can be alive and active). If that won't help try replacing GetPlayerStat(alive) with GetPlayerStat(health) > 0.
-
Oh.
Is he using 2.7.0 or 2.6.5?
-
2.6.5, in 2.7.0 all weapon parameters are byte not string.
-
Yeh, i was thinking he was writing the script for 2.6.5, not 2.7.0. :\
-
actually what this segment does is kill all zombies in 400 metre radius of Victim if Killer has Barret and is in "sight"
heres the full script :(attached)
@croatgamer: correct, my host is using 1.6.5
SN: DoDamageBy is commented out in the script as its causing instability (amazing how commenting out ONE line fixes all issues :S)
edit: actually i removed the DoDamageBy line
From: July 02, 2010, 11:40:32 pm
i just found out my host is using server version 2.6.6 for his customers
-
btw, if i use DoDamage with the syntax as DoDamageBy i get an "incorrect number of parameters" error so i have to use CreateBullet
-
Because DoDamage has the additional parameter Shooter in the beta server and DoDamageBy was removed due to that.
Hint: eC's manual is already up-to-date with the beta server, so don't use it if your not knowing much about all the functions in soldat scripting ;f If you would you would've known this :/
-
well im not using 2.7.0, and DoDamage(Shooter,Victim,Damage) doesnt work so what else can i use? CreateBullet doesnt work too well because zombies are always near walls so the created bullets somehow miss their targets even tho the bullet is spawned on each zombie and goes straight up
and, i know about the functions i the ec help center, but thats for 2.7.0, NOT 2.6.6 which is more like 2.6.5, which is why i dont use the ec help center, it would be different if my host was actually using 2.7.0 then i WOULD use it, but since he isnt, i cant use it because the code there is incorrect for 2.6.6, how is it incorrect? well i copy and paste...lets say a function with a begin and end, sometimes only that is enough to cause errors, especially when its an updated function name
so, i ask again, what else can i use to kill zombies that are in range of a raycast effectively, without using explosive rounds? explosive rounds are the only things that do work 100%, but BULLETS MISS, and bullets have a hit rate of about 30% compared to explosive rounds and DoDamageBy(which i cant use apparently) hangs the server. how do i get around that, explosions are causing too much CPU usage on host
there MUST be something i can use, all help appreciated :)
-
this sounds quite mysterious. Try it again with DoDamageBy, but add "if getplayerstat(i,'Active') = true then" after your "for i := 1 to 32 do"
-
Hung the server again
if Weapon = 'Barrett M82A1' then begin
for i := 1 to 32 do
begin
x := GetPlayerStat(Victim,'x');
y := GetPlayerStat(Victim,'y');
x2 := GetPlayerStat(i,'x');
y2 := GetPlayerStat(i,'y');
if RayCast(x,y,x2,y2,Dist,400) then begin
if i <> Killer then begin
if GetPlayerStat(i,'Alive') = true then begin
//WriteLn(IDtoName(i)+' is in range of Raycast');
CreateBullet(GetPlayerStat(i,'x'), GetPlayerStat(i,'y') - 0, 0,-1000,100, 3, Killer);
if getplayerstat(i,'Active') then DoDamageBy(i, Killer, 99);
BioKills[Killer]:=BioKills[Killer]+1;
end;
end;
end;
end;
WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills[Killer]),$EE81FAA1);
BioKills[Killer]:=BioKills[Killer]*0;
end;
full code in attachment
-
The way your script works is very inefficient. You access the position of Killer 32 times, in my version I only access it once. Also you must check whether the ID you are trying to access is active before trying to get values from it. Also this could be interesting for you:
Ineffective:
if (...) then begin
if (...) then begin
end;
end;
Effective:
if ((...) AND (...)) OR (...) then begin
end;
Also: Instead of "BioKills[Killer]:=BioKills[Killer]*0;" you can just set its value like "BioKills[Killer] := 0;".
Procedure OnPlayerKill(Killer,Victim:Byte; Weapon:String);
var
X1,X2,Y1,Y2:Single
i:Byte;
begin
if Weapon = 'Barrett M82A1' then begin
GetPlayerXY(Victim,X,Y)
for i := 1 to 32 do if (GetPlayerStat(i,'Active') = true) then begin
GetPlayerXY(i,X2,Y2);
if RayCast(X1,Y1,X2,Y2,Dist,400) AND (i <> Killer) AND (GetPlayerStat(i,'Alive') = true) then begin
//WriteLn(IDtoName(i)+' is in range of Raycast');
CreateBullet(GetPlayerStat(i,'x'), GetPlayerStat(i,'y') - 0, 0,-1000,100, 3, Killer);
DoDamageBy(i, Killer, 99);
BioKills[Killer]:=BioKills[Killer]+1;
end;
end;
WriteConsole(Killer,'Bio-Kills: '+Inttostr(BioKills[Killer]),$EE81FAA1);
BioKills[Killer] := 0;
end;
-
ooh i see, many thanks Dark
this might help me with other scripts also :)
-
wow, just had to comment on the line
BioKills[Killer] = BioKills[Killer] * 0
.........seriously?!
Without trying to sound condescending, I think you should go learn assembly and then C++ to have a better understanding of how the computer works. You'll learn how to be much more efficient with programming concepts. In my opinion, people should learn in this order:
1- physics
2- chemistry
3- electronic theory
4- analog design
5- logic design
6- digital design
7- microprocessors and assembly
8- C++
9- youdotherest
-
Without trying to sound condescending, I think you should go learn assembly and then C++ to have a better understanding of how the computer works. You'll learn how to be much more efficient with programming concepts. In my opinion, people should learn in this order:
1- physics
2- chemistry
3- electronic theory
4- analog design
5- logic design
6- digital design
7- microprocessors and assembly
8- C++
9- youdotherest
you forgot
0- common sense
-
Without trying to sound condescending, I think you should go learn assembly and then C++ to have a better understanding of how the computer works. You'll learn how to be much more efficient with programming concepts. In my opinion, people should learn in this order:
1- physics
2- chemistry
3- electronic theory
4- analog design
5- logic design
6- digital design
7- microprocessors and assembly
8- C++
9- youdotherest
you forgot
0- common sense
haha, i ddin't put it because i thought it was common sense to have common sense :P (but you're right)
-
OMFG my server is such a f**king douche, it hung again, with that code
From: July 14, 2010, 07:19:18 pm
i think DodamageBy is for 2.7.0 not 2.6.6 since my server doesnt like it, so ill just have to put up with BioKills not working right, unless i put a bullet to the left and right going into the player at high velocity, like my sig says, if at first you dont succeed, improvise :D
unless there is something OTHER THAN DoDamageBy AND CreateBullet, if there isnt, just say so, im getting sick of going round in circles here
if zombies all happen to be in the air, then the createbullet works fine 100%, but if they near wall, most of the bullets miss, and hit at 0-30%, i need something thats EFFICIENT (works 100%) and is NOT CreateBullet OR DoDamageBy
-
The server can crash when you choose a too high velocity.
Change...
CreateBullet(GetPlayerStat(i,'x'),GetPlayerStat(i,'y') - 0, 0,-1000,100, 3, Killer);
To...
CreateBullet(GetPlayerStat(i,'X'),GetPlayerStat(i,'Y'),0,0,350,5,Killer);
DoDamageBy() works just fine. It's all about CreateBullet(). I changed the bulletstyle to 5 (flames) and the hit multiplier to 350%. This should totally work now.
-
The server can crash when you choose a too high velocity.
Not really.
Just freakin' ask eC if he knows why DoDamageBy doesn't work correctly, either way your a fucking stupid cunt or, well there's no real or.
It works, prolly it's because of some other script you use, learn2debug.
-
I already crashed my server with 8 CreateBullets with high velocity..
-
well why is it that the server works perfect as soon as i REMOVE DoDamageBy?
i dont get it, and how the hell would i debug whats causing DoDamageBy to not work? and whats your server version Dark? if its 2.7.0 then thats the problem because mine IS NOT 2.7.0.....
also, if i use flames in CreateBullet, with No bullet Velocity, just 1 CreateBullet with flames lags the server to shit
-
It works, prolly it's because of some other script you use
That's also debugging if you disable of scripts.
Maybe you just fucked up some setting tho.
-
also, if i use flames in CreateBullet, with No bullet Velocity, just 1 CreateBullet with flames lags the server to s**t
Hmm i had the same problem with flames, but since i changed last variable ("Owner") to an existing one (player must be on the server) everything works fine, no server crushes
-
Are you running the server on your own computer? If that's so you must keep your scripts very light since you already have all those zombies and stuff.
Server version: 2.6.5
---------------------------
Lesson in debugging your script. Lets say we got this script:
Procedure AppOnIdle(Ticks:Integer);
var
i,ii:Byte;
begin
if (Mine_Enabled = true) then CheckMines();
for i := 1 to HighestID() do if (GetPlayerStat(i,'Active') = true) then begin
if (Player[i].Vanish) then
if (Player[i].VanishTimer = 0) then
RefreshVanish(i)
else
TimedVanish(i);
if (Player[i].Rage) then
if (Player[i].RageTimer = 0) then
RefreshRage(i)
else
TimedRage(i);
if (Player[i].Knife) AND (GetPlayerStat(i,'Primary') <> 14) then ForceWeapon(i,14,255,0);
for ii := 1 to HighestID() do if (GetPlayerStat(ii,'Active') = true) AND (Player[i].Spy[ii]) then DrawSpyInterface(i,ii);
end;
end;
The error lies in one of the procedures being called by AppOnIdle, but the soldatserver won't tell us. Now we put in WriteLn('n') (first WriteLn n = 1, second = 2 ...) after each line to see where the error lies. Now that we know where the error lies we go on with the same tactic and look where the error lies this time. Do this until your script is debugged, it's that simple ;)
-
nope the server is external on a host, its not on my comp
thanks for the lesson Dark :D ill give it a go, but later, got RL things that need my immediate attention, ill post back later on