Official Soldat Forums

Server Talk => Scripting Discussions and Help => Topic started by: kosik231 on June 05, 2010, 03:30:57 am

Title: Damage bonus in MissionMod
Post by: kosik231 on June 05, 2010, 03:30:57 am
Hi. I got a MissionMod from here and i want to do a damage bonus in character stats... i saw another Zombie Server with that (Rebuilded MissionMod with damage bonus). I mean +3% damage every lvl, ive done it but i got an error Type Mismatch... heres [uncomplete] code:
Code: [Select]
type tplayer = record
level: integer;
damage: double;
end;

procedure IncXP(ID: longint;XP: double);
begin
soldier[ID].xp := soldier[ID].xp + XP;
if (soldier[ID].xp >= soldier[ID].maxXP) then
    begin
soldier[ID].level := soldier[ID].level+1;
soldier[ID].damage := soldier[ID].damage + 0.03;
end;
end;

function Save(ID: longint; Name,Pass,Action: string): boolean;
begin
[...]
if WriteFile('accounts/'+Name+'.ini',
[...]
'Damage='+FloatToStr(soldier[ID].damage)+chr(13)+chr(10)
[...]end;

function Load(ID: longint; Name,Pass: string): string;
[...]
try
soldier[ID].damage := StrToFloat(ReadINI(file, 'STATS', 'Damage', '0'));
except
soldier[ID].damage := 0;
end;
[...]

function OnPlayerDamage(Victim,Shooter: longint;Damage: longint) : longint;
begin
Result:=Damage*soldier[Shooter].damage; // HERE IS THIS ERROR "TYPE MISMATCH"//
Error "Type mismatch" occur in OnPlayerDamage, what i have to do to fix it pls? Idk... can any1 correct it?
Title: Re: Damage bonus in MissionMod
Post by: Gizd on June 05, 2010, 03:48:28 am
Result:= Round(Damage*soldier[shooter].damage);
Title: Re: Damage bonus in MissionMod
Post by: kosik231 on June 05, 2010, 01:56:32 pm
it works :D tyvm ^^

#Edit:
ok... its not working... i dont know why... i got 75% Damage bonus (soldier[ID].damage := 0.750) and damage with that and without is same... i logged in, i see 75% but i deal 10 DMG to zombie with Usocom, when i log out (0% dmg) i got same dmg... whats wrong here?:
Code: [Select]
function OnPlayerDamage(Victim,Shooter: longint;Damage: longint) : longint;
var
    primary : longint;
rands: longint;
begin

rands:= random(1,20);
    if(soldier[Shooter].spec = MARINE) and (Shooter <> Victim) then
    begin
        primary := GetPlayerStat(Shooter,'Primary');
        if(primary = DEAGLES) or (primary = MINIMI) then
begin
if(Random(0,100) < ((soldier[Shooter].level*2)/3)) then
begin
Result := (Damage+(20*rands));
end;
end;
if(primary = FLAMER) then
begin
Result := Damage*3;
end;
end;
   

    if(soldier[Shooter].spec = COMMANDO) and (Shooter <> Victim) then
    begin
        primary := GetPlayerStat(Shooter,'Primary');
        if(primary = AK) or (primary = AUG) then
begin
if(Random(0,100) < ((soldier[Shooter].level*2)/3)) then
begin
Result := (Damage+(20*rands));
end;
end;     
    end;

if(soldier[Shooter].spec = Artillery) and (Shooter <> Victim) then
    begin
        primary := GetPlayerStat(Shooter,'Primary');
if(primary = M79) or (primary = MINIGUN) then
begin
if(Random(0,100) < ((soldier[Shooter].level*2)/3)) then
begin
Result := (Damage+(20*rands));
end;
end;
end;

if(soldier[Shooter].spec = Assault) and (Shooter <> Victim) then
    begin
        primary := GetPlayerStat(Shooter,'Primary');
        if(primary = MP5) or (primary = SPAS) then
begin
if(Random(0,100) < ((soldier[Shooter].level*2)/3)) then
begin
Result := (Damage+(20*rands));
end;
end;
end;


if(soldier[Shooter].spec = Assassin) and (Shooter <> Victim) then
begin
primary := GetPlayerStat(Shooter,'Primary');
if(primary = RUGER) or (primary = BARRET) then
begin
if(Random(0,100) < ((soldier[Shooter].level*2)/3)) then
begin
Result := (Damage+(20*rands));
end;
end;
end;




Result:= Damage + Round(Damage*soldier[shooter].damage);
end;
it should be for example
1000 + (1000*0.750) then Damage := 1750;
but its not... can any1 help me to fix it pls?

sry for my english if its bad ^^
Title: Re: Damage bonus in MissionMod
Post by: Hacktank on June 05, 2010, 02:39:10 pm
Replace your last line with:

Code: [Select]
result:= round(result * (soldier[shooter].damage+1));

That should work. Atm you have it totally ingorning all the other stuff that changes the damage, using the above will fix this.
Title: Re: Damage bonus in MissionMod
Post by: kosik231 on June 05, 2010, 02:50:15 pm
its not working :( still 10 dmg with Socom
Title: Re: Damage bonus in MissionMod
Post by: mich1103 on June 14, 2010, 02:44:39 pm
Help him !
i can't wait to see another update on his server !
hes server is really nice !  :D