Change health spawn enemy with weapon

dantedevil

Well-known member
I just realized that when you spawn an enemy with a weapon, the system not take into account the health that you put and always leave the one you have in the header of their txt.

Here enemy header txt:
Code:
name	SLICER
health	60
speed	10
type	enemy
risetime -200 -200 
gfxshadow  1
aggression -30
falldie 2
projectilehit   enemy obstacle
hmap 1 5
fmap 2
noquake 1

aimove Avoidz

weapons  none SLICER2 SLICER 

icon	data/chars/gang1/slicer/icon.png 1
animationscript data/scripts/escript.h 

palette data/chars/gang1/slicer/idle0.png
alternatepal data/chars/gang1/slicer/map.png
alternatepal data/chars/gang1/slicer/map2.png 
alternatepal data/chars/gang1/slicer/map3.png 
alternatepal data/chars/gang1/slicer/map4.png 
alternatepal data/chars/gang1/slicer/map5.png 
alternatepal data/chars/gang1/slicer/map6.png 
alternatepal data/chars/gang1/slicer/map7.png

Here enemy weapon header txt:
Code:
name	SLICER2
health	60
speed	10
type	none
risetime -200 -200 
gfxshadow  1
aggression -30
dust		dust
hmap 1 5
fmap 2
aimove avoid

load knife2

typeshot      0
weaploss      0 
modelflag     1

icon	data/chars/gang1/slicer/icon.png 1

animationscript data/scripts/escript.h 

palette data/chars/gang1/slicer/idle0.png
alternatepal data/chars/gang1/slicer/map.png
alternatepal data/chars/gang1/slicer/map2.png 
alternatepal data/chars/gang1/slicer/map3.png 
alternatepal data/chars/gang1/slicer/map4.png 
alternatepal data/chars/gang1/slicer/map5.png 
alternatepal data/chars/gang1/slicer/map6.png 
alternatepal data/chars/gang1/slicer/map7.png

In their Slicer txt have health  60, and always spawn with this health, when spawn the weapon.
Is this true or is it a bug?
And if so, is there a way to allocate more health?

Here in the example I put health 200, but always spawn with 60 health, as it is designated in the header txt. It would be important to find the solution to be able to manually designate the energy for 1p, 2p or 3p, as we normally do.

Code:
spawn  slicer
health   200
2phealth 230
3phealth 260
weapon knife
coords  362 242 0
at      0


I try this script by O Ilusionista (http://www.chronocrash.com/forum/index.php?topic=3980.msg55051#msg55051)
, but not work:
Code:
spawn  slicer
@script void main() {
void self = getlocalvar("self"); // get caller
int iLife = 300;
changeentityproperty(self, "maxhealth",iLife );
changeentityproperty(self, "health",iLife );
} @end_script
weapon knife 0
coords  362 242 0
at      0
 
I have some questions based on this:
Code:
spawn	Williams
@script
void main()
{
    void self = getlocalvar("self");
    setentityvar(self, 8, 130); // defines maximum's health
}
@end_script
health	130
map	5
weapon	KnifeW 0
coords	400 225
at	100

1) I see you use here heath 130, this means that in your army the enemy has 130 health in main model and all weapon models?

2)  If the enemy originally has health60 in main model and all weapon models, but I want to use these values:
Code:
health   80
2phealth 100
3phealth 120

How should I put it in the level and in the script?
 
1) I see yo use here heath 130, this means that in your army the enemy has 130 health in main model and all weapon models?

Oh I forgot to delete that. Because of the script, health declaration is pointless

How should I put it in the level and in the script?

Use this:
Code:
@script
void main()
{
    void self = getlocalvar("self");
    int P = openborvariant("count_players");

    if(P = 3){
      setentityvar(self, 8, 120);
    } else if(P = 2){
      setentityvar(self, 8, 100);
    } else {
      setentityvar(self, 8, 80);
    }
}
@end_script

HTH :)
 
Well my friend, I make some test and not work properly.

I Set health 60 in the enemy main model and the weapon model.

Then spawn like this:
Code:
spawn  slicer
alias      bet
@script
void main()
{
    void self = getlocalvar("self");
    int P = openborvariant("count_players");

    if(P = 3){
      setentityvar(self, 8, 120);
    } else if(P = 2){
      setentityvar(self, 8, 90);
    } else {
      setentityvar(self, 8, 60);
    }
}
@end_script
weapon  knife 0
coords   362 242 0

When play 1 player, the enemy spawn with health 120.
I try removing the script and the enemy spawn with health 60.
 
enemy's HP (which is resetted during weapon model change)
You gave me an idea - Maybe there is an easier way to do it, using onmodelcopyscript.

save this as health.c
Code:
void main()
{
    void old = getlocalvar("old"); //Get original model, without the weapon
    void self = getlocalvar("self"); // Get the new model, with the weapon
    void oldHealth = getentityproperty(old,"health"); //Get the old entity's HP.
    changeentityproperty(self, "health", oldHealth); // set the new entity HP

}

and call it only on the weapon model, not the original one, as onmodelcopyscript

 
O Ilusionista said:
enemy's HP (which is resetted during weapon model change)
You gave me an idea - Maybe there is an easier way to do it, using onmodelcopyscript.

save this as health.c
Code:
void main()
{
    void old = getlocalvar("old"); //Get original model, without the weapon
    void self = getlocalvar("self"); // Get the new model, with the weapon
    void oldHealth = getentityproperty(old,"health"); //Get the old entity's HP.
    changeentityproperty(self, "health", oldHealth); // set the new entity HP

}

and call it only on the weapon model, not the original one, as onmodelcopyscript
I try your method but not work properly.
When set like this:
2phealth 100
3phealth 120
The enemy ignore this and always spaw with the default health.
 
dantedevil said:
When play 1 player, the enemy spawn with health 120.
I try removing the script and the enemy spawn with health 60.

Okay, I'll check issue with 2phealth and 3phealth but I assume the script system works without enemy losing maximum HP somewhere?

[couple minutes later]

Now I know why it didn't work, the script was missing another =. It should be like this:
Code:
@script
void main()
{
    void self = getlocalvar("self");
    int P = openborvariant("count_players");

    if(P == 3){
      setentityvar(self, 8, 120);
    } else if(P == 2){
      setentityvar(self, 8, 100);
    } else {
      setentityvar(self, 8, 80);
    }
}
@end_script

HTH
 
I found some problem when try to spwn an enemy with an specific animation and add the script health in the spawn level.

I try like this and the enemy spawn with the specific animation, but the script health not work:
Code:
spawn  slicer
@script 
void main() {
	performattack(getlocalvar("self"), openborconstant("ANI_follow16"));
} @end_script
alias   Kendrick
@script
void main()
{
    void self = getlocalvar("self");
    int P = openborvariant("count_players");

    if(P == 3){
      setentityvar(self, 8, 100);
    } else if(P == 2){
      setentityvar(self, 8, 80);
    } else {
      setentityvar(self, 8, 60);
    }
}
@end_script
weapon  knife
coords  550 250
at      624

Next try like this and the script health works ok, but the enemy not spawn with the specific animation:
Code:
spawn  slicer
@script
void main()
{
    void self = getlocalvar("self");
    int P = openborvariant("count_players");

    if(P == 3){
      setentityvar(self, 8, 100);
    } else if(P == 2){
      setentityvar(self, 8, 80);
    } else {
      setentityvar(self, 8, 600);
    }
}
@end_script
alias   Kendrick
@script 
void main() {
	performattack(getlocalvar("self"), openborconstant("ANI_follow16"));
} @end_script
weapon  knife
coords  550 250
at      624

Finally I try to mix the two script in one, but I can't make it work...
 
spawn  slicer
@script
void main()
{
    void self = getlocalvar("self");
    int P = openborvariant("count_players");

    if(P == 3){
      setentityvar(self, 8, 100);
    } else if(P == 2){
      setentityvar(self, 8, 80);
    } else {
      setentityvar(self, 8, 60);
    }
    performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW16"));
}
@end_script
weapon  knife
coords  550 250
at      624
 
O Ilusionista said:
spawn  slicer
@script
void main()
{
    void self = getlocalvar("self");
    int P = openborvariant("count_players");

    if(P == 3){
      setentityvar(self, 8, 100);
    } else if(P == 2){
      setentityvar(self, 8, 80);
    } else {
      setentityvar(self, 8, 60);
    }
    performattack(getlocalvar("self"), openborconstant("ANI_FOLLOW16"));
}
@end_script
weapon  knife
coords  550 250
at      624

Thanks my friend!

Now I see where my error is when mixing the two scripts.
 
I found a great problem with this takedamage script.

storing.c
Code:
void main()
{// Preserves maximum health and health during weapon model change
// Also stores received damage
    void self = getlocalvar("self");
    int Damage = getlocalvar("damage"); //Get received damage
    int RilMHP = getentityvar(self, 8);
    int Dams = getentityvar(self, 9);

    if(RilMHP==NULL()){
      RilMHP = getentityproperty(self, "maxhealth");
      setentityvar(self, 8, RilMHP);
    }

    if(Dams==NULL()){
      Dams = 0;
    }

    changeentityproperty(self, "maxhealth", RilMHP);
    changeentityproperty(self, "health", RilMHP - Dams - Damage);

    setentityvar(self, 9, Dams+Damage);
}

The NOKILL 1 don't work in enemies with this takedamage script.
I thought it was a problem with Build 6315, but after many tests I discovered that by removing the takedamage scritp, everything was back to normal.

So seems the script need an update to work properly...
:-\
 
Bloodbane said:
Hmmm... can't find nokill in manual, what does the command do?

If you ser nokill 1 after the attack, this attack can't kill the enemy.
This is very useful to avoid kill the enemy during a combo.
The same way you need set nokill 0, to make the attack can kill the enemy.
 
rafhot did mention about using nokill 1.

rafhot said:
you can try it also using the command:

nokill 1

wth this set in all attack animations players/enemies will take damage until  life = 1 
and for attacks that makes enemies/players fall you dont use it and they will die in the way you want
 
maxman said:
rafhot did mention about using nokill 1.

rafhot said:
you can try it also using the command:

nokill 1

wth this set in all attack animations players/enemies will take damage until  life = 1 
and for attacks that makes enemies/players fall you dont use it and they will die in the way you want


Thanks for the info my friend!

But seems this turn into something more cpmplex to solve...
:-\
 
Back
Top Bottom