varargs int remove_armour(int silent) { object owner = environment(this_object()), obj; if (!worn) return 0; if (!owner->query_is_living()) return 0; set_target(this_object()); // check if they're wearing anything over this item foreach ( obj : all_inventory(owner) ) { if( obj->query_is_apparel() && (obj->query_body_parts() & query_body_parts()) && obj->query_layer() > layer) { if( !silent ) msg("You can't remove ~targ, without first removing "+obj->query_name()+"."); return 0; } } // returns true if on_remove() has been defined, so false means we have // to do this our selves as well if (this_object()->on_remove() == 0) { if (this_object()->query_cursed()) { if (!silent) msg_object(owner,"You can't remove ~targ! It appears to be cursed!"); } else { if (!silent) owner->msg_local("~Name ~verbremove ~targ."); set_worn(0); owner->recalc(); return 1; } } }
void cooldown() { remove_call_out( "cooldown" ); if( this_object()->query_held() ) { msg_object(environment(),"~[090Sharov pulses strongly in your hand, ready to be used again.~CDEF"); charged = 1; } }
main( string str ) { object ob; int i; if( !str ) { msg( "~CBRTLose whom?~CDEF" ); return 1; } str = lower_case( str ); this_player()->check_followers(); if( str == this_player()->query_name() ) { msg( "~CBRTYou become very, very confused for a moment....~CDEF" ); return 1; } ob = this_player()->query_followers(); for( i=0;i<sizeof(ob);i++ ) { if( ob[i]->query_name() == str ) { this_player()->remove_follower( ob[i] ); ob[i]->remove_leader( this_player() ); msg( "~CBRTYou manage to lose " + capitalize(ob[i]->query_name()) + " with some evasive movements.~CDEF" ); msg_object( ob[i], "~CBRT" + capitalize(this_player()->query_name()) + " has managed to evade your pursuit.~CDEF" ); return 1; } } msg( "~CBRTThat's great, really. Perhaps you should convince them to follow you first?~CDEF" ); 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; }
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; }
main(string str) { // This is the local echo func. Any wiz is allowed to do it object who; string wiz_str; WIZ_CHECK if(!str) { notify_fail("==> [Format] echoall [message]\n"); return 0; } str = "~CTIT"+str+"~CDEF"; wiz_str = "<echoall:~CCOM"+this_player()->query_name()+"~CDEF> "+str; foreach( who : users() ) { if ( who->query_level() >= WIZLEVEL ) msg_object(who,wiz_str); else msg_object(who,str); } return 1; }
main(string str) { // This is the local echo func. Any wiz is allowed to do it object who; string wiz_str; WIZ_CHECK if(!str) { notify_fail("==> [Format] echo message\n"); return 0; } str = "~CACT"+str+"~CDEF"; wiz_str = "<echo:~CCOM"+this_player()->query_name()+"~CDEF> "+str; foreach( who : all_inventory(environment(this_player())) ) { if ( !who->query_is_player() ) continue; else if ( who->query_level() >= WIZLEVEL ) msg_object(who,wiz_str); else msg_object(who,str); } return 1; }
void tick() { if (!vict->query_is_living()) destruct(this_object()); switch (type) { case "mana": vict->add_mana(speed); break; case "endurance": vict->add_endurance(speed); break; default: vict->add_hp(speed); } msg_object(vict,"You feel energy returning to your body."); size -= speed; if (speed >= size) speed = size; if (size <= 0) destruct(this_object()); call_out("tick",5); }
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; }
main(string str) { object targ; string targ_name; string message; WIZ_CHECK if(!str || sscanf(str, "%s %s", targ_name, message) != 2 ) { notify_fail("==> [Format] echoto person [message]\n"); return 0; } targ = find_living( targ_name ); if( !targ ) { notify_fail("==> [Error] No such target\n"); return 0; } msg("(To "+capitalize(targ->query_name())+"): ~[110"+message+"~[070"); msg_object(targ, "~[110"+message+"~[070"); return 1; }
/** Add headers from the request to the response message. */ int http_complete_response(msg_t *msg, int status, char const *phrase, http_t const *request) { su_home_t *home = msg_home(msg); http_t *http = msg_object(msg); if (!http || !request || !request->http_request) return -1; if (!http->http_status) http->http_status = http_status_create(home, status, phrase, NULL); if (!http->http_status) return -1; if (!http->http_separator) { http_separator_t *sep = http_separator_create(msg_home(msg)); if (msg_header_insert(msg, http, (http_header_t *)sep) < 0) return -1; } return 0; }
int main(int argc, char *argv[]) { char urlbuf[1024]; size_t n; int m, tcp; sip_t *sip; int exitcode = 0; msg_mclass_t const *sip_mclass = sip_default_mclass(); msg_t *msg = msg_create(sip_mclass, MSG_FLG_EXTRACT_COPY); msg_iovec_t iovec[1]; tcp = argv[1] && strcmp(argv[1], "-t") == 0; test_msg_class(sip_mclass); for (n = 0, m = 0;;) { if (msg_recv_iovec(msg, iovec, 1, 1, 0) < 0) { perror("msg_recv_iovec"); exit(1); } assert(iovec->mv_len >= 1); n = read(0, iovec->mv_base, 1); if (n < 0) { perror("test_sip_msg read"); exit(1); } msg_recv_commit(msg, n, n == 0); if (tcp) m = msg_extract(msg); if (n == 0 || m < 0) break; } if (!tcp) m = msg_extract(msg); sip = msg_object(msg); if (sip) fprintf(stdout, "sip flags = %x\n", sip->sip_flags); if (m < 0) { fprintf(stderr, "test_sip_msg: parsing error ("MOD_ZD")\n", n); exit(1); } if (sip->sip_flags & MSG_FLG_TRUNC) { fprintf(stderr, "test_sip_msg: message truncated\n"); exit(1); } if (msg_next(msg)) { fprintf(stderr, "test_sip_msg: stuff after message\n"); exit(1); } #if 0 fprintf(stderr, "test_sip_msg: %d headers (%d short ones), %d unknown\n", msg->mh_n_headers, msg->mh_n_short, msg->mh_n_unknown); if (msg->mh_payload) { fprintf(stderr, "\twith payload of %d bytes\n", msg->mh_payload->pl_len); } #endif if (MSG_HAS_ERROR(sip->sip_flags) || sip->sip_error) { fprintf(stderr, "test_sip_msg: parsing error\n"); exit(1); } else if (sip_sanity_check(sip) < 0) { fprintf(stderr, "test_sip_msg: message failed sanity check\n"); exit(1); } if (sip->sip_request) { fprintf(stdout, "\trequest %s (%d) %s %s\n", sip->sip_request->rq_method_name, sip->sip_request->rq_method, url_print(sip->sip_request->rq_url, urlbuf), sip->sip_request->rq_version); if (sip->sip_request->rq_url->url_type == url_unknown) { exitcode = 1; fprintf(stderr, "test_sip_msg: invalid request URI\n"); } } if (sip->sip_status) fprintf(stdout, "\tstatus %s %03d %s\n", sip->sip_status->st_version, sip->sip_status->st_status, sip->sip_status->st_phrase); if (sip->sip_cseq) fprintf(stdout, "\tCSeq: %u %s (%d)\n", sip->sip_cseq->cs_seq, sip->sip_cseq->cs_method_name, sip->sip_cseq->cs_method); if (sip->sip_call_id) fprintf(stdout, "\tCall-ID: %s (%x)\n", sip->sip_call_id->i_id, sip->sip_call_id->i_hash); if (sip->sip_from) fprintf(stdout, "\tFrom: %s@%s%s%s\n", sip->sip_from->a_user ? sip->sip_from->a_user : "******", sip->sip_from->a_host ? sip->sip_from->a_host : "[nowhere]", sip->sip_from->a_tag ? " ;tag=" : "", sip->sip_from->a_tag ? sip->sip_from->a_tag : ""); if (sip->sip_to) fprintf(stdout, "\tTo: %s@%s%s%s\n", sip->sip_to->a_user ? sip->sip_to->a_user : "******", sip->sip_to->a_host ? sip->sip_to->a_host : "[nowhere]", sip->sip_to->a_tag ? " ;tag=" : "", sip->sip_to->a_tag ? sip->sip_to->a_tag : ""); if (sip->sip_contact) print_contact(stdout, sip->sip_contact); if (sip->sip_via) print_via(stdout, sip->sip_via); if (sip->sip_content_length) { fprintf(stdout, "\tcontent length %u\n", sip->sip_content_length->l_length); } if (msg_next(msg)) { fprintf(stderr, "test_sip_msg: extra stuff after valid message\n"); exit(1); } return exitcode; }