* *
Welcome, Guest. Please login or register.
Did you miss your activation email?
April 28, 2017, 02:12:45 AM

Login with username, password and session length

Question Block

  • 10 Replies
  • 429 Views
*

Offline Sammy Smith

  • Jr. Member
  • **
  • 45
  • I have returned.
    • Tumblr Page
Question Block
« on: March 16, 2017, 01:55:44 AM »
I want to make a ? block that can give out various items similar to Mario.
For example, In my game, when Neptune hits the block by either jumping or attacking, it should dispense a coin, a 1up, or pudding (her favorite treat.)


Is it possible to do so with scripts?
Mods in Progress:
Gamindustri Riot: 50.2%

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 4566
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Question Block
« Reply #1 on: March 16, 2017, 09:49:33 AM »
For sure its possible. You just make the block hitable and put a attacbox on the character jump.
Set the block as an obstacle and set which item you want to be spawned.

If you want somenthing random, you would need script. I am writing this code, but I haven't finished (in fact, I have finished, just want to use arrays for that, but I am too busy to finish it right now)

*

Offline Sammy Smith

  • Jr. Member
  • **
  • 45
  • I have returned.
    • Tumblr Page
Re: Question Block
« Reply #2 on: March 17, 2017, 12:19:00 AM »
I haven't added atkbox on her jump yet, but for some reason, when I hit the block with a jump attack, the item comes out but the block ends up shifting to the direction the player's facing.
Mods in Progress:
Gamindustri Riot: 50.2%

*

Offline O Ilusionista

  • Global Moderator
  • Hero Member
  • *****
  • 4566
  • >> I WILL BE AWAY FOR SOME TIME <<
    • BMT - Brazil Mugen Team
Re: Question Block
« Reply #3 on: March 17, 2017, 03:36:20 PM »
Try to use this in the attacks:

forcedirection {dir}

~If this command is declared, opponents hit by attackbox will face specific direction instead of facing entity.
0 = no effect (used to turn off forcedirection).
-2 = Left. It means always left no matter where opponent is hit.
-1 = opposite of entity.
1 = same direction of entity.
2 = Right. It means always right no matter where opponent is hit.
~Use this command with an attackbox of course.

But I remember there was other way to do it. You can even force the direction on the entity:
@cmd   changeentityproperty getlocalvar("self") "direction" 1

*

Offline BeasTie

  • Hero Member
  • *****
  • 2413
Re: Question Block
« Reply #4 on: March 17, 2017, 10:30:28 PM »
If you want you can use unique attack/pain for this so normal attacks won't cause the box to react.  For example players attack can use ATTACK9 and the block entity would have PAIN9.  This way PAIN9 animation is the only one that will spawn an item.   The normal pain animation can be static so block wont visibly react.   Also the player's attack doesn't have to cause any damage, it can just be zero damage.

NB: make sure you increase maxattacks before using this in your mod's settings or the engine will crash

http://dcemulation.org/?title=OpenBORManual#Attack_types_.26_animation_limit
Code: [Select]
maxattacks {max}

    ~Sets the maximum number of normal attacks animation i.e ATTACK1, ATTACK2 etc.
    ~{max} is number of available animations.
    ~Default is 4.


maxattacktypes {max}

    ~Sets the maximum number of attack types.
    ~PAIN,FALL, RISE, BLOCKPAIN and DEATH animations limit is also set together with this.
    ~{max} is number of available types.
    ~Default is 10 & maximum value is 99.



*

Online Bloodbane

  • Hero Member
  • *****
  • 2978
  • Dark Dragon
Re: Question Block
« Reply #5 on: March 18, 2017, 12:21:11 AM »
@Sammy: Set facing 1 in block's header text to force it face right

*

Offline Sammy Smith

  • Jr. Member
  • **
  • 45
  • I have returned.
    • Tumblr Page
Re: Question Block
« Reply #6 on: March 18, 2017, 01:13:00 AM »
@Sammy: Set facing 1 in block's header text to force it face right
Already did that, but what I want is the block to stop moving when it's about to play its DEATH animation.
Mods in Progress:
Gamindustri Riot: 50.2%

*

Offline Sammy Smith

  • Jr. Member
  • **
  • 45
  • I have returned.
    • Tumblr Page
Re: Question Block
« Reply #7 on: March 18, 2017, 10:41:51 PM »
Maybe I wasn't clear, so here's my ? Block entity:
Code: [Select]
name q_block
type obstacle
health 1
gfxshadow 1 2
nodieblink 2
antigravity 100
facing 1
nodrop 0
offscreenkill 50

anim idle
bbox 0 4 22 17
platform 5 22 -5 0 14 17 5 16
loop 0
delay 100
offset 11 17
frame data/chars/misc/block.gif

anim death
platform 5 22 -5 0 14 17 5 16
offset 11 17
delay 10
frame data/chars/misc/block.gif
frame data/chars/misc/block2.gif
Mods in Progress:
Gamindustri Riot: 50.2%

*

Online Bloodbane

  • Hero Member
  • *****
  • 2978
  • Dark Dragon
Re: Question Block
« Reply #8 on: March 19, 2017, 12:02:19 AM »
 Maybe this is a bug
 But anyways, here's how I solved that bug:

Code: [Select]
name q_block
type obstacle
health 1
gfxshadow 1 2
nodieblink 2
antigravity 100
facing 1
nodrop 0
offscreenkill 50

anim idle
bbox 0 4 22 17
platform 5 22 -5 0 14 17 5 16
loop 0
delay 100
offset 11 17
frame data/chars/misc/block.gif

anim spawn
@script     
    if(frame==1){
      void self = getlocalvar("self");
      int x = getentityproperty(self,"x");

      setentityvar(self, 1, x);
    }
@end_script
platform 5 22 -5 0 14 17 5 16
delay 1
offset 11 17
frame data/chars/misc/block.gif
frame data/chars/misc/block.gif

anim death
@script
    if(frame==1){
      void self = getlocalvar("self");
      int Tx = getentityvar(self, 1);

      if(Tx){
        changeentityproperty(self, "position", Tx);
        changeentityproperty(self, "velocity", 0, 0, 0);

        setentityvar(self, 1, NULL());
      }
    }
@end_script
platform 5 22 -5 0 14 17 5 16
offset 11 17
delay 1
frame data/chars/misc/block.gif
delay 10
frame data/chars/misc/block.gif
frame data/chars/misc/block2.gif

*

Offline Sammy Smith

  • Jr. Member
  • **
  • 45
  • I have returned.
    • Tumblr Page
Re: Question Block
« Reply #9 on: March 20, 2017, 01:47:26 AM »
Maybe this is a bug
 But anyways, here's how I solved that bug:

Code: [Select]
name q_block
type obstacle
health 1
gfxshadow 1 2
nodieblink 2
antigravity 100
facing 1
nodrop 0
offscreenkill 50

anim idle
bbox 0 4 22 17
platform 5 22 -5 0 14 17 5 16
loop 0
delay 100
offset 11 17
frame data/chars/misc/block.gif

anim spawn
@script     
    if(frame==1){
      void self = getlocalvar("self");
      int x = getentityproperty(self,"x");

      setentityvar(self, 1, x);
    }
@end_script
platform 5 22 -5 0 14 17 5 16
delay 1
offset 11 17
frame data/chars/misc/block.gif
frame data/chars/misc/block.gif

anim death
@script
    if(frame==1){
      void self = getlocalvar("self");
      int Tx = getentityvar(self, 1);

      if(Tx){
        changeentityproperty(self, "position", Tx);
        changeentityproperty(self, "velocity", 0, 0, 0);

        setentityvar(self, 1, NULL());
      }
    }
@end_script
platform 5 22 -5 0 14 17 5 16
offset 11 17
delay 1
frame data/chars/misc/block.gif
delay 10
frame data/chars/misc/block.gif
frame data/chars/misc/block2.gif

Alright, finally got it to play death animation! All I need to do is get the item to pop out from the top of the block.
Mods in Progress:
Gamindustri Riot: 50.2%

*

Offline BeasTie

  • Hero Member
  • *****
  • 2413
Re: Question Block
« Reply #10 on: March 20, 2017, 09:26:50 PM »
you can use item spawn script to make it pop out, or there's also random spawn/jump scripts.

Code: [Select]
void Ispawn(void vName, float fX, float fY, float fZ)
{//Spawns item next to caller.
//
//vName: Spawned item
//fX   : X speed.
//fZ   : Y speed.
//fY   : Z speed.

void vSpawn = spawner(vName, 0, 0, 0); //Spawn object.

changeentityproperty(vSpawn, "direction", 1); //Set direction.
      tossentity(vSpawn, fY, fX,fZ); // Toss item.

return vSpawn; //Return spawn.
}

 

Recent

Members
  • Total Members: 5923
  • Latest: nick
Stats
  • Total Posts: 44233
  • Total Topics: 3011
  • Online Today: 39
  • Online Ever: 316
  • (January 04, 2013, 09:43:02 AM)
Users Online
Users: 1
Guests: 23
Total: 24