#TouhouDanmakufu
#Title[Danmaku Upgrade "Alpha Shock"]
#Text[An attack from somewhere else, as a Spell Card!]
#Player[FREE]
#ScriptVersion[2]
script_enemy_main{
let CSD = GetCurrentScriptDirectory;
let imgBoss = CSD ~ "system\PlaceholderBoss.png";
#include_function "lib\ExpandedShotData\shot_replace.dnh";
@Initialize{
SetLife(1000);
SetTimer(80);
SetScore(1000000);
SetMovePosition01(GetCenterX,GetCenterY-60,5);
SetEnemyMarker(true);
SetInvincibility(80);
SetDamageRate(25,25);
LoadGraphic(imgBoss);
shotinit;
CutIn(KOUMA,"Danmaku Upgrade "\""Alpha Shock"\","",0,0,0,0);
mainTask;
SoundTask;
}
@MainLoop{
SetCollisionA(GetX,GetY,32);
SetCollisionB(GetX,GetY,16);
yield;
}
@DrawLoop{
SetTexture(imgBoss);
SetRenderState(ALPHA);
SetAlpha(255);
SetGraphicRect(0,0,64,64);
SetGraphicScale(1,1);
SetGraphicAngle(0,0,0);
DrawGraphic(GetX,GetY);
}
@BackGround{
}
@Finalize{
DeleteGraphic(imgBoss);
}
task mainTask{
wait(50);
loop{
fire;
wait(100);
centerbolt;
wait(100);
}
}
task fire{
let n = 0;
let dxl = 0;
let dxr = 0;
let xa = (448/4)+dxl;
let xb = (448*3/4)+dxr;
//YELLOW01 is 16 px tall and the play field is 480 px tall, but this leaves safe lines
//create two lightning bolts from 1/3 and 2/3 the width of the screen starting at the top
while(n<480/12){
//if n is an odd number, the bullet will move to the right; otherwise it moves to the left
if(floor(n/2) < n/2){
lightning(xa+dxl,12*n,0,0,YELLOW01,n);
lightning(xb+dxr,12*n,0,0,YELLOW01,n);
}else{
lightning(xa+dxl,12*n,0,180,YELLOW01,n);
lightning(xb+dxr,12*n,0,180,YELLOW01,n);
}
wait(1);
dxl=rand_int(-8,8);
dxr=rand_int(-8,8);
xa+=dxl;
xb+=dxr;
n++;
}
n = 0;
dxl = 0;
dxr = 0;
xa = (448/4);
xb = (448*3/4);
}
task centerbolt{
let n = 0;
let dx = 0;
let xc = (448/2)+dx;
//create a lightning bolt starting from the top middle
while(n<480/12){
//bullets in the middle chain will have the opposite system from that above
if(floor(n/2) < n/2){
lightning(xc+dx,12*n,0,180,YELLOW01,n);
}else{
lightning(xc+dx,12*n,0,0,YELLOW01,n);
}
wait(1);
dx=rand_int(-8,8);
n++;
}
n = 0;
dx = 0;
xc = (448/2);
}
function wait(w){
loop(w){yield;}
}
//generate object bullet
task lightning(x,y,v,dir,graphic,delay){
let shard = Obj_Create(OBJ_SHOT);
Obj_SetPosition(shard,x,y);
Obj_SetAngle(shard,dir);
ObjShot_SetGraphic(shard,graphic);
ObjShot_SetDelay(shard,delay);
ObjShot_SetBombResist(shard,false);
wait(90+delay);
Obj_SetSpeed(shard,1.5);
}
task SoundTask{
loop{if(GetTimer <= 10 && GetTimer > 3){
PlaySE(CSD ~ "Materials/timer1.wav");
wait(60);
}
if(GetTimer <= 3){
PlaySE(CSD ~ "Materials/timer2.wav");
wait(60);
}
yield;}
}
}
Try this. Your problem was that you were calling 'wait' in the Mainloop, and yield; has substantially different effects depending on whether it's called in the Mainloop or outside it. I don't have the sound files, so I can't tell, but get back to me on this if this doesn't work (I relegated your snippet to a task, SoundTask, and called it separately from Maintask)
Also, yeah yeah, my syntax is kinda crap, big deal. I tested it, and it didn't freeze or do anything scary past timer = 10