• 0
crossworld

Need help with scripting consumable

Question

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

Share this post


Link to post
Share on other sites

7 answers to this question

Recommended Posts

  • 1
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

Share this post


Link to post
Share on other sites
  • 0

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

Share this post


Link to post
Share on other sites
  • 0
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?

Share this post


Link to post
Share on other sites
  • 0
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. 

Share this post


Link to post
Share on other sites
  • 0
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; }

Share this post


Link to post
Share on other sites
  • -1
Posted (edited)

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now