ArcEmu: [lua] Dummy Spells - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to join channel #arcemu /server /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[lua] Dummy Spells

#1 User is offline   hypersniper 

  • Advanced Member
  • Group: Retired
  • Posts: 227
  • Joined: 21-November 08
  • Gender:Male

Posted 03 January 2010 - 03:58 PM

What is it this time!?
Yeah, I know I've been bombarding you guys with info recently, but I've been working hard; and managed to create this very useful feature, dummy spell scripting. You can ignore this for now, but if you want to learn something new or are bored or need a challenge, continue reading.
Have you ever seen a spell with "Dummy", "Send event" or "scripted effect" in their effects list? here's an example, another, and yet another. You've probably come across them while scripting a boss and one of his spells was 'dummy', it didn't work, so you gave up and didn't use it.

No longer the case
With the new revision of Arcscripts, (r1054+) you can now script spells! Ie, make a spell (with dummy/scripted/send event effect) do whatever you want via Lua. This not only comes in handy in fixing the broken spells of your boss, but it has several other interesting applications as well, like scripted Chance On Hits and On Equips for your items. I will teach you how to do this now.

1. Find an existing scriptable spell you want to script
Pick an unscripted spell for you to use on your item. By unscripted, I mean "currently does nothing." So I'll pick a random one... hmm... looks alright. Make sure it has either "dummy", "scripted effect" or "send event" in it's effects list. I've gone in game and tested that it in fact does nothing, so it's ok to use. A list of scriptable spells can be found on thottbot via the effects page.
List of Script Effect spells
List of Dummy spells
List of Send event spells
So just pick one from one of those lists, and make sure it does nothing.

I want to script my chance on hit, so I put that spell down as my chance on hit spell. Here's how mine came out: Light Banhammer ;D I'm going to script it so it boots the target from the server.

2. Register that spell for scripting
Just like server hooks, we have to register a function that hooks with this scripted spell.
--Light Banhammer item
RegisterDummySpell(spellid, "function_to_call_when_spell_casts")

So let's fill in what we know and add a function.
--Light Banhammer item
function LBanHammer_ChanceOnHit(???)
RegisterDummySpell(30660, "LBanHammer_ChanceOnHit")

Hmm, still some unknown stuff. What goes in the brackets (aka the arguments)? Since there's really no way to know unless you're a C++ programmer, I'll just tell you now:
--Light Banhammer item
function LBanHammer_ChanceOnHit(effectIndex, spell)
RegisterDummySpell(30660, "LBanHammer_ChanceOnHit")

That's basically how it works. Your spell-hooked function needs those two arguments, effectIndex and spell. Why? You just do. Like how you always put pUnit, event with RegisterEvent. effectIndex is useless for most of us, it refers to what effect is the dummy/scripted/send event effect. You can ignore it for now.

spell refers to the spell object that was cast. This spell object is also brand new to Lua. You know how you usually do pUnit:Dothis() or pGo:DoThat() or item:DoSomething(); well now we can also do spell:Stuff(). So spell refers to our dummy spell itself. Interesting. Look at the LuaHypArc commands list under the ":SPELLS" section for some commands that you can use with spells.

So to kick a player that we hit, I'm going to need the Spell:GetTarget() command, as well as Plyr:KickPlayer(delay) command. The spell:GetTarget() command will always return the person you're hitting when the spell is a CoH. But what if we hit a regular creature? :KickPlayer will fail on a reg creature, so we will check that they're a player first.

--Light Banhammer item
function LBanHammer_ChanceOnHit(effectIndex, spell)
   if (spell:GetTarget():IsPlayer() == true) then
RegisterDummySpell(30660, "LBanHammer_ChanceOnHit")

Well that's about it
Well you're pretty pro if you managed to understand any of that. But that's a weapon that, Chance on Hit, kicks the target from the server. That's pretty cool imo xD. As usual, any questions PM or post.
Please don't PM me asking to fix, correct or look-over your scripts. Please post a new thread in the Lua Scripting section so others can learn and help.

#2 User is offline   Shadoxfix 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 312
  • Joined: 30-December 09
  • Gender:Male
  • Location:Netherlands

Posted 03 January 2010 - 04:27 PM

Awesome really nice function :(
With this you could also script the Starfall effect.

#3 User is offline   paroxysm 

  • Chatty Cathy
  • Group: Retired
  • Posts: 320
  • Joined: 25-June 08
  • Gender:Male
  • Server OS:Windows

Posted 03 January 2010 - 08:16 PM

You can also use this along with taxi functions to script those quests that transport players using taxis.

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users