Background-specific obstacles (falling rocks, columns of fire, etc..)

mulambo

Member
Hello again and sorry if a topic starts after the other so soon, it's just that I couldn't learn it myself. I wanted to add some particular features to my stages so to make the game more varied and some bosses more difficult.
So I thought about some atypical enemies, background-specific obstacles which damage the player only: falling rocks, columns of fire, chainsaws (well, their concept is not really so original, but I want to add them anyway).
More details: I imagined that fire columns can be blank images randomly moving on the floor and  becoming like erupting fire only during the attack state, but the player should not be able to interact with them (no grabbing, no attacking, etc.. they should be like un-material, if it makes sense).
The falling rocks should be the same, they just fall from above (in a cave background, for example) in attack state and destroy themselves if they touch the floor/player, same here: they can't be attacked or grabbed (well, that actually would be funny if the player stucks in grab position with the falling rock).
The chainsaws are like the rocks but the appear in a vertical or horizontal movement on the bottom edge. They can also be spears, blades, or other objects which just move from a part to the other of the screen, starting from the bottom edge, they appear and disappear randomly during the stage, they can't be blocked or attacked.

Is there a way to achieve this features ? Thank you
 
mulambo said:
Hello again and sorry if a topic starts after the other so soon, it's just that I couldn't learn it myself. I wanted to add some particular features to my stages so to make the game more varied and some bosses more difficult.
So I thought about some atypical enemies, background-specific obstacles which damage the player only: falling rocks, columns of fire, chainsaws (well, their concept is not really so original, but I want to add them anyway).
More details: I imagined that fire columns can be blank images randomly moving on the floor and  becoming like erupting fire only during the attack state, but the player should not be able to interact with them (no grabbing, no attacking, etc.. they should be like un-material, if it makes sense).
The falling rocks should be the same, they just fall from above (in a cave background, for example) in attack state and destroy themselves if they touch the floor/player, same here: they can't be attacked or grabbed (well, that actually would be funny if the player stucks in grab position with the falling rock).
The chainsaws are like the rocks but the appear in a vertical or horizontal movement on the bottom edge. They can also be spears, blades, or other objects which just move from a part to the other of the screen, starting from the bottom edge, they appear and disappear randomly during the stage, they can't be blocked or attacked.

Is there a way to achieve this features ? Thank you

The easiest way would be to not assign bboxes to these entities, I think.
 
You can use type trap for these hazards like this:
Code:
name		Duri
type		trap
candamage	player
nolife		1


anim idle
	loop	1
	delay	10
	offset	10 35
	attack	0 2 18 33 50 1 1 1
	frame	data/chars/traps/duri.png
	attack	0
	frame	data/chars/traps/duri.png

It's trap type so player can't grab this trap. It doesn't have bbox either

BTW don't use type enemy for traps, that will conflict with grouping

The falling rocks should be the same, they just fall from above (in a cave background, for example) in attack state and destroy themselves if they touch the floor/player

That might require two entities : the falling rock and rock spawner. Just like the above, both could use type trap
 
Bloodbane said:
You can use type trap for these hazards like this:
Code:
name		Duri
type		trap
candamage	player
nolife		1


anim idle
	loop	1
	delay	10
	offset	10 35
	attack	0 2 18 33 50 1 1 1
	frame	data/chars/traps/duri.png
	attack	0
	frame	data/chars/traps/duri.png

It's trap type so player can't grab this trap. It doesn't have bbox either

BTW don't use type enemy for traps, that will conflict with grouping

The falling rocks should be the same, they just fall from above (in a cave background, for example) in attack state and destroy themselves if they touch the floor/player

That might require two entities : the falling rock and rock spawner. Just like the above, both could use type trap
thanks, i'll try that out soon!
 
k, even if I add the entity and load/know it in models.txt... what should I do to make the "spawner" spawn it at a certain frame, in a random position and make it fall ?
 
Sorry for the late reply

what should I do to make the "spawner" spawn it at a certain frame, in a random position and make it fall ?

You'd need script for that. After searching my script libraries, this is the function you need:
Code:
void Rain(void vName, float fX, float fY, float fZ, float Sx, float Vx, float Vy)
{//Spawns other entity in random spot relative to screen edge and move it with defined speed
 //vName: Model name of entity to be spawned in
 //fX: X deviation relative to screen edge
 //fY: Starting altitude
 //fZ: Z deviation relative from center of playing field
 //Vx: X speed
 //Vy: Y speed

   void self = getlocalvar("self"); //Get calling entity
   int Direction = getentityproperty(self, "direction");
   int Screen = openborvariant("hResolution"); // Get screen width
   void vSpawn; int iDX; int iDZ;

   if(Direction == 0){ //Is entity facing left?                  
      Vx = -Vx; //Reverse Vx direction to match facing  
   }

   if(fX!=0){
     iDX = rand()%fX+Screen*0.5;
   } else {
     iDX = 0;
   }

   if(fZ!=0){
     iDZ = rand()%fZ;
   } else {
     iDZ = 0;
   }

   vSpawn = spawn04(vName, iDX+Sx, fY, iDZ, Screen); //Spawn in entity
   changeentityproperty(vSpawn, "velocity", Vx, 0, Vy);
   changeentityproperty(vSpawn, "direction", Direction);
}

void spawn04(void vName, float fX, float fY, float fZ, int Edge)
{
	//Spawns entity based on left screen edge and center of playing field
	//
	//vName: Model name of entity to be spawned in.
	//fX: X distance relative to left edge
	//fY: Y height from ground
      //fZ: Z location adjustment

	void self = getlocalvar("self"); //Get calling entity.
	void vSpawn; //Spawn object.
	int Direction = getentityproperty(self, "direction");
        int XPos = openborvariant("xpos"); //Get screen edge's position

	clearspawnentry(); //Clear current spawn entry.
      setspawnentry("name", vName); //Acquire spawn entity by name.

   if (Direction == 0){ //Is entity facing left?                  
      fX = Edge-fX; //Reverse X direction to match facing and screen length
   }

      fZ = fZ+(openborvariant("PLAYER_MIN_Z") + openborvariant("PLAYER_MAX_Z") )/2 ;

	vSpawn = spawn(); //Spawn in entity.

	changeentityproperty(vSpawn, "position", fX + XPos, fZ, fY); //Set spawn location.
	return vSpawn; //Return spawn.
}

Example:
Code:
	@cmd	Rain "WatDrop" 200 400 25 -200 1 -5

In this example, entity will spawn WatDrop around 200 pixels relative to screen edge in x axis, 400 pixels above the ground (so it falls), around 25 pixels wide from center of field in z axis, with 200 pixels offset to the back in x axis. WatDrop will fall with velocity : 1 pixel percentisecond in x axis and -5 in y axis

Mmm.... I know it sounds confusing but once you tried it, it will make more sense :)
It's called Rain cause if multiple functions like this are declared, it will create effect in which multiple projectiles falling from sky like rainfall ;)
 
Back
Top Bottom