| 
好友5
 在线时间0 小时
 最后登录2025-10-29
 
 见习骑士 
 
 UID3199602
 第纳尔1172 
 精华0
 互助36 
 荣誉0 
 贡献1 
 魅力227 
 注册时间2020-9-4
 
   鲜花(62 )   鸡蛋(0 ) | 
 
| 本帖最后由 奥杜因阿卡托什 于 2025-8-28 20:58 编辑 
 应某个勾东西的强烈要求,整了这个代码。简单来说,比如对着前方放一个气功波技能,虽然是范围伤害,但是只会对前方一个矩形区域的敌人造成伤害,这个代码就是用于检测敌方是否在该矩形区域中的。
 代码如下
 
 #矩形受击范围判定
 #输入起始点,需要判断的点,效果距离、边长和纵向长度(厘米)
 #比如一个技能能对前方5米、左右不超过两米、高度不超过1.5米范围内的所有敌人造成伤害,就输入5、2、1.5,敌方在玩家前方3米往左1.2米,能够打到,就判定通过
 ("cf_square_area_check", [
 (store_script_param, ":anchor_pos", 1),#起始点pos
 (store_script_param, ":check_pos", 2),#需要判定的点pos
 (store_script_param, ":skill_length", 3),#攻击距离(往前)
 (store_script_param, ":skill_width", 4),#攻击范围(左右)
 (store_script_param, ":skill_height", 5),#技能高度(为了避免在一楼放技能打到五楼的情况出现,实际填个2米就行)
 
 (set_fixed_point_multiplier, 100),
 (position_transform_position_to_local, ":check_pos", ":anchor_pos", ":check_pos"),
 (position_get_x, ":count_no", ":check_pos"),#左右
 (val_abs, ":count_no"),
 (le, ":count_no", ":skill_width"),
 (position_get_y, ":count_no", ":check_pos"),#前方
 (le, ":count_no", ":skill_length"),
 (position_get_z, ":count_no", ":check_pos"),#上下
 (val_abs, ":count_no"),
 (le, ":count_no", ":skill_height"),
 ]),
 
 
 使用例比如
 
 
         (eq, ":active_skill_no", "itm_active_ground_heaving"),#掀地          (try_for_agents, ":beattacked_agent_no", pos1, 700),             (agent_is_alive, ":beattacked_agent_no"),             (neq, ":beattacked_agent_no", ":attacker_agent_no"),             (agent_get_position, pos2, ":beattacked_agent_no"),             (call_script, "script_cf_square_area_check", pos1, pos2, 400, 150, 150),             (agent_deliver_damage_to_agent, ":attacker_agent_no", ":beattacked_agent_no", 100),#造成伤害          (try_end), 
 
 
 | 
 
  |