Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Player reaches % HP = Draw Animation


Vortigem
 Share

Recommended Posts

I'm using a DX8 engine, based on CS:DE. This is an unsupported engine, though a learning experience for me.

I have a few cool ideas I'd like to pixel for something like this and it seems like it would be an easy mod. Is there a tutorial out there for something like this or would anyone mind lending me a hand?

Example:

Playercharacter reaches 25% HP; Draw Animation #5 at Playercharacter.
Link to comment
Share on other sites

I don't really know how CS:DE works, but from what I know from Eclipse, you'd likely have to find a sub that runs every so often, like SendPlayerVitals or something like that, and slap the send drawanim in there. You'd have to add a variable to check if you've sent the anim already to not spam the animation, too.

Is this any help?
Link to comment
Share on other sites

> Sub NpcAttackPlayer, look at check where player HP is 0 and another if there and add there is players hp is 25% and then use SendAnimation Attacker…. etc.

I am pretty sure that the HP updates are sent to all map players. Therefore it would be better to handle all the stuff ClientSide. (If the animations are same for different then this would be preferred over sending extra packets.)
Link to comment
Share on other sites

> I am pretty sure that the HP updates are sent to all map players. Therefore it would be better to handle all the stuff ClientSide. (If the animations are same for different then this would be preferred over sending extra packets.)

Yeah, but it will require alot more work, you must make something like client-side map animations etc etc so my way is alot more simple. And nope, player HPs are not sent to all players, only if you are in party then it is sent to party members too, so your method will fail.
Link to comment
Share on other sites

I don't have the CS:DE source handy, but here's how you'd do it very easily in EFF, which also uses DX8\. Possible that the animations are done a little differently (see final note). Doing the following will render an animation under your character when below 25% HP. If you'd like it to be over, you'll have to move that animation uniquely past DrawPlayer in render_graphics (DX8 renders back-to-front; since most animations should be below, you can't move all of them).

In modGlobals add:

```
HurtAnimTrigger As Boolean

```
In SetPlayerVitals, add:

```
If Index = MyIndex Then
If Vital = hp Then
If value <= GetPlayerMaxVital(Index, hp) / 4 Then
If HurtAnimTrigger = False Then
AnimationIndex = AnimationIndex + 1
If AnimationIndex >= MAX_BYTE Then AnimationIndex = 1
With AnimInstance(AnimationIndex)
.Animation = 34
.x = Player(Index).x
.y = Player(Index).y
.LockType = TARGET_TYPE_PLAYER
.lockindex = Index
.Used(0) = True
.Used(1) = True
End With
HurtAnimTrigger = True
End If
Else: HurtAnimTrigger = False
End If
End If
End If 
```
You can remove the "If Index=MyIndex Then" and the last "End If" if you'd like the animation to trigger for any other players whose hp vital you're privy to (I think just party members, as discussed above).

Change 34 to your desired animation # and the engine should take care of the rest. The boolean ensures that this will only happen once per cross below 25% and will not be triggered again while from below 25% to below 25%, such as through regen.

Note: if lock types aren't supported, add HurtAnimIndex as Byte in modGlobals. Set HurtAnimIndex= AnimationIndex in SetPlayerVitals. In the DrawPlayerSub, set AnimInstance(HurtAnimIndex).x and .y to equal x and y. I think the animation will always be a pixel behind though, because it happens before the player is drawn, so it would get its x from the previous player x…
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...