TheHanna
December 29th, 2007, 10:16 PM
So, I decided to try and beef up my Actionscript skills by making an RPG. Everything started off ok (I actually used the tutorial here on kirupa.com to get my bearings), and I started working on the stat system recently. I can't seem to make it work how I want it to. I want the player to be able to collect weapons and spells, and then be able to select them from a ComboBox. Different weapons and spells will give different stats, of course. However, I'm just trying to get it to where when the player changes weapons and spells, the total power bonus they get is calculated correctly, and right now it isn't. When I initially set the variables (at 1), the function processes it correctly, but when the player switches weapons or spells, it doesn't change the total power, just the weapon and spell power. Here's my code:
var totalMoney = 0;
var weaponSwitch:Object = new Object();
weaponList.addEventListener("change", weaponSwitch);
weaponSwitch.change = function() {
weaponPower = weaponList.value;
}
var spellSwitch:Object = new Object();
spellList.addEventListener("change", spellSwitch);
spellSwitch.change = function() {
spellPower = spellList.value;
}
function totalPower(nA:Number, nB:Number, nC:Number):Number {
return(nA+nB+nC);
}
var basePower:Number = 1;
var weaponPower:Number = 1;
var spellPower:Number = 1;
var power:Number = totalPower(basePower, weaponPower, spellPower);
And here's a link to my FLA:
http://www.thehanna.com/game/runelord-engine.fla
PS: I'm just using filler graphics until I get the code working.
var totalMoney = 0;
var weaponSwitch:Object = new Object();
weaponList.addEventListener("change", weaponSwitch);
weaponSwitch.change = function() {
weaponPower = weaponList.value;
}
var spellSwitch:Object = new Object();
spellList.addEventListener("change", spellSwitch);
spellSwitch.change = function() {
spellPower = spellList.value;
}
function totalPower(nA:Number, nB:Number, nC:Number):Number {
return(nA+nB+nC);
}
var basePower:Number = 1;
var weaponPower:Number = 1;
var spellPower:Number = 1;
var power:Number = totalPower(basePower, weaponPower, spellPower);
And here's a link to my FLA:
http://www.thehanna.com/game/runelord-engine.fla
PS: I'm just using filler graphics until I get the code working.