by Grey-Wolf » Sun Mar 17, 2019 10:38 am
Blue Shadow wrote: Change s :enemyarmor to d :enemyarmor in the HudMessage call.
Of course, I'm such an idiot -_-"
But still, something's not right. When I spawn an enemy wearing armor and aim at them, I just see a "0" under their health. Then, after some seconds, the zero turns into a "200", no matter the kind of armor they're wearing.
To make things clearer:
This is the updated code for the hud script:
Spoiler:Code: Select all
#library "EnemyScouterThing"
#include "zcommon.acs"
str enemyname;
int enemyhealthmax;
int enemyhealth;
int monstercount;
int enemyarmor;
int enemyarmorPERCENT;
script "EnemyScouterThing" ENTER
{
if (GetCvar( "bd_disablescanner") == 1) { terminate;}
monstercount = GetLevelInfo (LEVELINFO_KILLED_MONSTERS);
while(TRUE)
{
//NOTE: PickActor requires careful handling. See the zdoom wiki about that!
// Actor's old TID needs to be saved, assigned a new TID, then restored back to old TID to keep things operational.
int old_tid = PickActor(0, GetActorAngle(0), GetActorPitch(0), 2048.0, 0, MF_SHOOTABLE | !MF_CORPSE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, PICKAF_RETURNTID);
int new_tid = UniqueTID();
if(PickActor(0, GetActorAngle(0), GetActorPitch(0), 2048.0, new_tid, MF_SHOOTABLE | !MF_CORPSE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, PICKAF_FORCETID))
{
//GET ACTOR INFO
enemyname = GetActorProperty(new_tid, APROP_NameTag); //name
enemyhealthmax = GetActorProperty(new_tid, APROP_SpawnHealth); //max hp
enemyhealth = GetActorProperty(new_tid, APROP_HEALTH); //current hp
enemyarmor = Checkinventory("BasicArmor");
//ACTOR HEALTH DISPLAY
if(GetActorProperty(new_tid, APROP_Speed) > 0)
{
if (enemyhealth >= 1)
{
//ACTOR NAME DISPLAY
HudMessage( s:"",
s:enemyname;
HUDMSG_FADEOUT, 112223, CR_DARKRED, 0.5, 0.02, 0.6, 0.2);
HudMessage( s:"\n \n",
d:enemyarmor;
HUDMSG_FADEOUT, 112226, CR_DARKGREY, 0.5, 0.02, 0.6, 0.2);
int pc = enemyhealth * 100 / enemyhealthmax;
if(pc>=75)
{
HudMessage( s:"\n",
d:enemyhealth,
s:"/",
d:enemyhealthmax;
HUDMSG_FADEOUT, 112224, CR_TAN, 0.5, 0.02, 0.6, 0.2);
}
else if(pc>=50)
{
HudMessage( s:"\n",
d:enemyhealth,
s:"/",
d:enemyhealthmax;
HUDMSG_FADEOUT, 112224, CR_GOLD, 0.5, 0.02, 0.6, 0.2);
}
else if(pc>=25)
{
HudMessage( s:"\n",
d:enemyhealth,
s:"/",
d:enemyhealthmax;
HUDMSG_FADEOUT, 112224, CR_ORANGE, 0.5, 0.02, 0.6, 0.2);
}
else if(pc>=0)
{
HudMessage( s:"\n",
d:enemyhealth,
s:"/",
d:enemyhealthmax;
HUDMSG_FADEOUT, 112224, CR_RED, 0.5, 0.02, 0.6, 0.2);
}
//ACTOR FRIENDLY INDICATOR
if(GetActorProperty(new_tid, APROP_Friendly) == TRUE)
{
HudMessage( s:"\n\n-Friendly-";
HUDMSG_FADEOUT, 112225, CR_GREEN, 0.5, 0.02, 0.6, 0.2);
}
}
}
This is the Custom armor I'm using for the monster:
Spoiler:Code: Select all
Actor 100ArmorMed : BasicArmorPickup
{
Game Doom
Scale 0.3
SpawnID 67
Radius 20
Height 16
Inventory.Pickupmessage "Your skin has become hard as iron!"
Inventory.Icon "ARM1B0"
Armor.SavePercent 99.99
Armor.SaveAmount 600
Inventory.PickupSound "ARMOR"
States
{
Spawn:
ARM1 A 10
loop
}
}
And this is the spawn state of said monster:
Spoiler:Code: Select all
{
Spawn:
TNT1 A 1
TNT1 A 0 A_GiveInventory("100ArmorMed")
TERM AB 10 A_Look
Loop
Note that I get the same results with other monster and other armor types, so I think the problem is elsewhere.
[quote="Blue Shadow"]Change [i][b]s[/b]:enemyarmor[/i] to [i][b]d[/b]:enemyarmor[/i] in the HudMessage call.[/quote] Of course, I'm such an idiot -_-" But still, something's not right. When I spawn an enemy wearing armor and aim at them, I just see a "0" under their health. Then, after some seconds, the zero turns into a "200", no matter the kind of armor they're wearing. To make things clearer: This is the updated code for the hud script: [spoiler][code]#library "EnemyScouterThing" #include "zcommon.acs" str enemyname; int enemyhealthmax; int enemyhealth; int monstercount; int enemyarmor; int enemyarmorPERCENT; script "EnemyScouterThing" ENTER { if (GetCvar( "bd_disablescanner") == 1) { terminate;} monstercount = GetLevelInfo (LEVELINFO_KILLED_MONSTERS); while(TRUE) { //NOTE: PickActor requires careful handling. See the zdoom wiki about that! // Actor's old TID needs to be saved, assigned a new TID, then restored back to old TID to keep things operational. int old_tid = PickActor(0, GetActorAngle(0), GetActorPitch(0), 2048.0, 0, MF_SHOOTABLE | !MF_CORPSE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, PICKAF_RETURNTID); int new_tid = UniqueTID(); if(PickActor(0, GetActorAngle(0), GetActorPitch(0), 2048.0, new_tid, MF_SHOOTABLE | !MF_CORPSE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, PICKAF_FORCETID)) { //GET ACTOR INFO enemyname = GetActorProperty(new_tid, APROP_NameTag); //name enemyhealthmax = GetActorProperty(new_tid, APROP_SpawnHealth); //max hp enemyhealth = GetActorProperty(new_tid, APROP_HEALTH); //current hp enemyarmor = Checkinventory("BasicArmor"); //ACTOR HEALTH DISPLAY if(GetActorProperty(new_tid, APROP_Speed) > 0) { if (enemyhealth >= 1) { //ACTOR NAME DISPLAY HudMessage( s:"", s:enemyname; HUDMSG_FADEOUT, 112223, CR_DARKRED, 0.5, 0.02, 0.6, 0.2); HudMessage( s:"\n \n", d:enemyarmor; HUDMSG_FADEOUT, 112226, CR_DARKGREY, 0.5, 0.02, 0.6, 0.2); int pc = enemyhealth * 100 / enemyhealthmax; if(pc>=75) { HudMessage( s:"\n", d:enemyhealth, s:"/", d:enemyhealthmax; HUDMSG_FADEOUT, 112224, CR_TAN, 0.5, 0.02, 0.6, 0.2); } else if(pc>=50) { HudMessage( s:"\n", d:enemyhealth, s:"/", d:enemyhealthmax; HUDMSG_FADEOUT, 112224, CR_GOLD, 0.5, 0.02, 0.6, 0.2); } else if(pc>=25) { HudMessage( s:"\n", d:enemyhealth, s:"/", d:enemyhealthmax; HUDMSG_FADEOUT, 112224, CR_ORANGE, 0.5, 0.02, 0.6, 0.2); } else if(pc>=0) { HudMessage( s:"\n", d:enemyhealth, s:"/", d:enemyhealthmax; HUDMSG_FADEOUT, 112224, CR_RED, 0.5, 0.02, 0.6, 0.2); } //ACTOR FRIENDLY INDICATOR if(GetActorProperty(new_tid, APROP_Friendly) == TRUE) { HudMessage( s:"\n\n-Friendly-"; HUDMSG_FADEOUT, 112225, CR_GREEN, 0.5, 0.02, 0.6, 0.2); } } } [/code][/spoiler] This is the Custom armor I'm using for the monster: [spoiler][code]Actor 100ArmorMed : BasicArmorPickup { Game Doom Scale 0.3 SpawnID 67 Radius 20 Height 16 Inventory.Pickupmessage "Your skin has become hard as iron!" Inventory.Icon "ARM1B0" Armor.SavePercent 99.99 Armor.SaveAmount 600 Inventory.PickupSound "ARMOR" States { Spawn: ARM1 A 10 loop } }[/code][/spoiler] And this is the spawn state of said monster: [spoiler][code] { Spawn: TNT1 A 1 TNT1 A 0 A_GiveInventory("100ArmorMed") TERM AB 10 A_Look Loop [/code][/spoiler] Note that I get the same results with other monster and other armor types, so I think the problem is elsewhere.