switch on/off a platform question

Minor

Member
Hi,
Is there a way to activate a switch (on/off) in order to toggle a platform?

XknQ1Wy.png
ItMwetR.png


thank you  :)
 
Yes, its doable using a script for that. But do you want to make the platform disappear (so the player won't stand over it) or do you want to convert it into a slope? The second case is harder to do, but is still doable.

I can think in some ways to do it. One of those ways is to make the switch and the platform into a single entity, which when its hit, is sent to new animation where the platform isn't avaliable and vice-versa. Or use a entity to disable another entity with the platform, using script (by checking if a entity with an specific name is on the screen).
 
O Ilusionista said:
Thank you man that's what i thought, a script...
I want the platform disappear, i thought about a slope, but was sure it was too hard to make.

I already made a single entity for platform and switch, but 2 problems.

-If i declare as an obstacle, i can't have a "nodieblink 3" animation in order to keep the "switch animation on".

-if i declare as an enemy, i can't walk on platform (maybe this is possible, but i can't find how to make a "block enemy" where i can walk on him).


So there's only this solution
Or use a entity to disable another entity with the platform, using script (by checking if a entity with an specific name is on the screen).

How can i do that? is this script already exist?
 
For switching off/on platform like this, I prefer to use type none. This platform entity doesn't have to disappear when being switched off, changing animation to off or invisible state is enough

For the switch itself, I'm not quite sure how to make one which can be hit multiple times to switch off/on. I'm trying couple methods ATM

BTW minor about this request, do you want single hit switch or multi use switch?
 
Bloodbane said:
For the switch itself, I'm not quite sure how to make one which can be hit multiple times to switch off/on. I'm trying couple methods ATM

Thank you bloodbane for help  ;)

It would be optimal to make a multiple hit time to swith, but don't worry about this man. If i can just activate once the switch i will be happy.


BTW minor about this request, do you want single hit switch or multi use switch?
i just want one single hit switch, but what's the difference if i would like a multi use switch?


 
i just want one single hit switch, but what's the difference if i would like a multi use switch?

When I posted that I haven't figured out best trick to create multi use switch but now I've known how, it's easy to create single hit switch with it

Now, since this method requires entity and indexed variables, you need to create script.txt placed inside data folder, with these texts in it:

maxindexedvars 10
maxentityvars 10

Next, the switch itself, you can use type obstacle for it. Here's an example on how to create simple on/off switch:

Code:
name		Drum2
health		10
type		obstacle
gfxshadow	1
death		1
defense		all 0
nodieblink	3
icon		data/chars/misc/drumicon.gif
takedamagescript data/scripts/switch.c
diesound 	data/sounds/klunk.wav


anim idle
@script
    void self = getlocalvar("self"); //Get calling entity.
    void State = getentityvar(self,1);

    if(State == 3){
      setindexedvar(0, 1);
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script
	loop	1 1 3
	delay	100
	offset	22 63
	frame	data/chars/misc/drum.gif
	delay	10
	bbox	0 -25 43 92
	frame	data/chars/misc/drum.gif
	frame	data/chars/misc/drum.gif
	frame	data/chars/misc/drum.gif

anim follow1
@script
    void self = getlocalvar("self"); //Get calling entity.
    void State = getentityvar(self,1);

    if(State == NULL()){
      setindexedvar(0, NULL());
      setidle(self, openborconstant("ANI_IDLE"));
    }
@end_script
	loop	1 1 3
	delay	100
	offset	22 63
	frame	data/chars/misc/drum3.gif
	delay	10
	bbox	0 -25 43 92
	frame	data/chars/misc/drum3.gif
	frame	data/chars/misc/drum3.gif
	frame	data/chars/misc/drum3.gif

anim death
	delay	10
	offset	23 63
	frame	data/chars/misc/drum3.gif
	frame	data/chars/misc/drum3.gif

You can change the sprites, delay, bbox etc but the scripts and animation names
Create this file in data/scripts folder:

switch.c
Code:
void main()
{// Switches personal state
    void self = getlocalvar("self"); //Get calling entity.
    void State = getentityvar(self,1);

    if(State == 3){
      setentityvar(self, 1, NULL());
    } else {
      setentityvar(self, 1, 3);
    }
}

This script is required by the switch to go on/off

Next is the switchable platform, here's a simple example:
Code:
name		Crusher
type	    	none
shadow		5


anim idle
@script
    void self = getlocalvar("self"); //Get calling entity
    void Status = getindexedvar(0);

    if(Status == 1){
      performattack(self, openborconstant("ANI_FOLLOW1"));
    }
@end_script
	loop	1
	delay	2
	offset	45 285
	platform 40 295 -50 -50 50 50 20 5000
	frame	data/chars/misc/crusher.gif
	frame	data/chars/misc/crusher.gif

anim follow1
@script
    void self = getlocalvar("self"); //Get calling entity
    void Status = getindexedvar(0);

    if(Status == NULL()){
      setidle(self, openborconstant("ANI_IDLE"));
    }
@end_script
	loop	1
	delay	2
	offset	45 475
	frame	data/chars/misc/crusher.gif
	frame	data/chars/misc/crusher.gif

With these, hitting the switch will set indexed variable 0 to 1. This variable will be read by the crusher to change animation to FOLLOW1. IOW hitting the switch switches the crusher to move up

Last create this script in data/scripts folder too:
endlevel.c
Code:
void main()
{
  setindexedvar(0, NULL());
}

This script will prevent switched on/off status be carried to next levels

The switch example above is multi use switch. If you want single use switch, just remove the script and/or remove the bbox in FOLLOW1 animation
Oh yes, the switch is indestructible BTW so don't worry about hitting it multiple times ;)
 
Bloodbane, I notice you are using magic number indexes for the entityvars. You don't have to do that any more, and probably shouldn't unless you're setting up iteration.

Indexed typed vars like entityvar are indexed at compile time now. Meaning you can use whatever name for them you like.

DC
 
I understood nothing about the 2 last posts  ;D

First, a big THANK YOU bloodbane you're really AMAZING!! (but we already know that :P)


Just 2 things for me, it works fine but:


- When i hit your drum2, seems to be always in idle animation. The "drum3.gif" (the green button) never appears for me.


-Another thing but it's not the theme (i should create a topic maybe, sorry), I have a "subject to obstacle" for my chars, i explain with the screen below.

lNMPR6k.png

0LxsMqs.png


The green is when i need my chars to be blocked(obstacle). but when i go to the switch (the obstacle you made), all the vertical zone is blocked, because of subject to obstacle. what can i do for this?
(i know it's something with z position, but i don't understand everything about it yet.)

Another time thank you man, really.
 
Back
Top Bottom