Trying to make a shopkeeper disappear at night
#1
Posté 08 août 2010 - 01:40
#2
Posté 08 août 2010 - 01:59
#3
Posté 08 août 2010 - 04:15
void main()
{
object oShopkeeper = GetObjectByTag("Shopkeeper");
int nAbsoluteTime = GetTimeHour();
int nCloseTime = 20;
int nOpenTime = 6;
effect eScale = EffectSetScale(0.001f);
effect eSupernaturalScale = SupernaturalEffect(eScale);
if ((nAbsoluteTime >= nCloseTime) && (nAbsoluteTime < nOpenTime))
{
ActionDoCommand(ApplyEffectToObject(DURATION_TYPE_PERMANENT,eSupernaturalScale, oShopkeeper));
}
if ((nAbsoluteTime >= nOpenTime) && (nAbsoluteTime < nCloseTime))
{
effect eEffect = GetFirstEffect(oShopkeeper);
int nEffectValid =GetIsEffectValid(eEffect);
while (nEffectValid == TRUE)
{
RemoveEffect(oShopkeeper,eEffect);
eEffect = GetFirstEffect(oShopkeeper);
nEffectValid =GetIsEffectValid(eEffect);
}
}
}
#4
Posté 08 août 2010 - 05:06
There is a small learning curve with the system, but I think it is worth it and faster in the long run.
#5
Posté 08 août 2010 - 05:26
If not, then another option is to make a script that locks the shop at night, thus circumventing the problem of the disappearing shopkeeper.
If you do want to be able to go in the shop when the shopkeeper is gone, than you could make a trigger located right outside of the shop and put your script on that. It would need to be located in such a way that the PC has to cross it to get into the shop.
Matt
Modifié par M. Rieder, 08 août 2010 - 05:34 .
#6
Posté 08 août 2010 - 06:40
#7
Posté 08 août 2010 - 06:40
void main()
{
object oEnter = GetEnteringObject();
object oShopkeeper = GetObjectByTag("Shopkeeper");
int nGametime = GetTimeHour();
int nClosetime = 20;
int nOpentime = 6;
//Stop script if entering object isn't PC.
if (!GetIsPC(oEnter)) return;
//If time is between 6AM-8PM, store is open
if ((nGametime >= 6) && (nGametime <= 20))
{
//If shopkeeper is hidden, unhide him. If already
//unhidden will do nothing.
SetScriptHidden(oShopkeeper, FALSE);
}
//Time is between 8:01PM-5:59AM, store is closed.
else
{
//If shopkeeper isn't hidden, will hide him.
//If already hidden, will keep him hidden.
SetScriptHidden(oShopkeeper, TRUE, TRUE);
}
}
#8
Posté 08 août 2010 - 10:51
#9
Posté 08 août 2010 - 11:12
Orion7486 wrote...
Well, try this. Put it in onclient enter. Rather than doing the scaling down, use script hidden. It causes the npc to not be able to react, do anything while he is script hidden. Compiles, not tested.
void main()
{
object oEnter = GetEnteringObject();
object oShopkeeper = GetObjectByTag("Shopkeeper");
int nGametime = GetTimeHour();
int nClosetime = 20;
int nOpentime = 6;
//Stop script if entering object isn't PC.
if (!GetIsPC(oEnter)) return;
//If time is between 6AM-8PM, store is open
if ((nGametime >= 6) && (nGametime <= 20))
{
//If shopkeeper is hidden, unhide him. If already
//unhidden will do nothing.
SetScriptHidden(oShopkeeper, FALSE);
}
//Time is between 8:01PM-5:59AM, store is closed.
else
{
//If shopkeeper isn't hidden, will hide him.
//If already hidden, will keep him hidden.
SetScriptHidden(oShopkeeper, TRUE, TRUE);
}
}
Thanks, that did the trick
#10
Posté 08 août 2010 - 11:28
Ah, right you are, sir._Knightmare_ wrote...
Just a note to you there Orion, as written your script just looks at the game hour, so the shop will be considered "open" until 9PM (ie. 8:00 to 8:59 inclusive). Not a big deal, just thought I'd point it out.
#11
Posté 09 août 2010 - 08:09
#12
Posté 10 août 2010 - 10:38
rjshae wrote...
A nice addition would be to have the shopkeeper announce the store closing a minute before it happens, then have them move to stand by the door expectantly. You could also mark up the prices if the PC tries to buy anything after the closing time.
That is a good idea, although I think I'll just alter the shopkeeper's conversation, so that he won't buy or sell anything after 19:00 and before 6:00 or 7:00.





Retour en haut






