‪Black Ops 3 Source Code Explorer  0.1
‪An script explorer for Black Ops 3 by ZeRoY
compass.gsc
Go to the documentation of this file.
1 #using scripts\codescripts\struct;
2 
3 #insert scripts\shared\shared.gsh;
4 
5 #namespace compass;
6 
7 function ‪setupMiniMap(material)
8 {
9  // use 0 for no required map aspect ratio.
10  requiredMapAspectRatio = GetDvarfloat( "scr_requiredMapAspectRatio");
11 
12  corners = getentarray("minimap_corner", "targetname");
13  if (corners.size != 2)
14  {
15  /# println("^1Error: There are not exactly two \"minimap_corner\" entities in the map. Could not set up minimap."); #/
16  return;
17  }
18 
19  corner0 = (corners[0].origin[0], corners[0].origin[1], 0);
20  corner1 = (corners[1].origin[0], corners[1].origin[1], 0);
21 
22  cornerdiff = corner1 - corner0;
23 
24  north = (cos(getnorthyaw()), sin(getnorthyaw()), 0);
25  west = (0 - north[1], north[0], 0);
26 
27  // we need the northwest and southeast corners. all we know is that corner0 is opposite of corner1.
28  if (vectordot(cornerdiff, west) > 0) {
29  // corner1 is further west than corner0
30  if (vectordot(cornerdiff, north) > 0) {
31  // corner1 is northwest, corner0 is southeast
32  northwest = corner1;
33  southeast = corner0;
34  }
35  else {
36  // corner1 is southwest, corner0 is northeast
37  side = ‪vecscale(north, vectordot(cornerdiff, north));
38  northwest = corner1 - side;
39  southeast = corner0 + side;
40  }
41  }
42  else {
43  // corner1 is further east than corner0
44  if (vectordot(cornerdiff, north) > 0) {
45  // corner1 is northeast, corner0 is southwest
46  side = ‪vecscale(north, vectordot(cornerdiff, north));
47  northwest = corner0 + side;
48  southeast = corner1 - side;
49  }
50  else {
51  // corner1 is southeast, corner0 is northwest
52  northwest = corner0;
53  southeast = corner1;
54  }
55  }
56 
57  // expand map area to fit required aspect ratio
58  if ( requiredMapAspectRatio > 0 )
59  {
60  northportion = vectordot(northwest - southeast, north);
61  westportion = vectordot(northwest - southeast, west);
62  mapAspectRatio = westportion / northportion;
63  if ( mapAspectRatio < requiredMapAspectRatio )
64  {
65  incr = requiredMapAspectRatio / mapAspectRatio;
66  addvec = ‪vecscale( west, westportion * (incr - 1) * 0.5 );
67  }
68  else
69  {
70  incr = mapAspectRatio / requiredMapAspectRatio;
71  addvec = ‪vecscale( north, northportion * (incr - 1) * 0.5 );
72  }
73  northwest += addvec;
74  southeast -= addvec;
75  }
76 
77  setMiniMap(material, northwest[0], northwest[1], southeast[0], southeast[1]);
78 }
79 
80 function ‪vecscale(vec, scalar)
81 {
82  return (vec[0]*scalar, vec[1]*scalar, vec[2]*scalar);
83 }
‪setupMiniMap
‪function setupMiniMap(material)
Definition: compass.gsc:7
‪vecscale
‪function vecscale(vec, scalar)
Definition: compass.gsc:80