![]() |
![]() |
#1 |
高级会员
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() 注册: 08年04月11日
来自: 盘丝洞
帖子: 311
声望力: 20
声望:
50
![]() 现金:29两梁山币
资产:1245两梁山币
致谢数: 0
获感谢文章数:0
获会员感谢数:0 |
定时发放礼物
发信人: xuejun (发呆中.........), 信区: wiz 标 题: 欢乐英雄生日礼物系统的实现 发信站: 交大兵马俑BBS站 (Wed Dec 1 08:16:31 1999), 转信 在欢乐英雄中可以自动发放生日礼物, 这主要是由/adm/daemons/herotimed.c和/feature/damage.c两个文件控制完成的. 以下是herotimed.c的全部程序. //欢乐英雄 // herotimed.c //by lion@hero #include #define ZERO_TIME 942940800 //定义元年一月一日一时一刻的时间,此处设定为1999 年11月19日零时整. #define ONE_YEAR_TIME 172800 //每年所需要的时间,这里为48小时 inherit F_CLEAN_UP; mapping check_time(int time_now); string check_season(); string check_usr_birthday(object ob); //此函数把time_now换算成欢乐英雄时间。 mapping check_time(int time_now) { int t; int year,month,day,hour,quarter; mapping date; string time; t = time_now-ZERO_TIME; if(t>=0){ time = "英雄"; year = t / ONE_YEAR_TIME; t -=year*ONE_YEAR_TIME; } else { time ="英雄前"; t =(-1)*t; year =t / ONE_YEAR_TIME; t = ONE_YEAR_TIME - (t-year*ONE_YEAR_TIME); } month = t/(30*480); t -=month*30*480; day =t/480; t -=day*480; hour =t/20; t -=hour*20; quarter =t/5; //此处年月日需要加一. year++; month++; day++; date =([ "YEAR" : time+((year==1)?"元":chinese_number(year)) + "年", "MONTH" : (month==1)?"元":chinese_number(month) +"月", "DAY" : chinese_number(day) +"日", "HOUR" : chinese_number(hour) +"时", "QUARTER" : (!quarter)?"":chinese_number(quarter)+"刻", ]); return date; } //返回现在的季节。 string check_season() { string month; string season; mapping date=check_time(time()); month=date["MONTH"]; if(month=="元月"||month=="十一月"||month=="十二月") season="冬季"; return season; } //把玩家生日转换成欢乐英雄时间。 string check_usr_birthday(object ob) { mapping date=check_time(ob->query("birthday")); return date["MONTH"]+date["DAY"]; } 以下是damage.c的部分程序 int heal_up() { ............ .... //added by lion@hh,按时发放生日礼物。 if(userp(me=this_object())) //首先确保这是玩家。 //确保离上次分礼物已经超过一年。 if((me->query("mud_age")-(int)me->query("gift/birthday_gift"))>=172800){ date=HEROTIME_D->check_time(time()); day=date["MONTH"]+date["DAY"]; if(day==HEROTIME_D->check_usr_birthday(me)){ message("system", "\n\n今天是欢乐英雄纪年"+day+",\n" +"让我们衷心祝愿"+me->query("name")+"生日快乐!\n" +HIY"HAPPY BIRTHDAY TO YOU,"+me->query("id")+"!!!\n\n"NOR, users()); gift=new("/obj/example/birthday_gift"); if(gift){ gift->move(me); me->set("gift/birthday_gift",me->query("mud_age")); } } } //发礼物程序结束。 ............ .... } |
![]() |
![]() |