Jump to content
  • 0

BossniaHP Edit


Gaspar145

Question


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  8
  • Reputation:   0
  • Joined:  05/06/19
  • Last Seen:  

I need help with this script, please. It spawns the monster but doesn't respawn it. I'm not sure why. This is the only way it works; if I place "BossniaHP::OnMyMobDead" at the end of the line, the script doesn't work. The only problem is that it's not calling OnMyMobDead.

 

function	script	BossniaHP	{
	.@monsterID = getarg(0,0);
	.@monsterName$ = getarg(1,"");
	.@amount = getarg(2,0);
	.@map$ = getarg(3,"");
	.@hp = getarg(4,0);

	OnInit:
		$@Cheffenia_ID = bg_monster("BossniaHP::OnMyMobDead", .@map$, 192, 99, .@monsterName$, .@monsterID, .@amount);
		setunitdata $@Cheffenia_ID,UMOB_HP,10; // Make Crystal immune to damage until Guardians are defeated
	end;


	OnMyMobDead:
		initnpctimer;
		end;

	OnTimer500:
		stopnpctimer;
		donpcevent "BossniaHP::OnInit";
		end;
}

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  63
  • Topics Per Day:  0.02
  • Content Count:  1016
  • Reputation:   191
  • Joined:  11/27/14
  • Last Seen:  

Your script has the core logic to spawn a monster and handle its death, but there are some adjustments needed to ensure that the monster respawns correctly. Specifically, the issue seems to stem from not correctly transitioning from the monster's death event back to the initial spawning logic.


Here is an improved version of your script with these adjustments:

function script BossniaHP {
	.@monsterID = getarg(0,0);
	.@monsterName$ = getarg(1,"");
	.@amount = getarg(2,0);
	.@map$ = getarg(3,"");
	.@hp = getarg(4,0);

	OnInit:
		// Spawn the monster and store its ID
		$@Cheffenia_ID = bg_monster("BossniaHP::OnMyMobDead", .@map$, 192, 99, .@monsterName$, .@monsterID, .@amount);
		setunitdata $@Cheffenia_ID, UMOB_HP, .@hp; // Set the monster's HP
		end;

	OnMyMobDead:
		// Initiate the timer to respawn the monster after a delay
		initnpctimer;
		end;

	OnTimer500:
		// Stop the timer
		stopnpctimer;
		// Respawn the monster by calling the OnInit label
		donpcevent "BossniaHP::OnInit";
		end;
}
  • Ensure the OnMyMobDead event properly respawns the monster.
  • Correctly initialize the timer to control the respawning of the monster.

    Explanation:

  • OnInit:

    • This section is called to initially spawn the monster. It uses the bg_monster function to spawn the monster and stores its ID in the variable $@Cheffenia_ID.
    • The setunitdata function sets the HP of the monster.
  • OnMyMobDead:

    • This section is called when the monster dies. The initnpctimer function starts the timer which will eventually trigger the OnTimer500 event.
  • OnTimer500:

    • This section is called when the timer started by OnMyMobDead reaches 500 milliseconds.
    • The stopnpctimer function stops the timer.
    • The donpcevent "BossniaHP::OnInit" function calls the OnInit label, which respawns the monster.
  • Common Issues to Check:

  • Ensure that the timer duration (500 milliseconds in this case) is appropriate for your needs. You can adjust this value if you need a different respawn delay.
  • Verify that the monster ID and other parameters passed to the bg_monster function are correct and that the monster can be spawned without issues.
  • Ensure there are no other script conflicts that might prevent the OnMyMobDead event from triggering.
  • This should ensure that the monster respawns correctly after it is killed.

  • Upvote 1
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...