ScarletBlackMarket/script/player/PrideJam_RinnoRemi/RinnoRemi_Function.dnh

115 lines
3.5 KiB
Plaintext
Raw Normal View History

2022-08-20 05:42:00 +00:00
task _LaserSpriteRender(
img, int target, float targetAng,
int rectLeft, int rectTop, int rectRight, int rectBottom,
float scaleX, float scaleY, int renderPriority, float alpha,
float scaleSpeed
){
let lasersprite = ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(lasersprite, img);
ObjSprite2D_SetSourceRect(lasersprite, rectLeft, rectTop, rectRight, rectBottom);
ObjRender_SetScaleXYZ(lasersprite, 0, scaleY, 1);
ObjSprite2D_SetDestRect(lasersprite, -(rectRight-rectLeft)/2, 0, (rectRight-rectLeft)/2, rectTop-rectBottom);
Obj_SetRenderPriorityI(lasersprite, renderPriority);
ObjRender_SetAlpha(lasersprite, 0);
ObjRender_SetBlendType(lasersprite, BLEND_ADD_ARGB);
async{
loop{
int[] EnemyList = ObjCol_GetListOfIntersectedEnemyID(target);
if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && GetVirtualKeyState(VK_SLOWMOVE) != KEY_FREE && !ripplayer && IsPermitPlayerShot){
// Assumes the intersecting color is right next to the right of the original color
if (length(EnemyList) > 0) {ObjSprite2D_SetSourceRect(lasersprite, rectRight, rectTop, rectRight+(rectRight-rectLeft), rectBottom);}
else{ObjSprite2D_SetSourceRect(lasersprite, rectLeft, rectTop, rectRight, rectBottom);}
float targetx = ObjRender_GetX(target);
float targety = ObjRender_GetY(target);
ObjRender_SetScaleX(lasersprite, min(scaleX+rand(-0.025, 0.025), ObjRender_GetScaleX(lasersprite) + scaleSpeed));
ObjRender_SetAlpha(lasersprite, min(alpha, ObjRender_GetAlpha(lasersprite)+alpha/5));
ObjRender_SetAngleZ(lasersprite, targetAng);
ObjRender_SetPosition(lasersprite, targetx, targety, 1);
yield;
}
else{
ObjRender_SetScaleX(lasersprite, max(0, ObjRender_GetScaleX(lasersprite) - scaleSpeed));
ObjRender_SetAlpha(lasersprite, max(0, ObjRender_GetAlpha(lasersprite)-alpha/5));
yield;
}
yield;
}
}
}
function _RenderLaser(target, float ang, float maxintersectX, float maxLength, float width, float speedLength, float dmg){ /* */
float angRender = asin(maxintersectX/absolute(maxLength));
//int laser = CreatePlayerShotA1(ObjRender_GetX(target), ObjRender_GetY(target), 0, ang, dmg, 9999999, 0);
int laser = CreateStraightLaserA1(ObjRender_GetX(target), ObjRender_GetY(target), ang-90, maxLength, width, 9999999, 0, 1);
ObjLaser_SetInvalidLength(laser, 0, 0);
ObjShot_SetDamage(laser, dmg);
ObjShot_SetAutoDelete(laser, false);
Obj_SetRenderPriorityI(laser, 38);
_Follow(laser, target);
_LaserSpriteRender(
teamimg, laser, ang,
3072, 0, 3072+256, 256,
0.45, 20, 38, 240,
0.14
);
// When shot key is being held, create a line intersection that stretches across the laser.
/*
Calculations:
startx: x of target
starty: y of target
endx: x of laser
endy: maxLength
width = width of laser
*/
async{
loop{
if(GetVirtualKeyState(VK_SHOT) != KEY_FREE && GetVirtualKeyState(VK_SLOWMOVE) != KEY_FREE && !ripplayer && IsPermitPlayerShot){
if(shotspeed % 5 == 0){ObjSound_Play(inferno);}
ObjShot_SetIntersectionEnable(laser, true);
//ObjShot_SetIntersectionLine(laser, ObjRender_GetX(target), ObjRender_GetY(target), ObjRender_GetX(target)+maxintersectX, -maxLength, width);
//WriteLog(ObjMove_GetX(laserfwd));
yield;
}
else{ObjShot_SetIntersectionEnable(laser, false); yield;}
}
}
// After shot key is released, let the laser leave and then delete it.
return laser;
}
task _Follow(follower, followed){
while(!Obj_IsDeleted(follower)){
float x = ObjRender_GetX(followed);
float y = ObjRender_GetY(followed);
ObjMove_SetPosition(follower, x, y);
yield;
}
}