It always says, that it is 0. Here is my code
Code: Select all
use uo;
use os;
use unicode;
use util;
include "include/canAccess";
include "include/unicode";
var boniPvM:=array{"Untote", "Orks", "Vampire", "Tiere", "Schatten", "Halbmenschen"};
var boniPvP:=array{"Schwertverteidigung","Zweihandverteidigung","Dolchverteidigung","Pfeilwiderstand","Magiewiderstand"};
var boniSonstiges:=array{"Abwehr gegen Ohnmacht","Ohnmachtchance","Max TP","Angriffsgeschwindigkeit"};
program segenskugel(who,item)
if (!can_access(who, item))
return;
endif
var use_on:= Target (who, TGTOPT_CHECK_LOS);
if (use_on.isA (POLCLASS_WEAPON) || use_on.isA (POLCLASS_ARMOR))
var existingBoni:= GetObjProperty (who, "existingBoni");
if (existingBoni== error)
existingBoni:= dictionary;
endif
SendSysMessageUC (who, asc2uc("Dictionary Size:"+existingBoni.Size()), "DEU", _DEFAULT_UCFONT, 5);
if(existingBoni.Size() >=3)
SendSysMessageUC (who, asc2uc("Ihr koennt diesem Gegenstand keinen weiteren Bonus mehr hinzufuegen!"), "DEU", _DEFAULT_UCFONT, 5);
return 0;
endif
var erfolg:=RandomDiceRoll("1d7");
if(erfolg > 3)
SendSysMessageUC (who, asc2uc("Das Hinzufuegen ist leider fehlgeschlagen!"), "DEU", _DEFAULT_UCFONT, 5);
DestroyItem(item);
return 0;
endif
var art:=RandomDiceRoll("1d3");
case(art)
1:
var bonusPvM:=RandomDiceRoll("1d6");
add(who, use_on, boniPvM[bonusPvM], RandomDiceRoll("1d20"));
2:
var bonusPvP:=RandomDiceRoll("1d5");
add(who, use_on, boniPvP[bonusPvP], RandomDiceRoll("1d10"));
3:
var bonusSonstiges:=RandomDiceRoll("1d4");
add(who, use_on, boniSonstiges[bonusSonstiges], RandomDiceRoll("1d8"));
endcase
DestroyItem(item);
else
SendSysMessageUC (who, asc2uc("Ihr koennt nur Waffen und Ruestungen einen Bonus hinzufuegen."), "DEU", _DEFAULT_UCFONT, 5);
endif
endprogram
function add(who,item, bonus, prozent)
var dict:=GetObjProperty(item,"existingBoni");
if (dict== error)
dict:= dictionary;
endif
dict.insert(bonus,prozent);
SetObjProperty(item,"existingBoni",dict);
SendSysMessageUC (who, asc2uc("Ihr habt den Bonus " + bonus + " hinzugefuegt!"), "DEU", _DEFAULT_UCFONT, 5);
endfunction