void do_disband (CHAR_DATA *ch, char *argument, int cmd) { CHAR_DATA *pal = NULL; char buf [MAX_STRING_LENGTH] = {'\0'}; argument = one_argument (argument, buf); if ( !*buf || !str_cmp (buf, "all") ) { act ("$n motions to $s clanmates.", FALSE, ch, 0, 0, TO_ROOM | TO_ACT_FORMAT); act ("You motion to your clanmates.", FALSE, ch, 0, 0, TO_CHAR | TO_ACT_FORMAT); for ( pal = ch->room->people; pal; pal = pal->next_in_room ) { if ( pal->following != ch || !IS_NPC (pal) ) continue; if ( is_leader (ch, pal) && AWAKE (pal) ) { act ("$N motions to you to stop following.", FALSE, pal, 0, ch, TO_CHAR | TO_ACT_FORMAT); act ("$n falls out of step.", FALSE, pal, 0, ch, TO_ROOM | TO_ACT_FORMAT); pal->following = NULL; } } return; } if ( !(pal = get_char_room_vis (ch, buf)) ) { send_to_char ("Nobody is here by that name.\n\r", ch); return; } if ( pal->following != ch ) { act ("$N is not following you.", FALSE, ch, 0, pal, TO_CHAR); return; } if ( !is_leader (ch, pal) ) { act ("You can't give $N orders.", FALSE, ch, 0, pal, TO_CHAR); return; } if ( !IS_NPC (pal) ) { send_to_char ("This command does not work on PCs.\n", ch); return; } pal->following = NULL; act ("You motion to $N.", FALSE, ch, 0, pal, TO_CHAR | TO_ACT_FORMAT); act ("$N motions to $n.", FALSE, pal, 0, ch, TO_NOTVICT | TO_ACT_FORMAT); act ("$N motions to you to stop following.", FALSE, pal, 0, ch, TO_CHAR); act ("$n falls out of step.", FALSE, pal, 0, ch, TO_ROOM | TO_ACT_FORMAT); }
void ccs_children_watcher(zhandle_t* zh, int type, int state, const char* path, void* watcherCtx) { printf("\n\n"); printf("children event happened: type[%d]\n", type); int ret = 0; struct watch_func_para_t* para= (struct watch_func_para_t*)watcherCtx; struct String_vector strings; struct Stat stat; ret = zoo_wget_children2(para->zkhandle, "/election", ccs_children_watcher, watcherCtx, &strings, &stat); if (ret) { fprintf(stderr, "child: zoo_wget_children2 error [%d]\n", ret); exit(EXIT_FAILURE); } if (is_leader(para->zkhandle, para->node)) { i_am_leader = true; printf("This is [%s], i am a leader\n", para->node); } else { i_am_leader = false; printf("This is [%s], i am a follower\n", para->node); } return; }
static void init_network_cb() { int rc; /* Init IB device */ rc = dare_init_ib_device(); if (0 != rc) { rdma_error(log_fp, "Cannot init IB device\n"); goto shutdown; } /* Init some IB data for the server */ rc = dare_init_ib_srv_data(&data); if (0 != rc) { rdma_error(log_fp, "Cannot init IB SRV data\n"); goto shutdown; } /* Init IB RC */ rc = dare_init_ib_rc(); if (0 != rc) { rdma_error(log_fp, "Cannot init IB RC\n"); goto shutdown; } if (!is_leader()) { /* Server joining the cluster */ join_cluster_cb(); } return; shutdown: dare_server_shutdown(); }
static VariantSF bottom_leader(th_context *th, VariantSF to_sgf) { CPtr csf = subg_compl_stack_ptr(to_sgf) ; while(!is_leader(csf) ) csf = prev_compl_frame(csf) ; return compl_subgoal_ptr(csf) ; }
bool can_demote(CHAR_DATA * ch) { /* ok if ch is a SUPREME or higher */ if (ch->level >= SUPREME || ch->trust >= SUPREME) return TRUE; /* not ok if ch is not guilded or is not a mortal leader */ if (ch->clan == 0 || !is_leader(ch)) return FALSE; return clan_table[ch->clan].ml[3]; } /* end: can_demote */
bool is_trustee(CHAR_DATA * ch, long id) { KINGDOM_DATA *kingdom = get_kingdom(id); if(!ch || kingdom == &kingdom_default) return FALSE; if(is_leader(ch, id) || strstr(kingdom->trustees, ch->name) != 0) return TRUE; return FALSE; }
bool can_promote(CHAR_DATA * ch) { /* ok if ch is a SUPREME or higher */ if (ch->level >= SUPREME || ch->trust >= SUPREME) return TRUE; /* not ok if ch is not guilded or is not a mortal leader */ if (ch->clan == 0 || !is_leader(ch)) return FALSE; /* is a mortal leader, but do they have the right? */ return clan_table[ch->clan].ml[2]; } /* end: can_promote */
// // 划分基本块 // int block_partition(Block block[], IR instr[], int n) { int count = 0; for (int i = 0; i < n; i++) { if (is_leader(instr, i)) { block[count].start = i; block[count].index = count; if (count > 0) { block[count - 1].end = i; } count++; } instr[i].block = count - 1; } block[count - 1].end = n; return count; }
void update_char_kingdom(CHAR_DATA * ch) { KINGDOM_DATA *kingdom; if(!ch || IS_NPC(ch)) return; if(ch->pcdata->kingdom > 0) { kingdom = get_kingdom(ch->pcdata->kingdom); if(kingdom == &kingdom_default) { ch->pcdata->kingdom = 0; return; } if(strstr(kingdom->members, ch->name) == 0 && !is_leader(ch, kingdom->id)) { remove_trustee(kingdom->id, ch->name); ch->pcdata->kingdom = 0; return; } return; } if(ch->pcdata->krank[0] != '\0') { free_string(ch->pcdata->krank); ch->pcdata->krank = str_dup(""); } for(kingdom = kingdom_list; kingdom; kingdom = kingdom->next) { if(strstr(kingdom->members, ch->name) != 0) remove_member(kingdom->id, ch->name); if(strstr(kingdom->trustees, ch->name) != 0) remove_trustee(kingdom->id, ch->name); } }
int main(int argc, const char *argv[]) { const char* host = "127.0.0.1:2181"; zhandle_t* zkhandle; int timeout = 5000; char node[512] = {0}; char tables[][64] = { {"employee_info_tab"}, {"boss_info_tab"} }; zoo_set_debug_level(ZOO_LOG_LEVEL_WARN); zkhandle = zookeeper_init(host, NULL, timeout, 0, "Zookeeper examples: config center services", 0); if (zkhandle == NULL) { fprintf(stderr, "Connecting to zookeeper servers error...\n"); exit(EXIT_FAILURE); } /* join the election group */ struct watch_func_para_t para; int ret = join_the_election(zkhandle, node, ¶); if (zkhandle == NULL) { fprintf(stderr, "join the election error...\n"); exit(EXIT_FAILURE); } /* leader election */ if (is_leader(zkhandle, node)) { i_am_leader = true; printf("This is [%s], i am a leader\n", node); (void)create_tables(zkhandle, tables, sizeof(tables)/sizeof(tables[0])); } else { i_am_leader = false; printf("This is [%s], i am a follower\n", node); } /* start the trigger listen thread */ pthread_attr_t attr1; ret = pthread_attr_init(&attr1); if (ret != 0) { fprintf(stderr, "pthread_attr_init error...\n"); exit(EXIT_FAILURE); } pthread_t trigger_listen_thr; ret = pthread_create(&trigger_listen_thr, &attr1, trigger_listen_thread, zkhandle); if (ret != 0) { fprintf(stderr, "pthread_create error...\n"); exit(EXIT_FAILURE); } ret = pthread_attr_destroy(&attr1); if (ret != 0) { fprintf(stderr, "pthread_attr_destroy error...\n"); exit(EXIT_FAILURE); } /* start the item expire thread */ pthread_attr_t attr2; ret = pthread_attr_init(&attr2); if (ret != 0) { fprintf(stderr, "pthread_attr_init error...\n"); exit(EXIT_FAILURE); } pthread_t expire_thr; ret = pthread_create(&expire_thr, &attr2, item_expire_thread, zkhandle); if (ret != 0) { fprintf(stderr, "pthread_create error...\n"); exit(EXIT_FAILURE); } ret = pthread_attr_destroy(&attr2); if (ret != 0) { fprintf(stderr, "pthread_attr_destroy error...\n"); exit(EXIT_FAILURE); } void *res; ret = pthread_join(trigger_listen_thr, (void**)&res); if (ret != 0) { fprintf(stderr, "pthread_join error...\n"); exit(EXIT_FAILURE); } ret = pthread_join(expire_thr, (void**)&res); if (ret != 0) { fprintf(stderr, "pthread_join error...\n"); exit(EXIT_FAILURE); } zookeeper_close(zkhandle); }
void do_recruit (CHAR_DATA *ch, char *argument, int cmd) { CHAR_DATA *pal = NULL; char buf [MAX_STRING_LENGTH]; argument = one_argument (argument, buf); if ( !*buf ) { for ( pal = ch->room->people; pal; pal = pal->next_in_room ) { if ( IS_NPC (pal) && pal->following != ch && is_leader (ch, pal) ) break; } if ( !pal ) { send_to_char ("Nobody else here will follow you.\n\r", ch); return; } pal->following = ch; act ("$N nods to you to follow.", FALSE, pal, 0, ch, TO_CHAR | TO_ACT_FORMAT); act ("$N motions to $S clanmates.", FALSE, pal, 0, ch, TO_NOTVICT | TO_ACT_FORMAT); act ("$n falls in.", FALSE, pal, 0, ch, TO_ROOM | TO_ACT_FORMAT); return; } if ( !str_cmp (buf, "all") ) { act ("$n motions to $s clanmates.", FALSE, ch, 0, 0, TO_ROOM | TO_ACT_FORMAT); for ( pal = ch->room->people; pal; pal = pal->next_in_room ) { if ( IS_NPC (pal) && pal->following != ch && is_leader (ch, pal) ) { pal->following = ch; act ("$N nods to you to follow.", FALSE, pal, 0, ch, TO_CHAR | TO_ACT_FORMAT); act ("$n falls in.", FALSE, pal, 0, ch, TO_ROOM | TO_ACT_FORMAT); } } if ( !pal ) { send_to_char ("Nobody else here will follow you.\n\r", ch); return; } return; } if ( !(pal = get_char_room_vis (ch, buf)) ) { send_to_char ("Nobody is here by that name.\n\r", ch); return; } if ( pal == ch ) { send_to_char ("Not yourself.\n\r", ch); return; } if ( !is_leader (ch, pal) ) { act ("You don't have the authority to recruit $N.", FALSE, ch, 0, pal, TO_CHAR); return; } if ( pal->following == ch ) { act ("$N is already following you.", FALSE, ch, 0, pal, TO_CHAR); return; } pal->following = ch; act ("$N motions to $S clanmates.", FALSE, pal, 0, ch, TO_NOTVICT | TO_ACT_FORMAT); act ("$n falls in.", FALSE, pal, 0, ch, TO_VICT | TO_ACT_FORMAT); act ("$N nods to you to follow.", FALSE, pal, 0, ch, TO_CHAR); return; }
/////////////// DO FUNCTIONS /////////////////// void do_kingdom(CHAR_DATA * ch, char *argument) { KINGDOM_DATA *kingdom; CHAR_DATA *vch = 0; DESCRIPTOR_DATA *d = 0; char buf[MAX_STRING_LENGTH]; char arg1[MAX_STRING_LENGTH]; char arg2[MAX_STRING_LENGTH]; char arg3[MAX_STRING_LENGTH]; long id = 0; long i = 0; if(IS_NPC(ch)) return; smash_tilde(argument); argument = one_argument_case(argument, arg1); argument = one_argument_case(argument, arg2); strcpy(arg3, argument); if(IS_IMMORTAL(ch) && ch->level == MAX_LEVEL) { if(!str_cmp(arg1, "save")) { write_kingdoms(); sprintf(buf,"cp %s %s.bak",KINGDOM_FILE,KINGDOM_FILE); system(buf); send_to_char("Done, and made backup.\n\r", ch); return; } if(arg1[0] == '\0') { send_to_char("Syntax: kingdom create\n\r", ch); return; } if(!str_cmp(arg1, "create")) { create_kingdom(); write_kingdoms(); send_to_char("Done.\n\r", ch); return; } if((!is_number(arg1) || !str_cmp(arg1, "help"))) { send_to_char("Syntax: kingdom <id #> <attribute> <value>\n\r", ch); send_to_char(" kingdom <id #> delete\n\r", ch); send_to_char("\n\r", ch); send_to_char("Attributes:\n\r", ch); send_to_char(" leader name points pks pds realpoints\n\r", ch); send_to_char(" noansiname\n\r", ch); send_to_char("\n\r", ch); } else { id = atoi(arg1); if((kingdom = get_kingdom(id)) == &kingdom_default) { send_to_char("There is no such kingdom with that ID.\n\r", ch); return; } if(!str_cmp(arg2, "leader")) { if((vch = get_char_world(ch, arg3)) == 0) { send_to_char("The leader must be logged on.\n\r", ch); return; } free_string(kingdom->leader); kingdom->leader = str_dup(arg3); vch->pcdata->kingdom = id; send_to_char("Done.\n\r", ch); return; } if(!str_cmp(arg2, "name")) { free_string(kingdom->name); kingdom->name = str_dup(arg3); send_to_char("Done.\n\r", ch); return; } if(!str_cmp(arg2, "noansiname")) { free_string(kingdom->noansiname); kingdom->noansiname = str_dup(arg3); send_to_char("Done.\n\r", ch); return; } if(!str_cmp(arg2, "delete") && !str_cmp(arg3, "yes")) { delete_kingdom(kingdom->id); return; } i = atoi(arg3); if(!str_cmp(arg2, "points")) { kingdom->points = i; send_to_char("Done.\n\r", ch); return; } if(!str_cmp(arg2, "realpoints")) { kingdom->realpoints = i; send_to_char("Done.\n\r", ch); return; } if(!str_cmp(arg2, "pds")) { kingdom->pds = i; send_to_char("Done.\n\r", ch); return; } if(!str_cmp(arg2, "pks")) { kingdom->pks = i; send_to_char("Done.\n\r", ch); return; } if(!str_cmp(arg2, "assists")) { kingdom->assists = i; send_to_char("Done.\n\r", ch); return; } } } if(ch->pcdata->kingdom == 0) // player not in a kingdom { if(!str_cmp(arg1, "create")) { if(ch->pcdata->quest < 1000) { send_to_char("You need 1000 quest points to create a new kingdom.\n\r", ch); return; } if(!arg2 || arg2[0] == '\0' || !arg3 || arg3[0] == '\0') { send_to_char ("Syntax (DO NOT MESS THIS UP!): kingdom create \"name WITH ansi\" \"name WITHOUT ansi\"\n\r", ch); send_to_char("I suggest you SAY the name a few times to make SURE THE ANSI IS CORRECT.\n\r", ch); send_to_char("And if you dont put a final {{x your kingdom will be DELETED.\n\r", ch); send_to_char("If your kingdom name has more than one word surround it in QUOTES!\n\r", ch); return; } if(ansistrlen(arg2) > 20 || strlen(arg3) > 20) { send_to_char("String length is limited to 20 characters!\n\r", ch); return; } kingdom = create_kingdom(); ch->pcdata->kingdom = kingdom->id; ch->pcdata->quest -= 1000; free_string(kingdom->leader); kingdom->leader = str_dup(ch->name); free_string(kingdom->name); kingdom->name = str_dup(arg2); free_string(kingdom->noansiname); kingdom->noansiname = str_dup(arg3); kingdom_message(0, "%s has {WCREATED{X The %s Kingdom!", ch->name, kingdom->name); write_kingdoms(); return; } if(ch->pcdata->kingdom_invite == 0) { send_to_char("You don't belong to a kingdom.\n\r", ch); return; } // make sure kingdom still exists if(get_kingdom(ch->pcdata->kingdom_invite) == &kingdom_default) { send_to_char("That kingdom was destroyed.\n\r", ch); return; } if(!str_cmp(arg1, "accept")) { add_member(ch->pcdata->kingdom_invite, ch); return; } if(!str_cmp(arg1, "decline")) { send_to_char("You decline the kingdom's invitation.\n\r", ch); if((vch = get_char_world(ch, get_kingdom(ch->pcdata->kingdom_invite)->leader)) != 0) { sprintf(buf, "%s has declined your invitation.\n\r", ch->name); send_to_char(buf, vch); } ch->pcdata->kingdom_invite = 0; return; } send_to_char("Type either kingdom accept or kingdom decline.\n\r", ch); return; } kingdom = get_kingdom(ch->pcdata->kingdom); if(!str_cmp(arg1, "leave") && !str_cmp(arg2, "for") && !str_cmp(arg3, "good")) { send_to_char("You leave the kingdom!\n\r", ch); remove_member(kingdom->id, ch->name); remove_trustee(kingdom->id, ch->name); return; } if(!str_prefix(arg1, "report")) { long percent; char *color; buf[0] = '\0'; sprintf(buf, "%-4s %-12s{X %5s :: %s\n\r", "CMBT", "Name", "Hits", "Room" ); for(d = descriptor_list; d; d = d->next) { if(d->connected != CON_PLAYING || !(vch = d->character) || vch->pcdata->kingdom != kingdom->id) continue; percent = (long) ((float) UMAX(1, vch->hit) / (float) UMAX(1, vch->max_hit) * 100); if(percent < 10) color = "{R"; else if(percent < 40) color = "{B"; else if(percent < 70) color = "{Y"; else color = "{C"; sprintf(buf + strlen(buf), "%-4s %s%-12s{X %5li :: %s\n\r", vch->fighting ? !IS_NPC(vch->fighting) ? "{R(PK){X" : "{r(F){X" : "", color, vch->name, vch->hit, !vch->in_room ? "somewhere" : vch->in_room->name); } send_to_char(buf, ch); return; } if(!is_trustee(ch, kingdom->id)) { send_to_char("Only leaders and trustees have power to modify their kingdom.\n\r", ch); return; } if(arg1[0] == '\0' || arg2[0] == '\0') { if(is_leader(ch, kingdom->id) || IS_IMMORTAL(ch)) { send_to_char("Syntax:\n\r", ch); send_to_char(" kingdom report\n\r", ch); send_to_char(" kingdom invite <player>\n\r", ch); send_to_char(" kingdom outcast <member>\n\r", ch); send_to_char(" kingdom war <kingdom ID>\n\r", ch); send_to_char(" kingdom treaty <kingdom ID>\n\r", ch); send_to_char(" kingdom rank <member> <rank>\n\r", ch); send_to_char(" kingdom trust <member>\n\r", ch); send_to_char(" kingdom recall\n\r", ch); send_to_char("\n\r", ch); } send_to_char("Syntax: kingdom scry <person>\n\r", ch); return; } if(is_leader(ch, kingdom->id)) { if(!str_cmp(arg1, "recall")) { if(kingdom->points < KINGDOM_RECALL_COST) { sprintf(buf, "It costs %d kingdom points to set a recall point.\n\r", KINGDOM_RECALL_COST); send_to_char(buf, ch); return; } if(ch->in_room == 0) { send_to_char("You are in a 0 room, eek.\n\r", ch); return; } kingdom->points -= KINGDOM_RECALL_COST; kingdom->recall = ch->in_room->vnum; kingdom_message(kingdom->id, "{MThe Kingdom Recall has been set to -> [%s]", ch->in_room->name); return; } if(!str_cmp(arg1, "trust")) { if((vch = get_char_world(ch, arg2)) == 0 || IS_NPC(vch)) { send_to_char("They need to be logged on.\n\r", ch); return; } if(vch->pcdata->kingdom != ch->pcdata->kingdom) { send_to_char("They aren't in your kingdom!\n\r", ch); return; } arg2[0] = UPPER(arg2[0]); if( strstr(kingdom->trustees, arg2) == 0 ) add_trustee(kingdom->id, vch); else remove_trustee(kingdom->id, arg2); return; } if(!str_cmp(arg1, "invite")) { if((vch = get_char_world(ch, arg2)) == 0) { send_to_char("They aren't logged on.\n\r", ch); return; } if(IS_NPC(vch)) { send_to_char("That's an NPC.\n\r", ch); return; } if(vch->pcdata->kingdom) { send_to_char("They are already a part of another kingdom!\n\r", ch); return; } vch->pcdata->kingdom_invite = ch->pcdata->kingdom; sprintf(buf, "You are invited to join the %s Kingdom by %s.\n\r" "Type kingdom accept or kingdom decline.\n\r", kingdom->name, ch->name); send_to_char(buf, vch); sprintf(buf, "You invite %s to join your glorious kingdom.\n\r", vch->name); send_to_char(buf, ch); return; } if(!str_cmp(arg1, "outcast")) { arg2[0] = UPPER(arg2[0]); if( strstr(kingdom->members, arg2) == 0 ) { send_to_char("That person isn't a member!\n\r",ch); return; } if(remove_member(ch->pcdata->kingdom, arg2)) kingdom_message(0, "%s has been outcasted from the %s Kingdom!", capitalize(arg2), kingdom->name); remove_trustee(kingdom->id, arg2); return; } if(!str_cmp(arg1, "treaty")) { if(kingdom->treaty_pending) { if(!get_kingdom(kingdom->treaty_pending)) { kingdom->treaty_pending = 0; return; } if(has_treaty(kingdom->id, kingdom->treaty_pending)) { send_to_char("You already have a treaty with them.\n\r", ch); return; } if(!str_cmp(arg2, "accept")) { add_treaty(kingdom->id, kingdom->treaty_pending); kingdom->treaty_pending = 0; return; } if(!str_cmp(arg2, "decline")) { kingdom_message(kingdom->id, "Your kingdom declines a treaty with the %s Kingdom.", get_kingdom(kingdom->treaty_pending)->name); kingdom_message(kingdom->treaty_pending, "%s Kingdom has declined your treaty offer.", kingdom->name); kingdom->treaty_pending = 0; return; } sprintf(buf, "You have a treaty offer pending with the %s Kingdom.\n\r" "Please type kingdom treaty accept or kingdom treaty decline.\n\r", get_kingdom(kingdom->treaty_pending)->name); send_to_char(buf, ch); return; } if(!is_number(arg2) || get_kingdom(atoi(arg2)) == &kingdom_default) { send_to_char("There is no such kingdom to make a treaty with.\n\r", ch); return; } i = atoi(arg2); if(kingdom->id == i) { send_to_char("You already have a treaty with yourself, smart one.\n\r", ch); return; } if(is_at_war(kingdom->id, i)) { send_to_char("You are at {RWAR{N with that kingdom!\n\r", ch); return; } if(has_treaty(kingdom->id, i)) { remove_treaty(kingdom->id, i); return; } if(get_kingdom(i)->treaty_pending) { send_to_char("They are already pending a treaty confirmation.\n\r", ch); return; } get_kingdom(i)->treaty_pending = kingdom->id; kingdom_message(i, "The %s Kingdom is asking for a treaty with your kingdom.", kingdom->name); kingdom_message(kingdom->id, "You ask the %s Kingdom for a treaty.", get_kingdom(i)->name); return; } if(!str_cmp(arg1, "war")) { if(!is_number(arg2) || get_kingdom(atoi(arg2)) == &kingdom_default) { send_to_char("There is no such kingdom to make war with.\n\r", ch); return; } i = atoi(arg2); if(i == kingdom->id) { send_to_char("That wouldn't be a very smart political move.\n\r", ch); return; } if(get_kingdom(i) == &kingdom_default) { send_to_char("That kingdom doesn't exist.\n\r", ch); return; } if(has_treaty(kingdom->id, i)) { send_to_char("But you have a treaty with them!\n\r", ch); return; } if(is_at_war(kingdom->id, i)) { remove_war(kingdom->id, i); return; } add_war(kingdom->id, i); return; } if(!str_cmp(arg1, "rank")) { if(!arg3 || arg3[0] == '\0') { send_to_char("Rank who as what?\n\r", ch); return; } if((vch = get_char_world(ch, arg2)) == 0 || IS_NPC(vch)) { send_to_char("They aren't on at the moment.\n\r", ch); return; } if(vch->pcdata->kingdom != ch->pcdata->kingdom) { send_to_char("They aren't apart of your kingdom!\n\r", ch); return; } if(ansistrlen(arg3) > 15) { send_to_char("String length is limited to 20 characters.\n\r", ch); return; } free_string(vch->pcdata->krank); if(!str_cmp(arg3, "clear")) { vch->pcdata->krank = str_dup(""); return; } arg3[0] = UPPER(arg3[0]); vch->pcdata->krank = str_dup(arg3); send_to_char("Done.\n\r", ch); return; } } if(!str_cmp(arg1, "scry")) { if(arg2[0] == '\0') { send_to_char("You must supply the name of the person.\n\r", ch); return; } if((vch = get_char_world(ch, arg2)) == 0 || IS_NPC(vch)) { send_to_char("They are not online.\n\r", ch); return; } if(kingdom->points < KINGDOM_SCRY_COST) { sprintf(buf, "It costs %d Kingdom Points to do this.\n\r", KINGDOM_SCRY_COST); send_to_char(buf, ch); return; } kingdom_message(kingdom->id, "%s has {cscryed{N %s {C. o O{N ({C%s{N)", ch->name, vch->name, vch->in_room == 0 ? "Nowhere" : vch->in_room->name); kingdom->points -= KINGDOM_SCRY_COST; return; } // default message do_kingdom(ch, "blah"); }
long award_points(CHAR_DATA * ch, CHAR_DATA * victim) { KINGDOM_DATA *kingdom; KINGDOM_DATA *vkingdom; AREA_DATA *area = 0; ASSIST_DATA *assist; long points = 0; long damage = 0; long totaldamage = 0; long totalpoints = 0; long mobdamage = 0; long percent = 0; if(!ch || !victim || IS_NPC(ch) || IS_NPC(victim)) return FALSE; update_assist(victim, ch, 1); area = ch->in_room ? ch->in_room->area : 0; kingdom = get_kingdom(ch->pcdata->kingdom); vkingdom = get_kingdom(victim->pcdata->kingdom); points = victim->pcdata->status * number_range(5, 10); points += victim->max_hit / 100; points += is_leader(ch, kingdom->id) ? number_range(0, points) : 0; points /= vkingdom ? 1 : 2; if(kingdom) { kingdom->pks++; kingdom->points += is_at_war(kingdom->id, vkingdom->id) ? points * 2 : points; kingdom->realpoints += is_at_war(kingdom->id, vkingdom->id) ? points * 2 : points; } if(vkingdom) { vkingdom->pds++; if(is_at_war(vkingdom->id, kingdom->id)) { points /= number_range(1, 3); kingdom_message(vkingdom->id, "You are at war with the %s Kingdom and lose %li points!", kingdom->name, points); vkingdom->points -= points; } /* if( calc_rating(vkingdom) < 200 && vkingdom != &kingdom_default && (vkingdom->pds + vkingdom->pks) > 50 ) { kingdom_message(0,buf,"%s has {DDESTROYED{N the %s Kingdom!", ch->name, vkingdom->name ); delete_kingdom(vkingdom->id); } */ } totalpoints = UMAX(1, points); totaldamage = UMAX(1, find_total_assist_damage(victim)); mobdamage = UMAX(1, find_mob_assist_damage(victim)); damage = UMAX(1, find_assist_damage(victim, ch)); percent = (long) UMAX(0, ((float) damage / (float) totaldamage) * 100); points = (long) UMAX(0, (float) totalpoints * ((float) damage / (float) (totaldamage - mobdamage))); kingdom_message(0, "[%s]%s has decapitated [%s]%s for %li(%li) points! (%li%% damage out of %li)", kingdom->name, ch->name, vkingdom->name, victim->name, points, totalpoints, percent, totaldamage); remove_assist(victim, ch); for(assist = victim->pcdata->assist; assist; assist = assist->next) { if(!assist->ch) continue; if(!IS_NPC(assist->ch)) { damage = find_assist_damage(victim, assist->ch); percent = (long) (((float) damage / (float) totaldamage) * 100); points = (long) ((float) totalpoints * ((float) damage / (float) (totaldamage - mobdamage))); kingdom = get_kingdom(assist->ch->pcdata->kingdom); assist->ch->pcdata->assists++; if(kingdom != &kingdom_default) { kingdom->points += points; kingdom->assists++; } kingdom_message(0, "[%s]%s assists for %li points. (%li%% damage)", kingdom->name, assist->ch->name, points, percent); } else { damage = find_assist_damage(victim, assist->ch); percent = (long) (((float) damage / (float) totaldamage) * 100); kingdom_message(0, "[{GMobile{x]%s assists doing %li%% damage.", assist->ch->short_descr, percent); } } while((assist = victim->pcdata->assist)) remove_assist(victim, assist->ch); write_kingdoms(); return points; }