0 Members and 1 Guest are viewing this topic.
procedure FLootItem(ID, enemy: byte);var loot: byte; degals, mp5, ak47, styer, spaz, ruger, m79, barret, minimi, minigun, socom, knife, chainsaw, law, medkit, nade, pred, berserk, flamer, vest, cluster: integer;beginpred := random(0,Cpred);barret := random(0,Cbarret);Spawnobject(getplayerstat(enemy,'x'),getplayerstat(enemy,'y'),loot);//WriteConsole(ID,'Looted -:- ' + -------,$ff5555ff);end;
procedure DropLoot(ID,Killer: byte);var rand,drop: byte; loot: string;begin if (Random(0,100) <= DROPCHANCE) then begin loot := ''; drop := 0; rand := Random(0,100); case Bots[ID].Species of 1: begin if rand >= 75 then begin if rand >= 85 then begin if rand >= 90 then begin drop := 5; end else drop := 12; end else drop := 11; end; end; 2: begin if rand >= 20 then begin if rand >= 70 then begin if rand >= 85 then begin drop := 19; end else drop := 17; end else drop := 16; end; end; 3: begin if rand >= 83 then begin drop := 21; end; end; 4: begin drop := rand DIV 4; if (drop > 22) or (drop = 15) or (drop = 18) or (drop = 20) then drop := 0; end; 6: drop := 19; end; case drop of 1: loot := 'Desert Eagle'; 2: loot := 'HK MP5'; 3: loot := 'AK 74'; 4: loot := 'Steyr AUG'; 5: loot := 'Spas 12'; 6: loot := 'Ruger77'; 7: loot := 'M79'; 8: loot := 'Barrett M82A1'; 9: loot := 'Minimi'; 10: loot := 'Minigun'; 11: loot := 'USSOCOM'; 12: loot := 'Combat Knife'; 13: loot := 'Chainsaw'; 14: loot := 'LAW'; 15: loot := 'Stationary Gun'; 16: loot := 'Medical Kit'; 17: loot := 'Grenade Kit'; 18: loot := 'Flamer Kit'; 19: loot := 'Vest Kit'; 20: loot := 'Predator Kit'; 21: loot := 'Berserk Kit'; 22: loot := 'Cluster Kit'; end; if drop > 0 then begin if Bots[ID].Species = 6 then GiveBonus(Killer,3) else SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),drop); WriteConsole(Killer,'Looted: '+loot,cLoot); end; end;end;
//weighted randomfunction Wrand(Input : array of integer) : integer;vari, total, randi : integer;begin result := 0; total := 0; for i:= 0 to getArrayLength(Input)-1 do inc(total, Input[i]); randi := random(0, total); total := 0; for i:= 0 to getArrayLength(Input)-1 do begin inc(total, Input[i]); if total >= randi then begin result := i; break; end; end;end;
I think damner knows better about what 'looting items' should be. But as far as I can see you just need a weighted random function. It can be handy in other cases, so I'll post it anyway.Code: [Select]//weighted randomfunction Wrand(Input : array of integer) : integer;vari, total, randi : integer;begin result := 0; total := 0; for i:= 0 to getArrayLength(Input)-1 do inc(total, Input[i]); randi := random(0, total); total := 0; for i:= 0 to getArrayLength(Input)-1 do begin inc(total, Input[i]); if total >= randi then begin result := i; break; end; end;end;Haven't tested it :p but it should swallow an array of ints that represent the chances of the outcome. For example, inputing [4, 3, 5] will have a 4/12th chance of hitting 0, 3/12th chance of 1 and 5/12 chance of 2. You can input as much integers as you like.
thats what i useCode: [Select]procedure DropLoot(ID,Killer: byte);var rand,drop: byte; loot: string;begin if (Random(0,100) <= DROPCHANCE) then begin loot := ''; drop := 0; rand := Random(0,100); case Bots[ID].Species of 1: begin if rand >= 75 then begin if rand >= 85 then begin if rand >= 90 then begin drop := 5; end else drop := 12; end else drop := 11; end; end; 2: begin if rand >= 20 then begin if rand >= 70 then begin if rand >= 85 then begin drop := 19; end else drop := 17; end else drop := 16; end; end; 3: begin if rand >= 83 then begin drop := 21; end; end; 4: begin drop := rand DIV 4; if (drop > 22) or (drop = 15) or (drop = 18) or (drop = 20) then drop := 0; end; 6: drop := 19; end; case drop of 1: loot := 'Desert Eagle'; 2: loot := 'HK MP5'; 3: loot := 'AK 74'; 4: loot := 'Steyr AUG'; 5: loot := 'Spas 12'; 6: loot := 'Ruger77'; 7: loot := 'M79'; 8: loot := 'Barrett M82A1'; 9: loot := 'Minimi'; 10: loot := 'Minigun'; 11: loot := 'USSOCOM'; 12: loot := 'Combat Knife'; 13: loot := 'Chainsaw'; 14: loot := 'LAW'; 15: loot := 'Stationary Gun'; 16: loot := 'Medical Kit'; 17: loot := 'Grenade Kit'; 18: loot := 'Flamer Kit'; 19: loot := 'Vest Kit'; 20: loot := 'Predator Kit'; 21: loot := 'Berserk Kit'; 22: loot := 'Cluster Kit'; end; if drop > 0 then begin if Bots[ID].Species = 6 then GiveBonus(Killer,3) else SpawnObject(GetPlayerStat(ID,'x'),GetPlayerStat(ID,'y'),drop); WriteConsole(Killer,'Looted: '+loot,cLoot); end; end;end;really basic, i think youll figgure it out
Also how do you do your bot changeing danmer? Do you just have a bunch of sets of zoms or what?