diff options
-rw-r--r-- | Changelog-Trunk.txt | 7 | ||||
-rw-r--r-- | db/Changelog.txt | 5 | ||||
-rw-r--r-- | db/const.txt | 11 | ||||
-rw-r--r-- | db/item_db.txt | 14 | ||||
-rw-r--r-- | doc/script_commands.txt | 79 | ||||
-rw-r--r-- | src/map/pc.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 105 | ||||
-rw-r--r-- | src/map/skill.c | 16 |
8 files changed, 146 insertions, 93 deletions
diff --git a/Changelog-Trunk.txt b/Changelog-Trunk.txt index 00049f3ad..1a3b75529 100644 --- a/Changelog-Trunk.txt +++ b/Changelog-Trunk.txt @@ -3,6 +3,13 @@ Date Added AS OF SVN REV. 5091, WE ARE NOW USING TRUNK. ALL UNTESTED BUGFIXES/FEATURES GO INTO TRUNK. IF YOU HAVE A WORKING AND TESTED BUGFIX PUT IT INTO STABLE AS WELL AS TRUNK. +2007/09/17 + * Applied various crash-protections to script commands that deal with the + equip-position array. + * Corrected and simplified the skill_magic_reflect function. Fixed damage + reflection being based on the caster rather than the target. + * Potions are now usable inside Gospel by the casting Paladin (as per Aegis + tests done by AuronX) 2007/09/14 * Some changes brought up by AuronX (see topics 160295 and 149176): * Gravitional Field is now a MISC type of attack. diff --git a/db/Changelog.txt b/db/Changelog.txt index d308bbef1..0b7ecfe38 100644 --- a/db/Changelog.txt +++ b/db/Changelog.txt @@ -27,6 +27,11 @@ 4425 Atros_Card Chance that for 10 seconds your aspd will increase by 100% while attacking. ======================== + +09/17 + * Added the EQI_* constants to db/const.txt in a format usable by the + equip-position related script commands. + * Updated some items to use the new EQI constants. [Skotlex] 09/17 * Reduced Necromancer's summon frequency [Playtester] 09/15 diff --git a/db/const.txt b/db/const.txt index 756595db8..18e97f9b8 100644 --- a/db/const.txt +++ b/db/const.txt @@ -407,6 +407,17 @@ bSPLossRate 2040 bAddSkillBlow 2041 bSPVanishRate 2042 +EQI_HEAD_TOP 1 +EQI_ARMOR 2 +EQI_HAND_L 3 +EQI_HAND_R 4 +EQI_GARMENT 5 +EQI_SHOES 6 +EQI_ACC_L 7 +EQI_ACC_R 8 +EQI_HEAD_MID 9 +EQI_HEAD_LOW 10 + Eff_Stone 0 Eff_Freeze 1 Eff_Stan 2 diff --git a/db/item_db.txt b/db/item_db.txt index d61263ba8..ed4ae5e25 100644 --- a/db/item_db.txt +++ b/db/item_db.txt @@ -945,7 +945,7 @@ 2112,Novice_Guard,Novice Guard,5,1,,1,,3,,0,0x00000001,7,2,32,,0,0,1,{},{},{} 2113,Novice_Shield,Novice Shield,5,5000,,1000,,3,,1,0x00000001,7,2,32,,40,1,3,{ bonus2 bSubEle,Ele_Water,20; bonus2 bSubEle,Ele_Earth,20; bonus2 bSubEle,Ele_Fire,20; bonus2 bSubEle,Ele_Wind,20; bonus2 bSubEle,Ele_Poison,20; bonus2 bSubEle,Ele_Ghost,20; bonus2 bSubEle,Ele_Undead,20; },{},{} 2114,Stone_Buckler,Stone Buckler,5,30000,,1500,,3,,1,0xFFFFFFFE,7,2,32,,65,1,2,{ bonus2 bSubSize,2,5; if (isequipped(2353,5122)) { bonus bStr,2; bonus bDef,5; bonus bMdef,5; if(BaseClass == Job_Swordman) bonus bDef,6; } },{},{} -2115,Valkyrja's_Shield,Valkyrie's Shield,5,30000,,500,,3,,1,0xFFFFFFFE,7,2,32,,65,1,3,{ bonus2 bSubEle,Ele_Water,20; bonus2 bSubEle,Ele_Fire,20; bonus2 bSubEle,Ele_Dark,20; bonus2 bSubEle,Ele_Undead,20; bonus bMdef,5; if(isequipped(2353,5124)) { bonus bDef,2; bonus bMdef,5+getrefine()+getequiprefinerycnt(1); } },{},{} +2115,Valkyrja's_Shield,Valkyrie's Shield,5,30000,,500,,3,,1,0xFFFFFFFE,7,2,32,,65,1,3,{ bonus2 bSubEle,Ele_Water,20; bonus2 bSubEle,Ele_Fire,20; bonus2 bSubEle,Ele_Dark,20; bonus2 bSubEle,Ele_Undead,20; bonus bMdef,5; if(isequipped(2353,5124)) { bonus bDef,2; bonus bMdef,5+getrefine()+getequiprefinerycnt(EQI_HEAD_TOP); } },{},{} 2116,Angel's_Safeguard,Angelic Guard,5,10000,,400,,3,,1,0x00000001,7,2,32,,20,1,3,{ bonus2 bSubRace,RC_Demon,5; },{},{} 2117,Arm_Guard,Arm Guard,5,10000,,150,,5,,0,0x02000000,7,2,32,,20,1,,{},{},{} 2118,Arm_Guard_,Arm Guard,5,10000,,150,,5,,1,0x02000000,7,2,32,,20,1,,{},{},{} @@ -1175,7 +1175,7 @@ 2506,Manteau_,Manteau,5,32000,,600,,4,,1,0x006654E2,7,2,4,,0,1,0,{},{},{} 2507,Cape_Of_Ancient_Lord,Ancient Cape,5,82000,,600,,2,,0,0xFFFFFFFE,7,2,4,,40,1,0,{ bonus bAgi,1; },{},{} 2508,Ragamuffin_Cape,Ragamuffin Manteau,5,56000,,500,,1,,0,0xFFFFFFFE,7,2,4,,0,1,0,{ bonus bMdef,10; },{},{} -2509,Clack_Of_Servival,Survivor's Manteau,5,20000,,550,,0,,0,0x00810204,7,2,4,,75,1,0,{ bonus bVit,10; if(isequipped(1618) || isequipped(1620)) bonus bMaxHP,300; bonus bMatkRate,-5; if(isequipped(1617) || isequipped(1618) || isequipped(1619) || isequipped(1620)) bonus bMatkRate,getequiprefinerycnt(4); bonus2 bSubEle,Ele_Neutral,getrefine()*3; },{},{} +2509,Clack_Of_Servival,Survivor's Manteau,5,20000,,550,,0,,0,0x00810204,7,2,4,,75,1,0,{ bonus bVit,10; if(isequipped(1618) || isequipped(1620)) bonus bMaxHP,300; bonus bMatkRate,-5; if(isequipped(1617) || isequipped(1618) || isequipped(1619) || isequipped(1620)) bonus bMatkRate,getequiprefinerycnt(EQI_HAND_R); bonus2 bSubEle,Ele_Neutral,getrefine()*3; },{},{} 2510,Novice_Hood,Somber Novice Hood,5,1,,1,,2,,0,0x00000001,7,2,4,,0,0,0,{ bonus2 bSubEle,Ele_Neutral,20; },{},{} 2511,Skeleton's_Cape,Skeleton Manteau,5,5000,,700,,1,,0,0xFFFFFFFE,7,2,4,,75,1,0,{ bonus bStr,2; bonus bInt,-3; bonus bDex,2; bonus bVit,-3; bonus bLuk,2; bonus bAgi,-4; },{},{} 2512,Novice_Manteau,Novice Manteau,5,50000,,500,,2,,1,0x00000001,7,2,4,,40,1,0,{ bonus2 bSubEle,Ele_Neutral,10; },{},{} @@ -1190,7 +1190,7 @@ 2521,Angel's_Warmth,Angelic Cardigan,5,10000,,400,,2,,1,0x00000001,7,2,4,,20,1,0,{ bonus bHPrecovRate,5; },{},{} 2522,Undershirt,Undershirt,5,20000,,150,,2,,0,0xFFFFFFFF,7,2,4,,1,1,0,{ bonus bMdef,1; if(isequipped(2339)) { bonus bAgi,5; bonus bFlee,10; } },{},{} 2523,Undershirt_,Undershirt,5,20000,,150,,2,,1,0xFFFFFFFF,7,2,4,,1,1,0,{ bonus bMdef,1; if(isequipped(2339)) { bonus bAgi,5; bonus bFlee,10; } },{},{} -2524,Valkyrie_Manteau,Valkyrie's Manteau,5,0,,500,,3,,1,0xFFFFFFFE,2,2,4,,1,1,0,{ if(BaseClass==Job_Mage||BaseClass==Job_Archer||BaseClass==Job_Acolyte) bonus bFlee2,5+(getequiprefinerycnt(5)*2); else if(BaseClass==Job_Swordman||BaseClass==Job_Merchant||BaseClass==Job_Thief) bonus bShortWeaponDamageReturn,5+(getequiprefinerycnt(5)*2); },{},{} +2524,Valkyrie_Manteau,Valkyrie's Manteau,5,0,,500,,3,,1,0xFFFFFFFE,2,2,4,,1,1,0,{ if(BaseClass==Job_Mage||BaseClass==Job_Archer||BaseClass==Job_Acolyte) bonus bFlee2,5+(getequiprefinerycnt(EQI_GARMENT)*2); else if(BaseClass==Job_Swordman||BaseClass==Job_Merchant||BaseClass==Job_Thief) bonus bShortWeaponDamageReturn,5+(getequiprefinerycnt(EQI_GARMENT)*2); },{},{} 2525,Cape_Of_Ancient_Lord_,Ancient Cape,5,82000,,600,,2,,1,0xFFFFFFFE,7,2,4,,40,1,0,{ bonus bAgi,1; },{},{} 2526,Dragonscale_Jacket,Dragonscale Jacket,5,,10,10,,4,,0,0xFFFFFFFF,7,2,4,,50,1,0,{},{},{} 2527,Breath_of_the_Dragon,Dragon's Breath,5,,10,600,,4,,1,0xFFFFFFFE,2,2,4,,48,1,0,{ bonus2 bSubRace,RC_Dragon,15; if (isequipped(1166) || isequipped(13001) || isequipped(1474)) bonus2 bAddRace,RC_Dragon,5; },{},{} @@ -1737,14 +1737,14 @@ 4418,Gazeti_Card,Gazeti Card,6,,10,10,,,,,,,,136,,,,,{ bonus3 bAutoSpell,14,2,10; },{},{} 4419,Ktullanux_Card,Ktullanux Card,6,,10,10,,,,,,,,16,,,,,{ bonus2 bAddEle,Ele_Fire,50; bonus5 bAutoSpellWhenHit,88,10,30,BF_WEAPON|BF_MAGIC,0; },{},{} 4420,Muscipular_Card,Muscipular Card,6,,10,10,,,,,,,,32,,,,,{ bonus5 bAutoSpellWhenHit,28,1,10,BF_SHORT,0; bonus5 bAutoSpellWhenHit,29,1,10,BF_SHORT,0; },{},{} -4421,Drosera_Card,Drosera Card,6,,10,10,,,,,,,,2,,,,,{ if (getiteminfo(getequipid(4),9) > 3) bonus bCritical,15; },{},{} +4421,Drosera_Card,Drosera Card,6,,10,10,,,,,,,,2,,,,,{ if (getiteminfo(getequipid(EQI_HAND_R),9) > 3) bonus bCritical,15; },{},{} 4422,Roween_Card,Roween Card,6,,10,10,,,,,,,,4,,,,,{ bonus bFlee,5; bonus bFlee2,3; bonus2 bAddEle,Ele_Water,10; bonus2 bCriticalAddRace,RC_Fish,15; },{},{} 4423,Galion_Card,Galion Card,6,,10,10,,,,,,,,136,,,,,{ bonus bHit,5; bonus2 bAddEle,Ele_Water,5; },{},{} 4424,Stapo_Card,Stapo Card,6,,10,10,,,,,,,,136,,,,,{ skill 151,1; skill 152,1; },{},{} 4425,Atroce_Card,Atroce Card,6,,10,10,,,,,,,,2,,,,,{ bonus bBaseAtk,25; },{},{} 4426,Byorgue_Card,Byorgue Card,6,,10,10,,,,,,,,16,,,,,{ if(BaseJob == Job_Rogue){ bonus bMatkRate,10; bonus bAtkRate,10; } },{},{} -4427,Sword_Guardian_Card,Sword Guardian Card,6,,10,10,,,,,,,,2,,,,,{ bonus bHit,5; bonus bCritical,5; if (getiteminfo(getequipid(4),11) == 2 || getiteminfo(getequipid(4),11) == 3) bonus2 bSkillAtk,62,25; },{},{} -4428,Bow_Guardian_Card,Bow Guardian Card,6,,10,10,,,,,,,,2,,,,,{ bonus bHit,5; bonus bCritical,5; if (getiteminfo(getequipid(4),11) == 11) bonus2 bSkillAtk,47,50; },{},{} +4427,Sword_Guardian_Card,Sword Guardian Card,6,,10,10,,,,,,,,2,,,,,{ bonus bHit,5; bonus bCritical,5; if (getiteminfo(getequipid(EQI_HAND_R),11) == 2 || getiteminfo(getequipid(EQI_HAND_R),11) == 3) bonus2 bSkillAtk,62,25; },{},{} +4428,Bow_Guardian_Card,Bow Guardian Card,6,,10,10,,,,,,,,2,,,,,{ bonus bHit,5; bonus bCritical,5; if (getiteminfo(getequipid(EQI_HAND_R),11) == 11) bonus2 bSkillAtk,47,50; },{},{} 4429,Salamander_Card,Salamander Card,6,,10,10,,,,,,,,4,,,,,{ bonus2 bSkillAtk,80,40; bonus2 bSkillAtk,83,40; },{},{} 4430,Ifrit_Card,Ifrit Card,6,,10,10,,,,,,,,136,,,,,{ bonus bAtk,(JobLevel/7); bonus bCritical,(JobLevel/7); bonus bHit,(JobLevel/7); bonus3 bAutoSpellWhenHit,653,2,10; },{},{} 4431,Kasa_Card,Kasa Card,6,,10,10,,,,,,,,4,,,,,{ bonus3 bAutoSpell,17,5,10; bonus3 bAutoSpell,19,5,10; },{},{} @@ -1756,7 +1756,7 @@ 4437,Hell_Poodle_Card,Hell Poodle Card,6,,10,10,,,,,,,,136,,,,,{ bonus bHit,1; bonus2 bAddItemHealRate,517,100; bonus2 bAddEff,Eff_Bleeding,100; },{},{} 4438,Banshee_Card,Banshee Card,6,,10,10,,,,,,,,769,,,,,{ if(BaseClass == Job_Mage){ bonus bMaxSP,100; bonus bMaxHP,-100; bonus2 bSkillAtk,11,20; bonus2 bSkillAtk,13,20; bonus2 bSkillAtk,400,20; } },{},{} 4439,Flame_Skull_Card,Flame Skull Card,6,,10,10,,,,,,,,32,,,,,{ bonus2 bResEff,Eff_Blind,3000; bonus2 bResEff,Eff_Stun,3000; bonus2 bResEff,Eff_Curse,3000; bonus2 bResEff,Eff_Stone,3000; bonus2 bAddEffWhenHit,Eff_Blind,100; bonus2 bAddEffWhenHit,Eff_Stun,100; bonus2 bAddEffWhenHit,Eff_Curse,100; bonus2 bAddEffWhenHit,Eff_Stone,100; },{},{} -4440,Necromancer_Card,Necromancer Card,6,,10,10,,,,,,,,2,,,,,{ if (getiteminfo(getequipid(4),11) == 10) { bonus bInt,1; bonus bIgnoreMdefRate,2; } },{},{} +4440,Necromancer_Card,Necromancer Card,6,,10,10,,,,,,,,2,,,,,{ if (getiteminfo(getequipid(EQI_HAND_R),11) == 10) { bonus bInt,1; bonus bIgnoreMdefRate,2; } },{},{} 4441,Fallen_Bishop_Hibram_Card,Fallen Bishop Hibram Card,6,,10,10,,,,,,,,64,,,,,{ bonus bMAtkRate,10; bonus bMaxSPrate,-50; bonus2 bAddRace,RC_Angel,50; bonus2 bAddRace,RC_DemiHuman,50; },{},{} // More Headgears //=================================================================== diff --git a/doc/script_commands.txt b/doc/script_commands.txt index f564ffc1a..5acb3e883 100644 --- a/doc/script_commands.txt +++ b/doc/script_commands.txt @@ -2074,16 +2074,16 @@ This function returns the item ID of the item equipped in the equipment slot specified on the invoking character. If nothing is equpped there, it returns -1. Valid equipment slots are: -1 - Upper head gear -2 - Armor (Where you keep your Jackets and Robes) -3 - What is in your Left hand. -4 - What is in your Right hand. -5 - The garment slot (Mufflers, Hoods, Manteaus) -6 - What foot gear the player has on. -7 - Accessory 1. -8 - Accessory 2. -9 - Middle Headgear (masks and glasses) -10 - Lower Headgear (beards, some masks) +EQI_HEAD_TOP (1) - Upper head gear +EQI_ARMOR (2) - Armor (Where you keep your Jackets and Robes) +EQI_HAND_L (3) - What is in your Left hand. +EQI_HAND_R (4) - What is in your Right hand. +EQI_GARMENT (5) - The garment slot (Mufflers, Hoods, Manteaus) +EQI_SHOES (6) - What foot gear the player has on. +EQI_ACC_L (7) - Accessory 1. +EQI_ACC_R (8) - Accessory 2. +EQI_HEAD_MID (9) - Middle Headgear (masks and glasses) +EQI_HEAD_LOW (10) - Lower Headgear (beards, some masks) Notice that a few items occupy several equipment slots, and if the character is wearing such an item, 'getequipid' will return it's ID number for either slot. @@ -2091,7 +2091,7 @@ wearing such an item, 'getequipid' will return it's ID number for either slot. Can be used to check if you have something equiped, or if you haven't got something equiped: - if(getequipid(1)==2234) goto L_WearingTiara; + if(getequipid(EQI_HEAD_TOP)==2234) goto L_WearingTiara; mes "Come back when you have a Tiara on"; close; L_WearingTiara: @@ -2102,7 +2102,7 @@ You can also use it to make sure people don't pass a point before removing an item totally from them. Let's say you don't want people to wear Legion Plate armor, but also don't want them to equip if after the check, you would do this: - if ((getequipid(2) == 2341) || (getequipid(2) == 2342) goto L_EquipedLegionPlate; + if ((getequipid(EQI_ARMOR) == 2341) || (getequipid(EQI_ARMOR) == 2342) goto L_EquipedLegionPlate; // the || is used as an or argument, there is 2341 and 2342 cause there are // two different legion plate armors, one with a slot one without. if ((countitem(2341) > 0) || (countitem(2432) > 0) goto L_InventoryLegionPlate; @@ -2126,8 +2126,8 @@ equipment slot on the invoking character. Almost identical to 'getequipid', good for an NPC to state what your are wearing, or maybe saving as a string variable. See 'getequipid' for a full list of valid equipment slots. - if (getequipname(1)==0) goto L_No_HeadGear; - mes "So you are wearing a "+getequipname(1)+" on your head"; + if (getequipname(EQI_HEAD_TOP)==0) goto L_No_HeadGear; + mes "So you are wearing a "+getequipname(EQI_HEAD_TOP)+" on your head"; close; L_No_HeadGear: mes "You are not wearing any head gear"; @@ -2165,7 +2165,7 @@ This functions will return 1 if there is an equipment placed on the specified equipment slot and 0 otherwise. For a list of equipment slots see 'getequipid'. Function originally used by the refining NPCs: - if (getequipisequiped(1)) goto L_equipped; + if (getequipisequiped(EQI_HEAD_TOP)) goto L_equipped; mes "[Refiner]"; mes "Do you want me to refine your dumb head?"; close; @@ -2183,7 +2183,7 @@ Will return 1 if the item equipped on the invoking character in the specified equipment slot is refinable, and 0 if it isn't. For a list of equipment slots see 'getequipid'. - if (getequipisenableref(1)) goto L_Refine; + if (getequipisenableref(EQI_HEAD_TOP)) goto L_Refine; mes "[Refiner]"; mes "I can't refine this hat!..."; close; @@ -2202,11 +2202,11 @@ slot. For a list of equipment slots see 'getequipid'. Can be used to check if you have reached a maximum refine value, default for this is +10: - if(getequiprefinerycnt(1) < 10) goto L_Refine_HeadGear; + if(getequiprefinerycnt(EQI_HEAD_TOP) < 10) goto L_Refine_HeadGear; mes "Sorry, it's not possible to refine hats better than +10"; close; L_Refine_HeadGear: - mes "I will now upgrade your "+getequipname(1); + mes "I will now upgrade your "+getequipname(EQI_HEAD_TOP); --------------------------------------- @@ -2216,28 +2216,32 @@ This function returns the weapon level for the weapon equipped in the specified equipment slot on the invoking character. For a list of equipment slots see 'getequipid'. -Only 3 (Left hand) and 4 (Right hand) normally make sense, since only weapons +Only EQI_HAND_L and EQI_HAND_R normally make sense, since only weapons have a weapon level. You can, however, probably, use this field for other equippable custom items as a flag or something. If no item is equipped in this slot, or if it doesn't have a weapon level according to the database, 0 will be returned. - if(getequipweaponlv(4)==0) mes "Seems you don't have a weapon on"; - if(getequipweaponlv(4)==1) mes "You are holding a lvl 1 weapon"; - if(getequipweaponlv(4)==2) mes "You are holding a lvl 2 weapon"; - if(getequipweaponlv(4)==3) mes "You are holding a lvl 3 weapon"; - if(getequipweaponlv(4)==4) mes "You are holding a lvl 4 weapon"; - if(getequipweaponlv(4)==5) mes "You are holding a lvl 5 weapon, hm, must be a custom design"; + switch (getequipweaponlv(EQI_HAND_R)) { + case 1: mes "You are holding a lvl 1 weapon"; break; + case 2: mes "You are holding a lvl 2 weapon"; break; + case 3: mes "You are holding a lvl 3 weapon"; break; + case 4: mes "You are holding a lvl 4 weapon"; break; + case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design"; break; + default: mes "Seems you don't have a weapon on"; break; + } Or for the left hand, cause it can hold a weapon or a shield: - if(getequipid(3)==0) goto L_NothingEquiped; - if(getequipweaponlv(3)==0) mes "You are holding a shield, so it doesnt have a level"; - if(getequipweaponlv(3)==1) mes "You are holding a lvl 1 weapon"; - if(getequipweaponlv(3)==2) mes "You are holding a lvl 2 weapon"; - if(getequipweaponlv(3)==3) mes "You are holding a lvl 3 weapon"; - if(getequipweaponlv(3)==4) mes "You are holding a lvl 4 weapon"; - if(getequipweaponlv(3)==5) mes "You are holding a lvl 5 weapon, hm, must be a custom design"; + if(getequipid(EQI_HAND_R)==0) goto L_NothingEquiped; + switch (getequipweaponlv(EQI_HAND_L)) { + case 0: mes "You are holding a shield, so it doesnt have a level"; break; + case 1: mes "You are holding a lvl 1 weapon"; break; + case 2: mes "You are holding a lvl 2 weapon"; break; + case 3: mes "You are holding a lvl 3 weapon"; break; + case 4: mes "You are holding a lvl 4 weapon"; break; + case 5: mes "You are holding a lvl 5 weapon, hm, must be a custom design"; break; + } close; L_NothingEquiped: mes "Seems you have nothing equiped"; @@ -2249,10 +2253,9 @@ Or for the left hand, cause it can hold a weapon or a shield: This function calculates and returns the percent value chance to successfully refine the item found in the specified equipment slot of the invoking character -by +1. The actual formula is beyond the scope of this document, however, it is -calculated as if the character was a blacksmith trying to refine this particular -weapon, and depends on lots and lots of stuff. For a list of equipment slots see -'getequipid'. +by +1. There is no actual formula, the sucess rate for a given weapon level of +a certain refine level is found in the db/refine_db.txt file. For a list of +equipment slots see 'getequipid'. These values can be displayed for the player to see, or used to calculate the random change of a refine succeeding or failing and then going through with it @@ -2260,7 +2263,7 @@ random change of a refine succeeding or failing and then going through with it // This will find a random number from 0 - 99 and if that is equal to or more // than the value recoverd by this command it will go to L_Fail - if (getequippercentrefinery(3)<=rand(100)) goto L_Fail; + if (getequippercentrefinery(EQI_HAND_L)<=rand(100)) goto L_Fail; --------------------------------------- @@ -2387,7 +2390,7 @@ Returns value from equipped item slot in the indicated slot: getequipcardid(num,slot) where: - num = eqip position slot + num = equip position slot slot = 0,1,2,3 (Card Slot N) This func returns CARD ID, 255,254,-255 (for card 0, if the item is produced) it's useful diff --git a/src/map/pc.c b/src/map/pc.c index 00662e91c..3dd2289c3 100644 --- a/src/map/pc.c +++ b/src/map/pc.c @@ -3071,8 +3071,6 @@ int pc_useitem(struct map_session_data *sd,int n) sd->sc.data[SC_BERSERK].timer!=-1 || sd->sc.data[SC_MARIONETTE].timer!=-1 || (sd->sc.data[SC_GRAVITATION].timer!=-1 && sd->sc.data[SC_GRAVITATION].val3 == BCT_SELF) || - //Cannot use Potions/Healing items while under Gospel. - (sd->sc.data[SC_GOSPEL].timer!=-1 && sd->sc.data[SC_GOSPEL].val4 == BCT_SELF && sd->inventory_data[n]->type == IT_HEALING) || sd->sc.data[SC_TRICKDEAD].timer != -1 || sd->sc.data[SC_BLADESTOP].timer != -1 || (sd->sc.data[SC_NOCHAT].timer!=-1 && sd->sc.data[SC_NOCHAT].val1&MANNER_NOITEM) diff --git a/src/map/script.c b/src/map/script.c index a754aca14..d423d433e 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -6776,7 +6776,7 @@ unsigned int equip[10]={EQP_HEAD_TOP,EQP_ARMOR,EQP_HAND_L,EQP_HAND_R,EQP_GARMENT *------------------------------------------*/ BUILDIN_FUNC(getequipid) { - int i,num; + int i=-1,num; TBL_PC *sd; struct item_data* item; @@ -6787,7 +6787,8 @@ BUILDIN_FUNC(getequipid) return 0; } num=script_getnum(st,2); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0){ item=sd->inventory_data[i]; if(item) @@ -6805,7 +6806,7 @@ BUILDIN_FUNC(getequipid) *------------------------------------------*/ BUILDIN_FUNC(getequipname) { - int i,num; + int i=-1,num; TBL_PC *sd; struct item_data* item; char *buf; @@ -6815,7 +6816,8 @@ BUILDIN_FUNC(getequipname) buf=(char *)aMallocA(64*sizeof(char)); sd=script_rid2sd(st); num=script_getnum(st,2); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0){ item=sd->inventory_data[i]; if(item) @@ -6890,22 +6892,19 @@ BUILDIN_FUNC(repair) *------------------------------------------*/ BUILDIN_FUNC(getequipisequiped) { - int i,num; + int i=-1,num; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - if ((num - 1) >= (sizeof(equip) / sizeof(equip[0]))) - i = -1; - else + if (num > 0 && num <= ARRAYLENGTH(equip)) i=pc_checkequip(sd,equip[num-1]); - if(i >= 0) - script_pushint(st,1); - else - script_pushint(st,0); - + if(i >= 0) + script_pushint(st,1); + else + script_pushint(st,0); return 0; } @@ -6914,12 +6913,13 @@ BUILDIN_FUNC(getequipisequiped) *------------------------------------------*/ BUILDIN_FUNC(getequipisenableref) { - int i,num; + int i=-1,num; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0 && sd->inventory_data[i] && !sd->inventory_data[i]->flag.no_refine) { script_pushint(st,1); @@ -6935,12 +6935,13 @@ BUILDIN_FUNC(getequipisenableref) *------------------------------------------*/ BUILDIN_FUNC(getequipisidentify) { - int i,num; + int i=-1,num; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0) script_pushint(st,sd->status.inventory[i].identify); else @@ -6954,12 +6955,13 @@ BUILDIN_FUNC(getequipisidentify) *------------------------------------------*/ BUILDIN_FUNC(getequiprefinerycnt) { - int i,num; + int i=-1,num; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0) script_pushint(st,sd->status.inventory[i].refine); else @@ -6973,12 +6975,13 @@ BUILDIN_FUNC(getequiprefinerycnt) *------------------------------------------*/ BUILDIN_FUNC(getequipweaponlv) { - int i,num; + int i=-1,num; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0 && sd->inventory_data[i]) script_pushint(st,sd->inventory_data[i]->wlv); else @@ -6992,12 +6995,13 @@ BUILDIN_FUNC(getequipweaponlv) *------------------------------------------*/ BUILDIN_FUNC(getequippercentrefinery) { - int i,num; + int i=-1,num; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0 && sd->status.inventory[i].nameid && sd->status.inventory[i].refine < MAX_REFINE) script_pushint(st,percentrefinery[itemdb_wlv(sd->status.inventory[i].nameid)][(int)sd->status.inventory[i].refine]); else @@ -7011,12 +7015,13 @@ BUILDIN_FUNC(getequippercentrefinery) *------------------------------------------*/ BUILDIN_FUNC(successrefitem) { - int i,num,ep; + int i=-1,num,ep; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0) { ep=sd->status.inventory[i].equip; @@ -7063,12 +7068,13 @@ BUILDIN_FUNC(successrefitem) *------------------------------------------*/ BUILDIN_FUNC(failedrefitem) { - int i,num; + int i=-1,num; TBL_PC *sd; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0) { //Logs items, got from (N)PC scripts [Lupus] if(log_config.enable_logs&0x40) @@ -9749,13 +9755,20 @@ BUILDIN_FUNC(requestguildinfo) * ---------------------------------------------------------------------*/ BUILDIN_FUNC(getequipcardcnt) { - int i,num; + int i=-1,num; TBL_PC *sd; int c=MAX_SLOTS; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); + + if (i < 0) { + script_pushint(st,0); + return 0; + } + if(itemdb_isspecial(sd->status.inventory[i].card[0])) { script_pushint(st,0); @@ -9777,14 +9790,21 @@ BUILDIN_FUNC(getequipcardcnt) * ----------------------------------------------------------------*/ BUILDIN_FUNC(successremovecards) { - int i,j,num,cardflag=0,flag; + int i=-1,j,num,cardflag=0,flag; TBL_PC *sd; struct item item_tmp; int c=MAX_SLOTS; num=script_getnum(st,2); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); + + if (i < 0) { + script_pushint(st,0); + return 0; + } + if(itemdb_isspecial(sd->status.inventory[i].card[0])) return 0; @@ -9844,7 +9864,7 @@ BUILDIN_FUNC(successremovecards) * ----------------------------------------------------------------*/ BUILDIN_FUNC(failedremovecards) { - int i,j,num,cardflag=0,flag,typefail; + int i=-1,j,num,cardflag=0,flag,typefail; TBL_PC *sd; struct item item_tmp; int c=MAX_SLOTS; @@ -9852,7 +9872,14 @@ BUILDIN_FUNC(failedremovecards) num=script_getnum(st,2); typefail=script_getnum(st,3); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); + + if (i < 0) { + script_pushint(st,0); + return 0; + } + if(itemdb_isspecial(sd->status.inventory[i].card[0])) return 0; @@ -10403,13 +10430,14 @@ BUILDIN_FUNC(setiteminfo) *------------------------------------------*/ BUILDIN_FUNC(getequipcardid) { - int i,num,slot; + int i=-1,num,slot; TBL_PC *sd; num=script_getnum(st,2); slot=script_getnum(st,3); sd=script_rid2sd(st); - i=pc_checkequip(sd,equip[num-1]); + if (num > 0 && num <= ARRAYLENGTH(equip)) + i=pc_checkequip(sd,equip[num-1]); if(i >= 0 && slot>=0 && slot<4) script_pushint(st,sd->status.inventory[i].card[slot]); else @@ -11893,10 +11921,11 @@ BUILDIN_FUNC(unequip) num = script_getnum(st,2) - 1; sd=script_rid2sd(st); - if(sd!=NULL && num<10) + if(sd!=NULL && num > 0 && num <= ARRAYLENGTH(equip)) { - i=pc_checkequip(sd,equip[num]); - pc_unequipitem(sd,i,2); + i=pc_checkequip(sd,equip[num-1]); + if (i >= 0) + pc_unequipitem(sd,i,2); return 0; } return 0; diff --git a/src/map/skill.c b/src/map/skill.c index c81aa3aaf..f3464be83 100644 --- a/src/map/skill.c +++ b/src/map/skill.c @@ -1890,13 +1890,13 @@ int skill_blown(struct block_list* src, struct block_list* target, int count, in } -//Checks if there should be magic reflection. +//Checks if bl should reflect back a spell. //type is the type of magic attack: 0: indirect (aoe), 1: direct (targetted) -static int skill_magic_reflect(struct block_list *src, struct block_list *target, int type) +static int skill_magic_reflect(struct block_list *bl, int type) { - struct status_change *sc = status_get_sc(target); + struct status_change *sc = status_get_sc(bl); struct map_session_data *sd; - BL_CAST(BL_PC, src, sd); + BL_CAST(BL_PC, bl, sd); if(sd && sd->magic_damage_return && type && rand()%100 < sd->magic_damage_return) return 1; @@ -1906,11 +1906,11 @@ static int skill_magic_reflect(struct block_list *src, struct block_list *target if(sc->data[SC_MAGICMIRROR].timer != -1 && rand()%100 < sc->data[SC_MAGICMIRROR].val2) return 1; - if(sc->data[SC_KAITE].timer != -1 && (sd || status_get_lv(src) <= 80)) + if(sc->data[SC_KAITE].timer != -1 && (sd || status_get_lv(bl) <= 80)) { //Works on players or mobs with level under 80. - clif_specialeffect(target, 438, AREA); + clif_specialeffect(bl, 438, AREA); if (--sc->data[SC_KAITE].val2 <= 0) - status_change_end(target, SC_KAITE, -1); + status_change_end(bl, SC_KAITE, -1); return 1; } } @@ -1994,7 +1994,7 @@ int skill_attack (int attack_type, struct block_list* src, struct block_list *ds if (attack_type&BF_MAGIC) { if (!(sstatus->mode&MD_BOSS) && (dmg.damage || dmg.damage2) && - skill_magic_reflect(src, bl, src==dsrc)) + skill_magic_reflect(bl, src==dsrc)) { //Magic reflection, switch caster/target struct block_list *tbl = bl; bl = src; |