Bleeding Player (Help Needed Fast,if possible)
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Bleeding Player (Help Needed Fast,if possible)
I know I can make this using a flipbook entity or something,but it doesn't really look well in the game.I'm talking abaout when the player gets hit by a projectile or something (when the player's health attribute decreases) the screen to go red.OK,this can be done with a flipbook and a script,but I want it to be a little more complicated.this thing exists in nirhis demo,but I couldn't figure out how it works and what is it.When the player's health decreases with for example 5,the screen goes red,but just a little red (I'm talking about the transparency of the red) and then the red screen smoothly dissapears,but if the player''s health decreases by 30,the transparency of the red will get smaller and the screen will go totally red...I don't really know how to explain this,I just hope that you've all played the nirhis demo and know what I'm talking about.
I don't know about a command for transparency and couldn't find nothing in the manual (if there is,I've missed it) can someone please help,that's important for the demo release.
I don't know about a command for transparency and couldn't find nothing in the manual (if there is,I've missed it) can someone please help,that's important for the demo release.
Re: Bleeding Player (Help Needed Fast,if possible)
In Nirhis it's done with the FillScreenArea command:
If you take a look at the player script (player.s) you'll find this in the damage() method.Where 'screenred' is a variable holding the amount of "red" drawn on the screen. In other words, the transparency. The variable itself is calculated with the line
Where 'lastdamage' is the amount of damage the player last received.
It's basically a red transparent rectangle which covers the whole screen.FillScreenArea(int Area#, bool KeepVisible, float Alpha);
FillScreenArea(int Area#, bool KeepVisible, float Alpha, float R, float G, float B);
FillScreenArea(int Area#, bool KeepVisible, float Alpha, float R, float G, float B, int Left, int Top, int Right, int Bottom);
Fills a rectangle on the screen with a color and an alpha
Area# is a number between 0 and 19 that is used to distinguish between different FillScreenArea commands within one order.
KeepVisible keeps the rectangle processed and visible independent of the selected ThinkTime
Alpha defines the transparency of the filled rectangle (0 is fully transparent, 255 is fully solid)
R, G, B define the color to be used to fill the rectangle. Default color is black (0, 0, 0).
Left, Top, Right, Bottom define the rectangle in screen coordinates to be filled. If not specified, the full screen will be filled
If you take a look at the player script (player.s) you'll find this in the damage() method.
Code: Select all
if(screenred > 0)
{
FillScreenArea(1,true,screenred,255,0,0);
if(redtime < self.time)
{
screenred = screenred - 5;
redtime = self.time + 0.05;
}
}
else
{
RemoveScreenArea(1);
}
Code: Select all
screenred = screenred + lastdamage*4;
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Bleeding Player (Help Needed Fast,if possible)
thanks,but as alway I got some questions . What's that "redtime" ?
it should be a variable,right,but for what?
Code: Select all
if(redtime < self.time)
Re: Bleeding Player (Help Needed Fast,if possible)
It's a variable for the timer that reduces the transparency. Every 0.05 seconds it reduces the transparency of the red by 5.
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Bleeding Player (Help Needed Fast,if possible)
OK,so this is what I made,and as always it doesn't work ...man I can't wait for the day when I'll make something MYSELF with no help and it will work.
I don't see any missed "{ }"..so maybe it's a whole missed command or more,but shouldn't that be working?
Code: Select all
{
screenred [0]
redtime [0]
lasthealth [0]
Spawn[ ()
{
Console(true);
LowLevel("execute");
} ]
execute[ ()
{
if(GetAttribute("health","Player") < lasthealth)
{
FillScreenArea(1,true,screenred,255,0,0);
if(redtime < self.time)
{
screenred = screenred - 10;
redtime = self.time + 0.05;
}
}
else
{
RemoveScreenArea(1);
}
} ]
}
Last edited by metal_head on Wed Oct 15, 2008 7:41 pm, edited 1 time in total.
Re: Bleeding Player (Help Needed Fast,if possible)
A script must start with { and end with }
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Bleeding Player (Help Needed Fast,if possible)
oh,that's just a copy/paste mistake,sorry I'll fix the post above. So it's not because of a { or }.
Re: Bleeding Player (Help Needed Fast,if possible)
Note that what I posted above is not the full script. That just draws the red rectangle on the screen. You still have to check if the player is damaged. Try something like:
***EDIT***
Oh, you're a moderator bernie? I never realized. When did you become one?
Congrats, no matter how late I am.
Code: Select all
execute[ ()
{
if(GetAttribute("health","Player") != lasthealth)
{
if(GetAttribute("health","Player") < lasthealth)
{
screenred = screenred + (lasthealth - GetAttribute("health","Player"))*4;
}
lasthealth = GetAttribute("health","Player");
}
if(screenred > 0)
{
FillScreenArea(1,true,screenred,255,0,0);
if(redtime < self.time)
{
screenred = screenred - 10;
redtime = self.time + 0.05;
}
}
else
{
RemoveScreenArea(1);
}
} ]
Oh, you're a moderator bernie? I never realized. When did you become one?
Congrats, no matter how late I am.
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Bleeding Player (Help Needed Fast,if possible)
I though I've done this with:
Oh,I still got a lot to learn.
Code: Select all
if(GetAttribute("health","Player") < lasthealth)
Re: Bleeding Player (Help Needed Fast,if possible)
All that does is it checks if the player's attribute 'health' is smaller than the script's variable 'lasthealth'. In the beginning of the script you set 'lasthealth' to 0 and never change it. This leads to player's health being always larger than the 'lasthealth' variable (unless the player is dead). And so your if-statement is always false. In other words the stuff inside the if-block is never executed.
Pain is only psychological.
- metal_head
- Posts: 1244
- Joined: Sat Jan 05, 2008 8:31 pm
- Location: Bulgaria,Sofia
- Contact:
Re: Bleeding Player (Help Needed Fast,if possible)
I see...well,it's going to take time till I understand and remember all theese But I won't give up,in school were are starting to learn the structure of programming and I think all theese things we'll get a lot much clearer for me,just a matter of time and hard work!