Jump to content
  • 0

Need help with scripting consumable


crossworld

Question


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  16
  • Reputation:   3
  • Joined:  12/10/18
  • Last Seen:  

Hey guys,

Can someone help me figure this out... I want to make a consumable, a healing potion only usable between certain levels. For example I only want a character base level 15 - 50 able to use the healing potion.  Is this possible if so please tell. 

Thanks

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 1

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

501,Red_Potion,Red Potion,0,50,,70,,,,,0xFFFFFFFF,63,2,,,15:50,,,{ itemheal rand(45,65),0; },{},{}
// Structure of Database:
// ID,AegisName,Name,Type,Buy,Sell,Weight,ATK[:MATK],DEF,Range,Slots,Job,Class,Gender,Loc,wLV,eLV[:maxLevel],Refineable,View,{ Script },{ OnEquip_Script },{ OnUnequip_Script }

use the field eLV[:maxLevel]

  • Like 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

if (BaseLevel <100) { percentheal 25,25; }

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

only usable between those levels i think its impossible, but, following what @melv0 told you can use script to make the effect work between 15-50.

In item db you can set a EquipLevel on potion that means you can only can use if are at least on EquipLevel value level.

if(BaseLevel >= 15 && BaseLevel <= 50) { percentheal xx,yy; /* this will heal xx(hp) and yy(sp) by %*/ itemheal rand(aa,bb),rand(cc,dd); /*this will heal by a fixed value or rand value between aa and bb for HP and cc and dd for SP */ }

 

Edited by Rizta
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  16
  • Reputation:   3
  • Joined:  12/10/18
  • Last Seen:  

On 12/15/2018 at 3:54 AM, Rizta said:

only usable between those levels i think its impossible, but, following what @melv0 told you can use script to make the effect work between 15-50.

In item db you can set a EquipLevel on potion that means you can only can use if are at least on EquipLevel value level.


if(BaseLevel >= 15 && BaseLevel <= 50) { percentheal xx,yy; /* this will heal xx(hp) and yy(sp) by %*/ itemheal rand(aa,bb),rand(cc,dd); /*this will heal by a fixed value or rand value between aa and bb for HP and cc and dd for SP */ }

 

Hey rizta, your method works great but one thing we noticed when testing is if you aren't within the the specified level and you try to use the item the item is consumed.   Is there a way to make it so it's not consumed when you don't meet the requirements to use the item?

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  22
  • Topics Per Day:  0.01
  • Content Count:  109
  • Reputation:   5
  • Joined:  08/12/17
  • Last Seen:  

5 hours ago, crossworld said:

Hey rizta, your method works great but one thing we noticed when testing is if you aren't within the the specified level and you try to use the item the item is consumed.   Is there a way to make it so it's not consumed when you don't meet the requirements to use the item?

as i said, theres some limitations of what you can do... one possible solution is create another conditional(in the example i give above, simple add an ELSE) that restore the item if user dont match the requirements to receive the bonus, using getitem on script. 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  107
  • Topics Per Day:  0.02
  • Content Count:  770
  • Reputation:   69
  • Joined:  02/10/12
  • Last Seen:  

6 hours ago, crossworld said:

Hey rizta, your method works great but one thing we noticed when testing is if you aren't within the the specified level and you try to use the item the item is consumed.   Is there a way to make it so it's not consumed when you don't meet the requirements to use the item?

just add

if(BaseLevel >= 15 && BaseLevel <= 50) { percentheal xx,yy;} else { getitem itemid,1; }
Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

let me have some fun do some source coding ~

 src/map/pc.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/map/pc.cpp b/src/map/pc.cpp
index 6f651eff3..72b34137b 100755
--- a/src/map/pc.cpp
+++ b/src/map/pc.cpp
@@ -5040,6 +5040,9 @@ int pc_useitem(struct map_session_data *sd,int n)
 		return 0;/* regardless, effect is not run */
 	}
 
+	if ( id->type == IT_HEALING && sd->status.base_level >= 15 && sd->status.base_level <= 50 )
+		return 0;
+
 	sd->itemid = item.nameid;
 	sd->itemindex = n;
 	if(sd->catch_target_class != PET_CATCH_FAIL) //Abort pet catching.

if you mean not restricting for whole item type, but only 1 item ID,
then change
    if ( id->type == IT_HEALING )
into
   if ( item.nameid == <item ID> )

=========================

EDIT: - Emistry answer is correct

Edited by AnnieRuru
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...