Help with Tables
raze_struck
Member, PRO Posts: 141
Hello,
I have a question, I have a game attribute called game.attk. I have an inventory that allows you to change which weapon(s) are equipped.
GAME . ATTACK = 20
Lets say weapon 1 = 5 + attack, and weapon 2 = 15+ attack
I have it set up to say if weapon.equipped =1, change attribute game.attack to game.attack +5
If weapon.equipped = 2, change attribute game.attack to game.attack + 15,
This is a problem because when I un-equip a weapon 1 game.attack is still 25, and it keeps stacking if I un-equip and re-equip.
I feel like tables are the solution, I just dont know how to go about it.
Comments
Yes, tables are the solution. In each row, put the value of the attack for that weapon (not the increase amount... the total attack) in the first column.
Use an integer game attribute called game.weapon to designate the weapon number that is equipped. To find the attack value for that weapon, use tableCellValue(tableName,game.weapon,1).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Thanks for the response, will this work though if I have other equipment as well. Like for example boots that give +5 attack. If I concurrently equip boots +5 attack, and a weapon +10 attack, if I change attack to the table cell value of weapon 1 it wont account for the +5 attack from boots, right?
I recommend that you have two attack stats. You have base power. And Attack. Make your attack equal to your Power plus any and all +s from the table. So that you never overwrite the original number entirely.
Here's the thing I have 5 seperate attributes, attack, magic attack, magic defense, luck and defense. 5 different types of equippable items at once, that will manipulate these attributes, so I need to account for the changes from each
That's a very good idea actually, That solves almost all problems, but now let me ask you this, if I change the value to table cell value whatever if a weapon is equipped, when I change to another weapon, will it deduct the initial values changed?
for example. base attack = 20 (int) Dont mind the syntax below, just saving time
table cell value 1 weapon grants + 5attk
table cell value 2 weapon grants +10 attk
If I say (if cell value 1 = true, change base.attk to base.attk+tablecellvalue1)
but if I say (if cell value 2 = true, change base.attk to base. attk+ table cell value 2)
it will stack both for a total of 20 + attk right?
Basically I need to make them mutually exclusive events
Nevermind, I misread your comment. But i have 80 items !!! llol
Sort them into categories. Give each category a Zero state, for Empty. So have it check each equipment slot for Empty or for whatever bonus it has.
Sorry , I don't understand, what do you mean by category?
Some items will have +5attack, and +10 magic attack as well
I just thought of a more messed up way of doing it,
what if I set game.attack to like 200, and then have each item say if equipped change game.attk to game.attk + 5, else game.attk to -5, and then initially you'll start with 20 attack because of all the false booleans.
In other words lets say the summation of all potential attribute bonuses on items equals
+400 in each category, I could set the initial values to 420, meaning the game will start with 20 in each attribute. because all booleans will be false.
I dont recommend it since that sounds a bit overcomplicating.
What I meant is, I assume you can only equip one of any "type" of item at a time. So the equation to confirm attack or stats should add one of each "type" like weapon, armor, hats, rings, so forth. Because of that, each type of item should have its own column or pair of columns, and each column should start with an empty hand option with zero stats, so that you can do the base as well. That way the game wont hunt through all 80 or so items one at a time, but instead sort them into their types and look for the one of each to plug into the equation.
I'll admit I haven't followed this whole thread but maybe a demo will be helpful: https://www.dropbox.com/s/odov10fwgkvnx5y/Weapon Select & Attack Strength.zip.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
well you are certainly right, I wish I read this before hand, guys I'm going crazy trying to figure this out
A bit confused about this one I'm not going to lie.
Nevermind this demo was helpful thank you soo much , iLL JUST HAVE TO CREATE
ATTACK INCREASE, ATTACK INCREASE 2....and so on for different types of equip and say
attack = base + attack inc 1 + attack inc 2 and so on