Jump to content
  • 0

Trying to make an NPC spawn randomly


chronoscrowler

Question


  • Group:  Members
  • Topic Count:  8
  • Topics Per Day:  0.00
  • Content Count:  17
  • Reputation:   0
  • Joined:  02/27/16
  • Last Seen:  

Requesting for support!

 

I am trying to make this script work, am not sure whats wrong? Anyone can help?

 

need to be able to properly execute a random date/time-triggered activation where target NPC warps from original position to a random map with random xy coordinates, and returns to original position after an hour. so far all attempts at tweaking the script doesn't execute the "return to original position" part.

 

-	script	EndActive	-1,{
OnInit:
OnDay0101:
OnDay0201:
OnDay0301:
OnDay0401:
OnDay0501:
OnDay0601:
OnDay0701:
OnDay0801:
OnDay0901:
OnDay1001:
OnDay1101:
OnDay1201:
setarray .@amonwarp$[0],"prontera","geffen","morocc","aldebaran","xmas","yuno","alberta","rachel","veins","hugel","payon","umbala","jawaii","comodo","niflheim","ayothaya","gonryun","louyang","mid_camp","lighthalzen","einbech","einbroch";
setarray .@monthday[0],01,02,03,04,05,06,07,08,09,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28;
setarray .@daytime[0],10,11,12,13,14,15,16,17,18,19,20,21,22;
if (gettime(5) == .@monthday[rand(28)] && gettime(3) == .@daytime[rand(14)])
while(1) {
set $@jx,rand(30,225);
set $@jy,rand(30,225);
unitwarp getnpcid(0,"Amon"),""+.@amonwarp$[rand(22)]+"",$@jx,$@jy;
if(checkcell(""+.@amonwarp$+"",$@jx,$@jy,cell_chkpass) == 1) break;
}
announce "An unspeakable evil has appeared. Netorian, Irunite and Schicksal units, proceed with caution.",bc_all,0xFF0000;
end;
}
else {
unitwarp getnpcid(0,"Amon"),"jupe_area2",145,10;
announce "Absolute Evil has retreated back into the Void. Everyone, be vigilant.",bc_all,0xFF0000;
end;
}
}

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

let's see

prontera,155,187,5	script	dsasda	1_F_MARIA,{
	.@map$ = strnpcinfo(4);
	npctalk "I am currently in "+ .@map$;
	sleep 1000;
	if ( .@map$ == "prontera" )
		unitwarp getnpcid(0), "morocc",156,93;
	else if ( .@map$ == "morocc" )
		unitwarp getnpcid(0), "prontera", 156,191;
	end;
}

still works in latest rathena, means your script has bugs

honestly from reading your script alone I can't tell what you are trying to do
your description on your 1st post doesn't match what you are trying to do with your script

3 hours ago, chronoscrowler said:

and returns to original position after an hour. so far all attempts at tweaking the script doesn't execute the "return to original position" part.

where is your *initnpctimer or *sleep ?

 

3 hours ago, chronoscrowler said:

if (gettime(5) == .@monthday[rand(28)] && gettime(3) == .@daytime[rand(14)])

I totally don't understand this line, if you want your script to execute on the 1st day on each month, why do a check gettime(DT_DAYOFWEEK) again ?
its like you are trying to make that condition false in purpose

 

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