Is it possible to add different destroy triggers to instance of objects?

N

Nathan

Guest
I want to have a base object, and have lets say 20 instances of this object in a room. When the player touches the different instances, is it possible to make the individual instances trigger different events without having to make a duplicate object for every object instance that I want reacting differently?
 
If you want different events once the object is touched by the player yo can create a collision event with the object and for example check if the player touch the object from the top or bottom. what kind of different reaction you want?
 
N

Nathan

Guest
I need it controlled in the instances to make the workflow go smooth. Each instance will trigger different events in whatever room they are in. Sometimes creating objects, sometimes destroying objects, sometimes changing the score, could be anything. Each instance will only be used in on spot in the game because they are very situational and serve only one purpose, so making an object per instance seems really inefficient.
 

woods

Member
if (this is true) and (this is true)
{do a thing}

its just a matter of checking the conditions...





if (room= rm_1) && (place_meeting(x,y,obj_thing))
{
// do a thing
}

if (room= rm_2) && (place_meeting(x,y,obj_thing))
{
// do a different thing
}
 

Reprom

Member
DESTROY EVENT:

randomise();
var _case = irandom( /*number of last case. In this example it would be 3*/ );

switch (_case) {

case 0: /*do nothing*/
break;

case 1: /*explode*/
break;

case 2: /*melt*/
break;

case 3: /*spawn enemies*/
break;

.../*more cases prehaps*/
}
DESTROY EVENT:

switch (room) {

case rmCave: /*do nothing*/
break;

case rmDungeon: /*explode*/
break;

case rmMushromForest: /*melt*/
break;

case rmSea: /*spawn enemies*/
break;

.../*more cases prehaps*/
}
SOMEWHERE OUTSIDE THE OBJECT. I WOULD PUT THIS IN A NEW SCRIPT:

enum death_effect {
do_nothing,
explode,
melt,
spawn_enemies
}

CREATE EVENT:

death_trigger = death_effect.do_nothing;

DESTROY EVENT:

switch (death_trigger) {

case death_effect.do_nothing: /*do nothing*/
break;

case death_effect.explode: /*explode*/
break;

case death_effect.melt: /*melt*/
break;

case death_effect.spawn_enemies: /*spawn enemies*/
break;

.../*more cases prehaps*/
}

WHEN CREATING NEW OBJECT:

var _id = instance_create_layer(/*your x*/, /*your y*/, /*your layer*/, /*this object that we are talkng about*/);
_id.death_effect = death_effect.melt;

=OR=

WHEN DESTROING THAT OBJECT WITH PLAYER OBJECT:

//Note! This part needs to be in your player object
//You need to get the id of that object you want to destroy. Lets say after collision...


var _id = instance_place(/*collision x*/, /*collision y*/, /*object we want to destory*/);

//Note! Not all collision functions return id! This one does.

_id.death_effect = death_effect.melt;
instance_destroy(_id);

Hope that I nailed what you want. Fingers crossed.
Also hope that I didn't confuse you even more.
 
Last edited:
Top