Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::Q&A

Quests::Q&A This is the quest support section

Reply
 
Thread Tools Display Modes
  #1  
Old 10-09-2013, 11:07 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default Charmfile vs Scriptfileid

When using a quest for an item.. is there any reason to use Scriptfileid?

I have yet to see something that the charmfile can't do that the scriptfileid can do...


Scriptfileid is restricted to ONE slot -- Meaning if you have two items that need scripts that are similar.. you would need TWO scripts to get them to BOTH work when equipping both items... (I am guessing this is unintended behavior?)


Charmfile is not restricted to ONE slot (thank god) .. I can have all my custom gear use the same exact charmfile and they all work well using the same quest to get what I need done.


TL;DR ... is scriptfileid useless / broken / or am I missing something...
Reply With Quote
  #2  
Old 10-11-2013, 04:01 AM
wolfwalkereci
Discordant
 
Join Date: Dec 2005
Posts: 435
Default

I use one scriptfileid for 3 pieces of gear, all of which have their own thing going on and it works for me.
Guess it depends on what your goal is and how you coded it.
__________________

Reply With Quote
  #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
  #4  
Old 10-11-2013, 09:09 AM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Quote:
Originally Posted by trevius View Post
I am not sure what you mean by the slot restrictions or by it only being useable by 1 item.
Create a script called... "Script_1.pl" ...

Now add it to a Helm / Chest / Bracer / ect / ect...

Add a debug line of some sort like so...

Code:
$DEBUG = 1;

sub EVENT_ITEM_CLICK {
	
	if($DEBUG == 1) { 	$client->Message(335, "CLICKED item!"); }

}
It seems I could get 2 of the same EXACT bracer to both work on the same script... but if it was a Bracer and a Helm the script would not work for both.. only worked for one... hmm


I was testing the Charmfile on 2 of the same weapns as well which is why I thought it worked for Charmfile... when I used 2 different weapons.. only of the of scripts would work and the other did not. (when using the same charmfile on both)
Reply With Quote
  #5  
Old 10-11-2013, 08:08 PM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

The way item scripts have changed a bit in the past few months Trev, it no longer really works like that and any item event can be triggered by any script.

This is from the Lua documentation but it should work the same for Perl with pl instead of lua extension:

Code:
Item Scripts are quest scripts attached to Items. Items will load a script on the first event that triggers them and will load one and only one from the following location. Which ever it finds first in the following order:

./quests/zone/items/item_script.lua
./quests/global/items/item_script.lua
./quests/zone/items/default.lua
./quests/global/items/default.lua
The format of the item_script is as follows:

If ScriptFileID != 0
	item_script = "script_" + ScriptFileID
Else If CharmFile != ""
	item_script = CharmFile
Else
	item_script = item_id
Items will only load one script but all events will get pushed to that based on that precedence order. If it doesn't work like this for both Lua and Perl then there's a bug that needs to be fixed.

Though I suspect you may be tripping over the precedence + item_script format unintentionally.
Reply With Quote
  #6  
Old 10-11-2013, 09:36 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

So KLS lets say script_1.pl is on my bracers I can't use script_1.pl on my boots as well?

Only one of the items can load that script at a time? (because that is how it is working currently)
Reply With Quote
  #7  
Old 10-12-2013, 06:36 AM
KLS
Administrator
 
Join Date: Sep 2006
Posts: 1,348
Default

In theory no that should work. I'm not seeing that behavior but I'm using Lua. I'll try Perl tomorrow and make sure it's not bugged.
Reply With Quote
  #8  
Old 10-20-2013, 11:21 PM
NatedogEZ's Avatar
NatedogEZ
Developer
 
Join Date: Dec 2012
Posts: 515
Default

Quote:
Originally Posted by KLS View Post
In theory no that should work. I'm not seeing that behavior but I'm using Lua. I'll try Perl tomorrow and make sure it's not bugged.


I figured out the problem actually.. was something I was completely overlooking till now ...


I had a hash outside of a sub so that I didn't have to copy paste it into each sub.. but doing that only allowed it to work for a single item with that script file. (doh)


I just copied the hash into both ... EVENT_EQUIP_ITEM and EVENT_UNEQUIP_ITEM and now it works for all items with the same exact script... yay!

I kinda feel stupid now.. :(
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

   

All times are GMT -4. The time now is 01:05 AM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3