骑马与砍杀中文站论坛

 找回密码
 注册(Register!)

QQ登录

只需一步,快速开始

搜索
购买CDKEY 衣谷三国
查看: 1583|回复: 2

[功能与代码] 近战武器弹开飞矢

[复制链接]

22

主题

123

回帖

59

积分

扈从

Rank: 2Rank: 2

UID
3084588
第纳尔
68
精华
0
互助
3
荣誉
0
贡献
0
魅力
1
注册时间
2019-6-29
鲜花(8) 鸡蛋(0)
发表于 2025-4-26 14:29:49 | 显示全部楼层 |阅读模式
本帖最后由 咸鱼圣代 于 2025-5-4 13:42 编辑

灵感来自 星球大战征服 - 新秩序 当中的kham_lightsaber_deflection,其源码已在制作者建立的discord群组中放出

效果就是正面打过来的任何飞行物都会等于没打,然后随机方向创建一个飞行物出去模拟玩家弹开了它的感觉。

不过声音效果不触发,我也不知道怎么回事。
2025.5.4
今天交流了一下,感谢夜幕(1403AD作者)提供的方法,在使用

agent_play_sound                         = 1750  # (agent_play_sound, <agent_id>, <sound_id>),
                                                 # Makes the agent emit the specified sound. Gets synchronized by game engine automatically if called on server. Works appearantly the same way as with particle effects, it's getting cut off at a specific distance, up4research.

之后声音顺利触发了

我不是专门搞战场触发器的,所以有些东西我也不是很清楚怎么做到的,但反正改了一些触发条件和判定,在我自己玩的模组里面也能顺利触发了,也不跳红字。

注释是我自己写的



    (ti_on_agent_hit, 0.000000, 0.000000,
    [
        (store_trigger_param, ":agent_no", 1),
        (get_player_agent_no, ":player_agent_no"),
        (eq, ":agent_no", ":player_agent_no"),#Deflecting is for player only.
        (store_trigger_param, ":missile_item_no", 5),
        (gt, ":missile_item_no", 0),#Proceed only if a missile is hitting the player.
        (agent_get_wielded_item, ":player_right_hand_equipment", ":agent_no", 0),#Make sure player is wielding melee weapon.
        (this_or_next|item_has_property, ":player_right_hand_equipment", itp_type_one_handed_wpn),
        (this_or_next|item_has_property, ":player_right_hand_equipment", itp_type_two_handed_wpn),
        (item_has_property, ":player_right_hand_equipment", itp_type_polearm),
        (agent_get_wielded_item, ":player_left_hand_equipment", ":agent_no", 1),#And player is not holding a shield.
        (eq, ":player_left_hand_equipment", -1),
        (agent_get_defend_action, ":defending", ":agent_no"),#Get player's current defending state.
        (gt, ":defending", 0),#If player is parrying or blocking.
        (position_move_y, pos0, -1000),#This and the following are supposed to make sure the incoming projectile is coming from player's front, though I don't understand it all.
        (agent_get_look_position, pos22, ":agent_no"),
        (position_transform_position_to_local, pos2, pos22, pos0),#Checking if Y position is meeting the requirement.
        (position_get_y, ":y", pos2),
        (ge, ":y", 0),#Proceed if yes.
        (assign, reg0, ":attacker_weapon"),
    ],
    [
        (assign, ":attacker_weapon", reg0),#Getting the attacker's weapon from trigger condition.
        (store_trigger_param, ":agent_no", 1),#Get basic data.
        (store_trigger_param, ":damage_value", 3),
        (store_trigger_param, ":missile_item_no", 5),#Data collecting finished.
        (get_player_agent_no, ":player_agent_no"),#Again checking the agent that's about to perform a deflection is player, but it's checked above, why here again?
        (eq, ":agent_no", ":player_agent_no"),
        (item_get_missile_speed, ":velocity", ":attacker_weapon"),#Getting velocity of attacker's weapon.
        (agent_get_look_position, pos22, ":agent_no"),#Get player's looking position to pos22, where the player is facing.
        (position_move_y, pos22, 100, 0),#Moving pos22 100 forward for spawning the deflected projectile later.
        (try_begin),#Further tweaking pos22 based on player's riding something or not.
            (agent_get_horse, ":mount", ":agent_no"),#If player has a mount, moving pos22 240 more forward,
            (neq, ":mount", -1),
            (position_move_z, pos22, 240, 0),
        (else_try),#If no mount, then 150 more forward.
            (position_move_z, pos22, 150, 0),
        (try_end),
        (store_random_in_range, ":rand_x", 80, 200),#This is probably for spawned flying objects trajectory randomizing initialization.
        (store_random_in_range, ":rand_z", 80, 280),
        (agent_get_defend_action, ":defending", ":agent_no"),#Again getting players defending state.
        (gt, ":defending", 0),
        (try_begin),
            (assign, ":damage_value", 0),#Incoming projectile will be neutralized.
            (val_sub, ":velocity", 100),#Make the spawned deflected projectile 100 slower in speed.
            (val_sub, ":rand_x", 200),#Making some extra tweaking for flying direction.
            (val_min, ":rand_x", 0),
            (val_sub, ":rand_z", 280),
            (val_min, ":rand_z", 0),#Tweaking end.
            (position_rotate_x, pos22, ":rand_x"),#Finally applying the calculation result of projectile's trajectory.
            (position_rotate_z, pos22, ":rand_z"),
            (set_fixed_point_multiplier, 1),#What is this?
            (add_missile, ":agent_no", pos22, ":velocity", ":attacker_weapon", 0, ":missile_item_no", 0),#Spawning another projectile based on the deflected one at random direction.
            (agent_set_animation, ":agent_no", "anim_projectile_deflection", 1),#Playing the deflecting animation.
            #(play_sound, "snd_hit_wood_wood"),
            (agent_play_sound, ":agent_no", "snd_hit_wood_wood"),
        (try_end),
        (set_trigger_result, ":damage_value"),#Setting damage player is about to recieve.
        (assign, reg0, ":attacker_weapon"),
    ]),


动作的话,用的都是战团本身里面就有的素材,我是改txt的,所以我只放我调过的txt码,在brf里面应该都搜得到。

projectile_deflection 0 33554448  4
  0.600000 parry_attack_thrust_onehanded 12 30 9 0 0.000000 0.000000 0.000000 0.000000
  0.600000 parry_attack_slashleft_onehanded 5 24 9 0 0.000000 0.000000 0.000000 0.000000
  0.600000 parry_attack_slashright_onehanded 3 20 9 0 0.000000 0.000000 0.000000 0.000000
  0.600000 defend_up_onehanded 10 20 9 0 0.000000 0.000000 0.000000 0.000000


战场触发器的txt:

-28.000000 0.000000 0.000000  20 2070 2 1224979098644774912 1 1700 1 1224979098644774913 31 2 1224979098644774912 1224979098644774913 2070 2 1224979098644774914 5 32 2 1224979098644774914 0 1726 3 1224979098644774915 1224979098644774912 0 1073744547 2 1224979098644774915 2 1073744547 2 1224979098644774915 3 2723 2 1224979098644774915 4 2133 2 72057594037927999 1224979098644774915 1726 3 1224979098644774916 1224979098644774912 1 31 2 1224979098644774916 -1 1764 2 1224979098644774917 1224979098644774912 32 2 1224979098644774917 0 721 2 0 -1000 1709 2 22 1224979098644774912 717 3 2 22 0 727 2 1224979098644774918 2 30 2 1224979098644774918 0 2133 2 72057594037927936 1224979098644774919  36 2133 2 1224979098644774912 72057594037927936 2070 2 1224979098644774913 1 2070 2 1224979098644774914 3 2070 2 1224979098644774915 5 1700 1 1224979098644774916 31 2 1224979098644774913 1224979098644774916 2709 2 1224979098644774917 1224979098644774912 1709 2 22 1224979098644774913 721 3 22 100 0 4 0 1714 2 1224979098644774918 1224979098644774913 2147483679 2 1224979098644774918 -1 722 3 22 240 0 5 0 722 3 22 150 0 3 0 2136 3 1224979098644774919 80 200 2136 3 1224979098644774920 80 280 1764 2 1224979098644774921 1224979098644774913 32 2 1224979098644774921 0 4 0 2133 2 1224979098644774914 0 2106 2 1224979098644774917 100 2106 2 1224979098644774919 200 2110 2 1224979098644774919 0 2106 2 1224979098644774920 280 2110 2 1224979098644774920 0 723 2 22 1224979098644774919 725 2 22 1224979098644774920 2124 1 1 1829 7 1224979098644774913 22 1224979098644774917 1224979098644774912 0 1224979098644774915 0 1740 3 1224979098644774913 1801439850948199070 1 600 1 1152921504606847072 3 0 2075 1 1224979098644774914 2133 2 72057594037927936 1224979098644774912


我猜应该是全模组通用的,我没有添加任何不存在于战团本体中的数据。

232

主题

3065

回帖

1629

积分

骑士长

中级译典官

Rank: 5Rank: 5Rank: 5

UID
2572488
第纳尔
4642
精华
0
互助
122
荣誉
3
贡献
355
魅力
306
注册时间
2015-8-1

骑砍中文站APP会员勋章原版正版勋章战团正版勋章火与剑正版勋章拿破仑正版勋章维京征服正版勋章汉匈决战正版勋章霸主正版勋章骑士美德之英勇勋章[杰出会员活跃勋章]骑士美德之仁慈勋章[杰出会员互助勋章]骑士美德之奉献勋章元老骑士勋章丝绸之路勋章

QQ
鲜花(424) 鸡蛋(200)
发表于 2025-4-26 18:37:26 来自手机 | 显示全部楼层
牛啊 铁汁来自: iPhone客户端

16

主题

130

回帖

204

积分

见习骑士

Rank: 3

UID
3304622
第纳尔
690
精华
0
互助
26
荣誉
3
贡献
0
魅力
158
注册时间
2021-12-28
鲜花(31) 鸡蛋(0)
发表于 2025-4-26 22:22:50 | 显示全部楼层
确实是个不错的代码思路
您需要登录后才可以回帖 登录 | 注册(Register!)

本版积分规则

Archiver|手机版|小黑屋|骑马与砍杀中文站

GMT+8, 2025-9-4 03:23 , Processed in 0.092575 second(s), 23 queries , Gzip On, MemCached On.

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表