本帖最后由 快乐风猫 于 2024-3-9 00:16 编辑
重新优化了代码并解决了bug,人头税设置中心的领主每周获得中心人口同等的第纳尔,就是人头税,可以根据自己喜好更改,至于玩家的城堡如果交不上钱欠税的部分,这部分有很多种用处,所以我就不贴上来了,每周欠缴的税存在slot_town_fuzhai里,可以按照自己的想法来调用
2个新的slot
- slot_town_renkou = 700
- slot_town_fuzhai = 701
复制代码
3个主体脚本
- #中心人口
- ("cf_center_renkou",
- [
- (store_script_param_1, ":center_no"),
-
- (party_get_slot, ":renkou", ":center_no", slot_town_renkou),
- (party_get_slot, ":prosperity", ":center_no", slot_town_prosperity),
- (store_div,":fanrong",":prosperity",20),
-
- (try_begin),
- (party_slot_eq, ":center_no", slot_party_type, spt_town),
- (store_random_in_range, ":shu1", 200, 500),
- (try_begin),
- (eq,":fanrong",0),
- (val_mul,":shu1",5),
- (val_sub,":renkou",":shu1"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",1),
- (val_mul,":shu1",3),
- (val_sub,":renkou",":shu1"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",2),
- (val_mul,":shu1",1),
- (val_add,":renkou",":shu1"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",3),
- (val_mul,":shu1",3),
- (val_add,":renkou",":shu1"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (gt,":fanrong",3),
- (val_mul,":shu1",5),
- (val_add,":renkou",":shu1"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (try_end),
- (else_try),
- (party_slot_eq, ":center_no", slot_party_type, spt_castle),
- (store_random_in_range, ":shu2", 50, 100),
- (try_begin),
- (eq,":fanrong",0),
- (val_mul,":shu2",5),
- (val_sub,":renkou",":shu2"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",1),
- (val_mul,":shu2",3),
- (val_sub,":renkou",":shu2"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",2),
- (val_mul,":shu2",1),
- (val_add,":renkou",":shu2"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",3),
- (val_mul,":shu2",3),
- (val_add,":renkou",":shu2"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (gt,":fanrong",3),
- (val_mul,":shu2",5),
- (val_add,":renkou",":shu2"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (try_end),
- (else_try),
- (party_slot_eq, ":center_no", slot_party_type, spt_village),
- (store_random_in_range, ":shu3", 10, 20),
- (try_begin),
- (eq,":fanrong",0),
- (val_mul,":shu3",5),
- (val_sub,":renkou",":shu3"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",1),
- (val_mul,":shu3",3),
- (val_sub,":renkou",":shu3"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",2),
- (val_mul,":shu3",1),
- (val_add,":renkou",":shu3"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (eq,":fanrong",3),
- (val_mul,":shu3",3),
- (val_add,":renkou",":shu3"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (else_try),
- (gt,":fanrong",3),
- (val_mul,":shu3",5),
- (val_add,":renkou",":shu3"),
- (party_set_slot, ":center_no", slot_town_renkou, ":renkou"),
- (try_end),
- (try_end),
- ]),
- #每周上交人头税
- ("cf_get_center_shui_npc",
- [
- (try_for_range, ":center_no", centers_begin, centers_end),
- (try_for_range, ":lord", active_npcs_begin, active_npcs_end),
- (party_slot_eq, ":center_no", slot_town_lord, ":lord"),
- (troop_get_slot, ":cur_wealth", ":lord", slot_troop_wealth),
- (troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
-
- (party_get_slot, ":center_wealth", ":center_no", slot_town_wealth),#获取中心财产
- (party_get_slot, ":center_renkou", ":center_no", slot_town_renkou),#获取中心人口
- (gt,":center_wealth",0),#是有财产的
- (gt,":center_renkou",0),#是有人口的
-
- (try_begin),
- (ge,":center_wealth",":center_renkou"),#如果中心有足够的钱交税
- (val_add,":cur_wealth",":center_renkou"),
- (troop_set_slot, ":center_no", slot_troop_wealth, ":cur_wealth"),#领主获得税钱
- (val_sub,":center_wealth",":center_renkou"),
- (party_set_slot, ":center_no", slot_town_wealth, ":center_wealth"),#中心减去税钱
- (else_try),
- (lt,":center_wealth",":center_renkou"),#如果中心没有足够的钱交税
- (store_sub,":qiankuan",":center_renkou",":center_wealth"),#获取交不起的税款部分
- (val_add,":cur_wealth",":center_wealth"),
- (troop_set_slot, ":lord", slot_troop_wealth, ":cur_wealth"),#领主收走所有税
- (val_div,":qiankuan",2),
- (party_set_slot, ":center_no", slot_town_renkou, ":qiankuan"),#中心失去未交税的50%人口
- (party_set_slot, ":center_no", slot_town_wealth, 0),
- (try_end),
- (try_end),
- (try_end),
- ]),
- #每周上交人头税
- ("cf_get_center_shui",
- [
- (try_for_range, ":center_no", centers_begin, centers_end),
- (party_slot_eq, ":center_no", slot_town_lord, "trp_player"),
-
- (party_get_slot, ":center_wealth", ":center_no", slot_town_wealth),#获取中心财产
- (party_get_slot, ":center_renkou", ":center_no", slot_town_renkou),#获取中心人口
- (party_get_slot, ":center_fuzhai", ":center_no", slot_town_fuzhai),#获取中心负债
- (gt,":center_wealth",0),#是有财产的
- (gt,":center_renkou",0),#是有人口的
-
- (try_begin),
- (ge,":center_wealth",":center_renkou"),#如果中心有足够的钱交税
- (troop_add_gold,"trp_player",":center_renkou"),
- (val_sub,":center_wealth",":center_renkou"),
- (party_set_slot, ":center_no", slot_town_wealth, ":center_wealth"),
- (str_store_party_name_link,s10,":center_no"),
- (assign,reg1,":center_renkou"),
- (display_message,"@{s10}上 交 了 {reg1}的 税 款 。",0xFFAAFFAA),
- (else_try),
- (lt,":center_wealth",":center_renkou"),#如果中心的钱不够交税
- (store_sub,":qiankuan",":center_renkou",":center_wealth"),#获取交不起的税款部分
- (troop_add_gold,"trp_player",":center_wealth"),#玩家收走中心所有的钱
- (val_add,":center_fuzhai",":qiankuan"),#开始累计欠税
- (party_set_slot, ":center_no", slot_town_fuzhai, ":center_fuzhai"),
- (party_set_slot, ":center_no", slot_town_wealth, 0),
- (assign,reg1,":qiankuan"),
- (assign,reg2,":center_wealth"),
- (assign,reg3,":center_fuzhai"),
- (str_store_party_name_link,s10,":center_no"),
- (display_message,"@{s10}上 交 了 {reg2}的 税 款 ,还 剩 余 {reg1}的 税 款 未 交 ,{s10}现 在 已 经 累 计 拖 欠 了 {reg3}的 税 款 。",0xFFFF0000),
- (try_end),
- (try_end),
- ]),
复制代码
2个简单触发器,给中心额外收入是我自己测试用的
- #中心每周额外收入
- (24*7,
- [
- (try_for_range, ":centers", centers_begin, centers_end),
- (party_get_slot, ":cur_wealth", ":centers", slot_town_wealth),
- (party_get_slot, ":prosperity", ":centers", slot_town_prosperity),
- (val_mul,":prosperity",10),
- (val_add,":cur_wealth",":prosperity"),
- (party_set_slot, ":centers", slot_town_wealth, ":cur_wealth"),
- (try_end),
- ]),
- #中心每周更新人口+上人头税
- (24*7,
- [
- (try_for_range, ":centers", centers_begin, centers_end),
- (call_script, "script_cf_center_renkou", ":centers"),
- (try_end),
-
- (call_script, "script_cf_get_center_shui_npc"),
- (call_script, "script_cf_get_center_shui"),
- ]),
复制代码
1个查看状况的脚本,加在game_context_menu_get_buttons最下面
- (try_begin),
- (is_between, ":party_no", centers_begin, centers_end),
- (party_get_slot, ":center_renkou", ":party_no", slot_town_renkou),
- (assign,reg1,":center_renkou"),
- (context_menu_add_item, "@常 住 人 口 : {reg1}"),
- (try_end),
-
- (try_begin),
- (is_between, ":party_no", centers_begin, centers_end),
- (party_get_slot, ":center_fuzhai", ":party_no", slot_town_fuzhai),
- (gt,":center_fuzhai",1),
- (assign,reg2,":center_fuzhai"),
- (context_menu_add_item, "@未 缴 税 款 : {reg2}"),
- (try_end),
复制代码
|