Author Topic: Danmakufu Q&A/Problem Thread II  (Read 166217 times)

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread II
« Reply #390 on: November 18, 2009, 12:11:17 PM »
I FAILED at trying to make my circle bend... but this was just too awesome to not show anyone... (that weird thing actually moves and keeps on creating more weird stuff, but still stays circular...)

I tried to do this just because of boredom and curiosity, so no need to explain to me how it works if you wanna explain... I was just bored :V and who knows... I may actually use this weird bending effect sometime in the future...
« Last Edit: November 18, 2009, 12:15:41 PM by kyle_090594 »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #391 on: November 18, 2009, 02:22:14 PM »
Drake, I didn't understand a thing of the spellcircle slingshot effect code. Therefor reasking it again =.=. I am a failure in math so this is the following I want to achieve by math (else I could take the long road)

- My spellcircle has starting size: 80.
- I want it to grow to 180 with an accelerating speed.
- When it reaches close to 180 I want it to deaccelerate
- At size 180 it should start shrinking with acceleration untill it reaches it's final size: 150

HOW ?!


Nvm I got it:
let c = 17;

inside loop:
if(c>0 && switch == 0){ size += c*cos(360/size); c-=0.5; if(c==0){switch=1;}}
if(c<15 && switch == 1){ size -= c*cos(360/size); c+=0.5; if(c==15){switch=2;}} 

Probably not the most efficient or beautiful method but for a math-failure like me it felt like the top of the mountain.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #392 on: November 18, 2009, 04:37:22 PM »
When I have the time I'll make an object bullet of which will be possible to substitute with the circle radius. I can't really understand what you're doing right now so :V

EDIT: I'll expand on it later. There should be an equation you can use so you don't have to manually test speeds like I did.

let obj = Obj_Create(OBJ_SHOT);
let radius = 80;
let maxradius = 180;
let finalradius = 150;
let speed = 3;
let accspeed = -0.04569;
Obj_SetX(obj,GetCenterX);Obj_SetSpeed(obj,0);
Obj_SetAngle(obj,270);ObjShot_SetGraphic(obj,WHITE01);
while(!Obj_BeDeleted(obj)){
    Obj_SetY(obj,GetCenterY+radius);
    radius+=speed;
    speed+=accspeed;
    if(radius>=maxradius){Obj_Delete(obj);}
    if(radius<=finalradius && speed<=0){speed=0;accspeed=0;}
    yield;
}
« Last Edit: November 18, 2009, 04:54:36 PM by Drake »

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Fujiwara no Mokou

  • Hourai Incarnate
  • Oh, so this trial of guts is for ME?
    • Profile
Re: Danmakufu Q&A/Problem Thread II
« Reply #393 on: November 18, 2009, 05:19:12 PM »
Drake, I didn't understand a thing of the spellcircle slingshot effect code. Therefor reasking it again =.=. I am a failure in math so this is the following I want to achieve by math (else I could take the long road)

- My spellcircle has starting size: 80.
- I want it to grow to 180 with an accelerating speed.
- When it reaches close to 180 I want it to deaccelerate
- At size 180 it should start shrinking with acceleration untill it reaches it's final size: 150

HOW ?!

I think I see what you're trying to do. You want it to start at 0, accelerate to 180, and then decelerate as it closes in on 150, which it stops at. 
You're going to have to use a bit of trigonometry for this one.  What you're looking for is sine.  I can't do the entire math in my head, but from what I already know, what you want to do is A*sin(X*F).

A -being the top speed (magnitude).  X-being the angle you'll get the sine of, and F, being how "quick" the acceleration and deceleration will be altogether.
Then, increase the value of X by a set amount of frames. There's math behind it, and you'll need it.

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #394 on: November 18, 2009, 07:59:30 PM »
I think I see what you're trying to do. You want it to start at 0, accelerate to 180, and then decelerate as it closes in on 150, which it stops at. 
You're going to have to use a bit of trigonometry for this one.  What you're looking for is sine.  I can't do the entire math in my head, but from what I already know, what you want to do is A*sin(X*F).

A -being the top speed (magnitude).  X-being the angle you'll get the sine of, and F, being how "quick" the acceleration and deceleration will be altogether.
Then, increase the value of X by a set amount of frames. There's math behind it, and you'll need it.
Correct. And if there is one thing I hate myself for is math :V I need it indeed but blending it into danmakufu is hard. I started messing with parabola formulas and all kind of stuff. ( I didn't even knew I had to use sinus ) I just ended up with cos and by some random luck it worked out. Yay me ( horrible presentation though )

@Drake be on IRC if you can so we can discuss stuff about Ijiyatsu

Infy♫

  • Demonic★Moe
  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #395 on: November 19, 2009, 04:10:47 PM »
how can i give some score when a player captures a nonspell, but without making dnh think its a spell?

Re: Danmakufu Q&A/Problem Thread II
« Reply #396 on: November 19, 2009, 04:16:34 PM »
AddScore(number);


@Finalize{
   if((GetMissCountInThisSpell + GetBomBCountInThisSPell)==0){
     AddScore(100000);
   }else{
     DrawText("You suck", GetPlayerX, GetPlayerY - 30, 12, 255);
     PlaySE(GetCurrentScriptDirectory~"Hawhaw.wav");
   }
}

Re: Danmakufu Q&A/Problem Thread II
« Reply #397 on: November 20, 2009, 04:55:56 AM »
How would you put SetGraphicRects in a task and how would you call it? Ive tried a code like this:
Code: [Select]
task animation1(start,endframe){
let anim = 0;
if(anim<5){SetGraphicRect(0, 229, 34, 300);}
if(anim>=5 && anim<10){SetGraphicRect(34, 229, 34, 300);}
if(anim>=10 && anim<15){SetGraphicRect(68, 229, 68, 300);}
if(anim>=15 && anim<20){SetGraphicRect(102, 229, 102, 300);}
if(anim==endframe){
start = 0;}
if(start>0){
anim++;}}

And when called, it does nothing...any ideas?

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #398 on: November 20, 2009, 05:02:51 AM »
I haven't tried this, but from my knowledge of how Danmakufu works, you aren't allowed to control graphics in the @MainLoop. Since most scripts run yield; in the @MainLoop, the tasks are counted as running there as well, and therefore things that control graphics wouldn't work either.

I think your best bet is to just write a bunch of conditionals in the @DrawLoop unless you don't wanna use tasks in the @MainLoop anymore. I may be wrong though.

EDIT: Perhaps putting a yield; in @DrawLoop will work too? I know @DrawLoop ignores bullet functions and @MainLoop ignores drawing functions... But this way, each task will need two yields to wait one frame.
« Last Edit: November 20, 2009, 05:16:43 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #399 on: November 20, 2009, 05:05:12 AM »
Not sure about tasks and yields, but if you call a drawing function in DrawLoop it'll work fine.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Danmakufu Q&A/Problem Thread II
« Reply #400 on: November 20, 2009, 05:16:53 AM »
Blargel is correct, you must sacrifice the use of @MainLoop tasks for @DrawLoop tasks to work. This tends to be why you don't see them very often at all.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #401 on: November 20, 2009, 08:09:08 AM »
How would you put SetGraphicRects in a task and how would you call it? Ive tried a code like this:
Code: [Select]
task animation1(start,endframe){
let anim = 0;
if(anim<5){SetGraphicRect(0, 229, 34, 300);}
if(anim>=5 && anim<10){SetGraphicRect(34, 229, 34, 300);}
if(anim>=10 && anim<15){SetGraphicRect(68, 229, 68, 300);}
if(anim>=15 && anim<20){SetGraphicRect(102, 229, 102, 300);}
if(anim==endframe){
start = 0;}
if(start>0){
anim++;}}

And when called, it does nothing...any ideas?

Actually you know what? Besides the problem with tasks running only in either MainLoop or DrawLoop, isn't your task only going through once and stopping? I mean, as far as I can tell, it makes a variable called anim set to 0, checks if anim is less than 5 (which it is so it runs SetGraphicRect(0, 229, 34, 300);), checks anim against a bunch of other if statements that won't be true, checks if start is greater tan 0, and then ends. It doesn't loop, nor does it even yield once.

EDIT: Stupid solution go!
Make a child enemy that has no hitbox, sets its position to the parent enemy, and handles drawing the parent enemy's graphic. Since this child enemy doesn't need to shoot bullets, you can put yield; inside the @DrawLoop instead of the @MainLoop to uses tasks to handle animation more easily. Meanwhile, the parent enemy has yield; in the @MainLoop like usual and handles all the danmaku creation and other things that might be needed.
« Last Edit: November 20, 2009, 09:03:04 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #402 on: November 20, 2009, 04:31:40 PM »
Oh my god that is so unnecessary
i guess it would work, but really

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Nimble

  • Broken English Fox
  • Rushing toward the bullet!
    • Viewmix
Re: Danmakufu Q&A/Problem Thread II
« Reply #403 on: November 21, 2009, 02:12:15 PM »
Can I make object shot in player spell has delay effect act like enemy shot?

I try on custom bullet shot and it delay by show it graphic until it fire out, not bullet cloud.

CK Crash

  • boozer
Re: Danmakufu Q&A/Problem Thread II
« Reply #404 on: November 21, 2009, 03:17:05 PM »
ObjShot_SetDelay(id,frames);

Keep in mind that if you use a task for each object shot, the task will continue while the shot is still delaying. You may want to loop yield until the delay is over.

Nimble

  • Broken English Fox
  • Rushing toward the bullet!
    • Viewmix
Re: Danmakufu Q&A/Problem Thread II
« Reply #405 on: November 21, 2009, 04:18:35 PM »
It happen like this when I delay it.


Edit ->
Normal delay that I want.

Any advice?

ObjShot_SetDelay(id,frames);

work as upper image.
« Last Edit: November 22, 2009, 09:36:02 AM by Nimble »

Re: Danmakufu Q&A/Problem Thread II
« Reply #406 on: November 22, 2009, 03:37:56 AM »
Can anyone tell me how to use custom danmaku?

Re: Danmakufu Q&A/Problem Thread II
« Reply #407 on: November 22, 2009, 05:02:42 AM »
Can anyone tell me how to use custom danmaku?

I'll be assuming you mean custom shots/
First, you will need a shot sheet with the bullets you want to fire.
Second, you will need to make a .txt with #UserShotData in the first line.
Third, you will need to load the Shot Sheet.
Before i go on, here is an example:
Code: [Select]
#UserShotData \\Defines as Shot Data

ShotImage = ".\img\shot.png" \\Loads the image

ShotData{//Opens the ShotData data
id = 1337 //Id used to fire the bullet
rect = ( 0, 0, 64, 64) //Rect, or location, where the bullet is located on the sheet. (left, up, right down)
render = ALPHA //"Just use it"
delay_color = ( 128, 128, 128 ) //Color of the delay that will shot up (red, blue, yellow)
angular_velocity = 0 //Decides if the bullet rotates, negative for counterclockwise, vice versa
} //Closes the Shot Data

Then in the script you want to call the bullet in, call:
LoadUserShotData in the Initalize, such as if we named the ShotData shot.txt:
LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");

Then call the bullet with the Id you have specified...

*faints*

« Last Edit: November 22, 2009, 05:09:40 AM by Demonbman »

Chronojet ⚙ Dragon

  • The Oddity
  • 今コソ輝ケ、我ガ未来、ソノ可能性!!
Re: Danmakufu Q&A/Problem Thread II
« Reply #408 on: November 22, 2009, 05:07:12 AM »
I'll be assuming you mean custom shots/
First, you will need a shot sheet with the bullets you want to fire.
Second, you will need to make a .txt with #UserShotData in the first line.
Third, you will need to load the Shot Sheet.
Before i go on, here is an example:
Code: [Select]
#UserShotData \\Defines as Shot Data

ShotImage = ".\img\shot.png" \\Loads the image

ShotData{\\Opens the ShotData data
id = 1337 \\Id used to fire the bullet
rect = ( 0, 0, 64, 64) \\Rect, or location, where the bullet is located on the sheet. (left, up, right down)
render = ALPHA \\"Just use it"
delay_color = ( 128, 128, 128 ) \\Color of the delay that will shot up (red, blue, yellow)
angular_velocity = 0 \\Decides if the bullet rotates, negative for counterclockwise, vice versa
} \\Closes the Shot Data

Then in the script you want to call the bullet in, call:
#LoadUserShotData in the Initalize, such as if we named the ShotData shot.txt:
#LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");

Then call the bullet with the Id you have specified...

*faints*
All your \\ replace by //
« Last Edit: November 22, 2009, 06:06:11 AM by Always お⑨烏 »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: Danmakufu Q&A/Problem Thread II
« Reply #409 on: November 22, 2009, 08:57:50 AM »
I wouldn't use 1337 as a number as danmakufu only allows a range from 1 to 255 :V

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread II
« Reply #410 on: November 22, 2009, 10:37:40 AM »
Is there a short and non-tedious way of turning a value into an array by digit? example... turning 123456 into [1, 2, 3, 4, 5, 6] ???
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Iryan

  • Ph?nglui mglw?nafh
  • Cat R?lyeh wgah?nagl fhtagn.
Re: Danmakufu Q&A/Problem Thread II
« Reply #411 on: November 22, 2009, 11:35:08 AM »
Okay, I cannot test if this works, but if I understand it correctly, it just might.

Create an array at the beginning of your script:

Code: [Select]
let test=[];
Then include the following task:

Code: [Select]
task Tconvert(X){
  let array = [];
  let array2 = [0];
  let array3 = [];

  while(X>=1){
    array2[0]=X;
    X=floor(X/10);
    array2[0]=array2[0]-10*X;
    array=array ~ array2;
  }

  descent(i in (length(array))..0) {
    array2[0]=array[i];
    array3=array3~array;
  }
  test=array3;
}


In theory, this should convert your number X into the array "test". There might be some mistakes, though. In praticular I am not shure if the descent shouldn't be descent(i in (length(array)-1)..(-1)) instead, but as I said, I cannot test it.

If it won't work, I' sorry.  :-\
Old Danmakufu stuff can be found here!

"As the size of an explosion increases, the numbers of social situations it is incapable of solving approaches zero."

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread II
« Reply #412 on: November 22, 2009, 12:43:09 PM »
thanks iryan, I'm not sure if that works, but I found another way of doing it, so nevermind ;D

I have a different question now... I'm trying to make items and I'm wondering why this won't work:
Code: [Select]
let itempic="lib\system\items.png";
LoadGraphic(itempic);

task item(type, x, y)
{
let counter=0;
let xpos=x;
let ypos=y;
let obj=Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(obj, itempic);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 4);
if(type=="POWER_S")
{
ObjEffect_SetVertexUV(obj, 0, 0, 0);
ObjEffect_SetVertexUV(obj, 1, 16, 0);
ObjEffect_SetVertexUV(obj, 2, 0, 16);
ObjEffect_SetVertexUV(obj, 3, 16, 16);
}
if(type=="POINT")
{
ObjEffect_SetVertexUV(obj, 0, 16, 0);
ObjEffect_SetVertexUV(obj, 1, 32, 0);
ObjEffect_SetVertexUV(obj, 2, 16, 16);
ObjEffect_SetVertexUV(obj, 3, 32, 16);
}
if(type=="COLLECT")
{
ObjEffect_SetVertexUV(obj, 0, 32, 0);
ObjEffect_SetVertexUV(obj, 1, 48, 0);
ObjEffect_SetVertexUV(obj, 2, 32, 16);
ObjEffect_SetVertexUV(obj, 3, 48, 16);
}
if(type=="POWER_L")
{
ObjEffect_SetVertexUV(obj, 0, 48, 0);
ObjEffect_SetVertexUV(obj, 1, 64, 0);
ObjEffect_SetVertexUV(obj, 2, 48, 16);
ObjEffect_SetVertexUV(obj, 3, 64, 16);
}
if(type=="POWER_F")
{
ObjEffect_SetVertexUV(obj, 0, 96, 0);
ObjEffect_SetVertexUV(obj, 1, 112, 0);
ObjEffect_SetVertexUV(obj, 2, 96, 16);
ObjEffect_SetVertexUV(obj, 3, 112, 16);
}
while(Obj_BeDeleted(obj)==false)
{
yield;
counter++;
if(counter<20)
{
ypos-=2;
}else{
ypos++;
}
ObjEffect_SetVertexXY(obj, 0, xpos-8, ypos-8);
ObjEffect_SetVertexXY(obj, 1, xpos+8, ypos-8);
ObjEffect_SetVertexXY(obj, 2, xpos-8, ypos+8);
ObjEffect_SetVertexXY(obj, 3, xpos+8, ypos+8);
if(((xpos-GetPlayerX)^2+(ypos-GetPlayerY)^2)^0.5<=10)
{
if(type=="POWER_S")
{
SetCommonData("power", GetCommonData("power")+1);
}
if(type=="POWER_L")
{
SetCommonData("power", GetCommonData("power")+10);
}
if(type=="POWER_F")
{
SetCommonData("power", 100);
}
if(type=="POINT")
{
AddScore(5000*(GetGraze/100)/((GetPlayerY-GetClipMinY-120)/50));
AddPoint(1);
}
if(type=="COLLECT")
{
SetCommonData("collect", GetCommonData("collect")+1);
}
Obj_Delete(obj);
}
}
}

and an enemy with the code... which works if it doesn't call the task
Code: [Select]
script_enemy_main {

#include_function ".\enemy1anim.txt"
#include_function "lib\items.txt"
let frame = 0;
let frame2 = 0;
let item = 0;

@Initialize {

SetLife(50);
SetDamageRate(180, 100);
          LoadUserShotData("lib\SHOT_REPLACE\shot_all.dnh");
}

@MainLoop{

SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 6);

frame ++;
frame2 ++;

if(frame == 1){
if(GetX<GetCenterX)
{
SetMovePositionHermite(GetClipMaxX+100,GetY+rand(-100,100),300,270,300,0,300);
}else{
SetMovePositionHermite(GetClipMinX-100,GetY+rand(-100,100),300,90,300,180,300);
}
}

if(frame2>20 && frame2%10==0){
PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
CreateShotA(1, GetX, GetY, 10);
SetShotDataA_XY(1, 0, rand(-3, 3), rand(-1, -3), rand(-0.01, 0.01), rand(0.01, 0.05), rand(-3, 3), rand(2, 4), 3);
FireShot(1);
}


if(GetY > GetClipMaxY || GetX>GetClipMaxX || GetX<GetClipMinX || GetY<GetClipMinY){
VanishEnemy();
item = 1;
}


}

@DrawLoop {
anim2;
}

@Finalize {
if(item == 0){
item("POWER_S", GetX, GetY);
}
}
}
}

I already checked and all the directories are pointed to the right area...

everytime the game loads an enemy that loads that function, it crashes... it doesn't give me an error... it just crashes... (I'm gonna put in the code for the item collection line later)
« Last Edit: November 22, 2009, 02:49:59 PM by kyle_090594 »
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Nimble

  • Broken English Fox
  • Rushing toward the bullet!
    • Viewmix
Re: Danmakufu Q&A/Problem Thread II
« Reply #413 on: November 22, 2009, 03:38:48 PM »
You set task name and variable with same name =w=/
task item(type, x, y)
let item = 0;
Set task name to other like itemdrop(type,x ,y) instead.

Re: Danmakufu Q&A/Problem Thread II
« Reply #414 on: November 22, 2009, 07:56:38 PM »
Is there anyway for Enemy Enumeration to keep selecting the same enemy until it dies, instead of switching between new enemies as they spawn? I've tried a couple different things (like putting whiles inside of whiles, hoo boy) and they have all yielded very interesting error messages, so I'll ask here in case anybody has already solved this problem.

Drake

  • *
Re: Danmakufu Q&A/Problem Thread II
« Reply #415 on: November 22, 2009, 08:56:04 PM »
You can use enemy IDs outside the enumeration loop. Make a variable currentenm and set it to -1. If currentenm == -1, run the enumeration loop and select one enemy, then keep the value gotten from EnumEnemyGetID in currentenm. This value isn't -1, so it keeps skipping the loop. Do your other stuff, and each frame if GetEnemyInfo(currentenm,ENEMY_LIFE)==false, set currentenm to -1.

A Colorful Calculating Creative and Cuddly Crafty Callipygous Clever Commander
- original art by Aiけん | ウサホリ -

Re: Danmakufu Q&A/Problem Thread II
« Reply #416 on: November 22, 2009, 09:09:53 PM »
let enemy = -1;

Code: [Select]
if(GetEnemyInfo(enemy, ENEMY_LIFE)==false){
enemy=-1;
}
if(GetEnemyNum>0 && enemy==-1){
if(!IsBossExisting){
ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
enemy=EnumEnemyGetID(i);
i=EnumEnemyEnd;
}
}else{
i = EnumEnemyBegin;
enemy=EnumEnemyGetID(i);
}
ex = GetEnemyInfo(enemy, ENEMY_X);
ey = GetEnemyInfo(enemy, ENEMY_Y);
}else{
ex = vv + 100*cos(osc);
ey = 0;
}

Errors:





And...

Code: [Select]
if(GetEnemyInfoDefault(enemy, ENEMY_LIFE, 1)==1){
enemy=-1;
}
if(GetEnemyNum>0 && enemy==-1){
if(!IsBossExisting){
ascent(i in EnumEnemyBegin..EnumEnemyEnd) {
enemy=EnumEnemyGetID(i);
i=EnumEnemyEnd;
}
}else{
i = EnumEnemyBegin;
enemy=EnumEnemyGetID(i);
}
ex = GetEnemyInfo(enemy, ENEMY_X);
ey = GetEnemyInfo(enemy, ENEMY_Y);
}else{
ex = vv + 100*cos(osc);
ey = 0;
}

...Just doesn't do anything.

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #417 on: November 23, 2009, 04:19:27 AM »
Here, have a code block that controls my homing lasers. Hope you can get what I did with just my poorly commented code. It's an extract from a giant task that controls the whole object bullet with some irrelevant parts cut out so using the code as is will probably not work.

Code: [Select]
//choose target closest to it
let target = -1;
let targetX = 0;
let targetY = 0;
let closestDistance = 65535;
ascent(enemy in EnumEnemyBegin..EnumEnemyEnd){
  let enemyID = EnumEnemyGetID(enemy);
  let enemyX = GetEnemyInfo(enemyID, ENEMY_X);
  let enemyY = GetEnemyInfo(enemyID, ENEMY_Y);
  let enemyLife = GetEnemyInfo(enemyID, ENEMY_LIFE);
  let enemyDistance = GetDistance(Obj_GetX(obj), Obj_GetY(obj), enemyX, enemyY);
  if(enemyDistance < closestDistance && enemyLife > 0){
    closestDistance = enemyDistance;
    target = enemyID;
    targetX = enemyX;
    targetY = enemyY;
  }
}
//change behavior per frame based on conditions until deleted
while(!Obj_BeDeleted(obj)){

  //if there is a target
  if(GetEnemyInfoDefault(target, ENEMY_LIFE, 0) > 0){
    //logic on what to do if the enemy is alive goes here
  }

  else {
    //logic on what to do if the enemy is dead goes here
  }

  yield;
}

EDIT: Note that you can stick the block that chooses a target in the place that gets run if the target is dead, and it'll choose another target if the enemy is dead already and continue running.
« Last Edit: November 23, 2009, 04:28:57 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.

Kylesky

  • *The Unknown*
  • Local Unbalanced Danmakufu Idiot Scripter
    • My useless youtube account... (will be useful in the future *I promise*)
Re: Danmakufu Q&A/Problem Thread II
« Reply #418 on: November 23, 2009, 10:22:59 AM »
You set task name and variable with same name =w=/
task item(type, x, y)
let item = 0;
Set task name to other like itemdrop(type,x ,y) instead.

I feel like such an idiot... thanks!

I have a different problem now... it's not showing anything when it's called...

itemcode
Code: [Select]
let itempic="lib\system\items.png";
LoadGraphic(itempic);

task itemdrop(type, x, y)
{
let counter=0;
let collection=0;
let xpos=x;
let ypos=y;
let obj=Obj_Create(OBJ_EFFECT);
ObjEffect_SetTexture(obj, itempic);
ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
ObjEffect_CreateVertex(obj, 4);
if(type=="POWER_S")
{
ObjEffect_SetVertexUV(obj, 0, 0, 0);
ObjEffect_SetVertexUV(obj, 1, 16, 0);
ObjEffect_SetVertexUV(obj, 2, 0, 16);
ObjEffect_SetVertexUV(obj, 3, 16, 16);
}
if(type=="POINT")
{
ObjEffect_SetVertexUV(obj, 0, 16, 0);
ObjEffect_SetVertexUV(obj, 1, 32, 0);
ObjEffect_SetVertexUV(obj, 2, 16, 16);
ObjEffect_SetVertexUV(obj, 3, 32, 16);
}
if(type=="COLLECT")
{
ObjEffect_SetVertexUV(obj, 0, 32, 0);
ObjEffect_SetVertexUV(obj, 1, 48, 0);
ObjEffect_SetVertexUV(obj, 2, 32, 16);
ObjEffect_SetVertexUV(obj, 3, 48, 16);
}
if(type=="POWER_L")
{
ObjEffect_SetVertexUV(obj, 0, 48, 0);
ObjEffect_SetVertexUV(obj, 1, 64, 0);
ObjEffect_SetVertexUV(obj, 2, 48, 16);
ObjEffect_SetVertexUV(obj, 3, 64, 16);
}
if(type=="POWER_F")
{
ObjEffect_SetVertexUV(obj, 0, 96, 0);
ObjEffect_SetVertexUV(obj, 1, 112, 0);
ObjEffect_SetVertexUV(obj, 2, 96, 16);
ObjEffect_SetVertexUV(obj, 3, 112, 16);
}
while(Obj_BeDeleted(obj)==false)
{
yield;
counter++;
if(counter<20)
{
ypos-=2;
}else{
ypos++;
}
ObjEffect_SetVertexXY(obj, 0, xpos-8, ypos-8);
ObjEffect_SetVertexXY(obj, 1, xpos+8, ypos-8);
ObjEffect_SetVertexXY(obj, 2, xpos-8, ypos+8);
ObjEffect_SetVertexXY(obj, 3, xpos+8, ypos+8);
if(((xpos-GetPlayerX)^2+(ypos-GetPlayerY)^2)^0.5<=10)
{
if(type=="POWER_S")
{
SetCommonData("power", GetCommonData("power")+1);
}
if(type=="POWER_L")
{
SetCommonData("power", GetCommonData("power")+10);
}
if(type=="POWER_F")
{
SetCommonData("power", 100);
}
if(type=="POINT")
{
AddScore(5000*(GetGraze/100)/((GetPlayerY-GetClipMinY-120)/50));
AddPoint(1);
}
if(type=="COLLECT")
{
SetCommonData("collect", GetCommonData("collect")+1);
}
Obj_Delete(obj);
}
if(GetPlayerY<GetClipMinY+120)
{
collection=1;
}
if(collection==1)
{
xpos+=5*cos(atan2(GetPlayerY-ypos, GetPlayerX-xpos));
ypos+=5*sin(atan2(GetPlayerY-ypos, GetPlayerX-xpos));
}
}
}

enemy code
Code: [Select]
script_enemy_main {

#include_function ".\enemy1anim.txt"
#include_function "lib\items.txt"
let frame = 0;
let frame2 = 0;
let item = 0;

@Initialize {

SetLife(50);
SetDamageRate(180, 100);
          LoadUserShotData("lib\SHOT_REPLACE\shot_all.dnh");
}

@MainLoop{

SetCollisionA(GetX, GetY, 16);
SetCollisionB(GetX, GetY, 6);

frame ++;
frame2 ++;

if(frame == 1){
if(GetX<GetCenterX)
{
SetMovePositionHermite(GetClipMaxX+100,GetY+rand(-100,100),300,270,300,0,300);
}else{
SetMovePositionHermite(GetClipMinX-100,GetY+rand(-100,100),300,90,300,180,300);
}
}

if(frame2>20 && frame2%10==0){
PlaySE(GetCurrentScriptDirectory~"sound\Shot1.wav");
CreateShotA(1, GetX, GetY, 10);
SetShotDataA_XY(1, 0, rand(-3, 3), rand(-1, -3), rand(-0.01, 0.01), rand(0.01, 0.05), rand(-3, 3), rand(2, 4), 3);
FireShot(1);
}


if(GetY > GetClipMaxY || GetX>GetClipMaxX || GetX<GetClipMinX || GetY<GetClipMinY){
VanishEnemy();
item = 1;
}


}

@DrawLoop {
anim2;
}

@Finalize {
if(item == 0){
itemdrop("POWER_S", GetX, GetY);
}
}
}
}

all the directories and paths are right... I checked... when the enemy dies... nothing comes out...
Danmakufu Script Thread :V Latest Script: Intertwining Mechanical Intervention (temp name)

Yooooouuutuuuubeeee Channel Latest Video: Contest #8 Entry

Blargel

  • RAWR!
  • I'M AN ANGRY LOLI!
Re: Danmakufu Q&A/Problem Thread II
« Reply #419 on: November 23, 2009, 10:25:40 AM »
You're calling LoadGraphic in the wrong place. Put it in the @Initialize of every enemy that's gonna drop items instead of in the separate file.

Alternatively, call it in the @Initialize of the stages you'll be making so you only need to write it once.
« Last Edit: November 23, 2009, 10:32:16 AM by Blargel »
<WorkingKeine> when i get home i just go to the ps3 and beat people up in blazblue with a loli
<Azure> Keine: Danmakufu helper by day, violent loli by night.