bool StartSkillScript(Client *client, const Attribute* attrib) { Character* chr = client->chr; ref_ptr<EScriptProgram> prog = find_script2( attrib->script_, true, // complain if not found config.cache_interactive_scripts ); if ( prog.get() != NULL ) { if ( chr->start_skill_script(prog.get()) ) { // Should the script handle the unhiding instead? if ( chr->hidden() && attrib->unhides ) chr->unhide(); if ( attrib->delay_seconds ) { chr->disable_skills_until = poltime() + attrib->delay_seconds; } return true; } } string msg = "Unable to start skill script:";//+attrib->script_.c_str(); msg += attrib->script_.c_str(); send_sysmessage(client, msg.c_str()); return false; }
bool CanUseSkill(Client* client) { Character* chr = client->chr; if ( chr->dead() ) { private_say_above(chr, chr, "I am dead and cannot do that."); return false; } else if ( chr->skill_ex_active() || chr->casting_spell() ) { private_say_above(chr, chr,"I am already performing another action."); return false; } else if ( poltime() < chr->disable_skills_until ) { send_sysmessage(client, "You must wait to perform another action."); return false; } else if ( chr->frozen() || chr->paralyzed() ) { private_say_above(chr, chr, "I am frozen and cannot do that."); return false; } return true; }
void regen_resources() { THREAD_CHECKPOINT( tasks, 700 ); time_t now = poltime(); for ( ResourceDefs::iterator itr = gamestate.resourcedefs.begin(), end = gamestate.resourcedefs.end(); itr != end; ++itr ) { ( *itr ).second->regenerate( now ); } THREAD_CHECKPOINT( tasks, 799 ); }
/// Resource Management ResourceRegion::ResourceRegion( Clib::ConfigElem& elem, RegionId id ) : Region( elem, id ), tilecount_( 0 ), units_per_area_( elem.remove_ulong( "UnitsPerArea" ) ), seconds_per_regrow_( elem.remove_ulong( "SecondsPerRegrow" ) ), last_regen_( poltime() ), capacity_( elem.remove_ulong( "Capacity" ) ), units_( 0 ) { }
UOExecutor::~UOExecutor() { // note, the os_module isn't deleted here because // the Executor deletes its ExecutorModules. if ((instr_cycles >= 500) && settingsManager.watch.profile_scripts) { int elapsed = static_cast<int>(poltime() - start_time); // Doh! A script can't run more than 68 years, for this to work. POLLOG_ERROR.Format("Script {}: {} instr cycles, {} sleep cycles, {} seconds\n") << scriptname() << instr_cycles << sleep_cycles << elapsed; } pParent = NULL; pChild = NULL; }
UOExecutor::~UOExecutor() { // note, the os_module isn't deleted here because // the Executor deletes its ExecutorModules. if ((instr_cycles >= 500) && watch.profile_scripts) { long elapsed = static_cast<long>(poltime() - start_time); // Doh! A script can't run more than 68 years, for this to work. Log( "Script %s: %"OUT64"d instr cycles, %"OUT64"d sleep cycles, %ld seconds\n", scriptname().c_str(), instr_cycles, sleep_cycles, elapsed ); cerr << "Script " << scriptname() << ": " << instr_cycles << " instr cycles, " << sleep_cycles << " sleep cycles, " << elapsed << " seconds elapsed." << endl; } pParent = NULL; pChild = NULL; }
UOExecutor::UOExecutor() : Executor(), os_module(NULL), instr_cycles(0), sleep_cycles(0), start_time(poltime()), warn_runaway_on_cycle(Plib::systemstate.config.runaway_script_threshold), runaway_cycles(0), eventmask(0), area_size(0), speech_size(1), can_access_offline_mobiles(false), auxsvc_assume_string(false), pParent(NULL), pChild(NULL) { weakptr.set(this); os_module = new Module::OSExecutorModule(*this); addModule(os_module); }