PDA

View Full Version : Updating weapons (SQL Help)


vkrr
04-01-2013, 12:42 PM
Hi,

I am attempting to replace all fabled weapon stats with regular weapon stats.
I have a list of fabled Items and a list of regular items, and I've matched up each of the IDs.

To replace all the stats on Fabled items with the stats on the regular items - what would that code look like?

I also want to randomize some stats on the (then normalized fabled items, in this case WEAPONS) , and to do that I could do this, right?

Update `items` set `damage` = `damage`*(RAND()+1), `astr`=`astr`+(15*RAND()), `asta`=`asta`+(15*RAND()),(ETC) WHERE (`itemtype` = 0 OR `itemtype` = 1 OR `itemtype` = 2 OR `itemtype` = 3 OR `itemtype` = 4 OR `itemtype` = 5

OR `itemtype` = 35 OR `itemtype` = 45) AND `name` like '%fabled%' AND `damage` > 1;


That would set the damage between 100-200% and add strength of 0-15, and add stamina between 0-15, right?

Do I need to make the randoms INTs or will the standard FLOATs be fine for this application?
CONVERT(INT, (10+3)RAND()) #example


Edit: I hope this is clear, My mind is a little fuzzy today.
In short:
1. Take Fabled Item, Replace stats with unfabled item (including req and rec level, etc)
2. Apply semi-random stats to fabled items.

c0ncrete
04-01-2013, 09:39 PM
you'll probably want to match the value returned with the data type of the field it's going to be updating. i'm not sure it won't just truncate the result, but it's never a bad idea to cover your bases.

also, this is shorter and more readable:
WHERE `itemtype` IN (1, 2, 3, 4, 5, 35, 45)

vkrr
04-01-2013, 10:40 PM
Thanks c0nc,

Any suggestion how I can go about updating these tables?
I have a list of regular items and their fabled counterparts saved, but I'm not really sure how to go about copying one set of values over to the other. (Well, all except name, and ID of course)


That's a lot of information to copy over, there has to be an easy way to do it, but i dont know what it is!

vkrr
04-02-2013, 10:06 AM
here's what I got so far


select * from items
where `Name` like 'FABLED%'
or `Name` in (
select replace(`Name`, 'FABLED ', '') as fable_item
from items
where `Name` like 'FABLED%'
);



but now im stuck trying to manipulate the items. I think I took a wrong approach here... any help?