Question Block

sammyrms1

Member
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.)
eHuKele.png


Is it possible to do so with scripts?
 
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)
 
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.
kwDEUF9.png
 
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
 
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:
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.

 
Maybe I wasn't clear, so here's my ? Block entity:
Code:
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
 
Maybe this is a bug
But anyways, here's how I solved that bug:

Code:
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
 
Bloodbane said:
Maybe this is a bug
But anyways, here's how I solved that bug:

Code:
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.
 
you can use item spawn script to make it pop out, or there's also random spawn/jump scripts.

Code:
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.
}
 
Back
Top Bottom