Author Topic: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry  (Read 243856 times)

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #360 on: February 12, 2015, 06:41:38 AM »
Yeah, that quirk mostly has to do with characters being treated as their codepoints. It gets pretty silly, since it doesn't seem consistent on how it's applied. In 0.12m it was mostly consistent that characters were treated as numbers for arithmetic, which also meant adding zero gave you the codepoint, for example. In ph3 you get type mismatches... unless you wrap it in an array first. Doing vector addition gives more type errors. In both 0.12m and ph3 having characters and numbers in an array gives type errors.

Code: [Select]
ph3:
'a' + 0 = type error
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = type error
['a' + 'b'] = [195]
"a" + "b" = ?

0.12m:
'a' + 0 = 97
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = 195
['a' + 'b'] = [195]
"a" + "b" = テ

The "wrong" example you give is basically because doing arithmetic turns the characters into numbers, despite still being able to be displayed as characters.



As an aside, I forgot about your other problem with the freezing a few pages back. I see that you've solved it, but you might not realize why moving the event code into a task worked. It's really just a matter of how the scheduling system works, and should be pretty obvious if you recognize what yield does. For example, test out what happens with this:

Code: [Select]
case(EV_PLAYER_SPELL){
loop(120){
AddGraze(1);
yield;
}
}

The thing is that the engine's main routines run sequentially. This is pretty much expected, I think. Because of this, every time you yield in @Event you're essentially yielding to other tasks (and back) an extra time before the frame is updated. In this case, using a bomb will make your graze shoot up by 120, and every thread will have advanced 120 yields in whatever state they're in (in other words it "skips" 120 "frames"). In your case where you yielded until a button was pushed, it yields, all the other threads run and yield, comes back and asks if a button is pressed, and since the frame never updated you'll never get any new button presses, and the game loops infinitely.

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

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #361 on: February 12, 2015, 06:59:36 AM »
Yeah, that quirk mostly has to do with characters being treated as their codepoints. It gets pretty silly, since it doesn't seem consistent on how it's applied. In 0.12m it was mostly consistent that characters were treated as numbers for arithmetic, which also meant adding zero gave you the codepoint, for example. In ph3 you get type mismatches... unless you wrap it in an array first. Doing vector addition gives more type errors. In both 0.12m and ph3 having characters and numbers in an array gives type errors.

Code: [Select]
ph3:
'a' + 0 = type error
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = type error
['a' + 'b'] = [195]
"a" + "b" = ?

0.12m:
'a' + 0 = 97
['a' + 0] = [97]
['a']+[0] = type error
'a' + 'b' = 195
['a' + 'b'] = [195]
"a" + "b" = テ

The "wrong" example you give is basically because doing arithmetic turns the characters into numbers, despite still being able to be displayed as characters.

And what about the quirk that things such as "a" + "b" can't be compared with regular strings such as "a"? I guess it's some difference lingering in the codebase? Then why doesn't the result become displayed as an array of numbers?
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #362 on: February 12, 2015, 07:50:16 AM »
i dunno lol

I'm pretty sure the intention is that you shouldn't be able to do arithmetic on characters at all, and that really these should all result in type errors. If these few rather non-obvious quirks are just missed cases, then it makes sense that nothing really makes sense when using them.

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

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #363 on: February 12, 2015, 10:14:55 PM »
I've been developing a Danmakufu script over the past week or so, and I've encountered a strange bug.
I have the boss firing two shots left and right, which are intended to bounce at the player when they hit the wall, but they... don't.
Despite the fact that I have code for that in place which is really odd.

Here's my code, for reference.

Sparen

  • Danmakufu Artist
  • Git ready, git set, PUUSH!
    • AFCDTech
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #364 on: February 13, 2015, 01:28:31 AM »
I've been developing a Danmakufu script over the past week or so, and I've encountered a strange bug.
I have the boss firing two shots left and right, which are intended to bounce at the player when they hit the wall, but they... don't.
Despite the fact that I have code for that in place which is really odd.

Here's my code, for reference.

Line 71: You need a ;
angletoplayer(): There is already a built-int function GetAngleToPlayer()


For more information on ObjMove_AddPattern, read http://sparen.github.io/ph3tutorials/ph3u1l8.html#sub5 - you are setting the angle to player when you call ObjMove_AddPattern. If you do this, the bullet will set its angle to what ObjMove_AddPattern had when it was called, not the angle at the time it hits the wall. Read the rest of the tutorial I linked above - you will find a while loop such as the following:
Code: [Select]
task BulletCommands(obj){
    while(<insert code for inside walls here>){yield;}
    ObjMove_SetAngle(obj, GetAngleToPlayer(obj);
}
to work better. Also, use GetStgFrameWidth and GetStgFrameHeight instead of 384 and 448.


Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #365 on: February 13, 2015, 05:25:24 AM »
What is the limitations of Danmakufu?  I am very new and although I wanna learn Unity I am worried I am walking through a land mine so if danmakufu is recommended for beginners and the limitations are not too bad I might use it to practice. (Please be the right thread I am sorry if it isn't I am trying)

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #366 on: February 13, 2015, 05:46:34 AM »
What is the limitations of Danmakufu?  I am very new and although I wanna learn Unity I am worried I am walking through a land mine so if danmakufu is recommended for beginners and the limitations are not too bad I might use it to practice. (Please be the right thread I am sorry if it isn't I am trying)

  • No first-class functions
  • Not-so-strong typing
  • Speed
  • Verbosity
  • No FFI
  • Sometimes strange behavior
  • Crashes
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #367 on: February 13, 2015, 07:58:18 AM »
I wouldn't call most of those limitations, really. Not having arbitrary features in the language specification isn't a real limitation, I think. Noting a lack of features in the language makes sense when the language probably should support a capability because of its relation to another capability but doesn't, or where something should be accessible but isn't. Not being able to curry functions in a procedural language isn't something to lose sleep over.

- Speed is a concern, although really it doesn't get bad until you start doing a serious amount of work. On the level of fully polished games you will probably have to be careful and optimize.

- The type system is quite weak, as the only "raw" types available to you are boolean values, numbers (only one datatype) and characters (arrays of which are strings). Many things you manipulate in Danmakufu are various types in the program itself but the scripting language only lets you refer to them with numbered IDs (object IDs, enemy IDs, etc).

- The only data structures available are arrays (which really behave more like lists), so you have to implement other structures yourself if you need to. Map structures are sort of available in the form of object "values" and CommonData, but it's fairly clunky.

- There are many things the engine does in the background that would be really nice to be able to access but you have no way to, so some things are just plain hidden from you. This has improved since 0.12m, but still isn't as good as it could be.

- Although there are objects and most of your programming is about manipulating them, the object-oriented language features are very limited both in what you can access and how you access them. Again, better than it was in 0.12m, but still very limited when compared to using libraries on top of more feature-rich programming languages.

(- Anonymous functions would be nice considering how many tasks you write in DNH are just going to be run the next line anyways.)

Mainly I'm wondering what FallenLegacy expects as examples of limitations, and what they expect to be able to do, if this is one their first programming experiences.
« Last Edit: February 13, 2015, 08:01:48 AM by Drake »

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

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #368 on: February 13, 2015, 08:47:42 AM »
I wouldn't call most of those limitations, really. Not having arbitrary features in the language specification isn't a real limitation, I think. Noting a lack of features in the language makes sense when the language probably should support a capability because of its relation to another capability but doesn't, or where something should be accessible but isn't. Not being able to curry functions in a procedural language isn't something to lose sleep over.

- Speed is a concern, although really it doesn't get bad until you start doing a serious amount of work. On the level of fully polished games you will probably have to be careful and optimize.

- The type system is quite weak, as the only "raw" types available to you are boolean values, numbers (only one datatype) and characters (arrays of which are strings). Many things you manipulate in Danmakufu are various types in the program itself but the scripting language only lets you refer to them with numbered IDs (object IDs, enemy IDs, etc).

- The only data structures available are arrays (which really behave more like lists), so you have to implement other structures yourself if you need to. Map structures are sort of available in the form of object "values" and CommonData, but it's fairly clunky.

- There are many things the engine does in the background that would be really nice to be able to access but you have no way to, so some things are just plain hidden from you. This has improved since 0.12m, but still isn't as good as it could be.

- Although there are objects and most of your programming is about manipulating them, the object-oriented language features are very limited both in what you can access and how you access them. Again, better than it was in 0.12m, but still very limited when compared to using libraries on top of more feature-rich programming languages.

(- Anonymous functions would be nice considering how many tasks you write in DNH are just going to be run the next line anyways.)

Mainly I'm wondering what FallenLegacy expects as examples of limitations, and what they expect to be able to do, if this is one their first programming experiences.


So in other words it is not for beginners and I am better off with Unity or UDK til I know what I am doing? These issues you stated sound complex to fix.

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #369 on: February 13, 2015, 08:56:03 AM »

So in other words it is not for beginners and I am better off with Unity or UDK til I know what I am doing? These issues you stated sound complex to fix.

It is meant for beginners; the weaknesses target mostly advanced users.
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #370 on: February 13, 2015, 10:28:48 AM »
Yeah to the above, DNH is pretty beginner-friendly when starting out. The framework is straightforward and making things happen doesn't take too much effort as long as the question "can I do this" has the answer "there's a function for that". This is why I asked what you mean by "limitations".

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #371 on: February 13, 2015, 10:29:56 AM »
@ FallenLegacy,

It is also quite black & white. If you decide to work in ph3, we can help you out here with info / questions. If you decide to pick Unity or other method, then you're kind of on your own. We have no resources like tutorials and such and you need to hope if others know about it.

Up to you how to approach this. We just provide you the info.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #372 on: February 13, 2015, 09:45:57 PM »
I will give it a try,besides what have I got to lose besides time? xD I got plenty

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #373 on: February 15, 2015, 05:57:59 AM »
Can NotifyEventAll be used in an event handler? If so, then what other circumstances might prevent an event from registering?
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #374 on: February 15, 2015, 06:14:10 AM »
You can, it'll just crash if you notify the same event without changing conditions. I can't really think of scenarios where an event just won't register at all, since if you use NotifyEventAll() and any script is running, it'll run at least some @Event routine. Whether it's handled after that is another matter.

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

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #375 on: February 15, 2015, 06:16:36 AM »
You can, it'll just crash if you notify the same event without changing conditions. I can't really think of scenarios where an event just won't register at all, since if you use NotifyEventAll() and any script is running, it'll run at least some @Event routine. Whether it's handled after that is another matter.

Really?

I have this in my system script:

Code: [Select]
@Event {
alternative (GetEventType())
case (EV_START_BOSS_SPELL) {
let path = dirCurrent ~ "system_magic_circle.dnh";
let id = LoadScript(path);
StartScript(id);
}
case (EV_GAIN_SPELL) {
let objScene = GetEnemyBossSceneObjectID();
let score = ObjEnemyBossScene_GetInfo(objScene, INFO_SPELL_SCORE);
TGainSpell(score);
}
case (EV_SUBMIT_COMPLETE) {
if (GetPlayerLife != 0.123) {
NotifyEventAll(EV_SUBMIT, [getCharacter, getDifficulty, isHidden, 12, GetScore]); // EV_SUBMIT = EV_USER + 6
while (!GetCommonData("HSSubmitDone", false)) {WriteLog("poop"); yield;}
SetCommonData("HSSubmitDone", false);
}
}
}

And in my package script:

Code: [Select]
@Event {
alternative (GetEventType)
case (EV_USER + 3) {
let path = GetEventArgument(0);
ObjSound_Stop(bgm);
if (path != "") {
ObjSound_Load(bgm, path);
ObjSound_Play(bgm);
let dPath = SplitString(path, "/");
SetAreaCommonData("Cy05", "HeardBGM " ~ dPath[length(dPath) - 1], true);
}
}
case (EV_USER + 4) {
let p = GetEventArgument(0);
if (p) {
TBackground;
}
else {
TStopBG;
}
PauseStageScene(p);
}
case (EV_USER + 5) {
whenYouAreDedz(GetEventArgument(0));
}
case (EV_USER + 6) {
RaiseError("event intercepted"); // <--!!
viewHS(GetEventArgument(0));
}
}

Notifying EV_SUBMIT_COMPLETE (which should happen at the end of the stage) doesn't raise any error.
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #376 on: February 15, 2015, 06:21:35 AM »
Output GetEventType() somewhere at the start of an @Event routine to dump all the events that happen. Are you sure EV_SUBMIT_COMPLETE triggers?

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

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #377 on: February 15, 2015, 06:37:19 AM »
Output GetEventType() somewhere at the start of an @Event routine to dump all the events that happen. Are you sure EV_SUBMIT_COMPLETE triggers?

It triggers.

Code: [Select]
2015/02/15 01:36:25.753 1000007pack
2015/02/15 01:36:25.772 1000007sys
2015/02/15 01:36:25.783 1000006sys

And EV_SUBMIT triggers ... but in the wrong script.
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #378 on: February 15, 2015, 07:49:44 AM »
I really can't replicate your problem. Can you get something simpler working, like NotifyEventAll(EV_USER+100,0) in the @MainLoop of your System script and if(GetEventType==EV_USER+100){ AddScore(1); } in your Package script?


Also silly me, many predefined events can only be called by certain scripts, like EV_REQUEST_LIFE by enemy scripts. These won't "register" if you notify it from another script. That isn't the issue here, but yeah.

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

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #379 on: February 15, 2015, 10:01:12 AM »
Since SetInvincibility isn't avail in ph3, I had made the following piece of code:

// Enemy or boss invul mode (since 0.12m doesn't have one)
task setInvulnerableTime(obj,t) {
   let lockHP = ObjEnemy_GetInfo(obj,INFO_LIFE);
   
   loop(t) {
      ObjEnemy_SetLife(obj,lockHP);
      yield;
   }
}


It works, but the HP is being visibly deducted (life bar) and then "reset" back to the initial value. I remember in 0.12m the bar didn't move at all. I know this has to do with the routine of the yield; because there is a 1 frame yield here which will indeed allow any other routines/threads to progress. Except how can I polish this up to act like 0.12m? Or perhaps alternative method?

Edit:
KimoKeine aka Blargel on IRC told me to work with DamageRates. How foolish of me to forget about this.

Here is the new code:
Code: [Select]
// Enemy or boss invul mode (since 0.12m doesn't have one)
task setInvulnerableTime(obj,t) {
// Get damage rate values from obj and store in vars.
let lockShotDmgRate = ObjEnemy_GetInfo(obj,INFO_DAMAGE_RATE_SHOT);
let lockSpellDmgRate = ObjEnemy_GetInfo(obj,INFO_DAMAGE_RATE_SPELL);

// Set damage rate to 0,0.
ObjEnemy_SetDamageRate(obj,0,0);

// yield for t-frames (similar to wait)
loop(t) { yield; }

// Reset damage rates to initial.
ObjEnemy_SetDamageRate(obj,lockShotDmgRate,lockSpellDmgRate);
}

Call the task by typing setInvulnerableTime(obj,t); where ever you want to give the boss or enemy object "god mode" for a while. This won't overwrite the initial damage rate because it is being locked before the actual "freezing" is happening. Unless you of course change the damage rates in between but that would be silly :V

Feel free to (ab)use if you want also.
« Last Edit: February 15, 2015, 10:36:34 AM by Helepolis »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #380 on: February 17, 2015, 08:45:05 AM »
Apologies for the double post-look , but a new question after fooling around for a specific object bullet behaviour. I wish to achieve the following behaviour for an object bullet.

> Boss tosses a bullet (aimed or random) with a certain angle
> bullet hits the walls and starts moving exactly along the walls
> it moves either clockwise or counter-clockwise based on approach angle.

I'll try to roughly show it:
Code: [Select]
task bullet(.....) {
while() {
if(bullet hits "ceiling/floor") {
> Change angle 90 degree exact horizontal (so it goes up or down)
}
if(bullet hits "walls") {
> Change angle 90 degree exact vertical (so it goes up or down)
}
}
}

Important behaviour note: If the bullet is shot "towards left-down", when hitting the edge of the field it will move counter-clockwise. Example:

bullet is shot at 179 = make bullet move counterclockwise
" 181 = make bullet move clockwise
" 180 = random choice
" 89 = make bullet move counterclockwise
" 91 = make bullet move clockwise
etc...

What I attempted
I managed to get the bullet to change exact horizonta/vertical direction by calculating the "needs adjustment angle". Because if a bullet would fly 260 degrees (upwards) and you want to make it move counter-clockwise, the angle needs to be: -90. But -90 would make the bullet not travel at 180 degree (left), but at 170 degree. Because 260-90 = 170. So I need to calculate the initial approach. How I did for ceiling was: track bullet angle with constant updating let dir = ObjMove_GetAngle(obj); and then let adjustDir = 270 - ObjMove_GetAngle(obj); followed by dir = dir - 90 + adjustDir. So the calculation becomes adjustDir = 270 - 260 = 10 which will do:
> dir = dir - 90 + adjustDir
> dir = dir - 90 + 10
> dir = 260 - 90 + 10
> dir = 170 + 10
> dir = 180

Actual problem
Right, so here comes the problem. I can probably calculate this for every side of the field but the problem is the bullet will get into trouble when approaching the corners. Because the way my statements listen, 2 statements will trigger and start forcing the bullet odd forms making it either not move or shake around.

At this point I started fucking up by overcomplicated and probably useless scripting methods. Probably there is an easier method to achieve my behaviour but I fail to see at this point.

Edit:
- Elaborated the specific behaviour with angle examples
- Eventually I want to bullet to stop moving along the walls but just "leave" or perhaps make it "explode" "disappear" but that is lesser issue atm.
- Awesome mspaint explanation.
« Last Edit: February 17, 2015, 09:14:55 AM by Helepolis »

Drake

  • *
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #381 on: February 17, 2015, 09:39:03 AM »
Code: [Select]
function GetNeatoLockAngle(angle){
    return [round(angle/90)*90 , round((angle%90)/90)*-180+90];
}

val[0]+val[1] is the angle to send it at, then every time it hits a corner add val[1] to it.

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

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #382 on: February 17, 2015, 05:40:25 PM »
Alternatively, I thought of checking both x and y, so, for example, a large value of x and a large value of y would trigger turning right or left, depending on the current direction. Don't forget to wait for some times before checking for a corner again.
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #383 on: February 17, 2015, 05:51:15 PM »
Delaying the thread would be really troublesome in general. I applied the function from Drake and checked the walls + added as he suggested a bit of "space" to avoid double corners from hitting. So far it behaves like I want it.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #384 on: February 19, 2015, 07:47:04 AM »

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #385 on: February 19, 2015, 08:39:34 AM »
Why is This (http://pastebin.com/bSiMecLL ) creating this (http://imgur.com/tIhhU1I)?
You're calling  TFire; in the @MainLoop thread. MainLoop runs continuously, which means every frame, TFire is summoned and thus causing that what you're showing us.

Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #386 on: February 20, 2015, 01:10:04 AM »
Why is ObjSprite2D_SetSourceRect(objRumia,64,1,127,64); not activating here? Rumia isn't switching back to her idle position. (http://pastebin.com/m8phaq9d)

Also, why is this (http://pastebin.com/DSyUgsGY) giving me an error at line 13 saying it can't comprehend it? o.0
« Last Edit: February 20, 2015, 06:38:45 AM by Youmu970 »

Uruwi

  • Nightmare of Torrential Precipitation
  • 478 million goober
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #387 on: February 20, 2015, 07:41:36 AM »
Why is ObjSprite2D_SetSourceRect(objRumia,64,1,127,64); not activating here? Rumia isn't switching back to her idle position. (http://pastebin.com/m8phaq9d)

Also, why is this (http://pastebin.com/DSyUgsGY) giving me an error at line 13 saying it can't comprehend it? o.0

You forgot a semicolon on line 10.
foo = foldl $ flip ($)
Highest difficulty 1CCed for each game, by shot type in the original order. (-: never 1CCed on any difficulty, or never used; E: easy, N: normal, H: hard, L / U: lunatic / unreal.)
EoSD [NNNE] PCB [EE--N-] IN [NEEE + Ex Border] PoFV [Mystia N, Mystia E no charge] MoF [EN--H- + Ex Marisa B] SA [N-----] UFO [----EN] TD [NENE] DDC [EE-EHE + Ex Marisa B & Sakuya A] LoLK [PD --N- Legacy ---N] EE [N- + Ex Yabusame] EMS [N-- + Ex Yabusame] RMI [NHN + Ex YaoSuku]
Avelantis (demo) Easy YuukiB 426,077,200

Helepolis

  • Charisma!
  • *
  • O-ojousama!?
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #388 on: February 24, 2015, 06:35:33 PM »
In my player script I've one remaining problem. I've sort of boomerangish behaviour for my shot type. Comparable to default Rumia's focus shot (the strange ball that appears and homes).

There is one major difference. My method uses a 2D Sprite as the "ball" and therefore cannot use any of the ObjMove functions (otherwise ObjMove_SetDestinationAtSpeed would've already saved my ass)  :ohdear:

I got the homing in place with calculating the direction between the ball and enemy object locked. I also used trig to add velocity to the ball to move towards the enemy using the following vars.
let dir = 0;
let x = ObjRender_GetX(obj);
let y = ObjRender_GetY(obj);
let v = 0;
let vx = v*cos(dir);
let vy = v*sin(dir);
x += vx;
y += vy;


By simply increasing v and setting the dir with atan2 makes it moves towards the enemy. Unfocussing also snaps it back to the player (because you simply set the v to 0 and x / y pos at the player.

But, how to make the ball return to the player while remaining focussed but not pressing the shot button? And also how to make the ball "stay" at the player to avoid it flying away or spassing around the place.

Edit

Manage to solve the issue by checking carefully the if/else statements. It returns to the player and stays there but the movement feels extremely wonky due to the calculations and such. I guess I'll revert to the Rumia style method: drawing my sprite on top of the invisible Shot object and use movement functions.

« Last Edit: February 25, 2015, 12:44:04 PM by Helepolis »

Shadow

  • Forever waiting for tomorrow
  • ...
Re: ※ Dnh Q&A/Problem thread II ※ for Danmakufu ph3 .1 preX(ry
« Reply #389 on: February 25, 2015, 07:17:41 PM »
I've got a quick way of smoothly returning the shot to the player, the calculation would be as follows:

Code: [Select]
x = (x*0.95)+(GetPlayerX*0.05);
y = (y*0.95)+(GetPlayerY*0.05);

You can adjust the multipliers to in turn adjust the smoothness of the movement, though I haven't experimented much with it myself.