CREATE TRIGGER [dbo].[NewChar_Level] ON [dbo].[ChaInfo]
after update
as
BEGIN
Update [ChaInfo] set [ChaInfo].ChaLevel=100
From Inserted
Where Inserted.ChaLevel = 1 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaSkillPoint=1500
From Inserted
Where Inserted.ChaSkillPoint = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaStRemain=1500
From Inserted
Where Inserted.ChaStRemain = 3 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaMoney=1000000
From Inserted
Where Inserted.ChaMoney = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaPower=100
From Inserted
Where Inserted.ChaPower = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaStrong=100
From Inserted
Where Inserted.ChaStrong = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaStrength=100
From Inserted
Where Inserted.ChaStrength = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaSpirit=100
From Inserted
Where Inserted.ChaSpirit = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaDex=100
From Inserted
Where Inserted.ChaDex = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
Update [ChaInfo] set [ChaInfo].ChaIntel=100
From Inserted
Where Inserted.ChaIntel = 0 and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
-- HERE
Update [ChaInfo] set [ChaInfo].ChaReborn = 0,[ChaInfo].ChaTribe = 1
from Inserted
Where Inserted.ChaTribe = 0
Update [ChaInfo] set [ChaInfo].ChaLevel=1, -- Level that you get after reborn
[ChaInfo].ChaReborn=[ChaInfo].ChaReborn + 1, -- Reborn counter
[ChaInfo].ChaExp=0, -- Set Exp back to 0
[ChaInfo].ChaStRemain = (100*[ChaInfo].ChaReborn), -- how many stat points you get per reborn
[ChaInfo].ChaPower = 0, -- Set the number of Pow you added to 0
[ChaInfo].ChaStrong = 0, -- Set the number of Vit you added to 0
[ChaInfo].ChaStrength = 0, -- Set the number of Stm you added to 0
[ChaInfo].ChaSpirit = 0, -- Set the number of Int you added to 0
[ChaInfo].ChaDex = 0, -- Set the number of Dex you added to 0
[ChaInfo].ChaMoney = [ChaInfo].ChaMoney - 2000000, -- Optional : Reborn cost 2m
[ChaInfo].ChaSkillPoint = (10*[ChaInfo].ChaReborn), -- Set the Skillpoints per reborn
[ChaInfo].ChaSkills = NULL, -- Optional : Forget all skills after reborn
[ChaInfo].ChaSkillSlot = NULL, -- Optional : Delete shortcut list of skills
[ChaInfo].ChaQuest = NULL -- Optional : Delete quest list (need restart all quests) after reborn
From Inserted
Where Inserted.ChaLevel = 300 -- Level to reborn
and [ChaInfo].ChaReborn < 10 -- Max Reborn number
and [ChaInfo].ChaName=inserted.ChaName
and [ChaInfo].UserNum =inserted.UserNum
and [ChaInfo].ChaBright >= 0 -- Optional : Require 0 or more attr for reborn
and [ChaInfo].ChaMoney >= 2000000 -- Optional : Require 2m gold for reborn
END