Skip to content

Replace health/armour limits.#1

Open
lorencpekaj wants to merge 1 commit intoMedAnisBenSalah:masterfrom
lorencpekaj:master
Open

Replace health/armour limits.#1
lorencpekaj wants to merge 1 commit intoMedAnisBenSalah:masterfrom
lorencpekaj:master

Conversation

@lorencpekaj
Copy link
Copy Markdown

Sometimes we want the NPC to have more health/armour as they die too quickly.

damn they are so annoying lol
@lorencpekaj
Copy link
Copy Markdown
Author

Also, just edited it on the spot so I didn't bother compiling yet BUT in other words, just give the limit a raise 👍

@NeoPhoenix
Copy link
Copy Markdown

Why would you want to implement a health/armor limit at all?

@lorencpekaj
Copy link
Copy Markdown
Author

Correct me if I'm wrong (probably is for ammo), but isn't Health/Armour meant to be within the 16-bit limit?

@NeoPhoenix
Copy link
Copy Markdown

Well, I have never heard of that limit (maybe because I never tried to use higher values) but it's nice to learn new stuff

@prineside
Copy link
Copy Markdown

You can set lots of health for any NPC without changes in plugin:
0. Create an array for NPC health:
enum e_NPC_Health {
Float:CURRENT,
FLoat:MAXIMUM
}
new NPC_Health[ e_NPC_Health ];

  1. When creating new NPC, set it's health:
    new npcid = ...
    NPC_Health[ npcid ][ MAXIMUM ] = 1000.0;
    NPC_Health[ npcid ][ CURRENT ] = 1000.0;
  2. In FCNPC_OnTakeDamage (or in any callback where you handle NPC damage):
    NPC_Health[ npcid ][ CURRENT ] -= damageAmount;
    If ( NPC_Health[ npcid ][ CURRENT ] <= 0.0 ) {
    // NPC was killed, do what you do in that case
    } else {
    FCNPC_SetHealth( npcid, NPC_Health[ npcid ][ CURRENT ] / NPC_Health[ npcid ][ MAXIMUM ] * 100.0 );
    }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants