In my module i have certain placeables at the end of my pve zones that summon bosses when used. I set an int on the placeable after use then delete it after x amount of time.
How can i send a message back to players telling exactly when the placeable can be used again (the time before the int gets deleted)?
I can post the code im using on the placeable object if that’d help.
void CommandMonster(object oMonster, object oPC)
{
AssignCommand(oMonster, ActionDoCommand(PlayVoiceChat(VOICE_CHAT_BATTLECRY1, OBJECT_SELF)));
AssignCommand(oMonster, ActionDoCommand(ActionPlayAnimation(ANIMATION_FIREFORGET_TAUNT)));
}
void DestroyMonster(object oMonster)
{
DestroyObject(oMonster, 0.01f);
}
////////////////////////////////////////////////////////////
// The Main script
////////////////////////////////////////////////////////////
void main()
{
object oPC = GetLastUsedBy();
object oBOSS1 = GetObjectByTag("Ettin_Boss");
if (GetIsObjectValid(oBOSS1) == TRUE )
{
FloatingTextStringOnCreature("The boss has already been summoned. Prepare for battle!!!", oPC, FALSE);
return;
}
if (GetLocalInt(OBJECT_SELF, "ZONE1BOSS"))
{
FloatingTextStringOnCreature("This object cannot be used right now, please try again later!", oPC, FALSE);
return;
}
if(GetIsPC(GetLastUsedBy()))
{
object oSumPoint = GetWaypointByTag("BOSS1_WP");
location lSumPoint = GetLocation(oSumPoint);
object oMonster = CreateObject(OBJECT_TYPE_CREATURE, "creatureresref",lSumPoint);
//PlaySound("");
ActionSpeakString("The boss has been summoned!!!", TALKVOLUME_TALK);
CommandMonster(oMonster, oPC);
SetLocalInt(OBJECT_SELF, "ZONE1BOSS", 1);
DelayCommand(1800.0f, SetLocalInt(OBJECT_SELF, "ZONE1BOSS", 0));
DelayCommand(900.0f, DestroyMonster(oMonster));
}
}
This section of the main script needs to send message telling the exact time before boss can be summoned again…
if (GetLocalInt(OBJECT_SELF, "ZONE1BOSS"))
{
FloatingTextStringOnCreature("This object cannot be used right now, please try again later!", oPC, FALSE);
return;
}
Maybe I’m stupid now but…eh…“please try again in 1800 seconds (or 30 minutes))” ? I mean, since you have a delaycommand of 1800 seconds it seems? I’m probably misunderstanding this whole thing.
nah it’s probably me not explaining things properly haha
i just need the exact time, i can send a message saying 30 minutes till boss can be summoned yada yada, but that isnt accurate depending on when players try to summon the boss.
So you need like the hour and minute of the day when the players can summon the boss?
I’m sorry, but I don’t know how to script that, but I’m sure someone else can help you…
Maybe if you use (at least this function is available in NWN2) GetTimeMinute, and then add 30 min to that, and the result you then send like a message to the players?
It will wrap at around year 68, so it’s best to subtract the starting year or set it to 0 in the toolset. The latter has the benefit of showing the player how much time he spent playing.
Referencing the calendar may also bring other issues when the date is forced forward.
However in this case, the easiest approach (when only real time matters) is in my opinion to start a 1-second pseudo-heartbeat that will reduce ZONE1BOSS var from 1800 to 0.
Then it is a matter of just parsing the current value in OnUsed to minutes and seconds to display them to the placeable’s user.
I use a script that gets total time in minutes, took it from my on player rest event… does the trick, not in seconds but it’s better this way i think.
int GetTotalTimeMinutes()
{
int nTimeMinutes;// Declaring a variable
int nMinutes = GetTimeMinute();// get number of minutes
int nHours = GetTimeHour();// get hours
int nDays = GetCalendarDay();// Get days
int nMonths = GetCalendarMonth();// Get months
int nYears = GetCalendarYear();// Get years
float fMinutesPerHour = HoursToSeconds(1);// Get number of seconds in 1 hour
int nMinutesPerHour = FloatToInt(fMinutesPerHour);// Change to int
nMinutesPerHour /= 60;// Divide by 60 to get minutes in an hour
// If you don't do this, any variance in the module hours/minutes can mess it up
nHours *= nMinutesPerHour;// Convert hours into minutes
nDays *= (nMinutesPerHour * 24);// Convert days into minutes
nMonths *= (nMinutesPerHour * 672);// Convert months into minutes
nYears *= (nMinutesPerHour * 8064);// Convert years into minutes
nTimeMinutes = (nMinutes + nHours + nDays + nMonths + nYears);// Add all together
return nTimeMinutes;// The return of the function is the total number of minutes
}