Advertisement
Guest User

OpenSpades modding

a guest
Nov 2nd, 2014
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.29 KB | None | 0 0
  1. This is tutorial for editing OpenSpades (in time of writing version is 0.0.12b) Weapon View scripts.
  2. I assume you have basic knowledge of C++ or any similar lanuguage. If you not, there are many tutorials on C++ and AngelScript, so I am not going to bother with that.
  3.  
  4.  
  5. 1.TOPIC
  6. * some notes
  7.  
  8. Point
  9. a)plus point a
  10. b)plus point b
  11. * notes for Point
  12. END OF 1.TOPIC
  13.  
  14.  
  15. Contents:
  16. 1.Folder Structure (.pak files)
  17. 2.AngelScript
  18. 3.Variables (simple ones, then Vector3 and Matrix4)
  19. 4.Animation
  20. 5.Scripts/Reference folder
  21.  
  22. 1.Folder Structure
  23. * .pak file is just a renamed .zip archive and it can be opened with 7zip easily.
  24.  
  25. The game (or program) can read the resources (models, scripts, sounds, textures) in three different ways:
  26. a) from uncompressed folders (just simple plain folder structure that is inside .pak files)
  27. b) from .zip files or .pak files with custom names (like M14MOD.zip)
  28. c) from the original .pak files (like pak000-name.pak or pak999-name.pak)
  29. * The game searches for Resources first a) then b) and then c).
  30.  
  31. You can extract every .pak file into /Resources/ folder and never bother with updating .pak files.
  32. Remember that folder structure must be kept intact or the game simply will not find the resources!
  33. (etc. /Resources/Scripts/Weapons/Rifle/View.as)
  34. END OF 1.Folder Structure
  35.  
  36. 2.AngelScript
  37. AS is similar to C++, but some syntax is a bit different.
  38. Though the only thing I can remember now is that after real/floating number (like "1.33333") there MUST be "f".
  39. Let's take a number "0.667"
  40. "0.667f" and ".667f" and "667.f/100" and "667/100" are ALL valid and represent the SAME number.
  41. But plain "0.667" will get you in trouble.
  42.  
  43. If your script fails to compile (game fails to launch), do not press "OK", because we are not ok with that.
  44. Instead, click on that console (black window with white text) and see what the error is.
  45. Going to SystemDump.log file (in C:/Docum and Sett/User/Applic Data/OpenS/) is a waste of time.
  46. END OF 2.AngelScript
  47.  
  48. 3.Variables
  49. Types of "simple" variables are:
  50. integer: int, uint, int8;
  51. real: float, double;
  52. int is just a number. -1, 1, 2, 3, 9000, -9999
  53. uint is used in "for(uint i = 0; i < n; i++) {}" cycle. "u"int probably means unsigned - it is always positive or zero.
  54. int8 is same int, but its limits are about -+128
  55. float is a real number like Pi or sqrt(2)
  56. double is just bigger than "float"
  57.  
  58. The more "difficult" ones were added by yvt. They are actually procedures or arrays, but are declared like the simple ones.
  59. Go to /Reference/API/Math.as for the definitions and much more ways to manipulate them.
  60. Vector2 represents coordinates in 2D. used for crosshair position
  61. Vector3 represents coordinates in 3D. can be used for model position,rotation,scaling. Used for left/rightHand position.
  62. Matrix4 represents the position, rotation and scaling of model in 3D
  63. ModelRenderParam represents the position, rotation, scaling, custom colour and "depthHack" (stay calm, this is not a hack)
  64.  
  65. Manipulating the "difficult" variables.
  66. I am going to make a "script" for each of it (which might not actually work because of syntax)
  67. ----A)Vector2 (x, y):
  68. //x is position on the horizontal line (or width)
  69. //y is position on the vertical line (or height)
  70. float xcoord,ycoord,length;
  71. Vector2 ImagePos;
  72. ImagePos.x = xcoord; //you can
  73. ImagePos.y = ycoord; //do this
  74. ImagePos = Vector2(xcoord, ycoord); //both ways
  75. length = ImagePos.Length; //you can also do
  76. length = sqrt(ImagePos.x*ImagePos.x+ImagePos.y*ImagePos.y); //this both ways
  77. //if you dont know what Pythagoras is, go away. SQRT() is SQuareRooT
  78. //END OF VECTOR2
  79. ----B)Vector3 (x, y, z):
  80. //this is far more complex than Vector2!
  81. //USEFUL Copy+Paste: Vector3 (x, y, z) (x+left/-right, y+further/-closer, z+down/-up)
  82. //first (x) coordinate moves left or right. Positive moves left.
  83. //second (y) coordinate moves further or closer. Positive moves further. (from viewpoint)
  84. //third (z) coordinate moves up or down. Positive moves down.
  85. float x,y,z,length;
  86. Vector3 HandPos;
  87. HandPos.x = x;
  88. HandPos.y = y;
  89. HandPos.z = z;
  90. HandPos = Vector3(x, y, z);
  91. length = HandPos.Length;
  92. //not gonna do the length formula :P
  93. //"Vector3" is the final parameter used for "left/rightHand = Vector3;" but you cannot use this for gun models.
  94. //Why? Because gun model rendering procedure "renderer.AddModel()" uses "ModelRenderParam". Not even "Matrix4" is "good enough" for this.
  95. //END OF VECTOR3
  96. ----C)Matrix4
  97. //There are some things(?) like Matrix4.GetOrigin, but if you are ever going to need THIS, then you should just go to Reference folder.
  98. //
  99. //There are two ways of changing this one to, but I will go with the easier one.
  100. Matrix4 weapMatrix; //lets declare our independent Matrix!
  101. //
  102. weapMatrix *= CreateTranslateMatrix(Vector3); //seems that our Matrix IS dependent!
  103. //This tells the game to change (but not overwrite!) and existing Matrix4.
  104. //It changes the position. Coordinates behave just like with Vector3
  105. //CreateTranslateMatrix (x,y,z) (x+left/-right, y+further/-closer, z+down/-up)
  106. //
  107. weapMatrix *= CreateRotateMatrix(Vector3), RotationInRadians);
  108. //Complex one. Rotates the model. Be careful which axis you rotate first!
  109. //Imagine that we are rolling a ball. It depends where it goes on what direction it is rolling in, right? Right.
  110. //(x, y, z) (x:+further/-closer, y:+right/-left, z:spins:+clockwise/-cockwise)
  111. //Alternative way is by telling where the end of the weapon moves
  112. //(x,y,z) (x+down/-up, y+rollright/-rollleft, z+turnright/-turnleft)
  113. //What are radians? Google knows. But find them with:
  114. //**x is degrees**
  115. //(x/180)*pi
  116. //
  117. weapMatrix *= CreateScaleMatrix(Vector3);
  118. weapMatrix *= CreateScaleMatrix(float);
  119. //uhh Vector3?
  120. //Yes. Each axis can be scaled independently
  121. //You can ofc scale all the axis together
  122. //Vector3 as always affects the same axis it moves.
  123. //Vector3 (x, y, z) (x.left/right, y.further/closer, z.down/up)
  124. //NOTE: Remember that .kv6 models can have "pivots"? Empty space will also be scaled, just like the rest of the model.
  125. //NOTE: So please make sure your pivots are less than 2 and more than -2 (not necessary, but you won't have to mess with CreateTranslateMatrix
  126. ----D)ModelRenderParam param;
  127. //you can find ^this^ line in View.as for sure
  128. param.matrix = weapMatrix;
  129. //
  130. //you can actually discard/avoid the Matrix4 and just do:
  131. param.matrix *= CreateTranslateMatrix(Vector3);
  132. param.matrix *= CreateRotateMatrix(Vector3), RotationInRadians);
  133. param.matrix *= CreateScaleMatrix(Vector3);
  134. //
  135. //And at the end you can find this thing
  136. renderer.AddModel(ModelName, param);
  137. //What is this^ "ModelName"?
  138. //It is the name and location of the model (.kv6 file).
  139. //
  140. private Model@ ModelName;
  141. //declares that there IS such a thing and must be in the begining
  142. //
  143. @ModelName = renderer.RegisterModel
  144. ("Models/Weapons/BOLTACTIONPLS/PLEASE-ADD-BOLTACTION-IN-FUTURE-aOS.kv6");
  145. //tells renderer to register this model and its location so it can be added later
  146. //so you can add models until you run out of RAM/GPU/CPU/god knows what
  147. //
  148. //I also recommend setting "depthHack" to true. Idk why, but every other model has it.
  149. //
  150. END OF 3.Variables
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement