Jump to content

How to make NPC's appear out of nowhere at a certain time of the day


Recommended Posts

There are opposite checkings after else commands in both scripts you present - should be GetDisabled == 0

 

scn GHOUndeadTownEnemies
 
begin GameMode
 
if GameHour >= 23 || GameHour < 6 ;midnight to morning
 
   if TownGhost1.GetDisabled != 0 ;ghost IS disabled
     TownGhost1.Enable
   endif
   if TownGhost2.GetDisabled != 0
     TownGhost2.Enable
   endif
   if TownGhost3.GetDisabled != 0
     TownGhost3.Enable
   endif
   if TownGhost4.GetDisabled != 0
     TownGhost4.Enable
   endif 

else 

   if TownGhost1.GetDisabled == 0 ;ghost IS NOT disabled
     TownGhost1.Disable
   endif
   if TownGhost2.GetDisabled == 0
     TownGhost2.Disable
   endif
   if TownGhost3.GetDisabled == 0
     TownGhost3.Disable
   endif 
   if TownGhost4.GetDisabled == 0
     TownGhost4.Disable
   endif 

endif
 
end
Similar in second script.

It doesn't work. The ghost never appear and the lights are always enabled.

Link to comment
Share on other sites

  • Replies 82
  • Created
  • Last Reply

Top Posters In This Topic

@Dimitrisgb:"It doesn't work. The ghost never appear and the lights are always enabled."

 

I tested my approach with Seed-Neeus and found it working. According to my script she dissappeared at day and appeared only between 23:00 and 5:59, exactly as your ghosts should. Test quest script was:

scn RomRDisableQuestScript
float fQuestDelayTime

begin GameMode 
	set fQuestDelayTime to 1.0
	;let her appear between 23:00 and 5:59 hour only in her shop
	if GameHour >= 23 || GameHour < 6
		if SeedNeeusRef.GetDisabled != 0 
			SeedNeeusRef.Enable
		endif
	else
		if SeedNeeusRef.GetDisabled == 0
			SeedNeeusRef.Disable
		endif
	endif
end

In a worst case simply remove all GetDisabled functions as using them in a way you do doesn't have much sense. If your script still won't work, maybe you're using wrong references or having some script clash.

Edited by RomanR
Link to comment
Share on other sites

If you have more than one script which could control your ghosts, disable them for testing purposes and leave active only one you want to test. By disabling I mean to temporaly remove the other scripts from their objects/quests/spells. If the one you're testing behaves normaly, then an error is in other ones. If not, that means you must fix a testing script first and continue only after that one is debugged. So for now I would debug the ghost script first as it's shorter.

 

So ghots script after removing all GetDisabled functions will look like this:

scn GHOUndeadTownEnemies
 
begin GameMode
 
if GameHour >= 23 || GameHour < 6 ;midnight to morning
 
   TownGhost1.Enable
   TownGhost2.Enable
   TownGhost3.Enable
   TownGhost4.Enable

else 

   TownGhost1.Disable
   TownGhost2.Disable
   TownGhost3.Disable
   TownGhost4.Disable

endif
 
end

Now it shouldn't be hard to check it how it's core works.

Link to comment
Share on other sites

There are opposite checkings after else commands in both scripts you present - should be GetDisabled == 0

scn GHOUndeadTownEnemies
 
begin GameMode
 
if GameHour >= 23 || GameHour < 6 ;midnight to morning
 
   if TownGhost1.GetDisabled != 0 ;ghost IS disabled
     TownGhost1.Enable
   endif
   if TownGhost2.GetDisabled != 0
     TownGhost2.Enable
   endif
   if TownGhost3.GetDisabled != 0
     TownGhost3.Enable
   endif
   if TownGhost4.GetDisabled != 0
     TownGhost4.Enable
   endif 

else 

   if TownGhost1.GetDisabled == 0 ;ghost IS NOT disabled
     TownGhost1.Disable
   endif
   if TownGhost2.GetDisabled == 0
     TownGhost2.Disable
   endif
   if TownGhost3.GetDisabled == 0
     TownGhost3.Disable
   endif 
   if TownGhost4.GetDisabled == 0
     TownGhost4.Disable
   endif 

endif
 
end

Similar in second script.

How about an inversion of logic such that 1 function can handle object enabling while getting rid of the main 'else'. Of course, you've provided a correct answer but how about that, how about the thinking?

 

EDIT: Okay, I've suggested the opposite of what I would do here. The time period in terms of enable is boolean and should be evaluated as such; when enable period is met it should be done once and flagged as done; when disable period is met it should be done once and flagged as done. Using OBSE this would be 2 functions where it would be cleaner to nest the time conditional function as a parameter.

Link to comment
Share on other sites

@glowplug: Yes, experienced scripter/coder will surely make more clean and optimized solutions. But as Dimitrisgb is at novice level and seems showing problems with abstract thinking in general (previous thread regarding changing texture paths was successfully solved only by seemingly unlimited patience of Striker879), I'm sticking to fix scripts he made only and only enhancing his approach to problems by things which in my opinion will bring more safety, stability or speed.

 

Besides his one or two sentence answers aren't bring much insight too. And he is showing typical beginner mistake - working on too much things at once, creating too much errors at too much places, which he can't debug, because he can't find the source of them due to their count.

Edited by RomanR
Link to comment
Share on other sites

Very wise RomanR, over a quarter of a century ago I told myself to never forget the learning curve - I'll remember this next time I post support code and so on.

Link to comment
Share on other sites

Very wise RomanR, over a quarter of a century ago I told myself to never forget the learning curve - I'll remember this next time I post support code and so on.

I definitely see striker giving a lot of help to a lot of people, as alluded to by Roman. Theres a very nice community here of people who know a lot and help the rest of us; both of you guys included with striker, too, so thanks.

Link to comment
Share on other sites

Don't forget to include yourselves in that line of thinking.

 

I do my best to limit my responses to the things I have some experience with, but I also aspire to expand my abilities so I follow the questions and answers on this forum closely.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.

×
×
  • Create New...