/* -------------------------------------------------------------------- /////////////// UNIVERSAL/GENERAL LIBRARY ///////////////// A library meant for universal functions and including other libraries. -------------------------------------------------------------------- */ #include "script/KevinSystem/kevin_system/Kevin_ItemLib.txt" #include "script/KevinSystem/kevin_system/Kevin_ItemConst.txt" #include "script/default_system/Default_Effect.txt" // Probably change this somewhere down the line. #include "script/KevinSystem/GeneralSoundLib.txt" // Ryannlib momento //#include "script/KevinSystem/TerraShot2x/shot_const.dnh" #include "script/KevinSystem/Universal_EnemyLib.dnh" #include "script/KevinSystem/KevinShot/shotconst_HD.txt" // Convenience constants const STG_WIDTH = GetStgFrameWidth(); const STG_HEIGHT = GetStgFrameHeight(); InstallFont("script/KevinSystem/font/Connecting Chain Handserif.ttf"); InstallFont("script/KevinSystem/font/AnkeCall.ttf"); // Placeholder let invalid = "script/KevinSystem/img/lol.png"; let testEnemyTex = "script/game/resourceLib/Spritesheet_StationJam.png"; LoadTextureEx(invalid, true, true); LoadTextureEx(testEnemyTex, true, true); int PetalEffect = ObjParticleList_Create(OBJ_PARTICLE_LIST_2D); _EffectListPreRender(PetalEffect, testEnemyTex, [1536, 0, 1792, 256]); _SoundTask; // Simple text object creation (adapted from mkm) function CreateTextObject( float mx, my, size, string text, font, int colorTop, colorBottom, int borderColor, borderWidth, int renderPriority ){ let obj = ObjText_Create(); ObjText_SetText(obj, text); ObjText_SetFontSize(obj, size); ObjText_SetFontType(obj, font); ObjText_SetFontColorTop(obj, colorTop); ObjText_SetFontColorBottom(obj, colorBottom); ObjText_SetFontBorderType(obj, BORDER_FULL); ObjText_SetFontBorderColor(obj, borderColor); ObjText_SetFontBorderWidth(obj, borderWidth); Obj_SetRenderPriorityI(obj, renderPriority); ObjRender_SetX(obj, mx); ObjRender_SetY(obj, my); return obj; } // Simple 2D image creation function _Create2DImage(imgpath, int rectleft, int recttop, int rectright, int rectbottom){ int imgname = ObjPrim_Create(OBJ_SPRITE_2D); ObjPrim_SetTexture(imgname, imgpath); ObjSprite2D_SetSourceRect(imgname, rectleft, recttop, rectright, rectbottom); ObjSprite2D_SetDestCenter(imgname); //ObjRender_SetPosition(imgname, positionstart) return imgname; } // Overload that uses arrays instead function _Create2DImage(imgpath, int[] rectarray){ int imgname = ObjPrim_Create(OBJ_SPRITE_2D); ObjPrim_SetTexture(imgname, imgpath); ObjSprite2D_SetSourceRect(imgname, rectarray); ObjSprite2D_SetDestCenter(imgname); //ObjRender_SetPosition(imgname, positionstart) return imgname; } // Task to make bullet fade after a certain time, bullet loses hitbox while fading task _EnemyShotFade(int target, int time, bool fadedelay, float delaymultiplier){ ObjShot_SetDeleteFrame(target, time); if (fadedelay){ wait(time-time/delaymultiplier); ObjShot_SetIntersectionEnable(target, false); ascent(i in 0..time/delaymultiplier){ ObjRender_SetAlpha(target, Interpolate_Smoother(ObjRender_GetAlpha(target), 0, i/(time/delaymultiplier))); yield; } } else{ ascent(i in 0..time){ ObjRender_SetAlpha(target, Interpolate_Smoother(ObjRender_GetAlpha(target), 0, i/time)); yield; } } return; } // Delay function by Naudiz task _Delay(target, del){ ObjShot_SetDelay(target, del); ObjShot_SetDelayGraphic(target, ObjShot_GetImageID(target)); // unless you already have the ID in the function somewhere, in which case you can just use that, or use any other graphic ObjShot_SetDelayMode(target, DELAY_LERP, LERP_ACCELERATE, LERP_DECELERATE); // delay mode, scale lerp, alpha lerp (these are the modes I use in my entry) ObjShot_SetDelayScaleParameter(target, 1, 2, del); // lerps from 2 to 1 scale in del frames (use the value from ObjShot_SetDelay for del) ObjShot_SetDelayAlphaParameter(target, 1, 0, del); // lerps from 0 to 1 (255) alpha in del frames return; } // Overloads by me task _Delay(target, del, orgscale, destscale, orgalpha, destalpha, scalelerp, alphalerp){ ObjShot_SetDelay(target, del); ObjShot_SetDelayGraphic(target, ObjShot_GetImageID(target)); ObjShot_SetDelayMode(target, DELAY_LERP, scalelerp, alphalerp); ObjShot_SetDelayScaleParameter(target, destscale, orgscale, del); ObjShot_SetDelayAlphaParameter(target, destalpha, orgalpha, del); return; } task _Delay(target, del, orgscale, destscale, orgalpha, destalpha){ ObjShot_SetDelay(target, del); ObjShot_SetDelayGraphic(target, ObjShot_GetImageID(target)); ObjShot_SetDelayMode(target, DELAY_LERP, LERP_ACCELERATE, LERP_DECELERATE); ObjShot_SetDelayScaleParameter(target, destscale, orgscale, del); ObjShot_SetDelayAlphaParameter(target, destalpha, orgalpha, del); return; } task _Delay(target, del, orgscale, orgalpha){ ObjShot_SetDelay(target, del); ObjShot_SetDelayGraphic(target, ObjShot_GetImageID(target)); ObjShot_SetDelayMode(target, DELAY_LERP, LERP_ACCELERATE, LERP_DECELERATE); ObjShot_SetDelayScaleParameter(target, 1, orgscale, del); ObjShot_SetDelayAlphaParameter(target, 1, orgalpha, del); return; } // Rescales the bullet. Very important. task _BulletRescale(target, float scale, bool hitboxscale, hitboxlevel){ ObjRender_SetScaleXYZ(target, scale, scale, 1); if (hitboxscale){ ObjShot_SetIntersectionScaleXY(target, scale*hitboxlevel, scale*hitboxlevel); return; } else{return;} } // Item drop functions. //////////// TO-DO: Move all item creation to the item script, rendering both of these tasks obsolete. //////////// task _NonspellItemDrop(int targetscene, int targetenemy, int itemamount){ float ex = ObjMove_GetX(targetenemy); float ey = ObjMove_GetY(targetenemy); if(ObjEnemyBossScene_GetInfo(targetscene, INFO_PLAYER_SHOOTDOWN_COUNT) == 0){ loop(itemamount){ CreateScoreItem(POINT_REGULAR, rand(ex-90, ex+90), rand(ey-90, ey+90)); } } else{ loop(trunc(itemamount/2)){ CreateScoreItem(POINT_REGULAR, rand(ex-90, ex+90), rand(ey-90, ey+90)); } } } task _SpellItemDrop(int targetscene, int targetenemy, int itemamount){ float ex = ObjMove_GetX(targetenemy); float ey = ObjMove_GetY(targetenemy); if(ObjEnemyBossScene_GetInfo(targetscene, INFO_PLAYER_SHOOTDOWN_COUNT) == 0 && ObjEnemyBossScene_GetInfo(targetscene, INFO_PLAYER_SPELL_COUNT) == 0){ loop(itemamount){ CreateScoreItem(POINT_BHESTIE, rand(ex-90, ex+90), rand(ey-90, ey+90)); } } else if (ObjEnemyBossScene_GetInfo(targetscene, INFO_PLAYER_SHOOTDOWN_COUNT) == 0 && ObjEnemyBossScene_GetInfo(targetscene, INFO_PLAYER_SPELL_COUNT) >= 0){ loop(trunc(itemamount/2)){ CreateScoreItem(POINT_BHESTIE, rand(ex-90, ex+90), rand(ey-90, ey+90)); } } else{} } // By Neck_Logo task _CreateCustomTelegraphLine( float posX_, float posY_, float initAngle_, float destAngle_, float initLength_, float destLength_, float initWidth_, float destWidth_, int color_, int maxAlpha_, float growthTime_, float lifeTime_, float fadeTime_ ) // damn this is some cursed indenting { int scene = GetEnemyBossSceneObjectID(); let _shotF_Telegraph_Line = ObjParticleList_Create(OBJ_PARTICLE_LIST_2D); ObjPrim_SetTexture(_shotF_Telegraph_Line, invalid); Obj_SetRenderPriorityI(_shotF_Telegraph_Line, 39); ObjPrim_SetPrimitiveType(_shotF_Telegraph_Line, PRIMITIVE_TRIANGLELIST); ObjPrim_SetVertexCount(_shotF_Telegraph_Line, 4); ObjRender_SetBlendType(_shotF_Telegraph_Line, BLEND_ALPHA); // float dU = 0.5, dV = 0.5; // Left-top, right-top, left-bottom, right-bottom ObjPrim_SetVertexUVT(_shotF_Telegraph_Line, 0, 0, 0); ObjPrim_SetVertexUVT(_shotF_Telegraph_Line, 1, 1, 0); ObjPrim_SetVertexUVT(_shotF_Telegraph_Line, 2, 0, 1); ObjPrim_SetVertexUVT(_shotF_Telegraph_Line, 3, 1, 1); // Vertex positions are offset with deltas so that the sprite is centered ObjPrim_SetVertexPosition(_shotF_Telegraph_Line, 0, -dU, -dV, 1); ObjPrim_SetVertexPosition(_shotF_Telegraph_Line, 1, dU, -dV, 1); ObjPrim_SetVertexPosition(_shotF_Telegraph_Line, 2, -dU, dV, 1); ObjPrim_SetVertexPosition(_shotF_Telegraph_Line, 3, dU, dV, 1); ObjPrim_SetVertexIndex(_shotF_Telegraph_Line, [0, 1, 2, 1, 2, 3]); float angle = initAngle_; float span = initLength_; float width = initWidth_; int alpha = 0; //_CreateParticleList(); _TelegraphLineControl(); if(scene != ID_INVALID){ // growth phase for (int i = 1; i <= growthTime_ && 0 < ObjEnemyBossScene_GetInfo(scene, INFO_ACTIVE_STEP_TOTAL_LIFE); i++) { width = Interpolate_Decelerate(initWidth_, destWidth_, i / growthTime_); alpha = Interpolate_Decelerate(0, maxAlpha_+32, i / growthTime_); RenderTelegraphLine(); yield; } // static phase for (int j = 1; j <= lifeTime_ && 0 < ObjEnemyBossScene_GetInfo(scene, INFO_ACTIVE_STEP_TOTAL_LIFE); j++) { RenderTelegraphLine(); yield; } if (!(0 < ObjEnemyBossScene_GetInfo(scene, INFO_ACTIVE_STEP_TOTAL_LIFE))) fadeTime_ = min(fadeTime_, 25); } else{ for (int i = 1; i <= growthTime_ ; i++) { width = Interpolate_Decelerate(initWidth_, destWidth_, i / growthTime_); alpha = Interpolate_Decelerate(0, maxAlpha_+32, i / growthTime_); RenderTelegraphLine(); yield; } // static phase for (int j = 1; j <= lifeTime_; j++) { RenderTelegraphLine(); yield; } } destWidth_ = width; maxAlpha_ = alpha; // deletion phase for (int k = 1; k <= fadeTime_; k++) { width = Interpolate_Accelerate(destWidth_, destWidth_ - (destWidth_ - initWidth_) / 2, k / fadeTime_); alpha = Interpolate_Accelerate(maxAlpha_+32, 0, k / fadeTime_); RenderTelegraphLine(); yield; } Obj_Delete(_shotF_Telegraph_Line); task _TelegraphLineControl() { for (int l = 1; l <= growthTime_ + lifeTime_; l++) { angle = Interpolate_Decelerate(initAngle_, destAngle_, l / (growthTime_ + lifeTime_)); span = Interpolate_Decelerate(initLength_, destLength_, l / (growthTime_ + lifeTime_)); yield; } } function RenderTelegraphLine() { float midX = posX_ + span * cos(angle) + (width / 2) * cos(angle + 90); float midY = posY_ + span * sin(angle) + (width / 2) * sin(angle + 90); ObjParticleList_SetPosition(_shotF_Telegraph_Line, midX, midY, 1); ObjParticleList_SetScale(_shotF_Telegraph_Line, span, width, 1); ObjParticleList_SetAngleZ(_shotF_Telegraph_Line, angle); ObjParticleList_SetColor(_shotF_Telegraph_Line, color_); ObjParticleList_SetAlpha(_shotF_Telegraph_Line, alpha); ObjParticleList_AddInstance(_shotF_Telegraph_Line); } //return _shotF_Telegraph_Line; }