Menu

Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Show posts Menu

Topics - vitovc

#1

This script can be helpful in development to draw npc paths, visualize raytrace or just for laser rifle feature.

::line3d <- {
  "list" : {},
  "del" : function(id){
    if(::line3d.list.rawin(id)){
      return ::line3d.list.rawdelete(id);
    }
  },
  "set" : function(id, color, from, to){
    if(::line3d.list.rawin(id)){
      return ::line3d.update(id, from, to);
    }
    local item = {
      "id" : id,
      "pos" : {
        "from" : ::Vector(0, 0, 0),
        "to" : ::Vector(0, 0, 0)
      },
      "dist" : 0
      "raw" : []
    }
    for(local j = 0; j < 4; j++){
      local ca = ::GUICanvas();
      ca.Colour = color;
      ca.Position = ::VectorScreen(0, 0);
      ca.Size = ::VectorScreen(1, 1);
      ca.AddFlags(GUI_FLAG_BACKGROUND | GUI_FLAG_3D_ENTITY);
      ca.Position3D = ::Vector(0.0,0.0,0.0);
      ca.Rotation3D = ::Vector(0.0,0.0,0.0);
      if(j < 2){
        ca.Size3D = ::Vector(0.01, 0.01, 0.0);
      } else {
        ca.Size3D = ::Vector(0.01, 0.01, 0.0);
      }
      item.raw.push(ca);
    }
    ::line3d.list.rawset(id, item);
    return ::line3d.update(id, from, to);
  },
  "update" : function(id, from, to){
    if(::line3d.list.rawin(id)){
      local item = ::line3d.list.rawget(id);
      item.pos.from = ::Vector(from.X, from.Y, from.Z);
      item.pos.to = ::Vector(to.X, to.Y, to.Z);
      item.dist = ::line3d.dist_3d(from.X, from.Y, from.Z, to.X, to.Y, to.Z);

      local lp2 = item.pos.from;
      local lp = item.pos.to;
      local fp = ::Vector(lp2);
      local fp0 = ::Vector(lp);

      for(local j = 0; j < 4; j++){
        if(0 == j){
          local rot = ::line3d.rotate1(lp.X, lp.Y, lp.Z, lp2.X, lp2.Y, lp2.Z);
          rot.X += -1.570796;
          item.raw[j].Rotation3D = ::Vector(rot);
          local pitch = rot.X;
          local yaw = rot.Z;
          local rel_y = 1;
          local reloffset = sin(pitch) + 1;
          local X = fp.X + -0.005 * cos(yaw) - ((rel_y * -2) + rel_y + reloffset) * sin(yaw);
          local Y = fp.Y + -0.005 * sin(yaw) + ((rel_y * -2) + rel_y + reloffset) * cos(yaw);
          local Z = fp.Z + 1 + cos(pitch) * -1;
          item.raw[j].Size3D.Y = item.dist;
          item.raw[j].Position3D = ::Vector(X, Y, Z);
        } else if(1 == j){
          local rot = ::line3d.rotate1(lp.X, lp.Y, lp.Z, lp2.X, lp2.Y, lp2.Z);
          rot.X += 1.570796;
          item.raw[j].Rotation3D = ::Vector(rot);
          local pitch = rot.X;
          local yaw = rot.Z;
          local rel_y = 1;
          local reloffset = sin(pitch) + 1;
          local X = fp0.X + -0.005 * cos(yaw) - ((rel_y * -2) + rel_y + reloffset) * sin(yaw);
          local Y = fp0.Y + -0.005 * sin(yaw) + ((rel_y * -2) + rel_y + reloffset) * cos(yaw);
          local Z = fp0.Z + 1 + cos(pitch) * -1;
          item.raw[j].Size3D.Y = item.dist;
          item.raw[j].Position3D = ::Vector(X, Y, Z);
        } else if(2 == j){
          local rot = ::line3d.rotate2(lp.X, lp.Y, lp.Z, lp2.X, lp2.Y, lp2.Z);
          rot.X += -1.570796;
          item.raw[j].Rotation3D = ::Vector(rot);
          local pitch = rot.X;
          local yaw = rot.Z;
          local rel_y = 1;
          local reloffset = sin(pitch) + 1;
          local X = fp.X + -0.005 * cos(yaw) - ((rel_y * -2) + rel_y + reloffset) * sin(yaw);
          local Y = fp.Y + -0.005 * sin(yaw) + ((rel_y * -2) + rel_y + reloffset) * cos(yaw);
          local Z = fp.Z + 1 + cos(pitch) * -1;
          item.raw[j].Size3D.X = item.dist;
          item.raw[j].Position3D = ::Vector(X, Y, Z);
        } else if(3 == j){
          local rot = ::line3d.rotate2(lp.X, lp.Y, lp.Z, lp2.X, lp2.Y, lp2.Z);
          rot.X += 1.570796;
          item.raw[j].Rotation3D = ::Vector(rot);
          local pitch = rot.X;
          local yaw = rot.Z;
          local rel_y = 1;
          local reloffset = sin(pitch) + 1;
          local X = fp.X + -0.005 * cos(yaw) - ((rel_y * -2) + rel_y + reloffset) * sin(yaw);
          local Y = fp.Y + -0.005 * sin(yaw) + ((rel_y * -2) + rel_y + reloffset) * cos(yaw);
          local Z = fp.Z + 1 + cos(pitch) * -1;
          item.raw[j].Size3D.X = item.dist;
          item.raw[j].Position3D = ::Vector(X, Y, Z);
        }
      }
    }
  },
  "dist_2d" : function (x, y, x2, y2){
    return ::sqrt((x - x2)*(x - x2) + (y - y2)*(y - y2));
  },
  "dist_3d" : function (x, y, z, x2, y2, z2){
    return ::sqrt((x - x2)*(x - x2) + (y - y2)*(y - y2) + (z - z2)*(z - z2));
  },
  "rotate1" : function(x1, y1, z1, x2, y2, z2){
    local rotx = ::atan2(z2 - z1, ::line3d.dist_2d(x1, y1, x2, y2));
    rotx = rotx - 1.570796;
    local rotz = -1 * ::atan2( x2 - x1, y2 - y1 );
    if(rotz < -3.141592){
      rotz = rotz + 6.283184;
    }
    return ::Vector(rotx, 0,rotz);
  },
  "rotate2" : function(x1, y1, z1, x2, y2, z2){
    local rotx = ::atan2(z2 - z1, ::line3d.dist_2d(x1, y1, x2, y2));
    local rotz = -1 * ::atan2( x2 - x1, y2 - y1 );
    rotz = rotz + -1.570796;
    if(rotz < -3.141592){
      rotz = rotz + 6.283184;
    }
    local roty = ::atan2(z2 - z1, ::line3d.dist_2d(x1, y1, x2, y2));
    rotx = rotx - roty;
    return ::Vector(rotx, roty,rotz);
  }
}

::line3d.set("test", ::Colour(255,0,0,200), Vector(-29.2778, -1342.03, 12.3133), Vector(-36.4452, -1342.45, 10.3133));
#2
Snippet Showroom / Relative position (in 3d)
Jan 26, 2024, 01:08 PM
I'd wanted to share some functions from my vc-mp archive.

This function will find relative position based by z_angle (vertical angle) and relative X and Y distance from base point.
rel_pos2d <- function(z_angle, pos_x, pos_y, pos_z, rel_x, rel_y, rel_z){
  local rX = pos_x + rel_x * ::cos(z_angle) - rel_y * ::sin(z_angle);
  local rY = pos_y + rel_x * ::sin(z_angle) + rel_y * ::cos(z_angle);
  local rZ = pos_z + rel_z;
  return ::Vector(rX, rY, rZ);
}

This function will find relative position based by z_angle (vertical angle), y_angle (horizontal angle) and distance.
rel_pos3d <- function(dist, pos_x, pos_y, pos_z, y_angle, z_angle){
  local rX = dist * ::cos(y_angle) * ::cos(z_angle);
  local rY = dist * ::cos(y_angle) * ::sin(z_angle);
  local rZ = dist * ::sin(y_angle);
  return ::Vector(pos_x + rX, pos_y + rY, pos_z + rZ);
}
#3
Tutorials / VC-MP on linux [knowage database]
Dec 27, 2023, 12:24 PM
i moved from windows to linux about 2 years ago and i want to share some useful information how to configure wine (playonlinux) for vcmp by my own experience:

wine version, correctly working with vcmp (I tested on rel004 client):
7.0-staging
7.0-rc6-staging
7.0-rc6
7.0-rc5-stagging
7.0-rc4-staging
7.0-rc3-stagging
7.0-rc2-stagging
6.18-stagging
6.18
6.17-staging
6.17
6.16-staging
6.16
6.15-staging
6.15
in some others wine versions vcmp browser will not run, in some - mouse sensitivity will be incorrect - so it wont be playable.
please note: in official vcmp browser text in servers list will not be visible, i still dont know how to fix that so most likely i have to live with that.

my display configuration:

to load .dll plugins from game's dir you need to add them here:

if you want to add something useful how to use vcmp in linux - feel free to post here.
#4
Map Showroom / small downtown addon (stairs)
Sep 20, 2023, 05:24 AM

I have added some stairs in downtown. Feel free to use it in your server.


<?xml version="1.0" encoding="ASCII" ?>
<map>
<itemlist>
<item model="2027" name="fix9"><!-- dt g-spot stairs 1 -->
<position x="-573.91" y="1374.23" z="15.63" />
<rotation format="axisangle" x="0.936672" y="0" z="0" angle="0.350207" />
</item>
<item model="2027" name="fix10"><!-- dt g-spot stairs 2 -->
<position x="-367.1" y="913.05" z="16.28" />
<rotation format="axisangle" x="-0.191693" y="-0.952011" z="0.233975" angle="-0.0467349" />
</item>
<item model="2334" name="fix23"><!-- dt hole stairs 1 -->
<position x="-536.29" y="880.1" z="70.7" />
<rotation format="axisangle" x="0" y="0" z="-0.999998" angle="-0.00174547" />
</item>
<item model="2334" name="fix24"><!-- dt hole stairs 2 -->
<position x="-517.09" y="1024.7" z="70.7" />
<rotation format="axisangle" x="0" y="0" z="0.0017449" angle="0.999999" />
</item>
<item model="449" name="fix25"><!-- dt hole palm 1 -->
<position x="-521.09" y="1020.9" z="60.3" />
<rotation format="axisangle" x="0" y="0" z="-0.921185" angle="-0.389124" />
</item>
<item model="449" name="fix26"><!-- dt hole palm 2 -->
<position x="-532.69" y="883.3" z="60.3" />
<rotation format="axisangle" x="0" y="0" z="-0.921185" angle="-0.389124" />
</item>
</itemlist>
</map>