|
|
Amadeus 09-04-2003, 02:02 PM Multiplying a vector with a value does not work. It's like this:
%vec = "10 20 30";
%vec2 = %vec * 2;
echo(%vec2);
This returns 20, instead of "20 40 60". How can I multiply vectors then?
SuperSlug 09-04-2003, 03:58 PM Try using some of the vector functions:
Vector::add();
Vector::dot();
Vector::getDistance();
Vector::getFromRot();
Vector::getRotation();
Vector::neg();
Vector::normalize();
Vector::sub();
Amadeus 09-04-2003, 04:34 PM Yeah, I know these... but with these you still can't decrease a vector to it's half... isn't there a way to recall the three values of a vector? Something like %vec.x, %vec.y, %vec.z or %vec[x], %vec[y], %vec[z]...
cyclonite 09-04-2003, 05:07 PM You could always write your own function to do it.
Shinigami 09-04-2003, 05:10 PM Edit: Whoops, misread what he was trying to do.
That made no sense at all, but whatever.
function vectorMult(%vec, %val)
{
%vecX = firstWord(%vec) * %val;
%vecY = getWord(%vec, 1) * %val;
%vecZ = getWord(%vec, 2) * %val;
return %vecX SPC %vecY SPC %vecZ;
}
That's at least a basis, from memory.
Amadeus 09-05-2003, 01:16 AM Many thanks! This is just what I needed; only thing I'm not sure about is what's the name of the variable the return command makes. (%vec or other).
BTW, how can you make optional parameters to a function (like offSetZ in the gamebase::activateShield( ) function)? Simply add 'if (!%val2) %val2 = 1' or is there a better way to do it? Just wondering.
You would use the function like this, for example:
%vec = %obj.getVelocity(); // This would be the velocity vector.
%vec = vectMult(%vec, 3); // This would multiply the vector by 3.
Other than that, I don't really understand the rest of your question.
Amadeus 09-05-2003, 10:47 AM Thanks again.
There are some functions that have variables that you can define, but if you don't, they are simply not used. This is from www.tribalwar.com/sitecore/editing/editing-specs/
GameBase::activateShield( Object, Vector, <OffSetZ>)
Object: The object Id. Example: 8361.
Vector: A vector from the center of the object to the location where the projectile hit the shield.
OffsetZ: Allows you to adjust the height of the shield if needed.
USED IN: Player.cs, Staticshape.cs
RETURN: True if succeed or False if failed.
Used to display the shield effect on shielded objects
Well, it really just depends on the type of function and value you're going to be using.
If it's an offset, you would basically just do it like this:
function addZOffset(%vec, %offset)
{
%vecX = firstWord(%vec);
%vecY = getWord(%vec, 1);
%vecZ = getWord(%vec, 2);
%vecZ += %offset;
}
And, if %offset equals anything at all... it'll add it or do whatever. If it equals nothing, it won't do anything... it'll just leave %vecZ alone.
Not quite sure if that answered your question or not. And again, this is all from memory...
Amadeus 09-05-2003, 02:55 PM Never mind... I'm just unraveling the mysteries of the C language... :) But thanks anyway!
I was just thinking that if the function could have one necessary %val and some optional ones, then I could spare making a new variable when multiplying with several values. But it's really no big deal.
Probably not a good idea to compare Tribes scripting to C / C++, other than at the syntax level. Because other than that, it's not really similar.
Amadeus 09-05-2003, 04:28 PM Well I'm sure I never saw anything like '%value *= %val2' either in Pascal or Basic, neither anything like 'if (!%value)'... actually, it's the syntax design that really counts. Tribes obviously has a very comfortable system.
You really can't be serious....
|
|