Jump to content
  • 0

OnEquip or UnEquip Script


zanjetopakin

Question


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  2
  • Reputation:   0
  • Joined:  11/22/17
  • Last Seen:  

Hello, is there a trigger for 'OnEquip' or 'UnEquip' in scripting? I'm creating a script that will be triggered when an item is equipped. The script should check if the weapon, armor, shoes, and garment have the same refine level. If the condition is met, a bonus will be applied. Can you suggest any possible methods for this scenario?

the code above is sample (AI Generated, just to show the algorithm)" 
 

-	script	CheckRefineLevel	-1,{

	OnEquip:
		// Variables to store refine levels
		set .@refine_weapon, getequiprefinerycnt(EQI_HAND_R); // Main hand weapon
		set .@refine_armor, getequiprefinerycnt(EQI_ARMOR);   // Armor
		set .@refine_shoes, getequiprefinerycnt(EQI_SHOES);   // Shoes
		set .@refine_garment, getequiprefinerycnt(EQI_GARMENT); // Garment

		// Check if all items have the same refine level and meet the desired level (e.g. +10)
		if (.@refine_weapon == 10 && .@refine_armor == 10 && .@refine_shoes == 10 && .@refine_garment == 10) {
			// Apply bonus if all conditions are met
			bonus bAtkRate,10; // Increase attack by 10%
			bonus bMaxHP,5;    // Increase MaxHP by 5%
			dispbottom "All your equipment is refined to +10! Bonus applied.";
		} else {
			// Remove bonus if not all equipment are at +10
			bonus bAtkRate,0; // Remove attack bonus
			bonus bMaxHP,0;   // Remove MaxHP bonus
			dispbottom "Not all your equipment is refined to +10. No bonus applied.";
		}
	
	OnUnequip:
		// Remove bonus when equipment is unequipped
		bonus bAtkRate,0; // Remove attack bonus
		bonus bMaxHP,0;   // Remove MaxHP bonus
		dispbottom "Equipment unequipped, bonus removed.";
	
	end;
}

 

Edited by zanjetopakin
Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  223
  • Reputation:   35
  • Joined:  12/13/11
  • Last Seen:  

OnEquip/Unequip would be considered a label Because those arent reserved Special Triggers like OnInit or OnPCDieEvent. You can't Trigger when somone equips an item unless you were to do it via the Item Database under the specific item's script section. You wouldn't need to put the script in each item. since the way you're describing would need all of them to be equipped to be considered true. 

Bottom of Item_db.yml

#   Script                  Script to execute when the item is used/equipped. (Default: null)
#   EquipScript             Script to execute when the item is equipped. (Default: null)
#   UnEquipScript           Script to execute when the item is unequipped or when a rental item expires. (Default: null)
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  2
  • Reputation:   0
  • Joined:  11/22/17
  • Last Seen:  

17 hours ago, LCDTheOG said:

OnEquip/Unequip would be considered a label Because those arent reserved Special Triggers like OnInit or OnPCDieEvent. You can't Trigger when somone equips an item unless you were to do it via the Item Database under the specific item's script section. You wouldn't need to put the script in each item. since the way you're describing would need all of them to be equipped to be considered true. 

Bottom of Item_db.yml

#   Script                  Script to execute when the item is used/equipped. (Default: null)
#   EquipScript             Script to execute when the item is equipped. (Default: null)
#   UnEquipScript           Script to execute when the item is unequipped or when a rental item expires. (Default: null)

I am aware of EquipScript and UnEquipScript. However, since the equip will be general (like wearing a mink coat or chainmail), it will trigger the script as long as it has the same refine level. Using EquipScript and UnEquipScript, I need to include them in all items in item_db.yml. I've read about OnPutOnEquip and OnPutOffEquip, special labels created by cydh, but after trying them, they seem outdated and no longer functional. So far, my only solution is to trigger the script every 10 or 30 seconds to check the condition. However, I'm concerned that this might impact server performance, as it will constantly check all players and could potentially cause lag.

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...