View Single Post
  #3  
Old 10-11-2013, 08:30 AM
trevius's Avatar
trevius
Developer
 
Join Date: Aug 2006
Location: USA
Posts: 5,946
Default

The Charmfile scripts are for scaling items and the scripts are ran automatically on regular intervals. The scriptfileid field is used for scripts that are triggered when right clicking an item similar to a clicky item that would normally cast a spell. I am not sure what you mean by the slot restrictions or by it only being useable by 1 item.

Here is a simple example of a charm script that uses qglobals:
Code:
#Aug Scale

sub EVENT_SCALE_CALC {


	if (defined($qglobals{Example_Qglobal_Value}))
	{
		$questitem->SetScale($qglobals{Example_Qglobal_Value}/100); 
	}
	else
	{
		$questitem->SetScale(0);
	}
	
}
Here is a very simple script file id script that sends a message to the client that clicked it. The nice thing about this is that it does not require a clicky spell to be on the item in order to trigger a script when right clicked. Keep in mind that this only works for clients later than Titanium, as Titanium does not send anything to the server if a non-clicky item is right clicked:
Code:
# Clicky Item Test Script

sub EVENT_ITEM_CLICK { 
	if ($client)
	{
		$client->Message(15,"Click Event Worked for $itemname ($itemid)!");
	}
}
You can also use spell IDs in the quests/spells folder for scripts that trigger when a spell is cast from an item (or any regular cast as well). Here is an example that enforces size limits to a growth spell:
Code:
# Script for setting a cap on Growth spells
	
%RaceSizes = (
	1 => 6, # Human
	2 => 8, # Barbarian
	3 => 6, # Erudite
	4 => 5, # Wood Elf
	5 => 5, # High Elf
	6 => 5, # Dark Elf
	7 => 5, # Half Elf
	8 => 4, # Dwarf
	9 => 9, # Troll
	10 => 9, # Ogre
	11 => 3, # Halfling
	12 => 3, # Gnome
	128 => 6, # Iksar
	130 => 6, # Vah Shir
	330 => 5, # Froglok
	522 => 6, # Drakkin
);

# Sub to handle the growth limits so it doesn't have to be repeated multiple times
sub DoGrowth {
	my $Mob = $_[0]; # This is the Mob that was passed into the sub
	my $CurSize = $Mob->GetSize();
	if (!$CurSize) {
		$CurSize = 6;
	}
	my $CurRace = $Mob->GetRace();
	my $BaseSize = $RaceSizes{$CurRace};
	if (!$BaseSize) {
		$BaseSize = 6;
	}
	if ($CurSize < $BaseSize + 5) {
		$Mob->ChangeSize($CurSize + 1);
	}
}

sub EVENT_SPELL_EFFECT_CLIENT {
	my $ClientID = $entity_list->GetClientByID($caster_id);
	if ($ClientID) {
		$ClientTarget = $ClientID->GetTarget();
		if ($ClientTarget) {
			DoGrowth($ClientTarget);
		}
		else {
			DoGrowth($ClientID);
		}
	}
}

sub EVENT_SPELL_EFFECT_NPC {
	my $NPCID = $entity_list->GetMobByID($caster_id);
	if ($NPCID) {
		$NPCTarget = $NPCID->GetTarget();
		if ($NPCTarget) {
			DoGrowth($NPCTarget);
		}
		else {
			DoGrowth($NPCID);
		}
	}
}
It isn't much, but this wiki page shows the events related to different types of item scripts:
http://www.eqemulator.net/wiki/wikka...kka=ItemQuests

In short; the different types of scripts are all fully functional. You are probably just not using them correctly.
__________________
Trevazar/Trevius Owner of: Storm Haven
Everquest Emulator FAQ (Frequently Asked Questions) - Read It!

Last edited by trevius; 10-11-2013 at 08:36 AM..
Reply With Quote