Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DELIMITER //
- CREATE FUNCTION expToLevel (experience BIGINT UNSIGNED)
- RETURNS SMALLINT UNSIGNED DETERMINISTIC
- BEGIN
- DECLARE level SMALLINT DEFAULT 1;
- DECLARE totalExp BIGINT DEFAULT 250;
- DECLARE toLevel BIGINT DEFAULT 50;
- WHILE experience >= totalExp + toLevel DO
- SET totalExp = totalExp + toLevel;
- IF level < 35 THEN SET toLevel = totalExp * 0.3;
- ELSEIF level < 80 THEN SET toLevel = totalExp * 0.1;
- ELSEIF level < 150 THEN SET toLevel = totalExp * 0.08;
- ELSEIF level < 180 THEN SET toLevel = totalExp * 0.05;
- ELSE SET toLevel = totalExp * 0.03;
- END IF;
- SET level = level + 1;
- END WHILE;
- RETURN level;
- END;//
- DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment