custom fall reactions in OpenBor

NED

Well-known member
Hello,
I have not coded something for several months now due to IRL stuffs.
I think I can possibly go on now. I'm trying to see if this is possible with this engine.
And more importantly, HOW, this can be done.
This is a very very very very very simplified version of what I had initially in my mind. To make it possible to be done without having one more break in my possible future project.

Basically : a fall anim with custom fall reactions based on interactions.
PD73ohB.png


I would really appreciate to have some support and help to code what this mockup shows.

If this is still too ambitious, or if it takes too much of your time, I would understand.
No problem. Thanks for your support.
 
For screen edge, it can be done using variants of x position and horizontal screen, along with entity's x coordinate (not variant) under fallxx anim you mentioned. If the victim goes against the screen, change the victim's facing during his fall. When the victim falls off to hit the screen, do you want him to keep rolling to lie down after he hits the screen? Or do you want him to go with the first frame of the same animation AFTER he touches the screen?

If you don't know what I mean, look at this:

Code:
anim fall17
@script
void self = getlocalvar("self"); // Get entity
int x = getentityproperty(self, "x"); // Get entity's x coordinate
int HRes = openborvariant("hresolution"); // Get horizontal resolution of the screen
int Xpos = openborvariant("xpos"); // Get x position, not from entity itself

if(x > Xpos+HRes-45){ // Entity next to the right side of the screen edge and going against it
   changeentityproperty(self, "direction", 0); // Change entity's facing to the left
}else if(x < Xpos+45){ // Entity next to the left side of screen edge and going against it
   changeentityproperty(self, "direction", 1); // Change entity's facing to the right
}
@end_script
delay 23
offset 31 111
move 4.7
frame data/chars/jack/fallen401.png
delay 11
frame data/chars/jack/fallen402.png
frame data/chars/jack/fallen403.png
frame data/chars/jack/fallen404.png
frame data/chars/jack/fallen405.png
frame data/chars/jack/fallen406.png
frame data/chars/jack/fallen407.png
frame data/chars/jack/fallen408.png
frame data/chars/jack/fallen409.png
frame data/chars/jack/fallen410.png
 
Yes, after hitting the wall or edge, it restart the animation in the opposite way.

In fact, I think I have a base of script that can be used for wall bounce and edge bounce.

The major problem is how to make it happen when hitting obstacle or character


EDIT : one more precision.
The initial move is an attack, hitting enemy and sending him in a custom pain anim (or fall)
But I dont know how to make the opponenet sliding on the ground until he hits something or falls. ???
 
Don't code this directly into fall animations, you're making it harder than it is that way. Use the "onblock" events - that's specifically what they are there for. They run whenever an entity's movement is stopped by obstacle, walls, screen boundaries, and so on.

Then you check for falling status and set up your reaction accordingly. I have an old script I used for wall bounce in 2009. I'll see if I can update it this week.

DC
 
Just a idea but your fall animation could have a blinded entity with a attack box with a follow animation that manipulates the falling players animation should work for people and obstacles.  Like DC said a onblock script can help when hitting walls.  Check out this example mod I made to show how to climb up platforms it uses a onblock script.



 
thanks
Sorry, I don't understand what to do.
I thnik, I'll have to give up one more time or simplify the system even more.
I think wall damage/edge damage is OK since I used something similar for fall anims in the past.

I still don't have any idea how to make an enemy slide on the ground during the pain anim.
slide slowly like a run or walk would do...
 
I think I'll try to resume this system. and point the elemnts where I need help.
(I had to make several drawn sketches event to think how I would expose my coding problem here)

-player sends enemy into a "slide/run" anim
how to send enemy into a custom "get hit" anim?
For the moment, it is an attackbox actually hitting opponent into this gethit anim "attackone 1" but I'm OK to change it if theres is better idea.
Hopefully, it can borrow the regular run anim of the entity and plays it in loop (instead of a get hit anim)
how to give this enemy a sliding/runing type velocity?
The idea would be to play this run in a loop (with the step sound effects) but with an attack box.
Do I have to create a full new anim for openbor?

-after the slide, enemy change to a "front fall anim"
(It happens after a certain time enemy played this run anim)
(How to change this anim to fall anim based on time?)

-during the "slide/run" these are the possible reactions.
-hit wall (not edge)
(how tho apply a onblock script for this situation?)
plays a bounce sound
turn around
then plays the "front fall anim"
(can it use the same "front fall anim" but plays a bounce sound before?)

-hit enemy or other character
simply hitting opponents with it's constant attack box
(nothing complicated for me here)

As an explanation, there is no more rope interaction in this game, this is too hard.
I just would like to complede this "send into wall" damage to have the regular game system completed.

Sorry, it's really difficult even to understand myself how it could work.
As an artist and art teacher, I'm more into instinct stuff like imaginative stuff and art.
Maths and coding logic is not my stuff (at all)
And english is not my language.

Thanks
 
nedflandeurse said:

Allof these things can and should be handled the same way - with use of a controller entity. Controller entities are models you set up specifically to spawn into play and temporarily control the actions of a target entity. One common example would be burning effects. The burn spark forces the entity that is burning to have an orange tint until it (the burn spark) is removed from play, at which point it turns the tint effect off.

The advantage to such an approach is it abstracts the special action, and removes it entirely from the the main entity. It thus becomes more dynamic and reusable. IOW, once you have it working, it's just a matter of spawning it in, linking it up to  the target entity and everything works from there.

-player sends enemy into a "slide/run" anim

When this action takes place, you can spawn an invisible controller entity that is bound to the target (enemy) and and has an update script that forces the enemy to move at whatever velocity you want, while also playing its RUN animation. This way, the attacking entity controls the run speed, and you get to reuse the target's RUN animation. After a certain amount of time (using lifespan), the controller entity kills itself, and when it does so, puts the target into a forward fall.

The attacking portion is a little trickier, so let's handle things step by step. See if you can get the "running" part down, and I'll show you how to put in an attack next.
 
I tried the last days and almost tried to undertand it during the full day, even at work/job.
But, no way for me to understand it.

I got the logic of why a controller entity have to be used, but I have no clue how to code it.
Is there template of code or exemple in a mod of how to make it?
 
Well dear friend, I think I have been able to solve all the movements that you indicate here:
PD73ohB.png

Here you can see a simple demo that I did, to test all the movements:
https://youtu.be/caVzSt_VJ1k

And here's the little demo, so you can implement everything.
Hope this can help you...
https://www.mediafire.com/file/tuk5th7npewosz1/Ned%20moves.rar
 
My friend, thanks a million for it!
This is something I had in my mind for almost 3 years now.
It took me almost 1 year to explain correctly it.

I really really appreciate this help you given.
Thanks a lot for your time.

I'm still testing, then and I'm about to adapt it for my mod project.
And finally complete the game system, then code the actual game levels, characters...
God bless you  :)
 
nedflandeurse said:
My friend, thanks a million for it!
This is something I had in my mind for almost 3 years now.
It took me almost 1 year to explain correctly it.

I really really appreciate this help you given.
Thanks a lot for your time.

I'm still testing, then and I'm about to adapt it for my mod project.
And finally complete the game system, then code the actual game levels, characters...
God bless you  :)

Those are great news!
I'm really glad that I helped you.
I hope that now you can continue advancing with your great Mod.
And if in any way I can help you, do not hesitate to let me know. ;)
 
To be honest, I forgot about onblockSscript (on block screen script) which DC suggested. I do believe DC's suggestion makes sense. That reminded me that I was working on an onpainscript without coding it into pain animations. If it were done in onblocksscript, it would've been like this, I guess:

blockScreen.c:

Code:
void main(){
   // Going against the screen boundaries and turn away
   void self = getlocalvar("self"); // Get entity
   void animID = getentityproperty(self, "animationid"); // Get animation ID
   int x = getentityproperty(self, "x"); // Get entity's x coordinate
   int HRes = openborvariant("hresolution"); // Get horizontal resolution of the screen
   int xPos = openborvariant("xpos"); // Get x position, not from entity itself

   if(animID == openborconstant("ANI_FALL17"){
      if(x > xPos+HRes-45){ // Entity next to the right side of the screen edge and going against it
         changeentityproperty(self, "direction", 0); // Change entity's facing to the left
      }else if(x < xPos+45){ // Entity next to the left side of screen edge and going against it
         changeentityproperty(self, "direction", 1); // Change entity's facing to the right
      }
   }
}

Code:
anim fall17
delay 23
offset 31 111
move 4.7
frame data/chars/jack/fallen401.png
delay 11
frame data/chars/jack/fallen402.png
frame data/chars/jack/fallen403.png
frame data/chars/jack/fallen404.png
frame data/chars/jack/fallen405.png
frame data/chars/jack/fallen406.png
frame data/chars/jack/fallen407.png
frame data/chars/jack/fallen408.png
frame data/chars/jack/fallen409.png
frame data/chars/jack/fallen410.png

For the character header:

Code:
name Jack # Model/entity Jack
type enemy # Jack is considered as enemy type
blahblah....
onblocksscript data/scripts/blockScreen.c # Script line doesn't have to be at the last part. It can be anywhere in the header.

EDIT:

I like how Dante made the scripts for you, Ned. I did notice he used my example for screen edge. It looks really cool of what he did.
 
Thanks for your support bro!
I'll check all these possibilities and see what I can do with my actual knowlege and abilities.

I'm about to implement it in my game system.
I'm just lacking some time right now.
 
I think I'm screwed.  :-[

I used what Dantedevil posted (his demo actually)
See what he uploaded.

I tweaked it a bit. velocities and minimal stuffs.
It still worked, but I made a try with my "only stable openbor version"
and it crashed immediatly.

The problem is I cannot change this older build.
Unless I recode all the game system and delete some features.

This is the log file
Code:
Total Ram: 4195418112 Bytes
 Free Ram: 1058824192 Bytes
 Used Ram: 4546560 Bytes

debug:nativeWidth, nativeHeight, bpp  1366, 768, 32
OpenBoR v3.0 Build 3769, Compile Date: Jan 19 2013

Game Selected: ./Paks/bor.pak

FileCaching System Init......	Disabled
Initializing video............
Reading video settings from 'data/video.txt'.
Initialized video.............	320x240 (Mode: 0, Depth: 16 Bit)

Loading menu.txt.............	Done!
Loading fonts................	1 2 3 4 Done!
Timer init...................	Done!
Initialize Sound..............	
sound_load_sample: Failed to load: data/sounds/go.wav

Loading sprites..............	Done!
Loading level order..........	Command 'disablegameover' not understood in level order!Done!
Loading script settings......	Done!
Loading scripts..............	Done!
Loading models...............

Cacheing 'Flash' from data/chars/misc/flash.txt
Cacheing 'Spark' from data/chars/misc/flash/spark.txt
Cacheing 'Nash' from data/chars/nash/nash.txt
Cacheing 'Time' from data/chars/misc/time.txt
Cacheing 'Jeger' from data/chars/jeger/jeger.txt
Cacheing 'Jegro' from data/chars/jeger/jegro.txt
Cacheing 'drum' from data/chars/misc/drum.txt
Cacheing 'Empty' from data/chars/misc/empty.txt

Loading 'Flash' from data/chars/misc/flash.txt
Loading 'Spark' from data/chars/misc/flash/spark.txt


Script error: data/scripts/script.c, line 1041: Unknown error 'float' (in production 20)

   float H = checkwall(x+Dist,z);
   ^


********** An Error Occurred **********
*            Shutting Down            *

Failed to parse script file: 'data/scripts/script.c'!
Total Ram: 4195418112 Bytes
 Free Ram: 1047392256 Bytes
 Used Ram: 13168640 Bytes

Release level data...........	Done!
Release graphics data........	Done!
Release game data............


Release game data............	Done!
Release timer................	Done!
Release input hardware.......	Done!
Release sound system.........	Done!
Release FileCaching System...	Done!

**************** Done *****************

Failed to parse script file: 'data/scripts/script.c'!

This is the script that causes problem + the build of Openbor I'm using right now.
https://www.mediafire.com/file/xqyae5xqw9kb10s/scro144b141.zip
Otherwise you still can download the game demo from Dantedevil, higher

I think the problem comes from the fact some scripts are not compatible with this 2011 Openbor build. Or they have to be implemented in another way.

But, I'm not a coder, so, I'm not sure.

I really hope some skilled person can understand it and perhaps help me.
Thanks


EDIT
I checked the log file.
And it seems to be linked to this line (in red) :

void wallhit2(int Dist, void Ani)
{// Checks if there is wall/platform at defined distance change animation
  void self = getlocalvar("self");
  int Direction = getentityproperty(self, "direction");
  int x = getentityproperty(self, "x");
  int z = getentityproperty(self, "z");

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

  float H = checkwall(x+Dist,z);
  float Hy = checkplatformbelow(x+Dist,z, 5000);

  if(H > 0 || Hy){
    performattack(self, openborconstant(Ani));
  }
}


I don't know why this particular line is not well detected in my 2011 build of Openbor. :/
 
The problem is I cannot change this older build.
Unless I recode all the game system and delete some features.

Why you can't use the last build?
Which are the features  you can't not use if change tof the last build ?

I change the build in every new release and I have had no problems. And you know I'm working in my mod for years.
Let me know if I can help you to update your mod to the last build.
I think is the best choice to avoid future problems.
 
Yes, it would be a solution to make it working.

Some of the problems are these :
platforms and walls width difference.
You can go through some walls.
A.I. acts in a total different way the way I configured it.
Command "B S" is not a valid command
... I can't remember the others.
But I tried to fix them in the past, and this is really not possible for me to change the build.

I don't know what is wrong with this line
Code:
   float H = checkwall(x+Dist,z);
If it's the use of floats or something, but. It might be a way to fix it in a different way :/
 
Thanks a lot for taking some time to give a reply BB.

I tried your suggestion, so th code looks like that.
Code:
void wallhit2(int Dist, void Ani)
{// Checks if there is wall/platform at defined distance change animation
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int z = getentityproperty(self, "z");

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

   float H = checkwall(x+Dist,z);
   float Hy = checkplatformbelow(x+Dist,z, 5000);

   if(H > 0 || Hy){
     performattack(self, openborconstant(Ani));
   }
}

And I have still have a crash.
log:
Code:
Script error: data/scripts/script.c, line 1041: Unknown error 'float' (in production 20)

   float H; float Hy;
   ^


********** An Error Occurred **********
*            Shutting Down            *

Failed to parse script file: 'data/scripts/script.c'!
Total Ram: 4195418112 Bytes
 Free Ram: 664440832 Bytes
 Used Ram: 12832768 Bytes

Release level data...........	Done!
Release graphics data........	Done!
Release game data............


Release game data............	Done!
Release timer................	Done!
Release input hardware.......	Done!
Release sound system.........	Done!
Release FileCaching System...	Done!

**************** Done *****************

Failed to parse script file: 'data/scripts/script.c'!


I know I'm not working the right way since I'm sticking to my olf build, but this is too complicated to update the full game. (In my future project, I'll avoid the old builds of course)


Perhaps it can helps, but as a reminder, I'm using a wall bounce script you helped me to set in the past. used for falling wall damage. and it works perfectly.
Perhaps some elements can be taken from this working script to help fixing the other one.

wall bounce script (working)
Code:
void walldam(int Dist, int Move, int Distz)
{// Checks if there is wall at defined distance
// If there is wall, entity will be moved away with defined movement (based on antiwall) envoie vers follow45
   void self = getlocalvar("self");
   int Direction = getentityproperty(self, "direction");
   int x = getentityproperty(self, "x");
   int y = getentityproperty(self, "a");
   int z = getentityproperty(self, "z");
   float H;
   float Hz;

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

   H = checkwall(x+Dist,z);
   Hz = checkwall(x+Dist,z+Distz);

   if(Hz > y)
   {
     changeentityproperty(self, "position", x, z-Distz);
     changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
     changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW45"));
   }

   if(H > y)
   {
     changeentityproperty(self, "position", x+Move);
     changeentityproperty(self, "velocity", 0, 0, 0); //Stop moving!
     changeentityproperty(self, "animation", openborconstant("ANI_FOLLOW45"));
   }
}
 
Back
Top Bottom