Welcome, Guest. Please login or register.

What openbor you prefer: Double dragon,battletoads or final fight !? by lirexpatrio
[December 07, 2012, 07:15:27 pm]


what are your favorite games OpenBOR?! by lirexpatrio
[December 07, 2012, 07:09:46 pm]


Post Some Awesome Videos by maxman
[December 07, 2012, 05:51:39 pm]


Can @cmd playmusic "aaaa" 1 also increse music sound ? by BeasTie
[December 07, 2012, 05:24:38 pm]


Streets of Rage: Silent Storm by mtrain
[December 07, 2012, 03:45:05 pm]


Site will be down for maintenance on 12/8/2012 thru 12/10/2012 by Damon Caskey
[December 07, 2012, 07:42:42 am]


Cancelled SOR 3d Remake by riccochet
[December 07, 2012, 03:58:33 am]


Dungeon Fighter: B.O.R. by msmalik681
[December 07, 2012, 03:24:27 am]


[TUTORIAL] How to create 4 Games of OpenBOR in 1 CD (650 MB) by magggas
[December 06, 2012, 09:46:25 pm]


custknife by Bloodbane
[December 06, 2012, 09:34:09 pm]


blockfx help by B.Kardi
[December 06, 2012, 04:09:14 pm]


street of age 4 hd by corradlo
[December 06, 2012, 01:41:36 pm]


ClaFan - Classic Fantasy ver 1.17 by soniczxblade
[December 06, 2012, 05:01:20 am]


Bug Archive by Bloodbane
[December 06, 2012, 02:00:44 am]


"Bio-Doom" and "Gears of Doom" by BulletBob
[December 05, 2012, 10:07:21 pm]


Contra Locked 'N' Loaded v2 by Bloodbane
[December 05, 2012, 09:39:43 pm]


Downloadable OpenBoR Manual by BeasTie
[December 05, 2012, 08:31:24 pm]


Having trouble testing changes by B.Kardi
[December 05, 2012, 03:05:53 pm]


DragonBall Absalon by msmalik681
[December 05, 2012, 02:52:13 pm]


[Hi-Res] Swamp by Vibrant
[December 05, 2012, 10:47:14 am]


  • Dot Guests: 194
  • Dot Hidden: 0
  • Dot Users: 0

There aren't any users online.



Author Topic: Draw player health to screen with fonts/numbers  (Read 3118 times)

0 Members and 1 Guest are viewing this topic.

Offline BeasTie

  • Hero Member
  • *****
  • Posts: 760
Re: Draw player health to screen with fonts/numbers
« Reply #15 on: May 30, 2012, 01:47:15 am »
You're right Bloodbane the anim trick is almost perfect duration, but pain and get animations are very fast/short, I just want them to display just a tiny bit longer without messing with their durations.  I could make them a bit longer but that would mean slower reaction times when grabbing a weapon during a battle or being attacked.

Mirror the sprite already there? Clever thinking! ;) it still needs the normal facing forward face between each face looking left and right thou.

This is kinda what the face does in original Doom when idle. (was studying it a bit, he may also do it as enemies approach)

When he's shot he faces the direction of his attacker

This is the faces I'm using for pain at the moment, but these are also for when he is attacking with chainsaw or in close quarters fight. I already added them to run during ATTACK anims.


EDIT: Thanks for the script Bloodbane, just tried it and it's basically working already just adding your code.  Still needs tweaking but another step closer, :cheers!:
« Last Edit: May 30, 2012, 02:23:12 am by BeasTie »

Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Draw player health to screen with fonts/numbers
« Reply #16 on: May 30, 2012, 04:54:12 am »
what you want is a method that checks if the enemy is to your right or to your left....


void self = getlocalvar("self");
void target = getentityproperty(self, "opponent");

void selfxposition = getentityproperty(self, "x") ;
void targetxposition = getentityproperty(target, "x");

if ( targetxposition >= selfxposition )
{
  //show right icon
} else {
  //show left icon
}

Offline BeasTie

  • Hero Member
  • *****
  • Posts: 760
Re: Draw player health to screen with fonts/numbers
« Reply #17 on: May 30, 2012, 08:42:30 am »
Cheers, I'll try that for the left and right pain faces.


Offline BeasTie

  • Hero Member
  • *****
  • Posts: 760
Re: Draw player health to screen with fonts/numbers
« Reply #18 on: June 12, 2012, 05:37:48 am »
Something I'm still messing up is just the logic for when it displays the face, it works but you can tell some are still being drawn underneath the next sprite.

Code: [Select]
if(p1disphealth >= 100) drawsprite(getglobalvar("faceb"), 456, 2, 2000, 0);
else if(p1disphealth >= 80) drawsprite(getglobalvar("faceb"), 456, 2, 2001, 0);
else if(p1disphealth <= 80) drawsprite(getglobalvar("facef"), 456, 2, 2001, 0);
if(p1disphealth <= 55) drawsprite(getglobalvar("facei"), 456, 2, 2002, 0);
if(p1disphealth <= 35) drawsprite(getglobalvar("facel"), 456, 2, 2003, 0);
if(p1disphealth <= 15) drawsprite(getglobalvar("faceo"), 456, 2, 2004, 0);
if(p1disphealth == 1) drawsprite(getglobalvar("faceo"), 456, 2, 2005, 0);

I'm kinda been stumped for ages how to do it better.  it's after the <= 80 I think it's flawed, I think it still runs the 80% part when it runs the others. (or something)

This is a sprite showing what it does.  Like I said mine works but it's not perfect.


Can someone show me how to fix the <=

(edit - typo)
« Last Edit: June 12, 2012, 11:42:18 pm by BeasTie »

Offline MatMan

  • Hero Member
  • *****
  • Posts: 1320
Re: Draw player health to screen with fonts/numbers
« Reply #19 on: June 12, 2012, 05:59:16 am »
If you have a IF block of code that is considered to be a group(like the face) then always use the else statement..

Code: [Select]
if(p1disphealth >= 100) { drawsprite(getglobalvar("faceb"), 456, 2, 2000, 0); } else
        if(p1disphealth >= 80) { drawsprite(getglobalvar("faceb"), 456, 2, 2001, 0); } else
if(p1disphealth <= 80) { drawsprite(getglobalvar("facef"), 456, 2, 2001, 0); } else
if(p1disphealth <= 55) { drawsprite(getglobalvar("facei"), 456, 2, 2002, 0); } else
if(p1disphealth <= 35) { drawsprite(getglobalvar("facel"), 456, 2, 2003, 0); } else
if(p1disphealth <= 15) { drawsprite(getglobalvar("faceo"), 456, 2, 2004, 0); } else
if(p1disphealth == 1) { drawsprite(getglobalvar("faceo"), 456, 2, 2005, 0); }

This also prevents problems that you just suggested and also prevents on cpu wastage.

Also try to use the curly brackets aswell.

Offline BeasTie

  • Hero Member
  • *****
  • Posts: 760
Re: Draw player health to screen with fonts/numbers
« Reply #20 on: June 12, 2012, 06:03:46 am »
Cheers dude, I was about to try some brackets and change to else if, but I thought my logic was still flawed anyway.
Oh yeah I forgot the updated screenshot.

Decided why have a revamped STBAR when you can just have the real thing ;) 

For when 2-4p are present then I'll make it use smaller versions.

EDIT: - I tried what you had but now it doesn't show the other faces, just the 100% and 80% ones, might need to tidy up the rest of my code thou, will try that first.
« Last Edit: June 12, 2012, 06:25:20 am by BeasTie »

Offline Bloodbane

  • Hero Member
  • *****
  • Posts: 7113
  • Dark Dragon
Re: Draw player health to screen with fonts/numbers
« Reply #21 on: June 14, 2012, 12:29:30 am »
 I found the flaw in your code Beastie:

Quote
if(p1disphealth >= 100) { drawsprite(getglobalvar("faceb"), 456, 2, 2000, 0); } else
        if(p1disphealth >= 80) { drawsprite(getglobalvar("faceb"), 456, 2, 2001, 0); } else
   if(p1disphealth <= 80) { drawsprite(getglobalvar("facef"), 456, 2, 2001, 0); } else
   if(p1disphealth <= 55) { drawsprite(getglobalvar("facei"), 456, 2, 2002, 0); } else
   if(p1disphealth <= 35) { drawsprite(getglobalvar("facel"), 456, 2, 2003, 0); } else
   if(p1disphealth <= 15) { drawsprite(getglobalvar("faceo"), 456, 2, 2004, 0); } else
   if(p1disphealth == 1) { drawsprite(getglobalvar("faceo"), 456, 2, 2005, 0); }

 With else, when one of the IFs is run, the others will be neglected.
 That's what happened here. When health is less than 80, the 3rd IF is run. It doesn't matter if health is less than 15, 35,  55 or 1, it fits 3rd IF. That explains the problem you have here.

 To solve this, you can either define the group strictly like this:

Quote
if(p1disphealth >= 80 && p1disphealth < 100)

 or reorder them like this:

Quote
if(p1disphealth <= 1) { drawsprite(getglobalvar("faceo"), 456, 2, 2005, 0);
 } else if(p1disphealth <= 15) { drawsprite(getglobalvar("faceo"), 456, 2, 2004, 0);
 } else if(p1disphealth <= 35) { drawsprite(getglobalvar("facel"), 456, 2, 2003, 0);
 } else if(p1disphealth <= 55) { drawsprite(getglobalvar("facei"), 456, 2, 2002, 0);
} else if(p1disphealth <= 80) { drawsprite(getglobalvar("facef"), 456, 2, 2001, 0);
 } else if(p1disphealth <= 100) { drawsprite(getglobalvar("faceb"), 456, 2, 2001, 0);
 } else if(p1disphealth > 100) { drawsprite(getglobalvar("faceb"), 456, 2, 2000, 0);
 }

 The former defines clearly health area so there won't be 'overlapping case' like this.
 The latter is advanced reorder trick which works by checking the less possible event to the most possible one. Getting health 1 or below (negative values included) is less possible that's why it's define earliest.

 HTH
OpenBoR Manual

Basic OpenBoR Tutorials

OpenBoR Tricks & Tutorials

"The more often enemies attack, the more open they are to counter attacks"

Offline BeasTie

  • Hero Member
  • *****
  • Posts: 760
Re: Draw player health to screen with fonts/numbers
« Reply #22 on: June 14, 2012, 08:39:16 am »
Ahh that makes a sense and explains a few things that were going on when I tried to fix it.

Worked great thanks heaps again. :cheers!:

Offline BeasTie

  • Hero Member
  • *****
  • Posts: 760
Re: Draw player health to screen with fonts/numbers
« Reply #23 on: June 18, 2012, 09:19:49 pm »
I finally sorted the IDLE face, I had an idea how to do it before, but I'm getting a little better with script now and managed to work it out this time.

Code checks if player is idle and also what frame number, the script displays looking left on frame 1 and looking right on frame 3.
Player has extra frames in his idle anim to control the timing of the eyes. (Currently about 4-5 frames with 80 delay.) 



Here a line of code to show how it runs, crude no doubt, but it works ;)
Code: [Select]
if(anim == openborconstant("ANI_IDLE") && (aniF == 1) && (p1disphealth <= 1)) drawsprite(getglobalvar("faceu"), 137, 4, 3008, 0);

Next step is to expand on it so it shows the varying speeds of eye movements like in the original game. 


Offline Bloodbane

  • Hero Member
  • *****
  • Posts: 7113
  • Dark Dragon
Re: Draw player health to screen with fonts/numbers
« Reply #24 on: June 19, 2012, 05:22:22 am »
 Great!

 I think you should try playing with time so face displaying code is controlled by time instead of player's IDLE animation.
OpenBoR Manual

Basic OpenBoR Tutorials

OpenBoR Tricks & Tutorials

"The more often enemies attack, the more open they are to counter attacks"

Offline BeasTie

  • Hero Member
  • *****
  • Posts: 760
Re: Draw player health to screen with fonts/numbers
« Reply #25 on: June 19, 2012, 05:55:04 am »
Agreed, but I don't how to do that yet thou.  :dunce: 
I tried to use openborvariant("elapsed_time") at first but I couldn't work it out.

MatMan's showed me some stuff from his scripts so I can do the whole GUI a lot better, I've got some of the text objects running from another script now, I just can't work out how to properly display sprites without update script, I'm just using drawsprite command.  But without update script they only display for a moment.

Will try to move it all to this other script eventually,
sticking with this one for now thou just so I can see it working while I'm modding ;D

Messing with scripts and stuff in another version of  the mod so I can keep one version kinda presentable.  Making some advances thou,  more than I could pull off a few months ago.

 



 0%




SimplePortal 2.3.3 © 2008-2010, SimplePortal