home *** CD-ROM | disk | FTP | other *** search
- function attachitem(item, num, type)
- {
- if(!random(item.rare) or !random(item.rare))
- {
- i = display.attachMovie("itemicon","itemicon" + items,items);
- i.gotoAndStop(type);
- i.icon.gotoAndStop(item.framename);
- i._x = items % 6 * 60 + 25;
- i._y = 25 + Math.floor(items / 6) * 60;
- items++;
- i.cost = item.cost;
- i.num = num;
- i.framename = item.framename;
- i.name = item.name;
- i.type = type;
- i.onRollOver = function()
- {
- statstr = "";
- for(obj in item.attr)
- {
- statstr += " " + obj + " +" + item.attr[obj];
- }
- desc = this.name + " - " + this.cost + "gp -" + statstr;
- };
- i.onRelease = function()
- {
- confirm.item = this;
- confirm.type = this.type;
- confirm._visible = true;
- confirm.gotoAndStop(1);
- if(_root.playerMoney >= this.cost)
- {
- confirm.txt = "would you like to buy the " + this.name + " for " + this.cost + "gp?";
- confirm.yes._visible = true;
- }
- else
- {
- confirm.txt = "you cannot afford this";
- confirm.yes._visible = false;
- }
- confirm.no.onRelease = function()
- {
- confirm._visible = false;
- };
- confirm.yes.onRelease = function()
- {
- _root.playerMoney -= confirm.item.cost;
- _root.playerCharacter.gotoAndPlay("land");
- switch(confirm.type)
- {
- case "weapon":
- _root.playerWeapons.push(confirm.item.num);
- break;
- case "helmet":
- _root.playerHelmets.push(confirm.item.num);
- break;
- case "shield":
- _root.playerShields.push(confirm.item.num);
- break;
- case "boots":
- _root.playerBoots.push(confirm.item.num);
- break;
- case "armour":
- _root.playerArmours.push(confirm.item.num);
- break;
- case "arm":
- _root.playerArms.push(confirm.item.num);
- }
- gp = "you have " + _root.playerMoney + "gp";
- confirm.item._visible = false;
- confirm.nextFrame();
- };
- };
- }
- }
- stop();
- gp = "you have " + _root.playerMoney + "gp";
- items = 0;
- for(w in _root.possibleWeapons)
- {
- owned = false;
- for(w2 in _root.playerWeapons)
- {
- if(_root.playerWeapons[w2] == w)
- {
- owned = true;
- }
- }
- if(!owned)
- {
- weap = _root.possibleWeapons[w];
- attachitem(weap,w,"weapon");
- }
- }
- for(w in _root.possibleShields)
- {
- owned = false;
- for(w2 in _root.playerShields)
- {
- if(_root.playerShields[w2] == w)
- {
- owned = true;
- }
- }
- if(!owned)
- {
- item = _root.possibleShields[w];
- attachitem(item,w,"shield");
- }
- }
- for(w in _root.possibleHelmets)
- {
- owned = false;
- for(w2 in _root.playerHelmets)
- {
- if(_root.playerHelmets[w2] == w)
- {
- owned = true;
- }
- }
- if(!owned)
- {
- item = _root.possibleHelmets[w];
- attachitem(item,w,"helmet");
- }
- }
- for(w in _root.possibleArmours)
- {
- owned = false;
- for(w2 in _root.playerArmours)
- {
- if(_root.playerArmours[w2] == w)
- {
- owned = true;
- }
- }
- if(!owned)
- {
- item = _root.possibleArmours[w];
- attachitem(item,w,"armour");
- }
- }
- for(w in _root.possibleArms)
- {
- owned = false;
- for(w2 in _root.playerArms)
- {
- if(_root.playerArms[w2] == w)
- {
- owned = true;
- }
- }
- if(!owned)
- {
- item = _root.possibleArms[w];
- attachitem(item,w,"arm");
- }
- }
- for(w in _root.possibleBoots)
- {
- owned = false;
- for(w2 in _root.playerBoots)
- {
- if(_root.playerBoots[w2] == w)
- {
- owned = true;
- }
- }
- if(!owned)
- {
- item = _root.possibleBoots[w];
- attachitem(item,w,"boots");
- }
- }
-