Page 1 of 1

Cannibalize Macro

Posted: Sun Oct 31, 2004 3:45 pm
by holmedog
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

Posted: Sun Oct 31, 2004 5:28 pm
by fearless

Code: Select all

/keypress F1 
Could theoretically target your pet.

You would have better luck with

Code: Select all

/target myself

Posted: Sun Oct 31, 2004 6:50 pm
by Virtuoso65
|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.

Posted: Mon Nov 01, 2004 7:58 am
by holmedog
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.

Posted: Mon Nov 01, 2004 9:31 am
by Chill
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

Posted: Mon Nov 01, 2004 9:41 am
by fearless
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.

Posted: Mon Nov 01, 2004 11:25 am
by holmedog
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.

Posted: Tue Nov 02, 2004 1:07 am
by zanomo
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

Posted: Tue Nov 02, 2004 11:28 am
by Rusty~
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