Bläddra i källkod

- Completed Mercenary Create, Delete, Save. Tests OK.
- Incremented MAX_SKILL required for a proper load of Mercenary Skills.
- Some fixes.

git-svn-id: https://svn.code.sf.net/p/rathena/svn/trunk@13118 54d463be-8e91-2dee-dedb-b68131a5f0ec

zephyrus 16 år sedan
förälder
incheckning
399efe15bd

+ 26 - 26
db/skill_cast_db.txt

@@ -1034,57 +1034,57 @@
 
 //===== Mercenary Skills ===================
 //-- MS_MAGNUM
-//8202,0,0,0,2000,10000
+8202,0,0,0,2000,10000
 //-- KN_BOWLINGBASH
-//8203,700,0,0,0,0
+8203,700,0,0,0,0
 //-- LK_PARRYING
-//8204,0,0,0,15000:20000:25000:30000:35000:40000:45000:50000:55000:60000,0
+8204,0,0,0,15000:20000:25000:30000:35000:40000:45000:50000:55000:60000,0
 //-- CR_REFLECTSHIELD
-//8205,0,0,0,300000,0
+8205,0,0,0,300000,0
 //-- MS_BERSERK
-//359,0,0,0,300000,15000
+8206,0,0,0,300000,15000
 //-- MA_DOUBLE
-//8207,0,0,0,100,0
+8207,0,0,0,100,0
 //-- MA_SHOWER
-//8208,0,0,0,100,0
+8208,0,0,0,100,0
 //-- MA_SKIDTRAP
-//8209,0,0,0,300000:240000:180000:120000:60000,0
+8209,0,0,0,300000:240000:180000:120000:60000,0
 //-- MA_LANDMINE
-//8210,0,0,0,200000:160000:120000:80000:40000,5000
+8210,0,0,0,200000:160000:120000:80000:40000,5000
 //-- MA_SANDMAN
-//8211,0,0,0,150000:120000:90000:60000:30000,12000:14000:16000:18000:20000
+8211,0,0,0,150000:120000:90000:60000:30000,12000:14000:16000:18000:20000
 //-- MA_FREEZINGTRAP
-//8212,0,0,0,150000:120000:90000:60000:30000,3000:6000:9000:12000:15000
+8212,0,0,0,150000:120000:90000:60000:30000,3000:6000:9000:12000:15000
 //-- MA_CHARGEARROW
-//8214,1500,0,0,0,0
+8214,1500,0,0,0,0
 //-- MA_SHARPSHOOTING
-//8215,2000,1500,0,0,0
+8215,2000,1500,0,0,0
 //-- ML_BRANDISHSPEAR
-//8217,700,0,0,0,0
+8217,700,0,0,0,0
 //-- ML_SPIRALPIERCE
-//8218,300:500:700:900:1000,1200:1400:1600:1800:2000,0,0,1000
+8218,300:500:700:900:1000,1200:1400:1600:1800:2000,0,0,1000
 //-- ML_DEFENDER
-//8219,0,800,0,180000,0
+8219,0,800,0,180000,0
 //-- ML_AUTOGUARD
-//8220,0,0,0,300000,0
+8220,0,0,0,300000,0
 //-- ML_DEVOTION
-//8221,3000,0,0,0,30000:45000:60000:75000:90000
+8221,3000,0,0,0,30000:45000:60000:75000:90000
 //-- MER_MAGNIFICAT
-//8222,4000,2000,0,30000:45000:60000:75000:90000,0
+8222,4000,2000,0,30000:45000:60000:75000:90000,0
 //-- MER_QUICKEN
-//8223,0,0,0,30000:60000:90000:120000:150000:180000:210000:240000:270000:300000,0
+8223,0,0,0,30000:60000:90000:120000:150000:180000:210000:240000:270000:300000,0
 //-- MER_SIGHT
-//8224,0,0,0,10000,0
+8224,0,0,0,10000,0
 //-- MER_CRASH
-//8225,1000,2000,0,0,0
+8225,1000,2000,0,0,0
 //-- MER_PROVOKE
-//8232,0,0,0,30000,0
+8232,0,0,0,30000,0
 //-- MER_DECAGI
-//8234,1000,1000,0,40000:50000:60000:70000:80000:90000:100000:110000:120000:130000,0
+8234,1000,1000,0,40000:50000:60000:70000:80000:90000:100000:110000:120000:130000,0
 //-- MER_SCAPEGOAT
-//8235,3000,0,0,0,0
+8235,3000,0,0,0,0
 //-- MER_LEXDIVINA
-//8236,0,3000,0,30000:35000:40000:45000:50000:60000:60000:60000:60000:60000,0
+8236,0,3000,0,30000:35000:40000:45000:50000:60000:60000:60000:60000:60000,0
 //==========================================
 
 //===== Guild Skills =======================

+ 37 - 37
db/skill_db.txt

@@ -676,43 +676,43 @@
 8016,4,6,4,-1,0xD2,4,3,1,no,0,0,0,misc,0,        HVAN_EXPLOSION,Bio Explosion
 
 // Mercenary Skill Place holders
-//8201,-1,6,1,-1,0,0,10,1,no,0,0,0,weapon,0,	MS_BASH,Bash
-//8202,0,6,4,3,0x2,2,10,1,no,0,0,0,weapon,2,	MS_MAGNUM,Magnum_Break
-//8203,-2,6,1,-1,0x2,1,10,1,no,33,0,0,weapon,1,	MS_BOWLINGBASH,Bowling_Bash
-//8204,0,6,4,0,0x1,0,10,1,no,0,0,0,weapon,0,	MS_PARRYING,Parry
-//8205,0,6,4,0,0,0,10,1,no,0,0,0,weapon,0,	MS_REFLECTSHIELD,Shield_Reflect
-//8206,0,6,4,0,0x1,0,1,1,no,0,0,0,weapon,0,	MS_BERSERK,Frenzy
-//8207,-9,8,1,-1,0,0,10,2,no,0,0,0,weapon,0,	MA_DOUBLE,Double_Strafe
-//8208,-9,6,2,-1,0x2,2,10,1,no,0,0,0,weapon,2,	MA_SHOWER,Arrow_Shower
-//8209,3,6,2,0,0x1,0,5,1,no,0,0x80,0,misc,6:7:8:9:10,	MA_SKIDTRAP,Skid_Trap
-//8210,3,6,2,2,0x40,0,5,1,no,0,0x80,0,misc,0,	MA_LANDMINE,Land_Mine
-//8211,3,6,2,0,0x3,2,5,1,no,0,0x80,0,misc,0,	MA_SANDMAN,Sandman
-//8212,3,6,2,1,0x42,1,5,1,no,0,0x80,0,weapon,0,	MA_FREEZINGTRAP,Freezing_Trap
-//8213,2,6,32,0,0x1,0,1,1,no,0,0,0,misc,0,	MA_REMOVETRAP,Remove_Trap
-//8214,-9,6,1,-1,0x2,0,1,1,no,0,0x1,0,weapon,6,	MA_CHARGEARROW,Arrow_Repel
-//8215,4,8,1,-1,0,2,5,1,yes,0,0,14,weapon,0,	MA_SHARPSHOOTING,Focused_Arrow_Strike
-//8216,-2,8,1,-1,0,0,10,3,no,0,0,0,weapon,0,	ML_PIERCE,Pierce
-//8217,-2,6,1,-1,0x1,0,10,1,no,33,0,0,weapon,3,	ML_BRANDISH,Brandish_Spear
-//8218,5,8,1,-1,0x20,0,5,5,no,0,0,0,weapon,0,	ML_SPIRALPIERCE,Spiral_Pierce
-//8219,0,6,4,0,0x1,0,5,1,no,0,0,0,weapon,0,	ML_DEFENDER,Defending_Aura
-//8220,0,6,4,0,0x1,0,10,1,no,0,0,0,weapon,0,	ML_AUTOGUARD,Guard
-//8221,7:8:9:10:11,6,16,0,0x1,0,5,1,yes,0,0x600,0,none,0,	ML_DEVOTION,Sacrifice
-//8222,0,6,4,0,0x3,-1,5,1,yes,0,0,0,magic,0,	MER_MAGNIFICAT,Magnificat
-//8223,0,6,4,0,0x1,0,10,1,no,0,0,0,weapon,0,	MER_QUICKEN,Two-Hand_Quicken
-//8224,0,6,4,3,0x3,3,1,1,yes,0,0,0,magic,0,	MER_SIGHT,Sight
-//8225,0,0,0,0,0x1,0,5,0,no,0,0,0,weapon,0,	MER_CRASH,Crash
-//8226,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_REGAIN,Regain
-//8227,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_TENDER,Tender
-//8228,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_BENEDICTION,Benediction
-//8229,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_RECUPERATE,Recuperate
-//8230,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_MENTALCURE,Mental_Cure
-//8231,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_COMPRESS,Compress
-//8232,9,6,1,0,1,0,10,1,no,0,0,0,none,0,	MER_PROVOKE,Provoke
-//8233,0,6,4,0,0x1,0,1,1,no,0,0x1,0,weapon,0,	MER_AUTOBERSERK,Berserk
-//8234,9,6,1,0,0x1,0,10,1,yes,0,0,0,magic,0,	MER_DECAGI,Decrease_AGI
-//8235,0,0,0,0,0,0,1,0,no,0,0,0,none,0,		MER_SCAPEGOAT,Scapegoat
-//8236,5,6,1,0,0x1,0,10,0,yes,0,0,0,magic,0,	MER_LEXDIVINA,Lex_Divina
-//8237,9,6,1,0,0x1,0,1,1,yes,0,0,0,magic,0,	MER_ESTIMATION,Sense
+8201,-1,6,1,-1,0,0,10,1,no,0,0,0,weapon,0,	MS_BASH,Bash
+8202,0,6,4,3,0x2,2,10,1,no,0,0,0,weapon,2,	MS_MAGNUM,Magnum_Break
+8203,-2,6,1,-1,0x2,1,10,1,no,33,0,0,weapon,1,	MS_BOWLINGBASH,Bowling_Bash
+8204,0,6,4,0,0x1,0,10,1,no,0,0,0,weapon,0,	MS_PARRYING,Parry
+8205,0,6,4,0,0,0,10,1,no,0,0,0,weapon,0,	MS_REFLECTSHIELD,Shield_Reflect
+8206,0,6,4,0,0x1,0,1,1,no,0,0,0,weapon,0,	MS_BERSERK,Frenzy
+8207,-9,8,1,-1,0,0,10,2,no,0,0,0,weapon,0,	MA_DOUBLE,Double_Strafe
+8208,-9,6,2,-1,0x2,2,10,1,no,0,0,0,weapon,2,	MA_SHOWER,Arrow_Shower
+8209,3,6,2,0,0x1,0,5,1,no,0,0x80,0,misc,6:7:8:9:10,	MA_SKIDTRAP,Skid_Trap
+8210,3,6,2,2,0x40,0,5,1,no,0,0x80,0,misc,0,	MA_LANDMINE,Land_Mine
+8211,3,6,2,0,0x3,2,5,1,no,0,0x80,0,misc,0,	MA_SANDMAN,Sandman
+8212,3,6,2,1,0x42,1,5,1,no,0,0x80,0,weapon,0,	MA_FREEZINGTRAP,Freezing_Trap
+8213,2,6,32,0,0x1,0,1,1,no,0,0,0,misc,0,	MA_REMOVETRAP,Remove_Trap
+8214,-9,6,1,-1,0x2,0,1,1,no,0,0x1,0,weapon,6,	MA_CHARGEARROW,Arrow_Repel
+8215,4,8,1,-1,0,2,5,1,yes,0,0,14,weapon,0,	MA_SHARPSHOOTING,Focused_Arrow_Strike
+8216,-2,8,1,-1,0,0,10,3,no,0,0,0,weapon,0,	ML_PIERCE,Pierce
+8217,-2,6,1,-1,0x1,0,10,1,no,33,0,0,weapon,3,	ML_BRANDISH,Brandish_Spear
+8218,5,8,1,-1,0x20,0,5,5,no,0,0,0,weapon,0,	ML_SPIRALPIERCE,Spiral_Pierce
+8219,0,6,4,0,0x1,0,5,1,no,0,0,0,weapon,0,	ML_DEFENDER,Defending_Aura
+8220,0,6,4,0,0x1,0,10,1,no,0,0,0,weapon,0,	ML_AUTOGUARD,Guard
+8221,7:8:9:10:11,6,16,0,0x1,0,5,1,yes,0,0x600,0,none,0,	ML_DEVOTION,Sacrifice
+8222,0,6,4,0,0x3,-1,5,1,yes,0,0,0,magic,0,	MER_MAGNIFICAT,Magnificat
+8223,0,6,4,0,0x1,0,10,1,no,0,0,0,weapon,0,	MER_QUICKEN,Two-Hand_Quicken
+8224,0,6,4,3,0x3,3,1,1,yes,0,0,0,magic,0,	MER_SIGHT,Sight
+8225,0,0,0,0,0x1,0,5,0,no,0,0,0,weapon,0,	MER_CRASH,Crash
+8226,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_REGAIN,Regain
+8227,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_TENDER,Tender
+8228,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_BENEDICTION,Benediction
+8229,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_RECUPERATE,Recuperate
+8230,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_MENTALCURE,Mental_Cure
+8231,0,0,0,0,0x1,0,1,0,no,0,0,0,magic,0,	MER_COMPRESS,Compress
+8232,9,6,1,0,1,0,10,1,no,0,0,0,none,0,	MER_PROVOKE,Provoke
+8233,0,6,4,0,0x1,0,1,1,no,0,0x1,0,weapon,0,	MER_AUTOBERSERK,Berserk
+8234,9,6,1,0,0x1,0,10,1,yes,0,0,0,magic,0,	MER_DECAGI,Decrease_AGI
+8235,0,0,0,0,0,0,1,0,no,0,0,0,none,0,		MER_SCAPEGOAT,Scapegoat
+8236,5,6,1,0,0x1,0,10,0,yes,0,0,0,magic,0,	MER_LEXDIVINA,Lex_Divina
+8237,9,6,1,0,0x1,0,1,1,yes,0,0,0,magic,0,	MER_ESTIMATION,Sense
 
 10000,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0,        GD_APPROVAL,Official Guild Approval
 10001,0,0,0,0,0,0,1,0,no,0,0x10,0,none,0,        GD_KAFRACONTRACT,Kafra Contract

+ 37 - 37
db/skill_require_db.txt

@@ -471,40 +471,40 @@
 8014,0,0,40,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//HVAN_CHAOTIC
 8016,0,0,1,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//HVAN_EXPLOSION
 
-//8201,0,0,8:8:8:8:8:15:15:15:15:15,0,0,0,0:1:2:3:4:5:6:7:8:9:10:12:13:14:15:16:17:18:19:20:21:22,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_BASH,Bash
-//8202,20:20:19:19:18:18:17:17:16:16,0,30,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_MAGNUM
-//8203,0,0,13:14:15:16:17:18:19:20:21:22,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_BOWLINGBASH
-//8204,0,0,50,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_PARRYING
-//8205,0,0,35:40:45:50:55:60:65:70:75:80,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_REFLECTSHIELD
-//8206,0,0,100,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_BERSERK
-//8207,0,0,12,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_DOUBLE
-//8208,0,0,15,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_SHOWER
-//8209,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_SKIDTRAP
-//8210,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_LANDMINE
-//8211,0,0,12,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_SANDMAN
-//8212,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_FREEZINGTRAP
-//8213,0,0,5,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_REMOVETRAP
-//8214,0,0,15,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_CHARGEARROW
-//8215,0,0,18:21:24:27:30,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		//MA_SHARPSHOOTING
-//8216,0,0,7,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_PIERCE
-//8217,0,0,12,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_BRANDISH
-//8218,0,0,18:21:24:27:30,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_SPIRALPIERCE
-//8219,0,0,30,0,0,0,99,0,0,shield,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_DEFENDER
-//8220,0,0,12:14:16:18:20:22:24:26:28:30,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_AUTOGUARD
-//8221,0,0,25,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_DEVOTION
-//8222,0,0,40,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_MAGNIFICAT
-//8223,0,0,14:18:22:26:30:34:38:42:46:50,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_QUICKEN
-//8224,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_SIGHT
-//8225,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_CRASH
-//8226,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_REGAIN
-//8227,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_TENDER
-//8228,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_BENEDICTION
-//8229,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_RECUPERATE
-//8230,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_MENTALCURE
-//8231,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_COMPRESS
-//8232,0,0,4:5:6:7:8:9:10:11:12:13,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_PROVOKE
-//8233,0,0,5,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_AUTOBERSERK
-//8234,0,0,15:17:19:21:23:25:27:29:31:33,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		//MER_DECAGI
-//8235,0,0,10,100,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_SCAPEGOAT
-//8236,0,0,20:20:20:20:20:18:16:14:12:10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_LEXDIVINA
-//8237,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_ESTIMATION
+8201,0,0,8:8:8:8:8:15:15:15:15:15,0,0,0,0:1:2:3:4:5:6:7:8:9:10:12:13:14:15:16:17:18:19:20:21:22,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_BASH
+8202,20:20:19:19:18:18:17:17:16:16,0,30,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_MAGNUM
+8203,0,0,13:14:15:16:17:18:19:20:21:22,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_BOWLINGBASH
+8204,0,0,50,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_PARRYING
+8205,0,0,35:40:45:50:55:60:65:70:75:80,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_REFLECTSHIELD
+8206,0,0,100,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MS_BERSERK
+8207,0,0,12,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_DOUBLE
+8208,0,0,15,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_SHOWER
+8209,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_SKIDTRAP
+8210,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_LANDMINE
+8211,0,0,12,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_SANDMAN
+8212,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_FREEZINGTRAP
+8213,0,0,5,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_REMOVETRAP
+8214,0,0,15,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MA_CHARGEARROW
+8215,0,0,18:21:24:27:30,0,0,0,99,1,1,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		//MA_SHARPSHOOTING
+8216,0,0,7,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_PIERCE
+8217,0,0,12,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_BRANDISH
+8218,0,0,18:21:24:27:30,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_SPIRALPIERCE
+8219,0,0,30,0,0,0,99,0,0,shield,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_DEFENDER
+8220,0,0,12:14:16:18:20:22:24:26:28:30,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_AUTOGUARD
+8221,0,0,25,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//ML_DEVOTION
+8222,0,0,40,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_MAGNIFICAT
+8223,0,0,14:18:22:26:30:34:38:42:46:50,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_QUICKEN
+8224,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_SIGHT
+8225,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_CRASH
+8226,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_REGAIN
+8227,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_TENDER
+8228,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_BENEDICTION
+8229,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_RECUPERATE
+8230,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_MENTALCURE
+8231,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_COMPRESS
+8232,0,0,4:5:6:7:8:9:10:11:12:13,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_PROVOKE
+8233,0,0,5,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_AUTOBERSERK
+8234,0,0,15:17:19:21:23:25:27:29:31:33,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0		//MER_DECAGI
+8235,0,0,10,100,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_SCAPEGOAT
+8236,0,0,20:20:20:20:20:18:16:14:12:10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_LEXDIVINA
+8237,0,0,10,0,0,0,99,0,0,none,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0	//MER_ESTIMATION

+ 4 - 4
db/skill_unit_db.txt

@@ -95,7 +95,7 @@
 535,0xbd,    , -1, 0,  20,enemy, 0x010	//NJ_KAENSIN
 538,0xbb,    ,  1:1:1:2:2:2:3:3:3:4,0,-1,all,0x010	//NJ_SUITON
 670,0xc7,    ,  1, 4:7:10:13:16:19:22:25:28:31,1000,all,0x008	//NPC_EVILLAND
-//8209,0x90,    ,  0, 1,1000,enemy, 0x002	//MA_SKIDTRAP
-//8210,0x93,    ,  0, 0,1000,enemy, 0x002	//MA_LANDMINE
-//8211,0x95,    ,  0, 1,1000,enemy, 0x002	//MA_SANDMAN
-//8212,0x97,    ,  0, 1,1000,enemy, 0x002	//MA_FREEZINGTRAP
+8209,0x90,    ,  0, 1,1000,enemy, 0x002	//MA_SKIDTRAP
+8210,0x93,    ,  0, 0,1000,enemy, 0x002	//MA_LANDMINE
+8211,0x95,    ,  0, 1,1000,enemy, 0x002	//MA_SANDMAN
+8212,0x97,    ,  0, 1,1000,enemy, 0x002	//MA_FREEZINGTRAP

+ 33 - 3
src/char_sql/int_homun.c

@@ -330,7 +330,7 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
 	merc->mercenary_id = merc_id;
 	merc->char_id = char_id;
 
-	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `mercenary` WHERE `merc_id` = '%d' AND `char_id` = '%d'", merc_id, char_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `class`, `hp`, `sp`, `kill_counter`, `life_time` FROM `mercenary` WHERE `mer_id` = '%d' AND `char_id` = '%d'", merc_id, char_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -356,7 +356,7 @@ bool mapif_mercenary_load(int merc_id, int char_id, struct s_mercenary *merc)
 
 bool mapif_mercenary_delete(int merc_id)
 {
-	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `merc_id` = '%d'", merc_id) )
+	if( SQL_ERROR == Sql_Query(sql_handle, "DELETE FROM `mercenary` WHERE `mer_id` = '%d'", merc_id) )
 	{
 		Sql_ShowDebug(sql_handle);
 		return false;
@@ -390,6 +390,34 @@ static void mapif_parse_mercenary_load(int fd, int merc_id, int char_id)
 	mapif_mercenary_send(fd, &merc, result);
 }
 
+static void mapif_mercenary_deleted(int fd, unsigned char flag)
+{
+	WFIFOHEAD(fd,3);
+	WFIFOW(fd,0) = 0x3871;
+	WFIFOB(fd,2) = flag;
+	WFIFOSET(fd,3);
+}
+
+static void mapif_parse_mercenary_delete(int fd, int merc_id)
+{
+	bool result = mapif_mercenary_delete(merc_id);
+	mapif_mercenary_deleted(fd, result);
+}
+
+static void mapif_mercenary_saved(int fd, unsigned char flag)
+{
+	WFIFOHEAD(fd,3);
+	WFIFOW(fd,0) = 0x3872;
+	WFIFOB(fd,2) = flag;
+	WFIFOSET(fd,3);
+}
+
+static void mapif_parse_mercenary_save(int fd, struct s_mercenary* merc)
+{
+	bool result = mapif_mercenary_save(merc);
+	mapif_mercenary_saved(fd, result);
+}
+
 /*==========================================
  * Inter Packets
  *------------------------------------------*/
@@ -406,8 +434,10 @@ int inter_homunculus_parse_frommap(int fd)
 	case 0x3093: mapif_parse_homunculus_delete(fd, (int)RFIFOL(fd,2)); break;
 	case 0x3094: mapif_parse_homunculus_rename(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6), (char*)RFIFOP(fd,10)); break;
 	// Mercenary Packets
-	case 0x3070: mapif_parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,8)); break;
+	case 0x3070: mapif_parse_mercenary_create(fd, (struct s_mercenary*)RFIFOP(fd,4)); break;
 	case 0x3071: mapif_parse_mercenary_load(fd, (int)RFIFOL(fd,2), (int)RFIFOL(fd,6)); break;
+	case 0x3072: mapif_parse_mercenary_delete(fd, (int)RFIFOL(fd,2)); break;
+	case 0x3073: mapif_parse_mercenary_save(fd, (struct s_mercenary*)RFIFOP(fd,4)); break;
 	default:
 		return 0;
 	}

+ 3 - 0
src/char_sql/int_homun.h

@@ -5,6 +5,7 @@
 #define _INT_HOMUN_SQL_H_
 
 struct s_homunculus;
+struct s_mercenary;
 
 int inter_homunculus_sql_init(void);
 void inter_homunculus_sql_final(void);
@@ -15,4 +16,6 @@ bool mapif_homunculus_load(int homun_id, struct s_homunculus* hd);
 bool mapif_homunculus_delete(int homun_id);
 bool mapif_homunculus_rename(char *name);
 
+bool mapif_mercenary_delete(int merc_id);
+
 #endif /* _INT_HOMUN_SQL_H_ */

+ 1 - 1
src/char_sql/inter.c

@@ -51,7 +51,7 @@ int inter_recv_packet_length[] = {
 	 5, 9, 0, 0,  0, 0, 0, 0,  7, 6,10,10, 10,-1,  0, 0,	// 3040-
 	-1,-1,10,10,  0,-1, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0,	// 3050-  Auction System [Zephyrus]
 	 6,-1,10, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0,	// 3060-  Quest system [Kevin]
-	-1,10, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0,	// 3070-  Mercenary packets [Zephyrus]
+	-1,10, 6,-1,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0,	// 3070-  Mercenary packets [Zephyrus]
 	48,14,-1, 6,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0,	// 3080-
 	-1,10,-1, 6,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0,	// 3090-  Homunculus packets [albator]
 };

+ 1 - 1
src/common/mmo.h

@@ -30,7 +30,7 @@
 #define MAX_ZENY 1000000000
 #define MAX_FAME 1000000000
 #define MAX_CART 100
-#define MAX_SKILL 1020
+#define MAX_SKILL 1040
 #define GLOBAL_REG_NUM 96
 #define ACCOUNT_REG_NUM 64
 #define ACCOUNT_REG2_NUM 16

+ 4 - 3
src/map/chrif.c

@@ -281,11 +281,12 @@ int chrif_save(struct map_session_data *sd, int flag)
 	WFIFOSET(char_fd, WFIFOW(char_fd,2));
 
 
-	if(sd->status.pet_id > 0 && sd->pd)
+	if( sd->status.pet_id > 0 && sd->pd )
 		intif_save_petdata(sd->status.account_id,&sd->pd->pet);
-
-	if (sd->hd && merc_is_hom_active(sd->hd))
+	if( sd->hd && merc_is_hom_active(sd->hd) )
 		merc_save(sd->hd);
+	if( sd->md && sd->md->mercenary.remain_life_time > 0 )
+		mercenary_save(sd->md);
 
 	return 0;
 }

+ 12 - 6
src/map/clif.c

@@ -7056,7 +7056,8 @@ int clif_charnameack (int fd, struct block_list *bl)
 	WBUFW(buf,0) = cmd;
 	WBUFL(buf,2) = bl->id;
 
-	switch(bl->type) {
+	switch( bl->type )
+	{
 	case BL_PC:
 		{
 			struct map_session_data *ssd = (struct map_session_data *)bl;
@@ -7117,6 +7118,9 @@ int clif_charnameack (int fd, struct block_list *bl)
 	case BL_HOM:
 		memcpy(WBUFP(buf,6), ((TBL_HOM*)bl)->homunculus.name, NAME_LENGTH);
 		break;
+	case BL_MER:
+		memcpy(WBUFP(buf,6), ((TBL_MER*)bl)->db->name, NAME_LENGTH);
+		break;
 	case BL_PET:
 		memcpy(WBUFP(buf,6), ((TBL_PET*)bl)->pet.name, NAME_LENGTH);
 		break;
@@ -12352,7 +12356,7 @@ void clif_mercenary_info(struct map_session_data *sd)
 	fd = sd->fd;
 	status = &md->battle_status;
 
-	WFIFOHEAD(fd,72);
+	WFIFOHEAD(fd,80);
 	WFIFOW(fd,0) = 0x029b;
 	WFIFOL(fd,2) = md->bl.id;
 	WFIFOW(fd,6) = cap_value(status->rhw.atk2+status->batk, 0, SHRT_MAX);
@@ -12369,10 +12373,12 @@ void clif_mercenary_info(struct map_session_data *sd)
 	WFIFOL(fd,52) = status->max_hp;
 	WFIFOL(fd,56) = status->sp;
 	WFIFOL(fd,60) = status->max_sp;
-	WFIFOL(fd,64) = 0; // Expiration Time
-	WFIFOW(fd,68) = 0; // No documentation (Guild Rank?)
-	WFIFOW(fd,70) = 0; // Times Summoned	
-	WFIFOSET(fd,72);
+	WFIFOL(fd,64) = 0; // Contract End
+	WFIFOW(fd,68) = 0; // Loyalty
+	WFIFOL(fd,70) = 0; // Summon Count
+	WFIFOL(fd,74) = 0; // Kill Counter
+	WFIFOW(fd,78) = 0;
+	WFIFOSET(fd,80);
 }
 
 void clif_mercenary_skillblock(struct map_session_data *sd)

+ 46 - 1
src/map/intif.c

@@ -38,7 +38,7 @@ static const int packet_len_table[]={
 	 9, 9,-1,14,  0, 0, 0, 0, -1,74,-1,11, 11,-1,  0, 0, //0x3840
 	-1,-1, 7, 7,  7,11, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0, //0x3850  Auctions [Zephyrus]
 	-1,11,11, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0, //0x3860  Quests [Kevin]
-	-1, 0, 0, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0, //0x3870  Mercenaries [Zephyrus]
+	-1, 3, 3, 0,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0, //0x3870  Mercenaries [Zephyrus]
 	11,-1, 7, 3,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0, //0x3880
 	-1,-1, 7, 3,  0, 0, 0, 0,  0, 0, 0, 0,  0, 0,  0, 0, //0x3890  Homunculus [albator]
 };
@@ -1909,6 +1909,49 @@ int intif_mercenary_request(int merc_id, int char_id)
 	return 0;
 }
 
+int intif_mercenary_delete(int merc_id)
+{
+	if (CheckForCharServer())
+		return 0;
+
+	WFIFOHEAD(inter_fd,6);
+	WFIFOW(inter_fd,0) = 0x3072;
+	WFIFOL(inter_fd,2) = merc_id;
+	WFIFOSET(inter_fd,6);
+	return 0;
+}
+
+int intif_parse_mercenary_deleted(int fd)
+{
+	if( RFIFOB(fd,2) != 1 )
+		ShowError("Mercenary data delete failure\n");
+
+	return 0;
+}
+
+int intif_mercenary_save(struct s_mercenary *merc)
+{
+	int size = sizeof(struct s_mercenary) + 4;
+
+	if( CheckForCharServer() )
+		return 0;
+
+	WFIFOHEAD(inter_fd,size);
+	WFIFOW(inter_fd,0) = 0x3073;
+	WFIFOW(inter_fd,2) = size;
+	memcpy(WFIFOP(inter_fd,4), merc, sizeof(struct s_mercenary));
+	WFIFOSET(inter_fd,size);
+	return 0;
+}
+
+int intif_parse_mercenary_saved(int fd)
+{
+	if( RFIFOB(fd,2) != 1 )
+		ShowError("Mercenary data save failure\n");
+
+	return 0;
+}
+
 //-----------------------------------------------------------------
 // inter serverからの通信
 // エラーがあれば0(false)を返すこと
@@ -1999,6 +2042,8 @@ int intif_parse(int fd)
 #endif
 // Mercenary System
 	case 0x3870:	intif_parse_mercenary_received(fd); break;
+	case 0x3871:	intif_parse_mercenary_deleted(fd); break;
+	case 0x3872:	intif_parse_mercenary_saved(fd); break;
 
 	case 0x3880:	intif_parse_CreatePet(fd); break;
 	case 0x3881:	intif_parse_RecvPetData(fd); break;

+ 2 - 0
src/map/intif.h

@@ -80,6 +80,8 @@ int intif_quest_add(int char_id, struct quest * qd);
 // MERCENARY SYSTEM
 int intif_mercenary_create(struct s_mercenary *merc);
 int intif_mercenary_request(int merc_id, int char_id);
+int intif_mercenary_delete(int merc_id);
+int intif_mercenary_save(struct s_mercenary *merc);
 
 #ifndef TXT_ONLY
 // MAIL SYSTEM

+ 2 - 1
src/map/map.c

@@ -1584,7 +1584,8 @@ int map_quit(struct map_session_data *sd)
 	//Unit_free handles clearing the player related data, 
 	//map_quit handles extra specific data which is related to quitting normally
 	//(changing map-servers invokes unit_free but bypasses map_quit)
-	if(sd->sc.count) {
+	if( sd->sc.count )
+	{
 		//Status that are not saved...
 		if(sd->sc.data[SC_BOSSMAPINFO])
 			status_change_end(&sd->bl,SC_BOSSMAPINFO,-1);

+ 10 - 1
src/map/mercenary.c

@@ -54,7 +54,7 @@ int merc_search_index(int class_)
 
 bool merc_class(int class_)
 {
-	return (bool)(merc_search_index(class_) < 0);
+	return (bool)(merc_search_index(class_) > -1);
 }
 
 struct view_data * merc_get_viewdata(int class_)
@@ -91,6 +91,15 @@ int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime)
 	return 1;
 }
 
+int mercenary_save(struct mercenary_data *md)
+{
+	md->mercenary.hp = md->battle_status.hp;
+	md->mercenary.sp = md->battle_status.sp;
+	intif_mercenary_save(&md->mercenary);
+
+	return 1;
+}
+
 int merc_data_received(struct s_mercenary *merc, bool flag)
 {
 	struct map_session_data *sd;

+ 2 - 0
src/map/mercenary.h

@@ -40,7 +40,9 @@ struct mercenary_data {
 
 bool merc_class(int class_);
 struct view_data * merc_get_viewdata(int class_);
+int merc_create(struct map_session_data *sd, int class_, unsigned int lifetime);
 int merc_data_received(struct s_mercenary *merc, bool flag);
+int mercenary_save(struct mercenary_data *md);
 
 // Homunculus DB Structures
 // ===================================

+ 199 - 141
src/map/unit.c

@@ -1772,9 +1772,9 @@ int unit_remove_map_(struct block_list *bl, int clrtype, const char* file, int l
 	}
 	case BL_HOM:
 	{
-		struct homun_data *hd = (struct homun_data *) bl;
+		struct homun_data *hd = (struct homun_data *)bl;
 		ud->canact_tick = ud->canmove_tick; //It appears HOM do reset the can-act tick.
-		if(!hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) )
+		if( !hd->homunculus.intimacy && !(hd->master && !hd->master->state.active) )
 		{	//If logging out, this is deleted on unit_free
 			clif_emotion(bl, 28) ;	//sob
 			clif_clearunit_area(bl,clrtype);
@@ -1786,6 +1786,20 @@ int unit_remove_map_(struct block_list *bl, int clrtype, const char* file, int l
 
 		break;
 	}
+	case BL_MER:
+	{
+		struct mercenary_data *md = (struct mercenary_data *)bl;
+		ud->canact_tick = ud->canmove_tick;
+		if( !md->mercenary.remain_life_time && !(md->master && !md->master->state.active) )
+		{
+			clif_clearunit_area(bl,clrtype);
+			map_delblock(bl);
+			unit_free(bl,0);
+			map_freeblock_unlock();
+			return 0;
+		}
+		break;
+	}
 	default: ;// do nothing
 	}
 
@@ -1805,12 +1819,15 @@ void unit_remove_map_pc(struct map_session_data *sd, int clrtype)
 		unit_remove_map(&sd->pd->bl, clrtype);
 	if(merc_is_hom_active(sd->hd))
 		unit_remove_map(&sd->hd->bl, clrtype);
+	if(sd->md)
+		unit_remove_map(&sd->md->bl, clrtype);
 }
 
 void unit_free_pc(struct map_session_data *sd)
 {
 	if (sd->pd) unit_free(&sd->pd->bl,0);
 	if (sd->hd) unit_free(&sd->hd->bl,0);
+	if (sd->md) unit_free(&sd->md->bl,0);
 	unit_free(&sd->bl,3);
 }
 
@@ -1828,171 +1845,212 @@ int unit_free(struct block_list *bl, int clrtype)
 	map_freeblock_lock();
 	if( bl->prev )	//Players are supposed to logout with a "warp" effect.
 		unit_remove_map(bl, clrtype);
-	
-	if( bl->type == BL_PC ) {
-		struct map_session_data *sd = (struct map_session_data*)bl;
-		if(status_isdead(bl))
-			pc_setrestartvalue(sd,2);
-
-		pc_delinvincibletimer(sd);
-	
-		pc_autoscript_clear(sd->autoscript, ARRAYLENGTH(sd->autoscript));
-		pc_autoscript_clear(sd->autoscript2, ARRAYLENGTH(sd->autoscript2));
-
-		if (sd->followtimer != -1)
-			pc_stop_following(sd);
-			
-		if(sd->duel_invite > 0)
-			duel_reject(sd->duel_invite, sd);
-	
-		// Notify friends that this char logged out. [Skotlex]
-		map_foreachpc(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0);
-		party_send_logout(sd);
-		guild_send_memberinfoshort(sd,0);
-		pc_cleareventtimer(sd);
-		pc_delspiritball(sd,sd->spiritball,1);
-
-		if(sd->reg)
-		{	//Double logout already freed pointer fix... [Skotlex]
-			aFree(sd->reg);
-			sd->reg = NULL;
-			sd->reg_num = 0;
-		}
-		if(sd->regstr)
-		{
-			int i;
-			for( i = 0; i < sd->regstr_num; ++i )
-				if( sd->regstr[i].data )
-					aFree(sd->regstr[i].data);
-			aFree(sd->regstr);
-			sd->regstr = NULL;
-			sd->regstr_num = 0;
-		}
 
-		//Tell the script to end, not delete it, it will free itself when necessary [Kevin]
-		if (sd->st) {
-			sd->st->rid = 0;
-			sd->st->state = END;
-		}
-	} else if( bl->type == BL_PET ) {
-		struct pet_data *pd = (struct pet_data*)bl;
-		struct map_session_data *sd = pd->msd;
-		pet_hungry_timer_delete(pd);
-		if (pd->a_skill)
+	switch( bl->type )
+	{
+		case BL_PC:
 		{
-			aFree(pd->a_skill);
-			pd->a_skill = NULL;
+			struct map_session_data *sd = (struct map_session_data*)bl;
+			if( status_isdead(bl) )
+				pc_setrestartvalue(sd,2);
+
+			pc_delinvincibletimer(sd);
+			pc_autoscript_clear(sd->autoscript, ARRAYLENGTH(sd->autoscript));
+			pc_autoscript_clear(sd->autoscript2, ARRAYLENGTH(sd->autoscript2));
+
+			if( sd->followtimer != -1 )
+				pc_stop_following(sd);
+				
+			if( sd->duel_invite > 0 )
+				duel_reject(sd->duel_invite, sd);
+		
+			// Notify friends that this char logged out. [Skotlex]
+			map_foreachpc(clif_friendslist_toggle_sub, sd->status.account_id, sd->status.char_id, 0);
+			party_send_logout(sd);
+			guild_send_memberinfoshort(sd,0);
+			pc_cleareventtimer(sd);
+			pc_delspiritball(sd,sd->spiritball,1);
+
+			if( sd->reg )
+			{	//Double logout already freed pointer fix... [Skotlex]
+				aFree(sd->reg);
+				sd->reg = NULL;
+				sd->reg_num = 0;
+			}
+			if( sd->regstr )
+			{
+				int i;
+				for( i = 0; i < sd->regstr_num; ++i )
+					if( sd->regstr[i].data )
+						aFree(sd->regstr[i].data);
+				aFree(sd->regstr);
+				sd->regstr = NULL;
+				sd->regstr_num = 0;
+			}
+			//Tell the script to end, not delete it, it will free itself when necessary [Kevin]
+			if( sd->st )
+			{
+				sd->st->rid = 0;
+				sd->st->state = END;
+			}
+			break;
 		}
-		if (pd->s_skill)
+		case BL_PET:
 		{
-			if (pd->s_skill->timer != -1) {
-				if (pd->s_skill->id)
-					delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+			struct pet_data *pd = (struct pet_data*)bl;
+			struct map_session_data *sd = pd->msd;
+			pet_hungry_timer_delete(pd);
+			if( pd->a_skill )
+			{
+				aFree(pd->a_skill);
+				pd->a_skill = NULL;
+			}
+			if( pd->s_skill )
+			{
+				if (pd->s_skill->timer != -1) {
+					if (pd->s_skill->id)
+						delete_timer(pd->s_skill->timer, pet_skill_support_timer);
+					else
+						delete_timer(pd->s_skill->timer, pet_heal_timer);
+				}
+				aFree(pd->s_skill);
+				pd->s_skill = NULL;
+			}
+			if( pd->recovery )
+			{
+				if(pd->recovery->timer != -1)
+					delete_timer(pd->recovery->timer, pet_recovery_timer);
+				aFree(pd->recovery);
+				pd->recovery = NULL;
+			}
+			if( pd->bonus )
+			{
+				if (pd->bonus->timer != -1)
+					delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
+				aFree(pd->bonus);
+				pd->bonus = NULL;
+			}
+			if( pd->loot )
+			{
+				pet_lootitem_drop(pd,sd);
+				if (pd->loot->item)
+					aFree(pd->loot->item);
+				aFree (pd->loot);
+				pd->loot = NULL;
+			}
+			if( clrtype >= 0 )
+			{
+				if( pd->pet.intimate > 0 )
+					intif_save_petdata(pd->pet.account_id,&pd->pet);
 				else
-					delete_timer(pd->s_skill->timer, pet_heal_timer);
+				{	//Remove pet.
+					intif_delete_petdata(pd->pet.pet_id);
+					if (sd) sd->status.pet_id = 0;
+				}
 			}
-			aFree(pd->s_skill);
-			pd->s_skill = NULL;
-		}
-		if(pd->recovery)
-		{
-			if(pd->recovery->timer != -1)
-				delete_timer(pd->recovery->timer, pet_recovery_timer);
-			aFree(pd->recovery);
-			pd->recovery = NULL;
-		}
-		if(pd->bonus)
-		{
-			if (pd->bonus->timer != -1)
-				delete_timer(pd->bonus->timer, pet_skill_bonus_timer);
-			aFree(pd->bonus);
-			pd->bonus = NULL;
+			if( sd )
+				sd->pd = NULL;
+			break;
 		}
-		if (pd->loot)
+		case BL_MOB:
 		{
-			pet_lootitem_drop(pd,sd);
-			if (pd->loot->item)
-				aFree(pd->loot->item);
-			aFree (pd->loot);
-			pd->loot = NULL;
-		}
-		if (clrtype >= 0) {
-			if(pd->pet.intimate > 0)
-				intif_save_petdata(pd->pet.account_id,&pd->pet);
-			else
-			{	//Remove pet.
-				intif_delete_petdata(pd->pet.pet_id);
-				if (sd) sd->status.pet_id = 0;
+			struct mob_data *md = (struct mob_data*)bl;
+			if( md->deletetimer != -1 )
+			{
+				delete_timer(md->deletetimer,mob_timer_delete);
+				md->deletetimer = INVALID_TIMER;
 			}
-		}
-		if (sd) sd->pd = NULL;
-	} else if(bl->type == BL_MOB) {
-		struct mob_data *md = (struct mob_data*)bl;
-		if(md->deletetimer!=-1) {
-			delete_timer(md->deletetimer,mob_timer_delete);
-			md->deletetimer = INVALID_TIMER;
-		}
-		if(md->lootitem) {
-			aFree(md->lootitem);
-			md->lootitem=NULL;
-		}
-		if( md->guardian_data )
-		{
-			struct guild_castle* gc = md->guardian_data->castle;
-			if( md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS )
+			if( md->lootitem )
 			{
-				gc->guardian[md->guardian_data->number].id = 0;
+				aFree(md->lootitem);
+				md->lootitem=NULL;
 			}
-			else
+			if( md->guardian_data )
 			{
-				int i;
-				ARR_FIND(0, gc->temp_guardians_max, i, gc->temp_guardians[i] == md->bl.id);
-				if( i < gc->temp_guardians_max )
-					gc->temp_guardians[i] = 0;
+				struct guild_castle* gc = md->guardian_data->castle;
+				if( md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS )
+				{
+					gc->guardian[md->guardian_data->number].id = 0;
+				}
+				else
+				{
+					int i;
+					ARR_FIND(0, gc->temp_guardians_max, i, gc->temp_guardians[i] == md->bl.id);
+					if( i < gc->temp_guardians_max )
+						gc->temp_guardians[i] = 0;
+				}
+				aFree(md->guardian_data);
+				md->guardian_data = NULL;
+			}
+			if( md->spawn )
+			{
+				md->spawn->active--;
+				if( !md->spawn->state.dynamic )
+				{// permanently remove the mob
+					if( --md->spawn->num == 0 )
+					{// Last freed mob is responsible for deallocating the group's spawn data.
+						aFree(md->spawn);
+						md->spawn = NULL;
+					}
+				}
 			}
-			aFree(md->guardian_data);
-			md->guardian_data = NULL;
+			if( md->base_status)
+			{
+				aFree(md->base_status);
+				md->base_status = NULL;
+			}
+			if( mob_is_clone(md->class_) )
+				mob_clone_delete(md->class_);
+
+			break;
 		}
-		if(md->spawn)
+		case BL_HOM:
 		{
-			md->spawn->active--;
-
-			if( !md->spawn->state.dynamic )
-			{// permanently remove the mob
-				if( --md->spawn->num == 0 )
-				{// Last freed mob is responsible for deallocating the group's spawn data.
-					aFree(md->spawn);
-					md->spawn = NULL;
+			struct homun_data *hd = (TBL_HOM*)bl;
+			struct map_session_data *sd = hd->master;
+			// Desactive timers
+			merc_hom_hungry_timer_delete(hd);
+			if( clrtype >= 0 )
+			{
+				if( hd->homunculus.intimacy > 0 )
+					merc_save(hd);
+				else
+				{
+					intif_homunculus_requestdelete(hd->homunculus.hom_id);
+					if( sd )
+						sd->status.hom_id = 0;
 				}
 			}
+			if( sd )
+				sd->hd = NULL;
+			break;
 		}
-		if(md->base_status) {
-			aFree(md->base_status);
-			md->base_status = NULL;
-		}
-		if(mob_is_clone(md->class_))
-			mob_clone_delete(md->class_);
-	} else if(bl->type == BL_HOM) {
-		struct homun_data *hd = (TBL_HOM*)bl;
-		struct map_session_data *sd = hd->master;
-		// Desactive timers
-		merc_hom_hungry_timer_delete(hd);
-		if (clrtype >= 0) {
-			if (hd->homunculus.intimacy > 0)
-				merc_save(hd); 
-			else
+		case BL_MER:
+		{
+			struct mercenary_data *md = (TBL_MER*)bl;
+			struct map_session_data *sd = md->master;
+			/* Stop Mercenary Timer */
+			if( clrtype >= 0 )
 			{
-				intif_homunculus_requestdelete(hd->homunculus.hom_id);
-				if (sd) sd->status.hom_id = 0;
+				if( md->mercenary.remain_life_time > 0 )
+					mercenary_save(md);
+				else
+				{
+					intif_mercenary_delete(md->mercenary.mercenary_id);
+					if( sd )
+						sd->status.mer_id = 0;
+				}
 			}
+			if( sd )
+				sd->md = NULL;
+			break;
 		}
-		if(sd) sd->hd = NULL;
 	}
 
 	skill_clear_unitgroup(bl);
 	status_change_clear(bl,1);
 	map_deliddb(bl);
-	if (bl->type != BL_PC) //Players are handled by map_quit
+	if( bl->type != BL_PC ) //Players are handled by map_quit
 		map_freeblock(bl);
 	map_freeblock_unlock();
 	return 0;