View difference between Paste ID: GEXYfxRH and RNc8v7pW
SHOW: | | - or go back to the newest paste.
1
task Trail(x,y,dir)
2
		{
3
			let fcount = 0;
4
			let obj_trail = Obj_Create(OBJ_EFFECT);
5-
			Obj_SetAutoDelete (obj_trail,true);
5+
			Obj_SetAutoDelete (obj_trail,true);  //Should stop being spawned once the parent shot leaves the field, so probably redundant
6
			Obj_SetPosition(obj_trail,x,y);
7
			Obj_SetSpeed(obj_trail,0);
8
			Obj_SetAngle(obj_trail,dir);
9
			ObjEffect_SetRenderState(obj_trail,ALPHA);
10-
			Obj_SetAlpha(obj_trail,10);
10+
			Obj_SetAlpha(obj_trail,10);  //Does not work with effect objects, added fix below
11
12
			ObjEffect_SetTexture(obj_trail,plshot);
13
			ObjEffect_SetPrimitiveType(obj_trail,PRIMITIVE_TRIANGLEFAN);
14
			ObjEffect_CreateVertex(obj_trail,4);
15
			
16
			ObjEffect_SetVertexUV(obj_trail,0,1,177);
17
			ObjEffect_SetVertexUV(obj_trail,1,15,177);
18
			ObjEffect_SetVertexUV(obj_trail,2,15,203);
19
			ObjEffect_SetVertexUV(obj_trail,3,1,203);
20
			
21
			ObjEffect_SetVertexXY(obj_trail,0,-8,-16);
22
			ObjEffect_SetVertexXY(obj_trail,1,8,-16);
23
			ObjEffect_SetVertexXY(obj_trail,2,8,16);
24-
			loop(5)
24+
25
26
			ascent(i in 0..4){ ObjEffect_SetVertexColor(obj_trail,i,10,255,255,255); }
27-
				if (fcount >= 0 && fcount < 3)
27+
28
////This should be much less expensive and is shorter, but I included the solution you were looking for anyways
29-
					ObjEffect_SetVertexUV(obj_trail,0,1,177);
29+
//loop(3){ yield; }
30-
					ObjEffect_SetVertexUV(obj_trail,1,15,177);
30+
//ObjEffect_SetVertexUV(obj_trail,0,1,150);
31-
					ObjEffect_SetVertexUV(obj_trail,2,15,203);
31+
//ObjEffect_SetVertexUV(obj_trail,1,15,150);
32-
					ObjEffect_SetVertexUV(obj_trail,3,1,203);
32+
//ObjEffect_SetVertexUV(obj_trail,2,15,176);
33-
					fcount ++;
33+
//ObjEffect_SetVertexUV(obj_trail,3,1,176);
34
//loop(3){ yield; }
35
//ObjEffect_SetVertexUV(obj_trail,0,1,123);
36
//ObjEffect_SetVertexUV(obj_trail,1,15,123);
37
//ObjEffect_SetVertexUV(obj_trail,2,15,149);
38
//ObjEffect_SetVertexUV(obj_trail,3,1,149);
39
//loop(3){ yield; }
40
//Obj_Delete(obj_trail);
41
42-
					fcount ++;
42+
			while(!Obj_BeDeleted(obj_trail))
43
			{					
44
				//shouldn't need the first 3 frames if it's already set
45-
				if (fcount >= 6 && fcount < 9)
45+
46
				if (fcount >= 3 && fcount < 6)
47
				{
48
					ObjEffect_SetVertexUV(obj_trail,0,1,150);
49
					ObjEffect_SetVertexUV(obj_trail,1,15,150);
50
					ObjEffect_SetVertexUV(obj_trail,2,15,176);
51-
					fcount ++;
51+
52
				}
53
				else if (fcount >= 6 && fcount < 9)
54-
				if (fcount >= 9)
54+
55
					ObjEffect_SetVertexUV(obj_trail,0,1,123);
56
					ObjEffect_SetVertexUV(obj_trail,1,15,123);
57-
					return;
57+
58
					ObjEffect_SetVertexUV(obj_trail,3,1,149);
59
				}
60
				else
61
				{
62
					Obj_Delete(obj_trail);
63
				}
64
				fcount ++;
65
				yield;
66
			}
67
		}