Permalink
Browse files

1/18/2009 - giwo

	Moved the magic scroll handling from cPlayerAction.cpp out to JavaScript (items/magicscroll.js)
	Fixed a bug with the JS Method Char.CastSpell() where it never returned a value to the calling script.
  • Loading branch information...
1 parent 56b7782 commit 694e6e40bdb4a90971d10203bba87dc13ebbc1e4 giwo committed Jan 19, 2009
Showing with 118 additions and 15 deletions.
  1. +29 −0 js/item/magicscroll.js
  2. +1 −0 js/jse_fileassociations.scp
  3. +66 −0 js/jse_objectassociations.scp
  4. +4 −0 source/Changelog.txt
  5. +3 −0 source/UOXJSMethods.cpp
  6. +15 −15 source/cPlayerAction.cpp
@@ -0,0 +1,29 @@
+function onUseChecked( pUser, iUsed ) // Handling for using a Magic Scroll
+{
+ var pSock = pUser.socket;
+ if( pSock && iUsed && iUsed.isItem )
+ {
+ var usedID = iUsed.id;
+ if( usedID > 0x1F2C && usedID < 0x1F6D )
+ {
+ var success = false;
+ pSock.currentSpellType = 1; // spell from scroll
+ if( usedID == 0x1F2D ) // Reactive Armor spell scrolls
+ success = pUser.CastSpell( 7 );
+ else if( usedID >= 0x1F2E && usedID <= 0x1F34 ) // first circle spell scrolls
+ success = pUser.CastSpell( usedID - 0x1F2D );
+ else if( usedID >= 0x1F35 && usedID <= 0x1F6C ) // 2 to 8 circle spell scrolls
+ success = pUser.CastSpell( usedID - 0x1F2D + 1 );
+
+ if( success )
+ {
+ var iAmount = iUsed.amount;
+ if( iAmount > 1 )
+ iUsed.amount = iAmount - 1;
+ else
+ iUsed.Delete();
+ }
+ }
+ }
+ return false;
+}
@@ -188,6 +188,7 @@
5015=item/bankcheck.js
5016=item/moonstone.js
5017=item/spyglass.js
+5018=item/magicscroll.js
}
//-------------------------------------------
@@ -533,4 +533,70 @@
// Clock
0x104B=5014
0x104C=5014
+
+// Magic Scrolls
+0x1F2D=5018
+0x1F2E=5018
+0x1F2F=5018
+0x1F30=5018
+0x1F31=5018
+0x1F32=5018
+0x1F33=5018
+0x1F34=5018
+0x1F35=5018
+0x1F36=5018
+0x1F37=5018
+0x1F38=5018
+0x1F39=5018
+0x1F3A=5018
+0x1F3B=5018
+0x1F3C=5018
+0x1F3D=5018
+0x1F3E=5018
+0x1F3F=5018
+0x1F40=5018
+0x1F41=5018
+0x1F42=5018
+0x1F43=5018
+0x1F44=5018
+0x1F45=5018
+0x1F46=5018
+0x1F47=5018
+0x1F48=5018
+0x1F49=5018
+0x1F4A=5018
+0x1F4B=5018
+0x1F4C=5018
+0x1F4D=5018
+0x1F4E=5018
+0x1F4F=5018
+0x1F50=5018
+0x1F51=5018
+0x1F52=5018
+0x1F53=5018
+0x1F54=5018
+0x1F55=5018
+0x1F56=5018
+0x1F57=5018
+0x1F58=5018
+0x1F59=5018
+0x1F5A=5018
+0x1F5B=5018
+0x1F5C=5018
+0x1F5D=5018
+0x1F5E=5018
+0x1F5F=5018
+0x1F60=5018
+0x1F61=5018
+0x1F62=5018
+0x1F63=5018
+0x1F64=5018
+0x1F65=5018
+0x1F66=5018
+0x1F67=5018
+0x1F68=5018
+0x1F69=5018
+0x1F6A=5018
+0x1F6B=5018
+0x1F6C=5018
}
@@ -1,3 +1,7 @@
+1/18/2009 - giwo
+ Moved the magic scroll handling from cPlayerAction.cpp out to JavaScript (items/magicscroll.js)
+ Fixed a bug with the JS Method Char.CastSpell() where it never returned a value to the calling script.
+
1/18/2009 - giwo (0.98-4.0a)
Fixed a crash caused by clicking on the Virtue Gump icon in the paperdoll
Added some checking before sending a status window to ensure the character is visible and in range
@@ -2711,7 +2711,10 @@ JSBool CChar_CastSpell( JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
Magic->CastSpell( sock, myChar );
}
else
+ {
spellSuccess = Magic->SelectSpell( sock, spellCast );
+ *rval = BOOLEAN_TO_JSVAL( spellSuccess );
+ }
}
return JS_TRUE;
}
@@ -2302,21 +2302,21 @@ bool CPIDblClick::Handle( void )
return true;
// Begin Scrolls check
- if( iUsed->GetID( 1 ) == 0x1F && ( iUsed->GetID( 2 ) > 0x2C && iUsed->GetID( 2 ) < 0x6D ) )
- {
- bool success = false;
- tSock->CurrentSpellType( 1 ); // spell from scroll
- if( iUsed->GetID( 2 ) == 0x2D ) // Reactive Armor spell scrolls
- success = Magic->SelectSpell( tSock, 7 );
- if( iUsed->GetID( 2 ) >= 0x2E && iUsed->GetID( 2 ) <= 0x34 ) // first circle spell scrolls
- success = Magic->SelectSpell( tSock, iUsed->GetID( 2 ) - 0x2D );
- else if( iUsed->GetID( 2 ) >= 0x35 && iUsed->GetID( 2 ) <= 0x6C ) // 2 to 8 circle spell scrolls
- success = Magic->SelectSpell( tSock, iUsed->GetID( 2 ) - 0x2D + 1 );
-
- if( success )
- iUsed->IncAmount( -1 );
- return true;
- }
+ //if( iUsed->GetID( 1 ) == 0x1F && ( iUsed->GetID( 2 ) > 0x2C && iUsed->GetID( 2 ) < 0x6D ) )
+ //{
+ // bool success = false;
+ // tSock->CurrentSpellType( 1 ); // spell from scroll
+ // if( iUsed->GetID( 2 ) == 0x2D ) // Reactive Armor spell scrolls
+ // success = Magic->SelectSpell( tSock, 7 );
+ // if( iUsed->GetID( 2 ) >= 0x2E && iUsed->GetID( 2 ) <= 0x34 ) // first circle spell scrolls
+ // success = Magic->SelectSpell( tSock, iUsed->GetID( 2 ) - 0x2D );
+ // else if( iUsed->GetID( 2 ) >= 0x35 && iUsed->GetID( 2 ) <= 0x6C ) // 2 to 8 circle spell scrolls
+ // success = Magic->SelectSpell( tSock, iUsed->GetID( 2 ) - 0x2D + 1 );
+
+ // if( success )
+ // iUsed->IncAmount( -1 );
+ // return true;
+ //}
tSock->sysmessage( 486 );
return true;
}

0 comments on commit 694e6e4

Please sign in to comment.