diff --git a/data/dfndata/items/gear/clothing/aos_clothing.dfn b/data/dfndata/items/gear/clothing/aos_clothing.dfn new file mode 100644 index 000000000..0b43d075c --- /dev/null +++ b/data/dfndata/items/gear/clothing/aos_clothing.dfn @@ -0,0 +1,150 @@ +[0x2684] +{ +get=base_clothing +name=hooded shroud of shadows +id=0x2684 +colour=0x455 +newbie +weight=300 +value=68 34 +layer=0x16 +def=7 +hp=50 +orgin=aos +} + +[0x2683] +{ +get=0x2684 +id=0x2683 +} + +[hoodedshroudofshadows] +{ +get=0x2684 0x2683 +} + +[0x2310] +{ +get=base_clothing +name=formal shirt +id=0x2310 +weight=100 +value=55 27 +layer=0x5 +str=1 +hp=50 +orgin=aos +} + +[0x230F] +{ +get=0x2310 +id=0x230F +} + +[formalshirt] +{ +get=0x2310 0x230F +} + +[0x2307] +{ +get=base_clothing +name=fur boots +id=0x2307 +weight=300 +value=45 22 +layer=0x03 +def=6 +hp=30 +str=10 +dyeable=1 +decay=1 +good=19 +restock=10 +orgin=aos +} + +[0x2308] +{ +get=0x2307 +id=0x2308 +} + +[furboots] +{ +get=0x2307 0x2308 +} + +[0x230A] +{ +get=base_clothing +name=fur cap +id=0x230A +weight=500 +value=43 21 +layer=0x14 +def=5 +hp=50 +orgin=aos +} + +[0x2309] +{ +get=0x230A +id=0x2309 +} + +[furcap] +{ +get=0x230A 0x2309 +} + +[0x230C] +{ +get=base_clothing +name=fur sarong +id=0x230C +weight=200 +value=31 15 +layer=0x17 +def=3 +hp=50 +orgin=aos +} + +[0x230B] +{ +get=0x230C +id=0x230B +} + +[fursarong] +{ +get=0x230C 0x230B +} + +[0x230E] +{ +get=base_clothing +name=gilded dress +id=0x230E +weight=200 +value=56 28 +layer=0x11 +def=4 +hp=50 +orgin=aos +} + +[0x230D] +{ +get=0x230E +id=0x230D +} + +[gildeddress] +{ +get=0x230E 0x230D +} \ No newline at end of file diff --git a/data/js/magic/clumsy.js b/data/js/magic/clumsy.js index 0460b360e..fe41ffd92 100644 --- a/data/js/magic/clumsy.js +++ b/data/js/magic/clumsy.js @@ -106,7 +106,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) // The following loop checks to see if any item is currently equipped (if not a GM) if( mChar.commandlevel < 2 ) { - if( spellType != 2 ) + if( spellType != 2 ) { var itemRHand = mChar.FindItemLayer( 0x01 ); var itemLHand = mChar.FindItemLayer( 0x02 ); @@ -114,9 +114,9 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) var rHandBlocks = false; // Evaluate blocking for left and right hand items - if( isSpellCastingAllowed( itemRHand ) || isSpellCastingAllowed( itemLHand )) + if( !isSpellCastingAllowed( itemRHand ) || !isSpellCastingAllowed( itemLHand )) { - var result = handleItem( itemLHand, itemRHand, mChar ); + var result = AutoUnequipAttempt( itemLHand, itemRHand, mChar ); lHandBlocks = result.lHandBlocks; rHandBlocks = result.rHandBlocks; } @@ -137,7 +137,6 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) return true; } } - return false; } if( mChar.visible == 1 || mChar.visible == 2 ) @@ -228,6 +227,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) if( !GetServerSetting( "CastSpellsWhileMOving" )) { mChar.frozen = true; + mChar.Refresh(); } } else @@ -257,7 +257,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) mChar.TextMessage( tempString ); mChar.isCasting = true; - mChar.StartTimer( delay, spellNum, true ); + mChar.StartTimer( delay * 1000, spellNum, true ); return true; } @@ -266,6 +266,7 @@ function onTimer( mChar, timerID ) { mChar.isCasting = false; mChar.frozen = false; + mChar.Refresh(); if( mChar.npc ) { @@ -406,27 +407,39 @@ function onSpellSuccess( mSock, mChar, ourTarg ) } // Function to check if an equipped item allows casting -function isSpellCastingAllowed( item ) +function isSpellCastingAllowed( item ) { return item != null && ( item.type == 9 || item.type == 119 ); // Assuming type 9 is spellbook, and type 119 is spell channeling item } // Function to handle items -function handleItem( itemLHand, itemRHand, mChar ) +function AutoUnequipAttempt( itemLHand, itemRHand, mChar ) { - const UnEquipEnabled = GetServerSetting("AutoUnequippedCasting"); + const autoUnequip = GetServerSetting( "AutoUnequippedCasting" ); var lHandBlocks = false; // Default to false var rHandBlocks = false; // Default to false - if( UnEquipEnabled && itemLHand != null && !isSpellCastingAllowed( itemLHand )) - { // Allow casting if item is spell channeling or type 9 spell book - itemLHand.container = mChar.pack; - lHandBlocks = true; // Set to true if item is blocking + if( itemLHand != null && !isSpellCastingAllowed( itemLHand )) + { + if( autoUnequip && mChar.pack.totalItemCount < mChar.pack.maxItems ) + { + itemLHand.container = mChar.pack; + } + else + { + lHandBlocks = true; // Set to true if item is blocking + } } - if( UnEquipEnabled && itemRHand != null && !isSpellCastingAllowed( itemRHand )) - { // Allow casting if item is spell channeling or type 9 spell book - itemRHand.container = mChar.pack; - rHandBlocks = true; // Set to true if item is blocking + if( itemRHand != null && !isSpellCastingAllowed( itemRHand )) + { + if( autoUnequip && mChar.pack.totalItemCount < mChar.pack.maxItems ) + { + itemRHand.container = mChar.pack; + } + else + { + rHandBlocks = true; // Set to true if item is blocking + } } return { lHandBlocks: lHandBlocks, rHandBlocks: rHandBlocks }; } diff --git a/data/js/magic/createfood.js b/data/js/magic/createfood.js index 8952e0944..1fb11cebc 100644 --- a/data/js/magic/createfood.js +++ b/data/js/magic/createfood.js @@ -6,11 +6,11 @@ function SpellRegistration() function onSpellCast( mSock, mChar, directCast, spellNum ) { // Are we recovering from another spell that was just cast - if( mChar.GetTimer( Timer.SPELLRECOVERYTIME ) != 0 ) + if( mChar.GetTimer( Timer.SPELLRECOVERYTIME ) != 0 ) { - if( mChar.GetTimer( Timer.SPELLRECOVERYTIME ) > GetCurrentClock() ) + if( mChar.GetTimer( Timer.SPELLRECOVERYTIME ) > GetCurrentClock() ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 1638, mSock.language )); // You must wait a little while before casting } @@ -23,7 +23,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) { if( mChar.isCasting ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 762, mSock.language )); // You are already casting a spell. } @@ -31,7 +31,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) } else if( mChar.GetTimer( Timer.SPELLTIME ) > GetCurrentClock() ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 1638, mSock.language )); // You must wait a little while before casting } @@ -53,7 +53,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) // Disallow spellcasting if character is in jail if( mChar.isJailed && mChar.commandlevel < 2 ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 704, mSock.language )); // You are in jail and cannot cast spells! } @@ -66,7 +66,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) // Is the spell actually enabled? if( !mSpell.enabled ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 707, mSock.language )); // That spell is currently not enabled. } @@ -87,9 +87,9 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) var rHandBlocks = false; // Evaluate blocking for left and right hand items - if( isSpellCastingAllowed( itemRHand ) || isSpellCastingAllowed( itemLHand )) + if( !isSpellCastingAllowed( itemRHand ) || !isSpellCastingAllowed( itemLHand )) { - var result = handleItem( itemLHand, itemRHand, mChar ); + var result = AutoUnequipAttempt( itemLHand, itemRHand, mChar ); lHandBlocks = result.lHandBlocks; rHandBlocks = result.rHandBlocks; } @@ -110,7 +110,6 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) return true; } } - return false; } // Turn character visible @@ -120,7 +119,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) } // Break character's concentration (affects Meditation skill) - if( mSock ) + if( mSock != null ) { mChar.BreakConcentration( mSock ); } @@ -128,12 +127,22 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) // If player commandlevel is below GM-level, check for reagents if( mChar.commandlevel < 2 ) { + //Check for enough reagents + // type == 0 -> SpellBook + if( spellType == 0 && !TriggerEvent( 6004, "CheckReagents", mChar, mSpell )) + { + mChar.SetTimer( Timer.SPELLTIME, 0 ); + mChar.isCasting = false; + mChar.spellCast = -1; + return true; + } + // type == 2 - Wands if( spellType != 2 ) { if( mSpell.mana > mChar.mana ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 696, mSock.language )); // You have insufficient mana to cast that spell. } @@ -144,7 +153,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) } if( mSpell.stamina > mChar.stamina ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 697, mSock.language )); // You have insufficient stamina to cast that spell. } @@ -155,7 +164,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) } if( mSpell.health >= mChar.health ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 698, mSock.language )); // You have insufficient health to cast that spell. } @@ -177,6 +186,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) if( !GetServerSetting( "CastSpellsWhileMoving" )) { mChar.frozen = true; + mChar.Refresh(); } } else @@ -209,6 +219,8 @@ function onTimer( mChar, timerID ) { mChar.isCasting = false; mChar.frozen = false; + mChar.Refresh(); + var ourTarg = mChar; if( mChar.npc ) @@ -218,7 +230,7 @@ function onTimer( mChar, timerID ) else { var mSock = mChar.socket; - if( mSock ) + if( mSock != null ) { mChar.SetTimer( Timer.SPELLRECOVERYTIME, Spells[mChar.spellCast].recoveryDelay ); onSpellSuccess( mSock, mChar, ourTarg ); @@ -304,13 +316,13 @@ function onSpellSuccess( mSock, mChar, ourTarg ) ourTarg.SpellStaticEffect( mSpell ); // List of foods to randomize between when casting the spell - foodItems = new Array ( + var foodItems = new Array ( "0x09d0", "0x09b7", "0x09f2", "0x097b", "0x0d1a", "0x09c9", "0x09eb", "0x09d2", "0x09c0", "0x097c" ); var rndNum = RandomNumber( 0, foodItems.length - 1 ); - if( mSock ) + if( mSock != null ) { CreateDFNItem( mSock, mChar, foodItems[rndNum], 1, "ITEM", true ); } @@ -327,21 +339,33 @@ function isSpellCastingAllowed( item ) } // Function to handle items -function handleItem( itemLHand, itemRHand, mChar ) +function AutoUnequipAttempt( itemLHand, itemRHand, mChar ) { - const UnEquipEnabled = GetServerSetting( "AutoUnequippedCasting" ); + const autoUnequip = GetServerSetting( "AutoUnequippedCasting" ); var lHandBlocks = false; // Default to false var rHandBlocks = false; // Default to false - if(UnEquipEnabled && itemLHand != null && !isSpellCastingAllowed( itemLHand )) - { // Allow casting if item is spell channeling or type 9 spell book - itemLHand.container = mChar.pack; - lHandBlocks = true; // Set to true if item is blocking + if( itemLHand != null && !isSpellCastingAllowed( itemLHand )) + { + if( autoUnequip && mChar.pack.totalItemCount < mChar.pack.maxItems ) + { + itemLHand.container = mChar.pack; + } + else + { + lHandBlocks = true; // Set to true if item is blocking + } } - if( UnEquipEnabled && itemRHand != null && !isSpellCastingAllowed( itemRHand )) - { // Allow casting if item is spell channeling or type 9 spell book - itemRHand.container = mChar.pack; - rHandBlocks = true; // Set to true if item is blocking + if( itemRHand != null && !isSpellCastingAllowed( itemRHand )) + { + if( autoUnequip && mChar.pack.totalItemCount < mChar.pack.maxItems ) + { + itemRHand.container = mChar.pack; + } + else + { + rHandBlocks = true; // Set to true if item is blocking + } } return { lHandBlocks: lHandBlocks, rHandBlocks: rHandBlocks }; } diff --git a/data/js/magic/level1targ.js b/data/js/magic/level1targ.js index 83d825df3..a79f92a3c 100644 --- a/data/js/magic/level1targ.js +++ b/data/js/magic/level1targ.js @@ -71,9 +71,9 @@ function ItemInHandCheck( mChar, mSock, spellType ) var rHandBlocks = false; // Evaluate blocking for left and right hand items - if( isSpellCastingAllowed( itemRHand ) || isSpellCastingAllowed( itemLHand )) + if( !isSpellCastingAllowed( itemRHand ) || !isSpellCastingAllowed( itemLHand )) { - var result = handleItem( itemLHand, itemRHand, mChar ); + var result = AutoUnequipAttempt( itemLHand, itemRHand, mChar ); lHandBlocks = result.lHandBlocks; rHandBlocks = result.rHandBlocks; } @@ -94,7 +94,6 @@ function ItemInHandCheck( mChar, mSock, spellType ) return false; } } - return true; } } @@ -105,7 +104,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) { if( mChar.GetTimer( Timer.SPELLRECOVERYTIME ) > GetCurrentClock() ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 1638, mSock.language )); // You must wait a little while before casting } @@ -135,7 +134,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) var ourRegion = mChar.region; if(( spellNum == 45 && ourRegion.canMark ) || ( spellNum == 52 && !ourRegion.canGate() ) || ( spellNum == 32 && !ourRegion.canRecall() )) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 705, mSock.language )); // This is not allowed here. } @@ -149,7 +148,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) { if( ourRegion.isSafeZone ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 1799, mSock.language )); // Hostile actions are not permitted in this safe area. } @@ -161,7 +160,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) if( !ourRegion.canCastAggressive ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 706, mSock.language )); // This is not allowed in town. } @@ -183,7 +182,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) mChar.visible = 0; } - if( mSock ) + if( mSock != null ) { mChar.BreakConcentration( mSock ); } @@ -195,7 +194,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) { if( mSpell.mana > mChar.mana ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 696, mSock.language )); // You have insufficient mana to cast that spell. } @@ -206,7 +205,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) } if( mSpell.stamina > mChar.stamina ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 697, mSock.language )); // You have insufficient stamina to cast that spell. } @@ -217,7 +216,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) } if( mSpell.health >= mChar.health ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 698, mSock.language )); // You have insufficient health to cast that spell. } @@ -238,6 +237,7 @@ function onSpellCast( mSock, mChar, directCast, spellNum ) if( !GetServerSetting( "CastSpellsWhileMoving" )) { mChar.frozen = true; + mChar.Refresh(); } } else @@ -281,6 +281,7 @@ function onTimer( mChar, timerID ) { mChar.isCasting = false; mChar.frozen = false; + mChar.Refresh(); if( mChar.npc ) { @@ -293,7 +294,7 @@ function onTimer( mChar, timerID ) else { var mSock = mChar.socket; - if( mSock ) + if( mSock != null ) { var cursorType = 0; var spellNum = mChar.spellCast; @@ -342,6 +343,7 @@ function onCallback0( mSock, ourTarg ) mChar.isCasting = false; mChar.spellCast = -1; mChar.frozen = false; + mChar.Refresh(); } } @@ -430,7 +432,7 @@ function onSpellSuccess( mSock, mChar, ourTarg, spellID ) if( !mChar.InRange( ourTarg, 10 ) ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 712, mSock.language )); // You can't cast on someone that far away! } @@ -445,7 +447,7 @@ function onSpellSuccess( mSock, mChar, ourTarg, spellID ) { if( targRegion.isSafeZone ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 1799, mSock.language )); // Hostile actions are not permitted in this safe area. } @@ -453,7 +455,7 @@ function onSpellSuccess( mSock, mChar, ourTarg, spellID ) } if( !targRegion.canCastAggressive ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 709, mSock.language )); // You can't cast in town! } @@ -461,7 +463,7 @@ function onSpellSuccess( mSock, mChar, ourTarg, spellID ) } if( !ourTarg.vulnerable || ourTarg.aiType == 17 ) { - if( mSock ) + if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 713, mSock.language )); // They are invulnerable merchants! } @@ -573,6 +575,7 @@ function MagicDamage( p, amount, attacker, mSock, element ) if( p.frozen && p.dexterity > 0 ) { p.frozen = false; + p.Refresh(); if( mSock != null ) { mSock.SysMessage( GetDictionaryEntry( 700, mSock.language )); // You are no longer frozen. @@ -657,21 +660,33 @@ function isSpellCastingAllowed( item ) } // Function to handle items -function handleItem( itemLHand, itemRHand, mChar ) +function AutoUnequipAttempt( itemLHand, itemRHand, mChar ) { - const UnEquipEnabled = GetServerSetting( "AutoUnequippedCasting" ); + const autoUnequip = GetServerSetting( "AutoUnequippedCasting" ); var lHandBlocks = false; // Default to false var rHandBlocks = false; // Default to false - if( UnEquipEnabled && itemLHand != null && !isSpellCastingAllowed( itemLHand )) - { // Allow casting if item is spell channeling or type 9 spell book - itemLHand.container = mChar.pack; - lHandBlocks = true; // Set to true if item is blocking + if( itemLHand != null && !isSpellCastingAllowed( itemLHand )) + { + if( autoUnequip && mChar.pack.totalItemCount < mChar.pack.maxItems ) + { + itemLHand.container = mChar.pack; + } + else + { + lHandBlocks = true; // Set to true if item is blocking + } } - if( UnEquipEnabled && itemRHand != null && !isSpellCastingAllowed( itemRHand )) - { // Allow casting if item is spell channeling or type 9 spell book - itemRHand.container = mChar.pack; - rHandBlocks = true; // Set to true if item is blocking + if( itemRHand != null && !isSpellCastingAllowed( itemRHand )) + { + if( autoUnequip && mChar.pack.totalItemCount < mChar.pack.maxItems ) + { + itemRHand.container = mChar.pack; + } + else + { + rHandBlocks = true; // Set to true if item is blocking + } } return { lHandBlocks: lHandBlocks, rHandBlocks: rHandBlocks }; } diff --git a/source/Changelog.txt b/source/Changelog.txt index 64d3fd4a8..0e0d3678e 100644 --- a/source/Changelog.txt +++ b/source/Changelog.txt @@ -5,6 +5,11 @@ Added OnCombatHit -Triggers for character with event attached when someone has taken damage +1/05/2024 - Dragon Slayer/Xuri + Fixed AutoUnequipAttempt function in clumsy.js, createfood.js level1target.js, will no longer fail on casting and return to hardcode. + Fixed createfood to check for reagents on cast. + Fixed many places missing proper null checks and refresh checks in magic js scripts. + 27/04/2024 - Dragon Slayer/Xuri Fixed an issue where non-corpse containers - including treasure chests in dungeons - would decay and leave all their contents on the ground. Converted LOOTDECAYSWITHCORPSE ini setting to two new settings, one for player corpses, one for NPC corpses: diff --git a/source/StringUtility.cpp b/source/StringUtility.cpp index 6adb6c46c..54a379019 100644 --- a/source/StringUtility.cpp +++ b/source/StringUtility.cpp @@ -5,6 +5,7 @@ // #include "StringUtility.hpp" +#include #include #include #include diff --git a/source/StringUtility.hpp b/source/StringUtility.hpp index 2be725277..2cb94fe7a 100644 --- a/source/StringUtility.hpp +++ b/source/StringUtility.hpp @@ -7,6 +7,7 @@ #ifndef StringUtility_hpp #define StringUtility_hpp +#include #include #include #include