natured.c
来自「C实现的MUD,对大家基本入门网络游戏很有帮助!」· C语言 代码 · 共 1,472 行 · 第 1/4 页
C
1,472 行
if(objectp(room=load_object("/d/quanzhou/zhongxin")) &&
objectp(badguy = new("/quest/feizei/feizei")))
badguy->move(room);
message("channel:chat", HIW"【官府通告】"HIR + "泉州城中今夜有飞贼横行,良民百姓请闭门不出,切莫自误!\n"NOR,users() );
}
if (random(12) == 11)
{
if(objectp(room=load_object("/d/suzhou/baodaiqiao")) &&
objectp(badguy = new("/quest/feizei/feizei")))
badguy->move(room);
message("channel:chat", HIW"【官府通告】"HIR + "苏州城中今夜有飞贼横行,良民百姓请闭门不出,切莫自误!\n"NOR,users() );
}
if (random(12) == 12)
{
if(objectp(room=load_object("/d/xiangyang/guangchang")) &&
objectp(badguy = new("/quest/feizei/feizei")))
badguy->move(room);
message("channel:chat", HIW"【官府通告】"HIR + "襄阳城中今夜有飞贼横行,良民百姓请闭门不出,切莫自误!\n"NOR,users() );
}
}
void event_afternoon()
{
object *ob_list;
int i;
if (random(30)==0)
{
ob_list = children("/d/migong/obj/npc1");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:我回家睡觉也,bye all!\n",ob_list[i]);
message("channel:chat",HIW"【江湖通告】:"
+ob_list[i]->query("name")+"("+ob_list[i]->query("id")+HIW")离开游戏了。本次连线经验增长"+random(800000)+HIW"!\n"NOR,users());
destruct(ob_list[i]);
}
}
ob_list = children("/quest/weiguo/japan/japan1");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/japan/japan2");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/japan/japan3");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/japan/japan4");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,东西也到手了,我闪!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/jinbing/jin1");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/jinbing/jin2");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/jinbing/jin3");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/jinbing/jin4");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,东西也到手了,我闪!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/menggu/mengu1");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/menggu/mengu2");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/menggu/mengu3");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/menggu/mengu4");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,东西也到手了,我闪!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/xixiabing/xixia1");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/xixiabing/xixia2");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/xixiabing/xixia3");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,撤兵!\n",ob_list[i]);
destruct(ob_list[i]);
}
ob_list = children("/quest/weiguo/xixiabing/xixia4");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N说道:天要黑了,东西也到手了,我闪!\n",ob_list[i]);
destruct(ob_list[i]);
}
}
void event_dawn()
{
object *ob_list;
int i;
ob_list = children("/quest/feizei/feizei");
for(i=0; i<sizeof(ob_list); i++)
if(environment(ob_list[i]))
{
message_vision("$N笑道:天亮了,东西也到手了,我闪!\n",ob_list[i]);
destruct(ob_list[i]);
}
}
void event_midnight()
{
string get_month, get_day;
get_day = CHINESE_D->chinese_monthday(TIME_TICK1);
get_month = CHINESE_D->chinese_month(TIME_TICK1);
switch(get_month)
{
//spring weather
case "三":
case "四":
case "五":
switch(random(3))
{
case 0:
day_phase = read_table("/adm/etc/nature/spring_rain");
break;
case 1:
day_phase = read_table("/adm/etc/nature/spring_sun");
break;
case 2:
day_phase = read_table("/adm/etc/nature/spring_wind");
break;
}
break;
//summer weather
case "六":
case "七":
case "八":
switch(random(3))
{
case 0:
day_phase = read_table("/adm/etc/nature/summer_rain");
break;
case 1:
day_phase = read_table("/adm/etc/nature/summer_sun");
break;
case 2:
day_phase = read_table("/adm/etc/nature/summer_wind");
break;
}
break;
//autumn weather
case "九":
case "十":
case "十一":
switch(random(3))
{
case 0:
day_phase = read_table("/adm/etc/nature/autumn_rain");
break;
case 1:
day_phase = read_table("/adm/etc/nature/autumn_sun");
break;
case 2:
day_phase = read_table("/adm/etc/nature/autumn_wind");
break;
}
break;
//winter weather
case "十二":
case "一":
case "二":
switch(random(3))
{
case 0:
day_phase = read_table("/adm/etc/nature/winter_rain");
break;
case 1:
day_phase = read_table("/adm/etc/nature/winter_sun");
break;
case 2:
day_phase = read_table("/adm/etc/nature/winter_wind");
break;
}
break;
default:
day_phase = read_table("/adm/etc/nature/day_phase");
}
// switch(get_day)
// {
// case "一月一日":
// day_phase = read_table("/adm/etc/nature/spring");
// break;
// case "五月五日":
// case "七月七日":
// case "八月十五日":
// case "九月九日":
// case "十二月八日":
// }
}
// This is called everyday noon by update_day_phase, defined in the
// "event_fun" field in /adm/etc/nature/day_phase
void event_noon()
{
object *ob;
int i, skill,con,con1,con2,con3;
string get_month,ill,msg;
get_month = CHINESE_D->chinese_month(TIME_TICK1);
switch(get_month)
{
case "三":
case "四":
case "五":
ill = "ill_kesou";
msg = HIG + "忽然喉头一阵痕痒,你感觉似乎要咳嗽了。\n" + NOR;
break;
case "六":
case "七":
case "八":
ill = "ill_zhongshu";
msg = HIG+"突然你胸臆之间一阵翻腾,你中暑了。\n" + NOR;
break;
case "九":
case "十":
case "十一":
ill = "ill_shanghan";
msg = HIG+"陡的你打了个冷战,头昏沉沉的,你得伤寒病了。\n"+NOR;
break;
case "十二":
case "一":
case "二":
ill = "ill_dongshang";
msg = HIG+"你肢体末端一阵僵直,看来你被冻伤了。\n"+NOR;
break;
}
if(random(2))
{
ill = "ill_fashao";msg = HIG+"你偶感风寒,竟而发起烧来。\n"+NOR;
}
ob = users();
for(i=0; i<sizeof(ob); i++)
{
if( !environment(ob[i]) ) continue;
if( !environment(ob[i])->query("outdoors") ) continue;
if( ob[i]->query("age")==14 ) continue;
con1 = ob[i]->query("qi");
con2 = ob[i]->query("max_qi");
(int)con = con1/con2*50;//形成第一个生病判断条件
con3 = ob[i]->query("neili");
con2 = ob[i]->query("max_neili");
if( con2 == 0) con2 = 1;
(int)con1 = con3/con2*50;//形成第二个生病判断条件
if(random(con)+random(50)+random(con1)<25)
{
ob[i]->apply_condition(ill, 10);
tell_object(ob[i], msg);
}
}
}
string outdoor_room_description()
{
return " " + sprintf(
day_phase[current_day_phase]["desc_msg"],
month_desc[current_month]) + "。\n";
}
string outdoor_room_outcolor()
{
return day_phase[current_day_phase]["outcolor"];
}
string game_time()
{
return CHINESE_D->chinese_date(TIME_TICK1);
}
mapping *read_table(string file)
{
string *line, *field, *format;
mapping *data;
int i, rn, fn;
line = explode(read_file(file), "\n");
data = ({});
for(i=0; i<sizeof(line); i++) {
if( line[i]=="" || line[i][0]=='#' ) continue;
if( !pointerp(field) ) {
field = explode( line[i], ":" );
continue;
}
if( !pointerp(format) ) {
format = explode( line[i], ":" );
continue;
}
break;
}
for( rn = 0, fn = 0; i<sizeof(line); i++) {
if( line[i]=="" || line[i][0]=='#' ) continue;
if( !fn ) data += ({ allocate_mapping(sizeof(field)) });
sscanf( line[i], format[fn], data[rn][field[fn]] );
fn = (++fn) % sizeof(field);
if( !fn ) ++rn;
}
return data;
}
mapping *query_day_phase() { return day_phase; }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?