home *** CD-ROM | disk | FTP | other *** search
/ 600 Games / 600games.iso / Acao / gladiator_castle_war.swf / scripts / DefineSprite_492 / frame_1 / DoAction.as
Encoding:
Text File  |  2007-03-15  |  4.1 KB  |  175 lines

  1. function attachitem(item, num, type)
  2. {
  3.    if(!random(item.rare) or !random(item.rare))
  4.    {
  5.       i = display.attachMovie("itemicon","itemicon" + items,items);
  6.       i.gotoAndStop(type);
  7.       i.icon.gotoAndStop(item.framename);
  8.       i._x = items % 6 * 60 + 25;
  9.       i._y = 25 + Math.floor(items / 6) * 60;
  10.       items++;
  11.       i.cost = item.cost;
  12.       i.num = num;
  13.       i.framename = item.framename;
  14.       i.name = item.name;
  15.       i.type = type;
  16.       i.onRollOver = function()
  17.       {
  18.          statstr = "";
  19.          for(obj in item.attr)
  20.          {
  21.             statstr += " " + obj + " +" + item.attr[obj];
  22.          }
  23.          desc = this.name + " - " + this.cost + "gp -" + statstr;
  24.       };
  25.       i.onRelease = function()
  26.       {
  27.          confirm.item = this;
  28.          confirm.type = this.type;
  29.          confirm._visible = true;
  30.          confirm.gotoAndStop(1);
  31.          if(_root.playerMoney >= this.cost)
  32.          {
  33.             confirm.txt = "would you like to buy the " + this.name + " for " + this.cost + "gp?";
  34.             confirm.yes._visible = true;
  35.          }
  36.          else
  37.          {
  38.             confirm.txt = "you cannot afford this";
  39.             confirm.yes._visible = false;
  40.          }
  41.          confirm.no.onRelease = function()
  42.          {
  43.             confirm._visible = false;
  44.          };
  45.          confirm.yes.onRelease = function()
  46.          {
  47.             _root.playerMoney -= confirm.item.cost;
  48.             _root.playerCharacter.gotoAndPlay("land");
  49.             switch(confirm.type)
  50.             {
  51.                case "weapon":
  52.                   _root.playerWeapons.push(confirm.item.num);
  53.                   break;
  54.                case "helmet":
  55.                   _root.playerHelmets.push(confirm.item.num);
  56.                   break;
  57.                case "shield":
  58.                   _root.playerShields.push(confirm.item.num);
  59.                   break;
  60.                case "boots":
  61.                   _root.playerBoots.push(confirm.item.num);
  62.                   break;
  63.                case "armour":
  64.                   _root.playerArmours.push(confirm.item.num);
  65.                   break;
  66.                case "arm":
  67.                   _root.playerArms.push(confirm.item.num);
  68.             }
  69.             gp = "you have " + _root.playerMoney + "gp";
  70.             confirm.item._visible = false;
  71.             confirm.nextFrame();
  72.          };
  73.       };
  74.    }
  75. }
  76. stop();
  77. gp = "you have " + _root.playerMoney + "gp";
  78. items = 0;
  79. for(w in _root.possibleWeapons)
  80. {
  81.    owned = false;
  82.    for(w2 in _root.playerWeapons)
  83.    {
  84.       if(_root.playerWeapons[w2] == w)
  85.       {
  86.          owned = true;
  87.       }
  88.    }
  89.    if(!owned)
  90.    {
  91.       weap = _root.possibleWeapons[w];
  92.       attachitem(weap,w,"weapon");
  93.    }
  94. }
  95. for(w in _root.possibleShields)
  96. {
  97.    owned = false;
  98.    for(w2 in _root.playerShields)
  99.    {
  100.       if(_root.playerShields[w2] == w)
  101.       {
  102.          owned = true;
  103.       }
  104.    }
  105.    if(!owned)
  106.    {
  107.       item = _root.possibleShields[w];
  108.       attachitem(item,w,"shield");
  109.    }
  110. }
  111. for(w in _root.possibleHelmets)
  112. {
  113.    owned = false;
  114.    for(w2 in _root.playerHelmets)
  115.    {
  116.       if(_root.playerHelmets[w2] == w)
  117.       {
  118.          owned = true;
  119.       }
  120.    }
  121.    if(!owned)
  122.    {
  123.       item = _root.possibleHelmets[w];
  124.       attachitem(item,w,"helmet");
  125.    }
  126. }
  127. for(w in _root.possibleArmours)
  128. {
  129.    owned = false;
  130.    for(w2 in _root.playerArmours)
  131.    {
  132.       if(_root.playerArmours[w2] == w)
  133.       {
  134.          owned = true;
  135.       }
  136.    }
  137.    if(!owned)
  138.    {
  139.       item = _root.possibleArmours[w];
  140.       attachitem(item,w,"armour");
  141.    }
  142. }
  143. for(w in _root.possibleArms)
  144. {
  145.    owned = false;
  146.    for(w2 in _root.playerArms)
  147.    {
  148.       if(_root.playerArms[w2] == w)
  149.       {
  150.          owned = true;
  151.       }
  152.    }
  153.    if(!owned)
  154.    {
  155.       item = _root.possibleArms[w];
  156.       attachitem(item,w,"arm");
  157.    }
  158. }
  159. for(w in _root.possibleBoots)
  160. {
  161.    owned = false;
  162.    for(w2 in _root.playerBoots)
  163.    {
  164.       if(_root.playerBoots[w2] == w)
  165.       {
  166.          owned = true;
  167.       }
  168.    }
  169.    if(!owned)
  170.    {
  171.       item = _root.possibleBoots[w];
  172.       attachitem(item,w,"boots");
  173.    }
  174. }
  175.