1. #1

    [Solved] Scripts: Dark Intent and Soulstone - need optimizing & improving code

    hello Treeston & other code experts,

    im really not an lua expert but I managed by grabing some code here and there to make two macros that worked fine but needed strong improvment for the script part:
    Thanks to Ellesardan and Treeston for solving this, so here is the result.

    This one is at 251/255
    Code:
    #showtooltip
    /use [help][@pet]Dark Intent
    /run local i=GetSpellLink(80398).." on %t!" if UnitExists"target"then SendChatMessage(i,"WHISPER",nil,UnitName"target");SendChatMessage(i,UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY"))end

    Will cast Dark intent on your target if it's friendly and exist, else will cast on you pet, whisper your buffed target, tell the raid who you buffed it with, or the party if you aren't in a raid.


    Then I made a macro for combat rez that worked as intended but needed improvement.

    This one 255/255 was solved with the help of Elessardan.
    Code:
    #showtooltip
    /use [help,dead][@player,btn:2]Soulstone;Create Soulstone
    /stopmacro [nodead]
    /run SendChatMessage("BREZ@ %t!",((UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY")));SendChatMessage("REZ @ you!","WHISPER",nil,UnitName"target");

    Works for combat rez situation, so basically what it does is: use the soulstone, only if i have a friendly dead target, if not, it creates a soulstone, if I already have a soulstone it does nothing. Then if I really do have a dead friendly target it warn the raid or party who im currently BRezing, and also warn my dead target in whisp, this reduce the risk of accidentally applying the soulstone on a target that has just been rezed by someone else just before you do. Then it applies an emergency soulstone on yourself with right click.

    Enjoy !
    Last edited by yook; 2011-12-28 at 01:10 AM. Reason: displaying the end result

  2. #2
    I'm not particularly good at code or macros but I think I might have something to help.

    For your first request on the first macro:
    Code:
    SendChatMessage("\124cff71d5ff\124Hspell:80398\124h[Dark Intent]\124h\124r on %t",((UnitInRaid("player")and "RAID")or(GetNumPartyMembers()>0 and "PARTY")))
    Should work. I think. You'd want to put that inside of the UnitExists("target") if statement that you had, before that end.

    As for checking to see if target is in range, I'm not sure that would be possible outside of an addon, would have to look at cast success events or something like that.

    And the third part, casting on pet, should be:
    Code:
    /cast [exists][target=pet] Dark Intent
    And you'd want that to replace what you had before for your second line.


    First request on the second macro:
    Code:
    SendChatMessage("Rez on you!","WHISPER",nil,UnitName("target"))
    Could also check to make sure you have a target with the same if statement you had in the first macro, not sure if that would be necessary. Also not sure if that is too long as it is.

    Second part, again not sure if that's possible.

    Third one, I was surprised it wouldn't let you use it on yourself with just a [target=player] conditional. But if you wanted to cast on yourself on a right-click, [target=player,button:2] I'd think would work just fine.

    (MMO-champion is being weird and won't let me use [AT] for the player/pet/etc conditionals, apparently I don't have enough posts for "links.")
    Last edited by Elessardan; 2011-12-27 at 06:40 PM.

  3. #3
    thanks for trying Ellessardan, but you missed the point in 1st macro, it's already whispering the target but I want to also warn the raid OR party (if not in a raid) so other locks adapt to what I did.
    it seem you just replaced the whole thing with the part of the script I have in my second macro ;p

    then I need everything to possibly work and fit in 255 that's why I added priorities to what the macro should do within the 255 limit, if it doesnt fit remove priority 3, still doesn't fit, remove priority 2 and so on. so I think only an expert would be able to give a head at this, no offense

    I was surprised it wouldn't let you use it on yourself with just a [target=player] conditional
    It won't let me because I have the "dead" conditionner because I only want to Brez dead targets, I don't want to apply a soulstone by mistake on a target that just got Brez by someone else, and since im not dead that won't cast it on me. I just want to be able to cast it on me in rare situations where im about to die and having it applied on myself could help.

    [target=player,button:2] I'd think would work just fine.
    thanks, you're probably right but it's damn long, will it fit in the 255 limit with other priorities? we'll see
    Last edited by yook; 2011-12-27 at 05:40 PM. Reason: quote part

  4. #4
    Ok well I meant that statement would be added after what you already had
    Code:
    #showtooltip
    /cast [exists][target=pet] Dark Intent
    /run if UnitExists"target"then SendChatMessage("\124cff71d5ff\124Hspell:80398\124h[Dark Intent]\124h\124r on you 30mn","WHISPER",nil,UnitName"target") SendChatMessage("\124cff71d5ff\124Hspell:80398\124h[Dark Intent]\124h\124r on %t",((UnitInRaid("player")and "RAID")or(GetNumPartyMembers()>0 and "PARTY")))end
    was what I meant for the first one as a whole. But that is over the character limit I believe.

    ---------- Post added 2011-12-27 at 12:40 PM ----------

    Quote Originally Posted by yook View Post
    It won't let me because I have the "dead" conditionner because I only want to Brez dead targets, I don't want to apply a soulstone by mistake on a target that just got Brez by someone else, and since im not dead that won't cast it on me. I just want to be able to cast it on me in rare situations where im about to die and having it applied on myself could help.
    Right but you only needed the [dead] conditional for the target part, and wouldn't need one for the player one.
    Edit: Oh right right, I misinterpreted, you didn't want it to cast on yourself accidentally as well as on others accidentally.

    thanks, you're probably right but it's damn long, will it fit in the 255 limit with other priorities? we'll see
    I don't think so, it's probably over, but that would be shortened slightly with [(AT-sign)player] replacing [target=player] and [btn:2] for [button:2].


    Really it's not the third priority on your list that makes them go over, just having that second SendChatMessage puts it over. The easiest way around it would either an addon like BindPad that lets you make macros longer than the normal 255 limit (but as far as I'm aware you can only bind them, you can't put them on your action bar), or use /click to chain a pair of them together...I really wish someone better at this was here to help...
    Last edited by Elessardan; 2011-12-27 at 06:15 PM.

  5. #5
    Quote Originally Posted by Elessardan View Post
    Code:
    #showtooltip
    /cast [exists][target=pet] Dark Intent
    that can be optimized like this
    Code:
    #showtooltip
    /use [help][@pet]Dark Intent
    "use" can replace cast, "help" is shorter and imply the target also exists, and @pet does the job. 9 char saved ! but the rest need strong optimization cause even with those 9, we're still around 300 char

    I don't think so, it's probably over, but that would be shortened slightly with [(AT-sign)player] replacing [target=player] and [btn:2] for [button:2].

    Ok so now for Macro n°2 im there atm and works like a charm: 213/255
    Code:
    #showtooltip
    /use [help,dead][@player,btn:2]Soulstone
    /use Create Soulstone
    /stopmacro [nodead]
    /run SendChatMessage("REZ COMBAT @ %t !", ((UnitInRaid("player")and "RAID")or(GetNumPartyMembers()>0 and "PARTY")));
    awesome, we only need to fit the whisper target part in there now with 42 char left.

  6. #6
    What about:
    Code:
    #showtooltip
    /use [help,dead][(AT)player,btn:2]Soulstone;Create Soulstone
    /stopmacro [nodead]
    /run SendChatMessage("REZ (AT) %t!",((UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY")));SendChatMessage("REZ (AT) you!","WHISPER",nil,UnitName"target");
    I think that should be exactly 255. Took out quite a few parenthesis that I think are ok to remove, definitely double check that. Also since you'd only be casting Create Soulstone if the conditionals on the first line fail, you should be able to put them in the same /use anyways. I think...

  7. #7
    Quote Originally Posted by Elessardan View Post
    What about:
    Code:
    #showtooltip
    /use [help,dead][(AT)player,btn:2]Soulstone;Create Soulstone
    /stopmacro [nodead]
    /run SendChatMessage("REZ (AT) %t!",((UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY")));SendChatMessage("REZ (AT) you!","WHISPER",nil,UnitName"target");
    I think that should be exactly 255. Took out quite a few parenthesis that I think are ok to remove, definitely double check that. Also since you'd only be casting Create Soulstone if the conditionals on the first line fail, you should be able to put them in the same /use anyways. I think...
    Code:
    #showtooltip
    /use [help,dead][@player,btn:2]Soulstone;Create Soulstone
    /stopmacro [nodead]
    /run SendChatMessage("REZ @ %t!",((UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY")));SendChatMessage("REZ @ you!","WHISPER",nil,UnitName"target");
    255 char ! Tested in raid and everything works like a charm ! thanks Eless

    now I feel the 1st macro will be a pain without an expert eventho you did pretty well

  8. #8
    Thanks. Well the first one would be easy if it weren't for the spell link, takes up a lot of space, especially linking it twice. Even using a variable for it only brings it down to around 300 characters, as the lowest I got it to.

  9. #9
    im pretty sure it should be possible to write the link only once and then duplicate message for target + raid or party (party if not in a raid)

    ps: 3 more posts and you will be able to use @ and links
    Last edited by yook; 2011-12-27 at 07:23 PM.

  10. #10
    Yeah that's what I have it as but since the link itself is 57 characters, and the second chat message is 95 characters or so (not counting the link in that), even linking it once would put you over considering it started at 184 characters.

    Edit: Could either drop the link, or use a /click command and have the SendChatMessage in a second macro, and use /click on that.

  11. #11
    Deleted
    GetSpellLink(id) instead of pasting the entire link?

  12. #12
    That would be the smart thing to do...

    ---------- Post added 2011-12-27 at 06:56 PM ----------

    K so I guess with that something like this:
    Code:
    #showtooltip
    /use [help][(AT)pet]Dark Intent
    /run local i=GetSpellLink(80398).."(AT) %t!" if UnitExists"target"then SendChatMessage(i,"WHISPER",nil,UnitName"target");SendChatMessage(i,(UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY"))end
    would work?

  13. #13
    Quote Originally Posted by Elessardan View Post
    That would be the smart thing to do...

    ---------- Post added 2011-12-27 at 06:56 PM ----------

    K so I guess with that something like this:
    Code:
    #showtooltip
    /use [help][(AT)pet]Dark Intent
    /run local i=GetSpellLink(80398).."(AT) %t!" if UnitExists"target"then SendChatMessage(i,"WHISPER",nil,UnitName"target");SendChatMessage(i,(UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY"))end
    would work?
    thanks for the tip Treeston, that works perfectly, and thank you so much for putting that together Ellesardan you rock man

    final modification on 1st macro we're at 252/255:
    Code:
    #showtooltip
    /use [help][@pet]Dark Intent
    /run local i=GetSpellLink(80398).." on %t!" if UnitExists"target"then SendChatMessage(i,"WHISPER",nil,UnitName"target");SendChatMessage(i,UnitInRaid"player"and"RAID")or(GetNumPartyMembers()>0 and"PARTY"))end

    Will cast Dark intent on your target if it's friendly and exist, else will cast on you pet, whisper your buffed target, tell the raid who you buffed it with, or the party if you aren't in a raid.

    Enjoy !

    ps: consider solved thx
    Last edited by yook; 2011-12-28 at 01:11 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •