Cannibalize Macro

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

holmedog
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Oct 27, 2003 1:48 pm

Cannibalize Macro

Post by holmedog » Sun Oct 31, 2004 3:45 pm

Start this within 2 seconds of your tick and it will canni dance for you

Edit: Think I fixed it to include all canni timers, may have to adjust how long you pause after the cast of canni

Edit: Took out the second function, it was erenuous and just causes more problems for 6 lines of code. Also changed some small things and tweaked it a little better.

Code: Select all

|cani.mac: a simple cani macro 
|usage: /mac cani [sit] 
|By:  holmedog

#include spell_routines.inc 


sub main

/if (${Me.PctMana}>95) /return
/cast "Cannibalize IV"
/delay 4s
/sit
/delay 2s
/if (${Me.PctHPs}<45) {
/varset TempID ${Target.ID} 
/keypress F1 
/echo Casting Heal Spell because of low health... 
/cast "Quiescence" 
/delay 5s
/sit
/delay 25s 
/target id ${TempID} 
}
/call main
/return
Last edited by holmedog on Mon Nov 01, 2004 7:57 am, edited 1 time in total.
You can complain that a rose has thorns, or be happy that thorns have roses, its all in how you look at it.

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Sun Oct 31, 2004 5:28 pm

Code: Select all

/keypress F1 
Could theoretically target your pet.

You would have better luck with

Code: Select all

/target myself
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

Virtuoso65
a hill giant
a hill giant
Posts: 150
Joined: Wed Oct 15, 2003 2:29 pm

Post by Virtuoso65 » Sun Oct 31, 2004 6:50 pm

|cani.mac: a simple cani macro
|usage: /mac cani [sit]
|By: holmedog

#include spell_routines.inc

sub main

/if (${Me.PctMana}>95) /return
/if (${Me.PctHPs}<45) /call heal
/cast "Cannibalize IV"
/delay 4s
/sit
/delay 2s
/call main
/return

sub heal
/varset TempID ${Target.ID}
/keypress F1
/echo Casting Heal Spell because of low health...
/cast "Quiescence"
/delay 30s
/target id ${TempID}
/return

I would suggest using a :loop instead of calling the parent sub from with in its self as doing such can cause serious slow downs via memory leak.

Code: Select all

sub main
:loop
/if (${Me.PctMana}>95) /return
/if (${Me.PctHPs}<45)  /call heal
/cast "Cannibalize IV"
/delay 4s
/sit
/delay 2s
/goto :loop
/return
Any way, this forum is for include files not macros, just a FYI.

holmedog
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Oct 27, 2003 1:48 pm

Post by holmedog » Mon Nov 01, 2004 7:58 am

Actually, calling a function from itself is a form of recursion. It is very useful and much more powerful than goto statements, there is no reason they should be used in code. In a function that takes up less than 1kb, it couldn't possibly cause more than a 1mb hold-up in ram over an hours worth of calling.
You can complain that a rose has thorns, or be happy that thorns have roses, its all in how you look at it.

Chill
Contributing Member
Contributing Member
Posts: 435
Joined: Fri May 07, 2004 5:06 pm
Location: Erie, PA

Post by Chill » Mon Nov 01, 2004 9:31 am

holmedog wrote:In a function that takes up less than 1kb, it couldn't possibly cause more than a 1mb hold-up in ram over an hours worth of calling.
lolz so 'only' taking up 1 meg per hour with this litle chunk of code is a good thing?

Yes, recursion is powerful. I use recursion in my slow routine for my chanter (if slow resists, it recalls itself) but the difference is that as soon as the mob gets slowed, they all return back to the main.

As far as I can tell, your recursion never returns, so it just keeps sucking up more and more memory. The fact that its 'only' sucking 1k every 6 seconds doesnt make it better imo.

This can be writen better man. In fact Im pretty sure it has been written better by someone else long ago, so if you doin like the code suggested above, you could probably do a SEARCH and find some inspiration elsewhere on the boards

User avatar
fearless
Not a Psychic
Posts: 2684
Joined: Wed Mar 10, 2004 3:52 pm

Post by fearless » Mon Nov 01, 2004 9:41 am

holmedog wrote:it couldn't possibly cause more than a 1mb hold-up in ram over an hours worth of calling.
So because it's small it doesn't matter? Boy if that isn't an arguement for bloatware I don't know what is.

Generally, things around here are as streamlined as possible. Just because it is a "small" leak / issue / whatever, doesn't mean you should be doing it.
Reading . . . it's not just for me.

[url=http://www.catb.org/~esr/faqs/smart-questions.html]How To Ask Questions The Smart Way[/url]
[quote="Ccomp5950"]Fearless showed me the light, you too shall learn.[/quote]

holmedog
decaying skeleton
decaying skeleton
Posts: 4
Joined: Mon Oct 27, 2003 1:48 pm

Post by holmedog » Mon Nov 01, 2004 11:25 am

The argument that it was small was not the reasoning that you leave the recursion in. The argument was that it is a valid type of programming, much more efficient than goto statements, and works. Take any programming classes and the first thing they will tell you is never use a goto statement, ever. Calling a function from itself with an option to quit (the /if statement concerning mana) is the exact same thing as calling a while looop or a for loop. Just because a function is called again in a program does not mean it is replicated in memory, the code is just reused. No variables are declared locally, and thus they aren't recreated, and they don't take up more space in memory. If there were a variable used in the function, every time it was called it would create a new 4byte area in memory to be stored. This is where your "bloatware" idea comes from.
You can complain that a rose has thorns, or be happy that thorns have roses, its all in how you look at it.

zanomo
a hill giant
a hill giant
Posts: 285
Joined: Thu Jun 24, 2004 11:21 pm

Post by zanomo » Tue Nov 02, 2004 1:07 am

hmm... I personally agree with fearless and chill. However, each has his own believes and and some seems to defend it strongly though either method has its own merits and short comings.

And this is how I do my canni:

Code: Select all

Sub Do_Canni
    /if (${Me.PctMana} > 95)                 /return
    /if (${Me.PctHPs} <= 70)                 /return
    /if (${Me.PctMana} > ${Me.PctHPs})       /return
    /if (!${Me.SpellReady[Cannibalize IV]})  /return
    /call Cast "Cannibalize IV"
    /call Sit_Check
/return

Rusty~
a hill giant
a hill giant
Posts: 244
Joined: Wed Apr 14, 2004 2:55 pm

Post by Rusty~ » Tue Nov 02, 2004 11:28 am

I wrote a small spell trainer that would sit at the start of a tic, cast minor healing, then sit again when it was close to the next tic. Here's the code :P
Could replace the minor healing with canni and of course add in few other changes, but this basically figures out when the next "tic" is for you

Code: Select all

#include spell_routines.inc

Sub Main
   /declare ticTime float outer
   /declare tempMana int local
:cast_loop
   /if ( ${Me.PctMana}<100 && !${ticTime} ) {
      /varset tempMana ${Me.CurrentMana}
      /delay 6s ${Me.CurrentMana}>${tempMana}
      /varset ticTime ${MacroQuest.Running}
   }
   /if ( ${Target.Distance3D}>100 || !${Target.ID} ) /tar id ${Me.ID}
   /if ( ${Math.Calc[(${MacroQuest.Running}-${ticTime})%6000]}>=4500 ) {
      /if ( !${Me.Sitting} ) /sit
   } else /if ( ${Me.CurrentMana}>=${Math.Calc[10+${Me.ManaRegen}]} && ${Math.Calc[(${MacroQuest.Running}-${ticTime})%6000]}>1000 ) {
      /if ( !${Me.Standing} ) /stand
      /call cast "minor healing"
   }
/goto :cast_loop