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

  1. function findStats()
  2. {
  3.    playerStats = {agi:40,def:0,att:0};
  4.    itms = new Array();
  5.    itms.push(_root.possibleWeapons[_root.playerActiveWeapon]);
  6.    itms.push(_root.possibleShields[_root.playerActiveShield]);
  7.    itms.push(_root.possibleHelmets[_root.playerActiveHelmet]);
  8.    itms.push(_root.possibleArmours[_root.playerActiveArmour]);
  9.    itms.push(_root.possibleArms[_root.playerActiveArms]);
  10.    itms.push(_root.possibleBoots[_root.playerActiveBoots]);
  11.    for(i in itms)
  12.    {
  13.       item = itms[i];
  14.       if(item.attr.agi !== undefined)
  15.       {
  16.          playerStats.agi += item.attr.agi;
  17.       }
  18.       if(item.attr.att !== undefined)
  19.       {
  20.          playerStats.att += item.attr.att;
  21.       }
  22.       if(item.attr.def !== undefined)
  23.       {
  24.          playerStats.def += item.attr.def;
  25.       }
  26.    }
  27.    stats = "att=" + playerStats.att + " def=" + playerStats.def + " agi=" + playerStats.agi;
  28.    return playerStats;
  29. }
  30. function attachitem(item, num, type)
  31. {
  32.    i = display.attachMovie("itemicon","itemicon" + items,items);
  33.    i.gotoAndStop(type);
  34.    i.icon.gotoAndStop(item.framename);
  35.    i._x = items % 4 * 60 + 25;
  36.    i._y = 25 + Math.floor(items / 4) * 60;
  37.    items++;
  38.    i.cost = item.cost;
  39.    i.num = num;
  40.    i.framename = item.framename;
  41.    i.name = item.name;
  42.    i.type = type;
  43.    i.onRollOver = function()
  44.    {
  45.       itemname = this.name;
  46.    };
  47.    i.onRollOut = function()
  48.    {
  49.       itemname = "";
  50.    };
  51.    i.onRelease = function()
  52.    {
  53.       switch(this.type)
  54.       {
  55.          case "weapon":
  56.             _root.playerActiveWeapon = this.num;
  57.             weapon.icon.gotoAndStop(this.framename);
  58.             break;
  59.          case "helmet":
  60.             _root.playerActiveHelmet = this.num;
  61.             helmet.icon.gotoAndStop(this.framename);
  62.             break;
  63.          case "shield":
  64.             _root.playerActiveShield = this.num;
  65.             shield.icon.gotoAndStop(this.framename);
  66.             break;
  67.          case "boots":
  68.             _root.playerActiveBoots = this.num;
  69.             boots.icon.gotoAndStop(this.framename);
  70.             break;
  71.          case "armour":
  72.             _root.playerActiveArmour = this.num;
  73.             armour.icon.gotoAndStop(this.framename);
  74.             break;
  75.          case "arm":
  76.             _root.playerActiveArms = this.num;
  77.             arm.icon.gotoAndStop(this.framename);
  78.       }
  79.       findStats();
  80.    };
  81. }
  82. findStats();
  83. stop();
  84. gp = "you have " + _root.playerMoney + "gp";
  85. items = 0;
  86. for(w in _root.playerWeapons)
  87. {
  88.    weap = _root.possibleWeapons[_root.playerWeapons[w]];
  89.    attachitem(weap,_root.playerWeapons[w],"weapon");
  90. }
  91. for(w in _root.playerShields)
  92. {
  93.    weap = _root.possibleShields[_root.playerShields[w]];
  94.    attachitem(weap,_root.playerShields[w],"shield");
  95. }
  96. for(w in _root.playerHelmets)
  97. {
  98.    weap = _root.possibleHelmets[_root.playerHelmets[w]];
  99.    attachitem(weap,_root.playerHelmets[w],"helmet");
  100. }
  101. for(w in _root.playerArmours)
  102. {
  103.    weap = _root.possibleArmours[_root.playerArmours[w]];
  104.    attachitem(weap,_root.playerArmours[w],"armour");
  105. }
  106. for(w in _root.playerArms)
  107. {
  108.    weap = _root.possibleArms[_root.playerArms[w]];
  109.    attachitem(weap,_root.playerArms[w],"arm");
  110. }
  111. for(w in _root.playerBoots)
  112. {
  113.    weap = _root.possibleBoots[_root.playerBoots[w]];
  114.    attachitem(weap,_root.playerBoots[w],"boots");
  115. }
  116.