View Single Post
  #1  
Old 01-28-2008, 06:01 PM
Chompy Chompy is offline
¯\(º_o)/¯
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Enchant item, fun function :)

PHP Code:
function onEnchantItem(singularprefixsuffixench_aench_b) {   
  
temp.o_singular singular;
  
temp.o_prefix prefix;
  
temp.o_suffix suffix;

  
temp.ench_a;
  
temp.ench_b;
  
  
temp.enchants = {"str""int""dex""luck""hp""mp""power""dmg""crit""dodge""def"};
  
  for(
temp.enchantsmakevar("this.output_" w) = "";
  
  
temp.c.loadvarsfromarray(a);  
  
temp.d.loadvarsfromarray(b);
  
  
temp.arr1 c.getDynamicVarNames();
  
temp.arr2 d.getDynamicVarNames();
  
  
temp.arr3 0;
  for(
temp.arr1) {
    if (
arr3.index(@ e) == -1) {
      
makevar("this.output_" e) = makevar("c." e) + makevar("d." e);
      
arr3.add(e);
    }
  }
  for(
temp.arr2) {
    if (
arr3.index(@ f) == -1) {
      
makevar("this.output_" f) = makevar("c." f) + makevar("d." f);
      
arr3.add(f);
    }
  }
  
temp.assign 0;
  
temp.output_stats "";
  for(
temp.arr3) {
    
assign = (this.(@ "output_" o).starts("-") ? this.(@ "output_" o) : "+" this.(@ "output_" o)) SPC o ", ";
    if (
o.starts("$")) assign o.substring(1) @ ", ";
    if (!(
assign.starts("+0")) && !(assign.starts("-0")))
      
output_stats @= assign;
  }
  
temp.enchants output_stats.substring(0output_stats.length() - 2);
  
temp."§s §s §s";
  if (
enchants.length() > 0@= " (§s)";
  
output_result format(fo_prefixo_singularo_suffixoutput_stats.substring(0output_stats.length() - 2));
  return 
output_result.trim();

(PS: Replace § with percentage symbol, stupid bad request )
Basicly, you give it a itemname, suffix, prefix and data for the suffix and prefix. You don't have to give prefix and/or suffix.

Basic example:

PHP Code:
temp.item "Pirate Shield";
temp.prefix = {"Warrior's", {"str=2""dex=2""crit=2"}};
temp.suffix = {"of Strength", {"str=3"}};

temp.enchanteditem onEnchantItem(itemprefix[0], suffix[0], prefix[1], suffix[1]);

echo(
enchanteditem); 
Would output:
NPC Code:

Warrior's Pirate Shield of Strength (+2 crit, +2 dex, +5 str)



To test out random items
PHP Code:
function onCreated() {
  
temp.suffix =  {
    {
"of Strength", {"str=2"}},
    {
"of Dexterity", {"dex=2"}},
    {
"of Intelligence", {"int=1""$Attuned Magic"}},
    {
"of Luck", {"luck=1""dex=1""dodge=1"}},
    {
"of Love", {"luck=2""dodge=4""crit=1"}},
    {
"of Light", {"$Attuned Light""int=4"}},
    {
"of Fire", {"$Attuned Fire""int=1""str=1"}},
    {
"of Darkness", {"$Attuned Dark""crit=4""dodge=-1"}},
    {
"of Water", {"$Attuned Water""int=4"}},
    {
"of Ice", {"int=2""dodge=1""crit=1"}},
    {
"of Air", {"dex=2""dodge=6"}},
    {
"of Nature", {"$Attuned Earth""dodge=4"}},
    {
"of Sound", {"dex=3""dodge=8""crit=-1"}},
    {
"of Pain", {"power=3""crit=4""dmg=4"}},
    {
"of Magic", {"int=5""$Attuned Magic"}},
    {
"of Fighting", {"power=4""crit=4""str=1"}},
    {
"of Time", {"dex=7""power=1"}},
    {
"of Power", {"power=3""dmg=10"}}
  };
  
temp.prefix = {
    {
"Warrior's", {"str=2""dex=2""crit=2"}},
    {
"Spellcaster's", {"int=3""luck=1""$Attuned Magic"}},
    {
"Mountaineer's", {"str=6""$Attuned Earth"}},
    {
"Druid's", {"int=5""str=3""$Attuned Earth"}},
    {
"Dragon's", {"str=3""dex=2""int=4""$Attuned Fire"}},
    {
"Shadow's", {"int=6""luck=4""dex=6""$Attuned Dark"}},
    {
"Conjurer's", {"int=9""luck=2"}},
    {
"Thief's", {"dex=8""dodge=5""crit=2"}},
    {
"Scout's", {"dex=7""dodge=6""crit=1"}},
    {
"Fighter's", {"str=9""power=4""dmg=8"}},
    {
"Soldier's", {"str=6""int=1""dmg=9"}},
    {
"Crusader's", {"str=11""dmg=19""crit=3""dodge=-1"}},
    {
"Warlock's", {"int=11""luck=4""$Attuned Dark"}},
    {
"Joker's", {"dodge=11""crit=1"}},
    {
"Archer's", {"dex=12""luck=4"}},
    {
"Berserker's", {"str=10""power=7""crit=5""dodge=-4"}},
    {
"Defender's", {"def=20""dodge=5""crit=1"}},
    {
"Fool's", {"dodge=10""luck=-5"}},
    {
"Gladiator's", {"power=6""crit=6""dodge=-5"}},
    {
"Cleric's", {"dodge=4""luck=8"}},
    {
"Behemoth's", {"def=42""crit=2""dodge=-1"}},
    {
"Beast's", {"str=14""crit=3""dodge=-7"}},
    {
"Captains'", {"int=4""dex=9""dodge=7""crit=-2"}},
    {
"Knight's", {"str=9""int=4""crit=6""dodge=-3"}},
    {
"Monk's", {"int=9""crit=1""dodge=-1""$Attuned Light"}},
    {
"Masters'", {"str=12""dex=11""dodge=17""crit=-2""dmg=15"}},
    {
"Pirate's", {"str=-4""dex=16""dodge=13""crit=1"}},
    {
"Rogue's", {"dex=10""dodge=11""crit=-1"}},
    {
"Sage's", {"int=15""luck=2""crit=-1"}},
    {
"Priest's", {"int=11""crit=3""$Attuned Light"}},
    {
"Necromancer's", {"int=9""crit=1""dodge=2""luck=3""$Attuned Fire"}},
    {
"Valkyrie's", {"int=9""luck=-5""crit=9""dodge=2"}},
    {
"Summoner's", {"int=10""crit=3""dodge=1""$Attuned Magic"}},
    {
"Shaman's", {"int=6""str=3""dodge=3"}},
    {
"Witch's", {"int=9""luck=-1""dodge=2""$Attuned Dark"}},
    {
"Newcomer's", {"str=1""crit=1"}},
    {
"Adventurer's", {"dex=15""luck=5""dodge=21""crit=5"}},
    {
"Forester's", {"$Attuned Earth""dodge=11""int=2"}}
    
  };
  
temp.items = {
    
"Wooden Sword",
    
"Inferno Blade",
    
"Cursed Blade",
    
"Iron Plate",
    
"Blaze Helmet",
    
"Fenix Sword",
    
"Zhar Blade",
    
"Blaze Wand",
    
"Flare Blade",
    
"Rusted Iron Sword",
    
"Pirate Shield",
    
"Spider Fang",
    
"Zitter"
  
};
  
  
temp.randomnumber int(random(0items.size() - 1));
  
temp.randomitem items[randomnumber][0];
  
  
temp.randomnumber int(random(0prefix.size() - 1));
  
temp.randomprefix = {prefix[randomnumber][0], prefix[randomnumber][1]};
  
  
temp.randomnumber int(random(0suffix.size() - 1));
  
temp.randomsuffix = {suffix[randomnumber][0], suffix[randomnumber][1]};
  
  echo(
onEnchantItem(randomitemrandomprefix[0], randomsuffix[0], randomprefix[1], randomsuffix[1]));

Some outputs:
NPC Code:

Pirate's Flare Blade of Darkness (+5 crit, +16 dex, +12 dodge, -4 str, Attuned Dark)
Rogue's Spider Fang of Nature (-1 crit, +10 dex, +15 dodge, Attuned Earth)
Scout's Spider Fang of Ice (+2 crit, +7 dex, +7 dodge, +2 int)
Mountaineer's Fenix Sword of Sound (Attuned Earth, +6 str, -1 crit, +3 dex, +8 dodge)
Joker's Blaze Helmet of Air (+1 crit, +17 dodge, +2 dex)
Scout's Cursed Blade of Dexterity (+1 crit, +9 dex, +6 dodge)
Beast's Wooden Sword of Water (+3 crit, -7 dodge, +14 str, Attuned Water, +4 int)
Warlock's Zhar Blade of Luck (Attuned Dark, +11 int, +5 luck, +1 dex, +1 dodge)
Cleric's Rusted Iron Sword of Dexterity (+4 dodge, +8 luck, +2 dex)



How it works:

Define all enchants that it will plus/minus together in 'temp.enchants' in the onEnchantItem() function. It also supports, 'text based enchants'. For example in some of the outputs above you see "Attuned Water" or "Attuned Dark". There vars are added to the () if in the function params (2 last params) the vars to be added contains $ as prefix, for example:

PHP Code:
temp.item "Gravitron Mace";
temp.suffix = {"of Reality", {"str=-11""dex=-5""crit=12"}};
temp.prefix = {"Halo's", {"int=27""dex=8""$Effect: Gravity"}};

temp.enchanteditem onEnchantItem(itemprefix[0], suffix[0], prefix[1], suffix[1]);

echo(
enchanteditem); 
Would output:
NPC Code:

Halo's Gravitron Mace of Reality (Effect: Gravity, +3 dex, +27 int, +12 crit, -11 str)



Enjoy..?
__________________

Last edited by Chompy; 01-28-2008 at 11:50 PM..
Reply With Quote