Alright projectile behaviour is for the most part done or at least fully understood, I just need to do the correct enemy movement interpolation, collision detection should be a ray cast.
Energy Staff Removed irrelevant information
Code:
<Object type="0xa97" id="Energy Staff">
<Projectile>
<ObjectId>Grey Missile</ObjectId>
<Speed>180</Speed>
<MinDamage>10</MinDamage>
<MaxDamage>25</MaxDamage>
<LifetimeMS>475</LifetimeMS>
<Amplitude>0.5</Amplitude>
<Frequency>2</Frequency>
</Projectile>
<NumProjectiles>2</NumProjectiles>
</Object>
17.2 source code, working outs.
Code:
private function _-Fx(_arg1:int, _arg2:Point):void{ //_arg1 is Elapsed time in milliseconds from when the program started
//This function is using values from the xml data for each projectile type
//_-1So.speed
//_-1So.lifetime in milliseconds
//-1So._-7D "Wavy"
//_-1So._-1nH "Parametric"
//-1So._-1EK "Magnitude" default 3
//-1So._-13q "Boomerang"
//_-1So._-0so "Amplitude" default 0
//_-1So._-0uf "Frequency" default 1
_arg2.x = this._-017; //startx
_arg2.y = this._-1fL; //starty
var vec:Number = (_arg1 * (this._-1So.speed_ / 10000)); //(Elapsed time * (speed /10000))
var _local4:Number = ((((this.bulletId_ % 2))==0) ? 0 : Math.PI); // this is Choosing 0 or pi, is_odd(bulletId) function
_arg2.x = (_arg2.x + (vec * Math.cos(this.angle_))); //moving incrementing x
_arg2.y = (_arg2.y + (vec * Math.sin(this.angle_))); //moving incrementing y
//Energy Staff is type "Amplitude"
_local14 = (Amplitude * Math.sin((_local4 + ((((_arg1 / lifetime_) * Frequency) * 2) * Math.PI))));
_arg2.x = (_arg2.x + (_local14 * Math.cos((this.angle_ + (Math.PI / 2)))));
_arg2.y = (_arg2.y + (_local14 * Math.sin((this.angle_ + (Math.PI / 2)))));
Solution for projectiles of type "Amplitude", game maker project.
Code:
amplitude=0.5
frequency=2
sspeed=180
lifetime=475
angle=degtorad(90+45)
starttime=current_time;
Solution for projectiles of type "Amplitude", game maker project step event.
Code:
elapsed_time=current_time-starttime
vec=(elapsed_time * (sspeed /10000))
x=xstart+ (vec * cos(angle)); //moving incrementing x
y=ystart+ (vec * sin(angle)); //moving incrementing y
modvec = (amplitude * sin((pi + ((((elapsed_time/ lifetime) * frequency) * 2) * pi))));
//modvec = (amplitude * sin((0 + ((((elapsed_time/ lifetime) * frequency) * 2) * pi))));
x+= (modvec * cos( (angle + (pi / 2)) ) );
y+= (modvec * sin( (angle + (pi / 2)) ) );
player shoot packet
Code:
bado.writeInt(this.time_);
bado.writeByte(this.bulletId_); // Byte
bado.writeShort(this.containerType_); // Short
startingPos_.writeToOutput(bado);
bado.writeFloat(this.angle_); // Float