• 0
Like it~*

How to rotate event npcs?

Question

Hello, I would like to know if it is possible to do this since there are many npcs in different files. The events are all already assembled, but each one in its separate file. I would like that as soon as one event is over, another is started, then another, another, and so on ... So after the last event is over, start the event count again from 1.
Example:
Started: event 1
Finished: event 1
Started: event 2
Finished: event 2
Started: event 3
Finished: event 3
...
...
...
Started: event 20
Finished: event 20
Started: event 1
Finished: event 1
Started: event 2
Finished: event 2

 

Share this post


Link to post
Share on other sites

7 answers to this question

  • 0

you can add donpcevent and set it up on your own liking.

 

Yup, basically this. You can use an arrangement of donpcevent() commands to activate events for your set times.

 

Example:

 

 
-     script     event 1     FAKE_NPC,{
 
OnAtCommand:
OnEventOne:
announce "Event 1 started.", bc_all;
initnpctimer;
end;
 
OnTimer10000:
announce "Event 1 ended." bc_all;
end;
 
OnTimer15000:
donpcevent("event 2::OnEventTwo");
stopnpctimer;
end;
 
OnInit:
bindatcmd("event1","event 1::OnAtCommand");
end;
 
}
 
-     script     event 2     FAKE_NPC,{
 
OnEventTwo:
announce "Event 2 started.", bc_all;
initnpctimer;
end;
 
OnTimer10000:
announce "Event 2 ended.", bc_all;
end;
 
OnTimer15000:
donpcevent("event 1::OnEventTwo");
stopnpctimer;
end;
 
}

 

You can start the loop by typing @event1, then it would loop the announcements every 10/15 seconds.

Share this post


Link to post
Share on other sites
  • 0

you can add donpcevent and set it up on your own liking.

 

 

 

you can add donpcevent and set it up on your own liking.

 

Yup, basically this. You can use an arrangement of donpcevent() commands to activate events for your set times.

 

Example:

 

 
-     script     event 1     FAKE_NPC,{
 
OnAtCommand:
OnEventOne:
announce "Event 1 started.", bc_all;
initnpctimer;
end;
 
OnTimer10000:
announce "Event 1 ended." bc_all;
end;
 
OnTimer15000:
donpcevent("event 2::OnEventTwo");
stopnpctimer;
end;
 
OnInit:
bindatcmd("event1","event 1::OnAtCommand");
end;
 
}
 
-     script     event 2     FAKE_NPC,{
 
OnEventTwo:
announce "Event 2 started.", bc_all;
initnpctimer;
end;
 
OnTimer10000:
announce "Event 2 ended.", bc_all;
end;
 
OnTimer15000:
donpcevent("event 1::OnEventTwo");
stopnpctimer;
end;
 
}

 

You can start the loop by typing @event1, then it would loop the announcements every 10/15 seconds.

 

Hello, gentlemen. Thank you very much for replying. I see that is a possibility. However, it is not yet fully effective, since events have varying times of duration. That is, it may be that one event ends sooner than expected and the other does not start because the interval between them has not yet been reached. So, is there any other way to be able to accomplish this in the best way?

Share this post


Link to post
Share on other sites
  • 0


-	script	CycleEvent	FAKE_NPC,{
 
OnExecute:
	if (.current_event >= .max_events) {
		.current_event = 0;
	} 
	switch(.current_event) {	// if max_events is 10, then .current_event goes from 0 to 9
	case 0:
		donpcevent("Event1::OnEvent"); break;
	case 1:
		donpcevent("Event2::OnEvent"); break;
	case 2:
		donpcevent("Event3::OnEvent"); break;
	//.. and so on..
	}
	// Or Use this below method if you really have Event NPC Names as Event1/Event2/Event3/... (Commented)
	// donpcevent("Event"+ (.current_event + 1) +"::OnEvent");
	announce "Event "+ (.current_event+1) +" started.", bc_all;
	end;

OnEnd: // Call CycleEvent::OnEnd when event ends(needs to be manually edited on each event script when end): donpcevent("CycleEvent::OnEnd")
	++.current_event;
	donpcevent(strnpcinf(NPC_NAME) +"::OnExecute")
	end;
 
OnTimer15000:
	donpcevent("event 2::OnEventTwo");
	stopnpctimer;
	end;

OnInit:
	.max_events = 10;
	bindatcmd("startevent", strnpcinfo(NPC_NAME) +"::OnExecute");
	end;
}

Hope this helps

Share this post


Link to post
Share on other sites
  • 0

Posted (edited)

 


-	script	CycleEvent	FAKE_NPC,{
 
OnExecute:
	if (.current_event >= .max_events) {
		.current_event = 0;
	} 
	switch(.current_event) {	// if max_events is 10, then .current_event goes from 0 to 9
	case 0:
		donpcevent("Event1::OnEvent"); break;
	case 1:
		donpcevent("Event2::OnEvent"); break;
	case 2:
		donpcevent("Event3::OnEvent"); break;
	//.. and so on..
	}
	// Or Use this below method if you really have Event NPC Names as Event1/Event2/Event3/... (Commented)
	// donpcevent("Event"+ (.current_event + 1) +"::OnEvent");
	announce "Event "+ (.current_event+1) +" started.", bc_all;
	end;

OnEnd: // Call CycleEvent::OnEnd when event ends(needs to be manually edited on each event script when end): donpcevent("CycleEvent::OnEnd")
	++.current_event;
	donpcevent(strnpcinf(NPC_NAME) +"::OnExecute")
	end;
 
OnTimer15000:
	donpcevent("event 2::OnEventTwo");
	stopnpctimer;
	end;

OnInit:
	.max_events = 10;
	bindatcmd("startevent", strnpcinfo(NPC_NAME) +"::OnExecute");
	end;
}

Hope this helps

 

Thank you for helping! 

I made some changes to the script for a more practical example, are they correct?
Although I did not understand a few things ...
  • How will npc know that it needs to execute the events in a certain order, only one at a time? I wish one event could only be started after the other one ended and there should be no events running concurrently. Can all events be started with the same command?
I at least did not recognize any part of the code that directs the NPC to do this.

 

 

 

-	script	CycleEvent	FAKE_NPC,{
 
OnExecute:
	// Or Use this below method if you really have Event NPC Names as Event1/Event2/Event3/... (Commented)
	// donpcevent("Event"+ (.current_event + 1) +"::OnEvent");
	donpcevent("Event Poring"+ (.current_event + 1) +"::OnEvent"); //Event 1
	announce "Hello, adventurers, The Event Poring"+ (.current_event+1) +" started, type @startevent to join.", bc_all;
	end;

OnEnd: // Call CycleEvent::OnEnd when event ends(needs to be manually edited on each event script when end): donpcevent("CycleEvent::OnEnd")
	++.current_event; //Is this variable correct, starting with "++" ? This is left right here or added to each npc line with: donpcevent("CycleEvent::OnEnd"); ?
	donpcevent(strnpcinf(NPC_NAME) +"::OnExecute")
	end;
 
OnTimer15000:
	donpcevent("Event Payon::OnEvent2"); //Event2
	announce "Hello, adventurers, The Event Payon"+ (.current_event+1) +" started, type @startevent to join.", bc_all;
	stopnpctimer;
	end;
	
OnTimer15000:
	donpcevent("Event Morroc::OnEvent3"); //Event3
	announce "Hello, adventurers, The Event Morroc"+ (.current_event+1) +" started, type @startevent to join.", bc_all;
	stopnpctimer;
	end;
	
OnTimer15000:
	donpcevent("Event Geffen::OnEvent4"); //Event4
	announce "Hello, adventurers, The Event Geffen"+ (.current_event+1) +" started, type @startevent to join.", bc_all;
	stopnpctimer;
	end;

	//.. and so on..
	
OnTimer15000:
	donpcevent("Event White::OnEvent30"); //Event30 - Last event
	stopnpctimer;
	end;

//Now the counter needs to be reset to the first, how do I do it?
//???????????????????????????????????????????
	
OnInit:
//	.max_events = 10; //Does this line need to continue? Since it will not have switch?
	bindatcmd("startevent", strnpcinfo(NPC_NAME) +"::OnExecute");
	end;
}

 

 

Edited by Like it~*

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now