Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::LUA

Quests::LUA Section regarding LUA scripts, help, questions, answers

Reply
 
Thread Tools Display Modes
  #1  
Old 01-24-2015, 10:08 AM
silvergrin46
Fire Beetle
 
Join Date: Jan 2015
Posts: 9
Default Progress!

After alot of experimenting in game with global/spells/spellid.lua (in my example global/spells/102.lua) and casting
my test spell over and over with minor changes and #reloadquest, also reading this again from
https://github.com/EQEmu/Server/wiki...player-scripts


Spell Events

event_spell_effect

Triggered when a spell affects a target. Passes an event table as an argument:

{
Spell self;
Mob target;
Integer buff_slot;
Integer caster_id;
}
Returning a non-zero value from this function will cancel the spell effect.


It finally sank in how to word this spell file properly. I am now at least getting some reaction when activating the script and I will continue attempting to convert more complex versions of my old perl spell files to lua.


Code:
--global/spells/102.lua  test spell target self
--Message is received whenever spell 102 is cast, with or without a target as spell 102 is self only spell

function event_spell_effect(e)

e.target:Message(15, "I just cast a spell FROM SPELL FILE ! "); 

end
Hopefully this will help someone else out at some point.
Reply With Quote
  #2  
Old 01-26-2015, 10:39 PM
silvergrin46
Fire Beetle
 
Join Date: Jan 2015
Posts: 9
Default Some progress, still stuck on a few ideas i'd like to implement in lua

Many of the functions found here seem to be read correctly upon casting my test spell:

https://github.com/EQEmu/Server/wiki/Lua-Mob

Here is an example script which all displays as it should when the spell is cast and triggers a script to be run from global/spells.

Code:
function event_spell_effect(e)

	local P_LVL = e.target:GetLevel(); 	
	local P_RACE = e.target:GetBaseRace(); 
	local P_STR = e.target:GetSTR(); 	
	
	local Mana = e.target:GetMana();
	local ManaCost = (P_LVL*5);
	local NewMana = (Mana - ManaCost);


	e.target:Message(15, "My LEVEL IS: "..P_LVL); 
	e.target:Message(15, "My RACE IS: "..P_RACE);
	e.target:Message(15, "My STR IS: "..P_STR);
	
	e.target:Message(15, "My INITIAL MANA IS: "..Mana);
	e.target:Message(15, "MANACOST TO CAST THIS SPELL IS: "..ManaCost);
	e.target:Message(15, "My MANA TOTAL AFTER CASTING IS: "..NewMana);
	
		if(NewMana < 0) then e.target:Message(5, "You do not have enough mana to use this ability.");
		elseif (NewMana >= 0) then e.target:SetMana(NewMana);
	
	
		end
	end

What one of my goals is to have a spell cast and trigger a script that will cast another spell or trigger the global_player file to cast another spell based on the conditions I specify.

I've tried variations of Selfcast /CastSpell /CastToClient /SignalClient /SignalAllClients etc. and can not seem to get the script to recognize just who e.target really is.

I have figured out how to do so in the lua global_player file, I was just trying to avoid constant access to the player file if I can do so in a separate spell file.
Reply With Quote
Reply

Thread Tools
Display Modes

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 09:49 PM.


 

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 - 2026, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3