Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- This is tutorial for editing OpenSpades (in time of writing version is 0.0.12b) Weapon View scripts.
- 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.
- 1.TOPIC
- * some notes
- Point
- a)plus point a
- b)plus point b
- * notes for Point
- END OF 1.TOPIC
- Contents:
- 1.Folder Structure (.pak files)
- 2.AngelScript
- 3.Variables (simple ones, then Vector3 and Matrix4)
- 4.Animation
- 5.Scripts/Reference folder
- 1.Folder Structure
- * .pak file is just a renamed .zip archive and it can be opened with 7zip easily.
- The game (or program) can read the resources (models, scripts, sounds, textures) in three different ways:
- a) from uncompressed folders (just simple plain folder structure that is inside .pak files)
- b) from .zip files or .pak files with custom names (like M14MOD.zip)
- c) from the original .pak files (like pak000-name.pak or pak999-name.pak)
- * The game searches for Resources first a) then b) and then c).
- You can extract every .pak file into /Resources/ folder and never bother with updating .pak files.
- Remember that folder structure must be kept intact or the game simply will not find the resources!
- (etc. /Resources/Scripts/Weapons/Rifle/View.as)
- END OF 1.Folder Structure
- 2.AngelScript
- AS is similar to C++, but some syntax is a bit different.
- Though the only thing I can remember now is that after real/floating number (like "1.33333") there MUST be "f".
- Let's take a number "0.667"
- "0.667f" and ".667f" and "667.f/100" and "667/100" are ALL valid and represent the SAME number.
- But plain "0.667" will get you in trouble.
- If your script fails to compile (game fails to launch), do not press "OK", because we are not ok with that.
- Instead, click on that console (black window with white text) and see what the error is.
- Going to SystemDump.log file (in C:/Docum and Sett/User/Applic Data/OpenS/) is a waste of time.
- END OF 2.AngelScript
- 3.Variables
- Types of "simple" variables are:
- integer: int, uint, int8;
- real: float, double;
- int is just a number. -1, 1, 2, 3, 9000, -9999
- uint is used in "for(uint i = 0; i < n; i++) {}" cycle. "u"int probably means unsigned - it is always positive or zero.
- int8 is same int, but its limits are about -+128
- float is a real number like Pi or sqrt(2)
- double is just bigger than "float"
- The more "difficult" ones were added by yvt. They are actually procedures or arrays, but are declared like the simple ones.
- Go to /Reference/API/Math.as for the definitions and much more ways to manipulate them.
- Vector2 represents coordinates in 2D. used for crosshair position
- Vector3 represents coordinates in 3D. can be used for model position,rotation,scaling. Used for left/rightHand position.
- Matrix4 represents the position, rotation and scaling of model in 3D
- ModelRenderParam represents the position, rotation, scaling, custom colour and "depthHack" (stay calm, this is not a hack)
- Manipulating the "difficult" variables.
- I am going to make a "script" for each of it (which might not actually work because of syntax)
- ----A)Vector2 (x, y):
- //x is position on the horizontal line (or width)
- //y is position on the vertical line (or height)
- float xcoord,ycoord,length;
- Vector2 ImagePos;
- ImagePos.x = xcoord; //you can
- ImagePos.y = ycoord; //do this
- ImagePos = Vector2(xcoord, ycoord); //both ways
- length = ImagePos.Length; //you can also do
- length = sqrt(ImagePos.x*ImagePos.x+ImagePos.y*ImagePos.y); //this both ways
- //if you dont know what Pythagoras is, go away. SQRT() is SQuareRooT
- //END OF VECTOR2
- ----B)Vector3 (x, y, z):
- //this is far more complex than Vector2!
- //USEFUL Copy+Paste: Vector3 (x, y, z) (x+left/-right, y+further/-closer, z+down/-up)
- //first (x) coordinate moves left or right. Positive moves left.
- //second (y) coordinate moves further or closer. Positive moves further. (from viewpoint)
- //third (z) coordinate moves up or down. Positive moves down.
- float x,y,z,length;
- Vector3 HandPos;
- HandPos.x = x;
- HandPos.y = y;
- HandPos.z = z;
- HandPos = Vector3(x, y, z);
- length = HandPos.Length;
- //not gonna do the length formula :P
- //"Vector3" is the final parameter used for "left/rightHand = Vector3;" but you cannot use this for gun models.
- //Why? Because gun model rendering procedure "renderer.AddModel()" uses "ModelRenderParam". Not even "Matrix4" is "good enough" for this.
- //END OF VECTOR3
- ----C)Matrix4
- //There are some things(?) like Matrix4.GetOrigin, but if you are ever going to need THIS, then you should just go to Reference folder.
- //
- //There are two ways of changing this one to, but I will go with the easier one.
- Matrix4 weapMatrix; //lets declare our independent Matrix!
- //
- weapMatrix *= CreateTranslateMatrix(Vector3); //seems that our Matrix IS dependent!
- //This tells the game to change (but not overwrite!) and existing Matrix4.
- //It changes the position. Coordinates behave just like with Vector3
- //CreateTranslateMatrix (x,y,z) (x+left/-right, y+further/-closer, z+down/-up)
- //
- weapMatrix *= CreateRotateMatrix(Vector3), RotationInRadians);
- //Complex one. Rotates the model. Be careful which axis you rotate first!
- //Imagine that we are rolling a ball. It depends where it goes on what direction it is rolling in, right? Right.
- //(x, y, z) (x:+further/-closer, y:+right/-left, z:spins:+clockwise/-cockwise)
- //Alternative way is by telling where the end of the weapon moves
- //(x,y,z) (x+down/-up, y+rollright/-rollleft, z+turnright/-turnleft)
- //What are radians? Google knows. But find them with:
- //**x is degrees**
- //(x/180)*pi
- //
- weapMatrix *= CreateScaleMatrix(Vector3);
- weapMatrix *= CreateScaleMatrix(float);
- //uhh Vector3?
- //Yes. Each axis can be scaled independently
- //You can ofc scale all the axis together
- //Vector3 as always affects the same axis it moves.
- //Vector3 (x, y, z) (x.left/right, y.further/closer, z.down/up)
- //NOTE: Remember that .kv6 models can have "pivots"? Empty space will also be scaled, just like the rest of the model.
- //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
- ----D)ModelRenderParam param;
- //you can find ^this^ line in View.as for sure
- param.matrix = weapMatrix;
- //
- //you can actually discard/avoid the Matrix4 and just do:
- param.matrix *= CreateTranslateMatrix(Vector3);
- param.matrix *= CreateRotateMatrix(Vector3), RotationInRadians);
- param.matrix *= CreateScaleMatrix(Vector3);
- //
- //And at the end you can find this thing
- renderer.AddModel(ModelName, param);
- //What is this^ "ModelName"?
- //It is the name and location of the model (.kv6 file).
- //
- private Model@ ModelName;
- //declares that there IS such a thing and must be in the begining
- //
- @ModelName = renderer.RegisterModel
- ("Models/Weapons/BOLTACTIONPLS/PLEASE-ADD-BOLTACTION-IN-FUTURE-aOS.kv6");
- //tells renderer to register this model and its location so it can be added later
- //so you can add models until you run out of RAM/GPU/CPU/god knows what
- //
- //I also recommend setting "depthHack" to true. Idk why, but every other model has it.
- //
- END OF 3.Variables
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement