varargs int on_cast(mapping param) { object decoy; int hp; // debit hp first hp = to_int(param["caster"]->query_hp() * 0.95); param["caster"]->add_hp( -hp ); // check for existing decoys... backlash decoy = present_clone( "/monsters/summon/decoy", environment(param["caster"]) ); if( decoy ) { param["caster"]->msg_local( "~[030~Name ~verbstand completely still until ~pron ~verbis knocked down by a green blast.~CDEF" ); msg_object( param["caster"], "~CWRNThere is already a decoy spirit at this location. Your spell has backfired.~CDEF" ); param["caster"]->set_stance( ST_LYING ); return 1; } // actually create the pet now decoy = clone_object( "/monsters/summon/decoy" ); decoy->move(environment(param["caster"])); decoy->set_coord(WALK_DAEMON->query_random_adjacent(param["caster"])); decoy->validate_position(); decoy->setup( param["caster"]->query_name(), hp ); set_actor(param["caster"]); set_target(decoy); param["caster"]->msg_local( "~[030~Name ~verbstand completely still as ~targ ~vertfade into view beside ~obje.~CDEF" ); return 1; }
varargs int on_cast(mapping param) { object jack, ai; int bonus = param["caster"]->skill_check("magic.mana.fire",50,60,70,80,90,100); set_actor(param["caster"]); set_target(param["target"]); param["caster"]->msg_local("~[030~Subt ~verttake on a life of ~post own and ~vertbegin to float next to ~name.~CDEF"); destruct(param["target"]); jack = clone_object("/monsters/summon/jackolantern"); jack->move(environment(param["caster"])); jack->validate_position(); // heal pumpkin man jack->set_stat("con",jack->query_stat("con")+(bonus/2)); jack->set_stat("int",jack->query_stat("int")+(bonus/2)); jack->set_stat("spd",jack->query_stat("spd")+bonus); jack->set_stat("wil",jack->query_stat("wil")+bonus); jack->set_hp(jack->query_max_hp()); jack->set_mana(jack->query_max_mana()); jack->set_endurance(jack->query_max_endurance()); // unfortunately, on_hire is a bit flaky right now and only works if the caster is // set to this_player() ai = present_clone("/ai/worker",jack); ai->on_hire(); command("follow "+(param["caster"]->query_name()),jack); jack->set_time_to_live( max(20,param["caster"]->get_skill_roll("magic.faith.blessing")/2) ); return 1; }
int main(string arg) { object who, victim; WIZ_CHECK if( !arg ) return notify_fail("==> [Format] frotz victim\n"); victim = find_player(arg); if( !victim ) return notify_fail("I can't find any such player '"+arg+"' to zap.\n"); AUDIO_DAEMON->sfx_mud("thunder.wav"); foreach( who : users() ) { set_actor( this_player() ); set_target( victim ); set_listener( who ); msg_object(who,"~CTITFROTZ! ~CBRT~Name ~verbstrike ~targ with lightning.~CDEF"); } victim->set_env_var( "cause_of_death", "was frotzed by "+capitalize(this_player()->query_name())+"." ); victim->add_hp( this_player()->query_level() / -4); return 1; }
varargs int on_cast(mapping param) { object apple = single_present(param["component"], param["caster"]); set_actor(param["caster"]); set_target(apple); param["caster"]->msg_local("~[030The turtle chomps ~targ, gulping it down before turning to carry ~npos message to its destination... eventually...~CDEF"); enqueue_delivery( param["option"], param["target"]->query_location("front") ); destruct(apple); return 1; }
void on_deliver( string name, string message ) { object who = find_player(name); if( !who ) { call_out( "on_deliver", 600, name, message ); } else { set_actor( who ); who->msg_local("~CACTA large turtle crawls up to ~name and whispers something into ~poss ear.~CDEF"); msg_object( who, "~CACTThe turtle says:~CDEF\n'"+message+"'"); } }
int main( string str ) { string pname, comm; object ob; if(this_player()->query_level() < WIZLEVEL) { msg("==> [Error] Access denied"); return 0; } if(!str || sscanf(str, "%s %s", pname, comm) != 2) { msg("==> [Format] force player command"); return 1; } ob = find_player(pname); if( !ob ) ob = find_living(pname); if(!ob) { msg("==> [Error] Could not find that player or creature."); return 1; } if(ob->query_level() < this_player()->query_level() || this_player()->query_level() >= ADMLEVEL ) { set_actor( this_player() ); set_listener( ob ); msg_object(ob, "~Name forces you to "+comm+"."); msg("You force them to "+comm); ob->receive( "\n"+this_player()->query_specific()+" forces you to '"+comm+"':\n" ); command(comm, ob); if( ob ) ob->receive( ob->query_prompt() ); } else { msg("==> [Error] Access denied."); set_actor( this_player() ); set_listener( ob ); msg_object(ob, "~CWRN~Name tried to force you to ~CCOM"+comm+"~CWRN.~CDEF"); msg("~CWRNThey have been notified of your attempt.~CDEF"); } return 1; }
varargs int on_cast(mapping param) { int amt, needed; needed = (param["max_cond"] * 2 / 3) - param["cond"]; amt = min(max( 20, param["caster"]->get_skill_roll("magic.concentration") * 2 ), needed); param["target"]->add_condition( needed ); set_actor(param["caster"]); set_target(param["target"]); param["caster"]->msg_local("~[030~Targ ~vertglow faintly in ~npos hands as it is mended slightly.~CDEF"); return 1; }
void ContainerViewGump::left_arrow() { sint8 party_mem_num = party->get_member_num(actor); if(party_mem_num >= 0) { if(party_mem_num > 0) party_mem_num--; else party_mem_num = party->get_party_size() - 1; set_actor(party->get_actor(party_mem_num)); force_full_redraw_if_needed(); } }
GUI_status ContainerViewGump::KeyDown(SDL_Keysym key) { if(left_arrow_button && left_arrow_button->Status() == WIDGET_VISIBLE) // okay to change member number { KeyBinder *keybinder = Game::get_game()->get_keybinder(); ActionType a = keybinder->get_ActionType(key); switch(keybinder->GetActionKeyType(a)) { case NEXT_PARTY_MEMBER_KEY: right_arrow(); return GUI_YUM; case PREVIOUS_PARTY_MEMBER_KEY: left_arrow(); return GUI_YUM; case HOME_KEY: set_actor(party->get_actor(0)); force_full_redraw_if_needed(); return GUI_YUM; case END_KEY: set_actor(party->get_actor(party->get_party_size() - 1)); force_full_redraw_if_needed(); return GUI_YUM; default: break; } } /* moved into container widget switch(key.sym) { case SDLK_RETURN: case SDLK_KP_ENTER: return GUI_YUM; default: break; } */ return container_widget->KeyDown(key); }
int main(string arg) { object who = find_player(arg), obj; if (!who) { msg("You can't find anyone with that name :)"); return 1; } foreach (obj : all_inventory(who)) { int x = obj->query_max_condition(); if (x) obj->set_condition(x); } set_actor(this_player()); set_target(who); msg_object(who,"~CBRT~Name has repaired all of your equipment.~CDEF"); msg("~CBRTYou have repaired all of ~post equipment.~CDEF"); return 1; }
bool InventoryWidget::init(Actor *a, uint16 x, uint16 y, TileManager *tm, ObjManager *om, Font *f) { tile_manager = tm; obj_manager = om; font = f; bg_color = Game::get_game()->get_palette()->get_bg_color(); obj_font_color = 0; if(Game::get_game()->get_game_type()==NUVIE_GAME_U6) { icon_x = 32; obj_font_color = 0x48; objlist_offset_x = 8; } else { icon_x = 23; objlist_offset_x = 0; } objlist_offset_y = 16; if(Game::get_game()->get_game_type() == NUVIE_GAME_U6) { empty_tile = tile_manager->get_tile(410); GUI_Widget::Init(NULL, x, y, 72, 64); //72 = 4 * 16 + 8 } else if(Game::get_game()->get_game_type() == NUVIE_GAME_MD) // FIXME: different depending on npc { empty_tile = tile_manager->get_tile(273); GUI_Widget::Init(NULL, x, y, 64, 82); } else // SE { empty_tile = tile_manager->get_tile(392); GUI_Widget::Init(NULL, x+2, y, 64, 82); } set_actor(a); set_accept_mouseclick(true, USE_BUTTON); // accept [double]clicks from button1 (even if double-click disabled we need clicks) return true; }
int on_use() { if( !this_object()->query_held() ) { msg("You must be wielding Sharov in order to use him."); return 0; } if( !charged ) { msg("Sharov is not yet fully recharged."); return 0; } if( !environment()->query_in_combat() ) { msg("You may only use Sharov while in combat."); return 0; } charged = 0; call_out( "cooldown", COOLDOWN ); environment()->add_readiness( 1000 ); set_actor( environment() ); set_target( this_object() ); environment()->msg_local("~CTIT~Name ~verbtighten ~poss grip on ~targ as a wave of light washes over ~pron.~CDEF"); return 1; }
// Fire lizards eat lava :P void on_tick() { int foodp, drinkp, wanderflag; if( !query_enabled() ) return; // Am I hungry? foodp = environment()->query_food() * 100 / environment()->query_food_capacity(); drinkp = environment()->query_drink() * 100 / environment()->query_drink_capacity(); // If not, this module doesn't need to run. if( foodp > 75 && drinkp > 75 ) return; if( foodp > 50 || drinkp > 50 ) wanderflag = 1; if( present_clone("/scn/ground/lava", environment(environment())) ) { set_actor( environment() ); environment()->msg_local("~CACT~Name ~verbtake a sip of the lava.~CDEF"); environment()->add_food( 100 ); environment()->add_drink( 100 ); } else { wanderflag = 1; } if( wanderflag ) environment()->wander(); }
int main(string param) { string command = "", arg = ""; string warcry = this_player()->query_env_var("warcry"); string myName = this_player()->query_cap_name(); set_actor(this_player()); set_target(this_player()); if(!param) { if( warcry ) { int check; object warcry_ob; // can't already be in combat if( this_player()->query_in_combat() ) { notify_fail("You cannot shout your warcry once battle has been joined!\n"); return 0; } // can't already have a warcry active if( present_clone("/battle/warcry_object",this_player()) ) { notify_fail("You have already shouted your warcry, hurry up and kill something!\n"); return 0; } // must have endurance if( this_player()->query_endurance() < 10 ) { notify_fail("You don't have enough endurance to shout your warcry.\n"); return 0; } // determine strength of cry check = this_player()->get_skill_roll("combat.tactics"); //practice is handled by the object so they don't get free pracs for shouting outside //of combat ;) //this_player()->practice_skill( "combat.tactics", min(1, check / 25) ); // debit endurance this_player()->add_endurance( -2 - check/10 ); if( this_player()->query_endurance() < 1 ) { check += this_player()->query_endurance() * 10; this_player()->set_endurance( 1 ); } // give them the object warcry_ob = clone_object("/battle/warcry_object"); warcry_ob->do_setup( this_player(), check ); // issue message warcry = recolor(warcry); if(!this_player()->query_toad()) this_player()->msg_local("~[010~Name ~verbshout ~poss warcry: ~CDEF" + warcry); } else { msg("You whimper like a puppy. Perhaps you should set a warcry first?"); } } else { if(sscanf(param, "%s %s", command, arg) != 2) { command = param; } switch(command) { case "check": if(warcry != 0) { msg("Your warcry is: " + warcry); } else { msg("Sorry, you haven't set a warcry yet."); } break; case "set": this_player()->set_env_var("warcry", arg); msg("Warcry set to: " + arg); break; default: msg("Please read ~CREFhelp warcry~CDEF for the correct usage of this verb."); } } return 1; }
void ContainerViewGump::right_arrow() { set_actor(party->get_actor((party->get_member_num(actor) + 1) % party->get_party_size())); force_full_redraw_if_needed(); }
int main(string str) { string what, where, with; object pen, paper; int length; struct page_contents_struct data; if( !str ) { return notify_fail("Usage: write [what] on|in <object> with <quill>\n"); } if( sscanf(str, "%s with %s", str, with) != 2 && str[0..4] != "with " ) { return notify_fail("You must specify which writing implement you are using.\n"); } if( str[0..2] != "on " && str[0..2] != "in " ) { if( sscanf(str, "%s on %s", what, where) != 2 && sscanf(str, "%s in %s", what, where) != 2 ) { return notify_fail("You must specify what you are planning on writing on.\n"); } } else { where = str[3..]; } msg("what = '"+what+"'"); msg("where = '"+where+"'"); msg("with = '"+with+"'"); // validate paper paper = single_present(where, this_player()); if (!paper) { return notify_fail("Couldn't find any '"+with+"' to write on.\n"); } else if (!paper->query_is_writable()) { return notify_fail("You can't write on that.\n"); } // validate pen pen = single_present(what, this_player()); if (!pen) { return notify_fail("Couldn't find any '"+with+"' to write with.\n"); } else if (!pen->query_can_write()) { return notify_fail("You can't write with that.\n"); } else if (!pen->query_held()) { return notify_fail("You must be holding the pen in order to write with it.\n"); } data.details = L_HAND | (pen->query_ink_colour() ? L_COLOUR | L_BLACK ); set_actor(this_player()); set_target(paper); // check for special thingies to write if (what) { // is it a signature? if (what == "my name" || what == "signature" || what == "my signature") { data.category = L_SIGNATURE; data.length = 1; data.language = this_player()->query_current_language(); data.contents = this_player()->query_name(); if (!paper->on_write( data )) return notify_fail("You are unable to sign that...\n"); else { this_player()->msg_local("~CACT~Name ~verbsign ~poss name on ~targ.~CDEF"); return 1; } } else // is it a spell? if (MAGIC_DAEMON->query_spell(what)) { } else // is it a skill? if (SKILL_DAEMON->skill_exists(what)) { } else // is it a deed? if (what == "deed") { // must stand inside of the building in question return notify_fail("Sorry, title deeds are not yet operational.\n"); } else // is it a license? if (what == "license") { // must be government official to write up such things return notify_fail("Sorry, licenses are not yet operational.\n"); } // if special, make sure we have enough room } else { // if not special, start writing until we run out of space } return 1; }