Jump to content
  • 0

Script - Spawn MVP only after the previous one is dead


Syon

Question


  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   10
  • Joined:  10/31/16
  • Last Seen:  

Hello rAthena Community,

Before anything else, here's the script I want to edit.

-	script	respawnMvp	-1,{
    OnInit:
        setarray .mob_id[0],1511;
        set .size, getarraysize(.mob_id);
        set .random, rand(.size);
        set .amount, 1; // amount of monster spawned
        set .monster, .mob_id[.random];
        end;
        

         OnMinute00:
         OnMinute01:
         OnMinute02:
         OnMinute03:
         OnMinute04:
         OnMinute05:
         OnMinute06:
         OnMinute07:
         OnMinute08:
         OnMinute09:
         OnMinute10:
         OnMinute11:
         OnMinute12:
         OnMinute13:
         OnMinute14:
         OnMinute15:
         OnMinute16:
         OnMinute17:
         OnMinute18:
         OnMinute19:
         OnMinute20:
         OnMinute21:
         OnMinute22:
         OnMinute23:
         OnMinute24:
         OnMinute25:
         OnMinute26:
         OnMinute27:
         OnMinute28:
         OnMinute29:
         OnMinute30:
         OnMinute31:
         OnMinute32:
         OnMinute33:
         OnMinute34:
         OnMinute35:
         OnMinute36:
         OnMinute37:
         OnMinute38:
         OnMinute39:
         OnMinute40:
         OnMinute41:
         OnMinute42:
         OnMinute43:
         OnMinute44:
         OnMinute45:
         OnMinute46:
         OnMinute47:
         OnMinute48:
         OnMinute49:
         OnMinute50:
         OnMinute51:
         OnMinute52:
         OnMinute53:
         OnMinute54:
         OnMinute55:
         OnMinute56:
         OnMinute57:
         OnMinute58:
         OnMinute59:
        monster "prontera",154,172,getmonsterinfo(.monster, 0),.monster,.amount,strnpcinfo(0)+ "::OnKill";
        announce "O MVP "+getmonsterinfo(.monster, 0)+" acabou de nascer!",0;
        end;
        
    OnKill:
        announce "O MVP "+getmonsterinfo(.monster, 0)+ " foi eliminado "+ (Sex?"pelo":"pela")+" "+ (Sex?"jogador":"jogadora")+" "+strcharinfo(0)+".",0;
        end;
        
        
}

How does it work?

The script will spawn a random MVP in "prontera 154 172" every minute, such MVPs are stored in an array called .mob_id[0]. The only MVP right now for testing purposes is Amon Ra(1511). When the MVP is spawned, it will show a global message: MPV Amon Ra has been spawned in prontera. Also, when the MVP is killed, it will show the following message: Amon Ra has been killed. It spawns only 1 MVP at a time.

What am I looking for?

I don't want the script to spawn a new MVP every minute when the previous one is still alive.

Case:

If Amon Ra has been spawned, it will only spawn a new Amon Ra when the previous one has been killed. It will keep checking every minute to see if the current Amon Ra(or any MVP in .mob_id[0] array) is alive. If the current MVP is alive, it will spawn a new one, if not, it will hold until the current one is dead.

What have I tried already?

I was checking the MVPs in LHZ_DUN03, but I couldn't understand how they work. A new MVP in lhz_dun03 only spawn after the current MVP is dead.

Also, I was checking how the MVP in other maps works, but they're just using the declaration boss_monster. I've tried to add it to the script above, but I got an error. I changed:

monster "prontera",154,172,getmonsterinfo(.monster, 0),.monster,.amount,strnpcinfo(0)+ "::OnKill";

to

boss_monster "prontera",154,172,getmonsterinfo(.monster, 0),.monster,.amount,strnpcinfo(0)+ "::OnKill";

Thanks,

respawn-mvp.txt

Edited by Elano
Link to comment
Share on other sites

5 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  81
  • Reputation:   14
  • Joined:  11/17/17
  • Last Seen:  

Hi,
try this script ?
 

-	script	respawnMvp	-1,{
OnInit:
        setarray .mob_id[0],1511;
        set .size, getarraysize(.mob_id);
        set .random, rand(.size);
        set .amount, 1; // amount of monster spawned
        set .monster, .mob_id[.random];

        while (true) {
            if (mobcount("prontera", "respawnMvp::OnKill") < 1) {
                monster "prontera",154,172,getmonsterinfo(.monster, 0), .monster, .amount, "respawnMvp::OnKill";
                announce "O MVP "+getmonsterinfo(.monster, 0)+" acabou de nascer!",0;
            }
            sleep 60000;
        }
    end;

OnKill:
 	announce "O MVP "+getmonsterinfo(.monster, 0)+ " foi eliminado "+ (Sex?"pelo":"pela")+" "+ (Sex?"jogador":"jogadora")+" "+strcharinfo(0)+".",0;
	sleep 1000;
    monster "prontera",154,172,getmonsterinfo(.monster, 0), .monster, .amount, "respawnMvp::OnKill";
    end;  
}

 

Edited by rongmauhong
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   10
  • Joined:  10/31/16
  • Last Seen:  

Thank you, rongmauhong. Your script helped me to solve part of my problem with the first version shared above. Thanks a ton!

Here is what happened when I tested your script:

 

Results:

It didn't spawn another MVP while the current MVP was still live. Great! But 2 things are not working properly :

- The message "MVP Amon Ra has been spawned" wasn't working after the first MVP(the one when I use @reloadscript) is dead. It didn't work for the other MVPs, but just for the very first.

- It was spawning a new Amon Ra too fast.

Your script with a few modifications:

-	script	respawnMvp	-1,{
OnInit:
        setarray .mob_id[0],1002,1857,1031,1113,1613,1836;
        set .size, getarraysize(.mob_id);
        set .random, rand(.size);
        set .amount, 1; // amount of monster spawned
        set .monster, .mob_id[.random];

        while (true) {
            if (mobcount("prontera", "respawnMvp::OnKill") < 1) {
                monster "prontera",154,172,getmonsterinfo(.monster, 0), .monster, .amount, "respawnMvp::OnKill";
                announce "O MVP "+getmonsterinfo(.monster, 0)+" acabou de nascer!",0;
            }
            else{sleep 10000;}
        }
    end;


OnKill:
 	announce "O MVP "+getmonsterinfo(.monster, 0)+ " foi eliminado "+ (Sex?"pelo":"pela")+" "+ (Sex?"jogador":"jogadora")+" "+strcharinfo(0)+".",0;
	end;
}

Here is what happened when I tested the version above (PLEASE MUTE VOLUME?

 

Results:

Positive:

- It didn't spawn a new MVP too fast(I'm using porings for testing purposes);
- The message "MVP has spawned" is working no matter how many times I kill the MVP;
- The MVP is spawning every 10 seconds*(check negative).

Negative:

- The random variable(set .random, rand(.size);) is only working when I @reloadscript and not every time the current MVP is killed.

Case: If a player kills the current MVP, it should run the random variable again so another random MVP from the array can be spawned. Right now is spawning the same MVP as a result from the first time the random variable got a random number.

- The 10 seconds trigger is running over and over again.

Case: If I kill the MVP as soon as it's spawned, it will count 10 seconds, but If I wait a few seconds to kill the MVP it will spawn in less than 10 seconds. Why? Because the 10 seconds trigger is running over and over again. I'm expecting the trigger to start counting only after the MVP is killed and not while it's still alive.

Thank you!

Edited by Elano
Link to comment
Share on other sites

  • 0

  • Group:  Content Moderator
  • Topic Count:  55
  • Topics Per Day:  0.02
  • Content Count:  1676
  • Reputation:   702
  • Joined:  12/21/14
  • Last Seen:  

-    script    respawnMvp    -1,{
OnInit:
	setarray .mob_id[0],1857,1002,1031,1113,1613,1836;
	.monster = .mob_id[rand(getarraysize(.mob_id))];
	monster "prontera",154,172,"--en--", .monster, 1, "respawnMvp::OnKill";
	announce "MVP "+getmonsterinfo(.monster, 0)+" has spawned!",0;
end;


OnKill:
	announce getmonsterinfo(.monster, 0)+ " was killed by "+strcharinfo(0)+".",0;
	.monster = .mob_id[rand(getarraysize(.mob_id))];
	monster "prontera",154,172,"--en--", .monster, 1, "respawnMvp::OnKill";
	announce "MVP "+getmonsterinfo(.monster, 0)+" has spawned!",0;
end;
}

 

  • Upvote 1
  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  11
  • Topics Per Day:  0.00
  • Content Count:  81
  • Reputation:   14
  • Joined:  11/17/17
  • Last Seen:  

-	script	respawnMvp	-1,{
OnInit:
        setarray .mob_id[0],1002,1857,1031,1113,1613,1836;
        set .size, getarraysize(.mob_id);
        set .random, rand(.size);
        set .amount, 1; // amount of monster spawned
        set .monster, .mob_id[.random];

        // Spawn MVP
 		donpcevent "respawnMvp::OnSpawn";  
    end;

OnSpawn:
	if (mobcount("prontera", "respawnMvp::OnKill") < 1) {
        monster "prontera",154,172,getmonsterinfo(.monster, 0), .monster, .amount, "respawnMvp::OnKill";
        announce "O MVP "+getmonsterinfo(.monster, 0)+" acabou de nascer!",0;
    }
	end;

OnKill: // If the mob dies
	
	// Announce
 	announce "O MVP "+getmonsterinfo(.monster, 0)+ " foi eliminado "+ (Sex?"pelo":"pela")+" "+ (Sex?"jogador":"jogadora")+" "+strcharinfo(0)+".",0;

 	// Wait 10 seconds
 	sleep 10000;

 	// Spawn MVP again
 	donpcevent "respawnMvp::OnSpawn";
	end;
}

Hello, please check this ? 

  • Love 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  12
  • Topics Per Day:  0.00
  • Content Count:  36
  • Reputation:   10
  • Joined:  10/31/16
  • Last Seen:  

Thanks, @rongmauhong! The solution provided by @sader1992 works great and it's easy to read. Here's the solution he provided working just like I wanted:

@rongmauhong your first solution helped me a lot to get what I wanted. Keep up the good work!

-	script	respawnMvp	-1,{
OnInit:
    setarray .mob_id[0],1857,1002,1031,1113,1613,1836;
    .monster = .mob_id[rand(getarraysize(.mob_id))];
    monster "prontera",154,172,"--en--", .monster, 1, "respawnMvp::OnKill";
    announce "MVP "+getmonsterinfo(.monster, 0)+" has spawned!",0;
end;


OnKill:
    announce getmonsterinfo(.monster, 0)+ " was killed by "+strcharinfo(0)+".",0;
	sleep 15000;
    .monster = .mob_id[rand(getarraysize(.mob_id))];
    monster "prontera",154,172,"--en--", .monster, 1, "respawnMvp::OnKill";
    announce "MVP "+getmonsterinfo(.monster, 0)+" has spawned!",0;
end;
}

Now the MVP will spawn randomly. If the MVP is dead, it will wait 15 seconds to spawn a new one from the setarray.

This topic can be closed!

Thanks,

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...