Dynamite weapon with time limit until explodes?

Joshiro

Member
Basically, I want the player to be able to pick up enemy thrown dynamite and throw it back before it explodes. If the player doesn't throw it in time, than it explodes while carrying it. I would want it to use the same time limit to carry over from the floor to being picked up. Any ideas on how to accomplish this?
 
Can you explain to me the script you made and how to use it? I'm a beginner at scripting and I'm trying to understand it. How did you become so good at scripting? 
 
I'm a programmer  :D
1) you need to copy in your game my *.c/*.h files that p_dynamite.txt imports like lib.c, defines.h, lib_motion.c, etc..
2) main script is in ondrawscript event:
here I simulate the physics like bouncing and frictioning of objects. then here I detect wall/platform to simulate wall bouncing.

bouncing/frictioning are functions:
check_friction(self,0.25,1.030);
check_bouncing(self,0.55,2);

and I use set_tossv(self); to store the y velocity.

3) I make sure that the dynamite explodes just after it has finished bouncing.
you can see that in FOLLOW10 animation.
I store the animation frame in getentityvar(self,10) like a previous anim position: prev_animpos var
than when I run FOLLOW10 anim (so it's in frame == 0) I use changeentityproperty(self,"animpos",prev_animpos+1);
to adjust the prev animation frame (animation was IDLE) in FOLLOW10 to not repeat the same frame.
In my case after frame 9 the dynamite can explode!!
 
I prefer to use a localvar in ondrawscript event to avoid memory issues.
in a localvar store the time that is openborconstant("elapsed_time") + openborconstant("game_speed")*ETA
ETA is a time that you want like 5.5 or 10.2 etc...
than if ( time >= getlocalvar("stored_time") ) ... EXPLODE!!
 
I'm not sure how to use the ondrawscript event. Can you explain it to me? Is their a list of built in variables and functions of openbor somewhere? I  understand how to make basic scripts, I just can't really find a good guide for openbor.  Do I make the script in a separate file or make it in the player's weapon file? Thanks for your help.
 
the unique script event variable is "self":
void self = getlocalvar("self");

ondrawscript event is triggered on entity rendering.
for all imported functions see files:
#import "data/scripts/lib.c"
#import "data/scripts/lib_wall.c"
#import "data/scripts/lib_platform.c"
#import "data/scripts/lib_motion.c"
#import "data/scripts/lib_weapon.c"
 
I get the concept of it, I just don't know how to make it.  So something like this in a separate file?

Code:
setlocalvar("stored_time");
time = openborconstant("elapsed_time") + openborconstant("game_speed")* 5.5

In the player's weapon file have something like this?

Code:
if ( time >= getlocalvar("stored_time") )
{
spawnsubentity("boom",x,z,a);
}

So how does it use the same time limit from when it's on the ground to when the player picks it up? Sorry, for being annoying.





 
Joshiro said:
I get the concept of it, I just don't know how to make it.  So something like this in a separate file?

Code:
setlocalvar("stored_time");
time = openborconstant("elapsed_time") + openborconstant("game_speed")* 5.5

In the player's weapon file have something like this?

Code:
if ( time >= getlocalvar("stored_time") )
{
spawnsubentity("boom",x,z,a);
}

So how does it use the same time limit from when it's on the ground to when the player picks it up? Sorry, for being annoying.

YES!! That is the concept!!
You can use spawnsubentity("boom",x,z,a); + killentity(self);
or damageentity(self,self,...); with a boom for the Death animation
 
YES!! That is the concept!!
You can use spawnsubentity("boom",x,z,a); + killentity(self);
or damageentity(self,self,...); with a boom for the Death animation]

Finally got some time to work on this. Anyway, I'm still a bit confused. I have to put ondrawscript and the file reference on top. Then put that script in the idle, walking, and running animation of the player's weapon. Is that right?

Now what confuses me is do I use the same script for the dynamite item? I wanted to have an effect that is blinking so it will indicate how long you have until it explodes, on the ground and while player holds it.
Also, if I put killentity wouldn't it kill the player or are you referring to putting that script in the explosion? 
 
Joshiro said:
YES!! That is the concept!!
You can use spawnsubentity("boom",x,z,a); + killentity(self);
or damageentity(self,self,...); with a boom for the Death animation]

Finally got some time to work on this. Anyway, I'm still a bit confused. I have to put ondrawscript and the file reference on top. Then put that script in the idle, walking, and running animation of the player's weapon. Is that right?

Now what confuses me is do I use the same script for the dynamite item? I wanted to have an effect that is blinking so it will indicate how long you have until it explodes, on the ground and while player holds it.
Also, if I put killentity wouldn't it kill the player or are you referring to putting that script in the explosion?

Wow, what you want is a bit complex.
So you have to use my script just for weapon to get. When you get the weapon you have to use sprites WITHOUT dynamite. In a separate entity you have to use a dynamite weapon with bindentity. Pay attention to bind every frame. Inthis dynamite entity you have to write a script for blinking etc..
 
I was going to have the blinking effect as sprites instead of a script. I guess it is too complex. Maybe not exactly how I want it but I'll find a way to make it work. That's a good idea. How do you make it bind though?
 
Back
Top Bottom