Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Quick question: Can you alter the dungeon reset timers? (https://forums.graalonline.com/forums/showthread.php?t=134264290)

Televangelist 08-22-2011 11:39 PM

Quick question: Can you alter the dungeon reset timers?
 
So, I know there's a 'standard' timer for when a level resets if nobody's on it.


Can that be overridden?

For puzzle reasons, I'd like for some of my dungeons to function such that if nobody's in any of the dungeon's rooms, it resets instantly.



(Explanation: This ties into a mechanic I'm building my game around, whereby your character can only adventure outside of 'safe' areas for a certain amount of time, and if the timer runs out they're warped back to their spawn point... building around this idea allows me to make wilderness areas feel more 'wild' and unexplored. I'm not doing stats, XP, or levels in my game for the most part, but over time, characters can find items scattered throughout the world that will increase the length of time they can continuously adventure into the wild.

Sort of like how in many games your ability to dive underwater is restricted by an oxygen bar, which then refills when you return to the surface!

This lets me build a certain 'tension' into a dungeon run, as you're working against the clock... and enables some content to get 'easier' as you become a more experienced player of the game, without the crude mechanic of levels, stats, and XP where content becomes easier because your 'numbers' become bigger than the enemy's.


If the dungeon didn't reset when all the players exited it -- well, that tension would be broken, because you could re-enter the dungeon before it resets and all your progress has already been 'saved'. :)


This feels like it should be easy... but perhaps it isn't?

ffcmike 08-22-2011 11:44 PM

You could easily do this via:

PHP Code:

function onPlayerLeaves(){
  if(
players.size() == 0){
    
//reset stuff
  
}



Televangelist 08-23-2011 08:31 AM

Ooh, nice!


So, just so I'm clear:

1. players.size refers to the number of players in the level, not the overall server?

2. The larger plan I have for the 'adventuring time limit' that can be expanded via power-ups (in the same way your heart meter, say, can be expanded in a Zelda game over time) is feasible as well?

Thanks!

Tricxta 08-23-2011 09:58 AM

Thats also simple, you can store the time limit for each player using a client string. To set this client string simple do:
PHP Code:

client.timelimit=32

Yep! it's as simple as that although you will want to use a clientr string so players can't use a memory scanner to manipulate it, clientr strings can only be set serverside but read both client and server side so you should keep that in mind.

Also i'm going to assume your relatively new to scripting in general so just so there's no confusion client and clientr are reserved words but the name isn't fixed and can be whatever you like.

Crow 08-23-2011 12:08 PM

Quote:

Originally Posted by Televangelist (Post 1664932)
Ooh, nice!


So, just so I'm clear:

1. players.size refers to the number of players in the level, not the overall server?

2. The larger plan I have for the 'adventuring time limit' that can be expanded via power-ups (in the same way your heart meter, say, can be expanded in a Zelda game over time) is feasible as well?

Thanks!

There's players and allplayers. The first always refers to the players in the level the code is executed in. The latter refers to all players on the server. Also, your "larger plan" should be possible as well. I suggest you store the time it can be extended in some clientr.variables (like Tricxta said), then just wait the specific time when all players left until you reset your stuff.

cbk1994 08-23-2011 09:50 PM

Quote:

Originally Posted by Crow (Post 1664940)
There's players and allplayers. The first always refers to the players in the level the code is executed in. The latter refers to all players on the server.

To clarify, allplayers is an array of player objects (TServerPlayer) for every player online.

players is an array of every player in the current level (on GMAPs, every player within roughly a one-level radius).

When you're doing players.size(), it's just returning the number of items in the array.

Televangelist 08-23-2011 11:54 PM

Very helpful, thanks!


All times are GMT +2. The time now is 05:18 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.