中国虚拟军事网(VME)- 专注于武装突袭系列虚拟军事游戏

 找回密码
 加入VME

QQ登录

只需一步,快速开始

搜索
查看: 5942|回复: 15

[求助] 如何用脚本获得楼顶的高度?

[复制链接]
发表于 2013-3-23 23:23:07 | 显示全部楼层 |阅读模式
以前在A2中,只要把trigger放在一个楼房上,然后读这个trigger的pos,就能拿到这个楼房房顶的高度了。因为trigger默认是放在object”上面的“。但是现在A3的楼房都可以进去了,所以这个方法就没用了,getPos拿到的只是楼房内部的pos。请问有人知道其他的方法吗?
发表于 2013-3-23 23:37:33 | 显示全部楼层
-.-去Holic下个3D编辑器 A3能用的 昨天刚出的 你就知道了
发表于 2013-3-23 23:39:58 | 显示全部楼层
发表于 2013-3-24 00:38:04 | 显示全部楼层
楼主要的似乎不是三D编辑器啊~~

如果按楼主这样说似乎是比原来麻烦点了~~设置一个 单位让他无敌然后setpos 到 30 米高【反正就超过房子高度】

然后等他摔到房顶了~再getpos{:soso_e113:}
发表于 2013-3-24 00:45:29 | 显示全部楼层
-.-3D编辑器实时显示三维坐标呢...你这样还不知道高度?
 楼主| 发表于 2013-3-24 09:11:11 | 显示全部楼层
下网上载 发表于 2013-3-24 00:38
楼主要的似乎不是三D编辑器啊~~

如果按楼主这样说似乎是比原来麻烦点了~~设置一个 单位让他无敌然后setp ...

这个方法以前看过。就是摔下来太慢了。。。。
 楼主| 发表于 2013-3-24 09:12:48 | 显示全部楼层
rasy 发表于 2013-3-24 00:45
-.-3D编辑器实时显示三维坐标呢...你这样还不知道高度?

我用脚本是为了整合到插件里,让单兵能够在游戏过程中跑到楼顶进行埋伏,侦查或狙击。所以必须用脚本实现.

但还是谢谢了! 这个3d编辑器看起来也不错
发表于 2013-3-24 09:13:30 | 显示全部楼层
2fast 发表于 2013-3-24 09:11
这个方法以前看过。就是摔下来太慢了。。。。

有时候还会摔死。。
不过多测试几遍吧,高度就设置的准确了,虽然是笨方法,,
发表于 2013-3-24 09:51:58 | 显示全部楼层
2fast 发表于 2013-3-24 09:12
我用脚本是为了整合到插件里,让单兵能够在游戏过程中跑到楼顶进行埋伏,侦查或狙击。所以必须用脚本实现 ...

我觉得你这个是瞬移上楼的脚本吧??玩家自己用动作菜单上楼~貌似是
发表于 2013-3-24 10:59:27 | 显示全部楼层
那天那个谁不是说新版编辑器中有个记录玩家操作动作的脚本么????
发表于 2013-3-24 11:05:16 | 显示全部楼层
  1. _c = 0;  while {format ["%1", (nearestBuilding this) buildingPos _c] != "[0,0,0]"} do {_c = _c + 1}; hint str (((nearestBuilding this) buildingpos (_c - 1)) select 2)
复制代码
返还可用建筑点最高值,不适用于已毁建筑,或建模中未定义位点的建筑。
 楼主| 发表于 2013-3-24 20:49:08 | 显示全部楼层
FFUR2007SLX2_5 发表于 2013-3-24 11:05
返还可用建筑点最高值,不适用于已毁建筑,或建模中未定义位点的建筑。

多谢,这就去测试!
 楼主| 发表于 2013-3-24 21:39:11 | 显示全部楼层
FFUR2007SLX2_5 发表于 2013-3-24 11:05
返还可用建筑点最高值,不适用于已毁建筑,或建模中未定义位点的建筑。

测试了一下,这个只是返还定义了的buildingPos。其实我要的是屋顶的pos,一般是没有被定义的。
发表于 2013-3-24 22:38:14 | 显示全部楼层
本帖最后由 FFUR2007SLX2_5 于 2013-3-24 22:57 编辑
  1. c_fnc_getBuildingPositions = {
  2.         private ["_fnc_checkLOS", "_b", "_offset", "_aslPos", "_bBox", "_bBoxWidth", "_bBoxDepth", "_bBoxHeight", "_searchW", "_searchH", "_notVisable", "_visFromSide", "_visFromAbove", "_i", "_bP", "_xPos", "_visIndex", "_p"];
  3.         _fnc_checkLOS = {
  4.                 private ["_b", "_pos", "_width", "_height", "_facing", "_return", "_aPos", "_blockingObjects", "_nrVis", "_numChecks", "_dirDif", "_i", "_c", "_xDir", "_sidePos"];
  5.                 _b                 = _this select 0;
  6.                 _pos         = ATLtoASL (_this select 1);
  7.                 _width        = _this select 2;
  8.                 _height        = _this select 3;
  9.                
  10.                 _facing = getDir _b;
  11.                
  12.                 _return = 0;
  13.        
  14.                 _aPos = [_pos select 0, _pos select 1, (_pos select 2) + _height];
  15.                 _blockingObjects = lineIntersectsWith [_pos, _aPos];
  16.                
  17.                 if( !(_b in _blockingObjects) ) then {
  18.                         _return = 2;
  19.                 } else {
  20.                         _nrVis = 4;
  21.                         _numChecks = 12;
  22.                         _dirDif = 360/_numChecks;
  23.                         _i = 0;
  24.                         _c = 0;
  25.                         while {_i < _numChecks && _c < _nrVis} do {
  26.                                 _xDir = _facing + _dirDif*_i;
  27.                                 _sidePos = [(_pos select 0)+(_width*sin _xDir), (_pos select 1)+(_width*cos _xDir), _pos select 2];
  28.                                
  29.                                 _blockingObjects = lineIntersectsWith [_pos, _sidePos];
  30.                                 if (!(_b in _blockingObjects)) then {
  31.                                         _c = _c + 1;
  32.                                 } else {
  33.                                         _c = 0;
  34.                                 };
  35.                                
  36.                                 _i = _i + 1;
  37.                         };
  38.                        
  39.                         if(_c == _nrVis) then {
  40.                                 _return = 1;
  41.                         };
  42.                 };               
  43.                 _return
  44.         };
  45.        
  46.         if(typeName _this == typeName []) then {
  47.                 _b                         = _this select 0;
  48.                 _offset         = if(count _this > 1) then { _this select 1 } else { 1.5 };

  49.                 _aslPos         = getPosASL _b;
  50.                 _bBox                 = boundingBox _b;
  51.                
  52.                 _bBoxWidth         = ((_bBox select 1) select 0) - ((_bBox select 0) select 0);
  53.                 _bBoxDepth         = ((_bBox select 1) select 1) - ((_bBox select 0) select 1);
  54.                 _bBoxHeight = ((_bBox select 1) select 2) - ((_bBox select 0) select 2);
  55.                
  56.                 _searchW         = if(_bBoxWidth > _bBoxDepth) then {_bBoxWidth} else {_bBoxDepth};
  57.                 _searchH        = _bBoxHeight;
  58.                
  59.                 _notVisable         = [];
  60.                 _visFromSide        = [];
  61.                 _visFromAbove        = [];
  62.                
  63.                 _i  = 0;
  64.                 _bP = _b buildingPos _i;       
  65.                 while {{_x != 0} count _bP > 0} do {
  66.                         _xPos = [_bP select 0, _bP select 1, (_bP select 2) + _offset];
  67.                         _visIndex = [_b, _xPos, _searchW, 50] call _fnc_checkLOS;
  68.                         switch (_visIndex) do {
  69.                                 case 0: {
  70.                                         _notVisable set [count _notVisable, _bP];
  71.                                 };
  72.                                 case 1: {
  73.                                         _visFromSide set [count _visFromSide, _bP];
  74.                                 };
  75.                                 case 2: {
  76.                                         _visFromAbove set [count _visFromAbove, _bP];
  77.                                 };
  78.                                 default {
  79.                                         diag_log text format ["c_fnc_getBuildingPositions - Invalid _visIndex: %1", _visIndex];
  80.                                 };
  81.                         };
  82.                         _i = _i + 1;
  83.                         _bP = _b buildingPos _i;
  84.                 };
  85.                 //Return
  86.                 [_notVisable, _visFromSide, _visFromAbove]
  87.                
  88.         } else {
  89.                 _b         = _this;
  90.                 _p         = [];
  91.                 _i  = 0;
  92.                 _bP = _b buildingPos _i;       
  93.                 while {{_x != 0} count _bP > 0} do {
  94.                         _p set [count _p, _bP];
  95.                         _i = _i + 1;
  96.                         _bP = _b buildingPos _i;
  97.                 };
  98.                 _p       
  99.         }
  100. };
复制代码
这里返还房屋最高的屋顶坐标,使用以下调用:
  1. hint format ["%1",((nearestBuilding this) call c_fnc_getBuildingPositions) select 2];
复制代码
注:受模型限制,某些房屋不具备屋顶坐标,所以只能搜索到最高的阳台坐标或最高的窗口坐标。对于模型非定义坐标获取屋顶高度则自己加码调节:
  1. player setpos [(((thislist select 0) call c_fnc_getBuildingPositions) select 2) select 0,(((thislist select 0) call c_fnc_getBuildingPositions) select 2) select 1,((((thislist select 0) call c_fnc_getBuildingPositions) select 2) select 2) + 2]
复制代码
PS以上是单个位置,若count (((nearestBuilding this) call c_fnc_getBuildingPositions) select 2) > 1那就可以selectRandom.
发表于 2013-3-24 22:43:52 | 显示全部楼层
FFUR2007SLX2_5 发表于 2013-3-24 22:38
这里返还房屋最高的屋顶坐标,使用以下调用:

咦?这个返还的是 XYZ 还是 一个高度值~~~? 还是一幢房的房顶位置?
您需要登录后才可以回帖 登录 | 加入VME

本版积分规则

小黑屋|中国虚拟军事网

GMT+8, 2024-4-27 09:13

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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