Author Topic: "Learning Reasorces"?  (Read 2725 times)

Haha yeah, reminds me of the Game Maker help file XD

Staying semi ontopic, I didn't understand a bit of Rky's or Muffin's =/

Staying semi ontopic, I didn't understand a bit of Rky's or Muffin's =/

Mine came from the original Shotgun script, and from my very limited knowledge on actual coding I concluded it changes the Image of the shotgun when it fires so it will fire 3 randomly oriented bullets instead of a single, linear one. The bulk of it looks like allot of mathematics, basically setting boundaries as variables and then linking them to changeable numbers set outside of the bulk, such as Spread and Shellcount.

One number I see for %x, %y and %z is 3.14..., which is the Pi constant used to explain angles in Rads (360 degrees is 2 Pi rads, or 6.28 rads). Those lines probably, but most likely have something to do with the direction of the bullets. The rest of it boggles my mind though.
« Last Edit: October 23, 2007, 10:18:57 PM by Muffinmix »

Kungfu, you probably saw the code where I posted it under coding help:

http://www.blockland.us/smf/index.php?topic=22885.15

Alright, after looking at it closely, I think I get SOME of the confusing part.

Code: [Select]
%vector = %obj.getMuzzleVector(%slot); //the direction the gun is pointing
%objectVelocity = %obj.getVelocity();  // if you're moving, the bullets will move differently
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity); //points the bullets the right way...?
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor); //no clue
%velocity = VectorAdd(%vector1,%vector2); //used later on
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread; //these three are aiming the bullets randomly
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z); //Whut?
%velocity = MatrixMulVector(%mat, %velocity); //The bullet speed

For anyone that cares =P

%vector = %obj.getMuzzleVector(%slot); //the direction the gun is pointing Correct
%objectVelocity = %obj.getVelocity();  // if you're moving, the bullets will move differently Partly, yes
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity); //points the bullets the right way...? Makes a gun bullet move faster than a rocket, a sniper go fast. The speed of the projectile.
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor); //no clue Calculations for below
%velocity = VectorAdd(%vector1,%vector2); //used later on That makes the bullets move differently when you move
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread; //these three are aiming the bullets randomly The 3.14 bits are making it a circle so you end up with a random round spread
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z); //Whut? Turns those three co-ordinates into a matrix
%velocity = MatrixMulVector(%mat, %velocity); //The bullet speed Aims the bullets slightly off from the velocity calculated above and the random spread matrix



Code: [Select]
function timedmg(%col,%amount,%type,%timer,%maxtime)
{
 if(%col.getClassName() $= "Player" && %col.getState() !$= "Dead" && isObject(%col.client.minigame)){
 %col.damage(%col, "Head", %amount, %type);
 %col.burn(1000);
 %col.psnamount = %col.psnamount + $FireSpeed;
 if(%col.psnamount < %maxtime){
%col.psn=schedule($FireSpeed,0,"timedmg",%col,%amount,%type,%timer,%maxtime);}}
}

The TimeDmg() function used in the Weapon Ammo mod. It does damage over time until a set amount of time has passed. Ideally it should check whether you are both in the same minigame and whether the player is a bot, but I forgot to. Explainationism:

Code: [Select]
function timedmg(%col,%amount,%type,%timer,%maxtime)
{
 if(You Are A Player && You Aren't Dead && You Are In A Minigame){
 Damage You For [amount] damage of 'death type' [type]
 Burn effect for a second
 Add a set amount to your 'Burn Time'
 if(Burn Time < Max Time){
Do Function Again After a Set Amount of Time}}
}
« Last Edit: October 24, 2007, 12:45:41 PM by Space Guy »