macro that edits mon_control.txt

All resolved question will be found here. It is recommended that you browse / search through this section first and see if your question has been answered before

Moderators: Moderators, Documentation Writers

Message
Author
nyak00
Noob
Noob
Posts: 13
Joined: 15 Apr 2012, 02:35
Noob?: No

macro that edits mon_control.txt

#1 Post by nyak00 »

hey there, i've seen a macro that edits your mon_control.txt to make your kore aggro(attack 2) or non aggro(attack 0)..

Code: Select all

automacro sayconfHP1 {
   hp >= 55%
   sp >= 25%
   run-once 1
   exclusive 1
   call {
   do p confHP1
}
}

#automacro sayconfHP3 {
   hp >= 55%, sp <= 25%
   run-once 1
   exclusive 1
   call {
   do p confHP2
}
}

automacro sayconfHP2 {
   hp <= 35%, sp <= 19%
   run-once 1
   exclusive 1
   call {
   do p confHP2
}
}

automacro sayconfHP4 {
   hp <= 55%, sp >= 25%
   run-once 1
   exclusive 1
   call {
   do p confHP2
}
}

automacro confHP1 {
   party /confHP1/
   exclusive 1
   run-once 1
   set setting Magmaring
   set attack 2
   call HP
}

automacro confHP2 {
   party /confHP2/
   exclusive 1
   run-once 1
   set setting Magmaring
   set attack 0
   call HP
}

macro HP {
     #Getting the value of the $setting monster name Ex: $setting $exist1 $exist2 $exist3
       $exist1 = @eval (defined Misc::mon_control("$setting")?Misc::mon_control("$setting")->{attack_auto}:"None")
       log Old Values are $setting $exist1 $exist2 $exist3
       log Changing the values to $setting $attack
       do eval Misc::mon_control("$::Macro::Data::varStack{setting}")->{attack_auto} = $attack
       log Writting mon_control.txt with new values
       rewrite()  # see the sub-routine function below
       log Reloading mon_control.txt
       do reload mon_control
       $exist1 = @eval (defined Misc::mon_control("$setting")?Misc::mon_control("$setting")->{attack_auto}:"None")
       log New mon_control.txt Setting: $setting $exist1
       log Macro done
    #if $teleport = 0 ; means the Higher automacro HP is currently triggered
    #if $teleport = 2 ; means the Lower automacro HP is currently triggered
       if ($attack > 2) goto releaseHighHp
       :releaseLowHp
            release confHP1
            stop
       :releaseHighHp
            release confHP2
            stop
}
sub rewrite {
  my $monster = Misc::mon_control("$::Macro::Data::varStack{setting}");
  my @lines = ();
  if (open(FILE, "<:utf8", Settings::getControlFilename("mon_control.txt"))) {
     while (<FILE>) {
        s/\x{FEFF}//g; chomp;
        if (/^#/ || /^\n/ || /^\r/) {
           push @lines,$_;
           next
        }
        /^(\d+|([a-zA-Z' ]+)*) -?\d/;
        if ("$::Macro::Data::varStack{setting}" eq $1 && defined $monster) {
           $_ = $1; s/\s+$//;
           push @lines,$_ . " $monster->{attack_auto} $monster->{teleport_auto} $monster->{teleport_search} $monster->{attack_lvl} $monster->{attack_jlvl} $monster->{attack_hp} $monster->{attack_sp} $monster->{weight}"
        }
        else {push @lines,$_}
     }
     close FILE
  }
  open(FILE, ">:utf8", Settings::getControlFilename("mon_control.txt"));
  print FILE join "\n", @lines;
  close FILE;
}
the problem is the macro just activates once, either it goes aggro or non-aggro whenever i test it, after that it just sends a party message and doesn't edit the mon_control.txt anymore.. can anyone help me?

EternalHarvest
Developers
Developers
Posts: 1798
Joined: 05 Dec 2008, 05:42
Noob?: Yes

Re: macro that edits mon_control.txt

#2 Post by EternalHarvest »

Well, you have some automacros which would be run only once, since they're run-once and not released anywhere.

Do you really need to edit mon_control for that? Why not just change attackAuto?

There is a xconf plugin to do mon_control and other changes easier.

nyak00
Noob
Noob
Posts: 13
Joined: 15 Apr 2012, 02:35
Noob?: No

Re: macro that edits mon_control.txt

#3 Post by nyak00 »

EternalHarvest wrote:Well, you have some automacros which would be run only once, since they're run-once and not released anywhere.

Do you really need to edit mon_control for that? Why not just change attackAuto?

There is a xconf plugin to do mon_control and other changes easier.
oh wow! it worked just the way I wanted it.. you're a lifesaver! thanks so much!

nyak00
Noob
Noob
Posts: 13
Joined: 15 Apr 2012, 02:35
Noob?: No

Re: macro that edits mon_control.txt

#4 Post by nyak00 »

can you use hp and sp as OR arguemnts like these?

Code: Select all

automacro mymacro {
	hp >= 55%, sp >= 25%
	run-once 1
	exclusive 1
	call mymacro1
}

User avatar
SkylorD
Moderators
Moderators
Posts: 1166
Joined: 16 Dec 2011, 02:53
Noob?: No
Location: Brazil
Contact:

Re: macro that edits mon_control.txt

#5 Post by SkylorD »

No, don't work.

No just in case.
Learn rules

Locked