[T1] Help port WeapHUD to VP

-kllr2001-
02-14-2003, 07:28 PM
Can someone please help me port this script to VP?




$NWH::UpdateTime = 0.30;
$NWH::XPos = 0;
$NWH::YPos = 300;
$NWH::Align = "Left";

Event::Attach(eventExit, NWH::Destroy);
Event::Attach(eventConnec tionAccepted, NWH::Destroy);
Event::Attach(eventConnec tionAccepted, NWH::Create);

function NWH::Create()
{
//
if(!$ConnectedToServer)
{
schedule("NWH::Create();", 1);
return;
}

$NWH::hudContainer=newObj ect(NewWeaponHud_Containe r, SimGui::Control, $NWH::XPos, $NWH::YPos, 222, 550);

if ($NWH::Align == "Left")
{

$NWH::WeapIcon00=newObjec t(newWeaponHud_WeapIcon00 , FearGuiFormattedText, 8, 135, 45, 22);
$NWH::WeapIcon01=newObjec t(newWeaponHud_WeapIcon01 , FearGuiFormattedText, 8, 135, 45, 22);
$NWH::WeapIcon02=newObjec t(newWeaponHud_WeapIcon02 , FearGuiFormattedText, 8, 135, 45, 22);
$NWH::WeapIcon03=newObjec t(newWeaponHud_WeapIcon03 , FearGuiFormattedText, 8, 135, 45, 22);
$NWH::WeapIcon04=newObjec t(newWeaponHud_WeapIcon04 , FearGuiFormattedText, 8, 135, 45, 22);

$NWH::AmmoText00=newObjec t(newWeaponHud_AmmoText00 , FearGuiFormattedText, 103, 135, 0, 0);
$NWH::AmmoText01=newObjec t(newWeaponHud_AmmoText01 , FearGuiFormattedText, 103, 135, 0, 0);
$NWH::AmmoText02=newObjec t(newWeaponHud_AmmoText02 , FearGuiFormattedText, 103, 135, 0, 0);
$NWH::AmmoText03=newObjec t(newWeaponHud_AmmoText03 , FearGuiFormattedText, 103, 135, 0, 0);
$NWH::AmmoText04=newObjec t(newWeaponHud_AmmoText04 , FearGuiFormattedText, 103, 135, 0, 0);

$NWH::PackIcon=newObject( newWeaponHud_PackIcon, FearGuiFormattedText, 34, 190, 22, 22);
}
else
{

$NWH::WeapIcon00=newObjec t(newWeaponHud_WeapIcon00 , FearGuiFormattedText, 118, 0, 24, 18);
$NWH::WeapIcon01=newObjec t(newWeaponHud_WeapIcon01 , FearGuiFormattedText, 90, 0, 24, 18);
$NWH::WeapIcon02=newObjec t(newWeaponHud_WeapIcon02 , FearGuiFormattedText, 62, 0, 24, 18);
$NWH::WeapIcon03=newObjec t(newWeaponHud_WeapIcon03 , FearGuiFormattedText, 34, 0, 24, 18);
$NWH::WeapIcon04=newObjec t(newWeaponHud_WeapIcon04 , FearGuiFormattedText, 6, 0, 24, 18);

$NWH::AmmoText00=newObjec t(newWeaponHud_AmmoText00 , FearGuiFormattedText, 119, 22, 0, 0);
$NWH::AmmoText01=newObjec t(newWeaponHud_AmmoText01 , FearGuiFormattedText, 91, 22, 0, 0);
$NWH::AmmoText02=newObjec t(newWeaponHud_AmmoText02 , FearGuiFormattedText, 63, 22, 0, 0);
$NWH::AmmoText03=newObjec t(newWeaponHud_AmmoText03 , FearGuiFormattedText, 35, 22, 0, 0);
$NWH::AmmoText04=newObjec t(newWeaponHud_AmmoText04 , FearGuiFormattedText, 6, 22, 0, 0);

$NWH::PackIcon=newObject( newWeaponHud_PackIcon, FearGuiFormattedText, 146, 0, 24, 18);
}

addToSet(NewWeaponHud_Con tainer, $NWH::WeapIcon00);
addToSet(NewWeaponHud_Con tainer, $NWH::WeapIcon01);
addToSet(NewWeaponHud_Con tainer, $NWH::WeapIcon02);
addToSet(NewWeaponHud_Con tainer, $NWH::WeapIcon03);
addToSet(NewWeaponHud_Con tainer, $NWH::WeapIcon04);

addToSet(NewWeaponHud_Con tainer, $NWH::AmmoText00);
addToSet(NewWeaponHud_Con tainer, $NWH::AmmoText01);
addToSet(NewWeaponHud_Con tainer, $NWH::AmmoText02);
addToSet(NewWeaponHud_Con tainer, $NWH::AmmoText03);
addToSet(NewWeaponHud_Con tainer, $NWH::AmmoText04);

addToSet(NewWeaponHud_Con tainer, $NWH::PackIcon);

addToSet(PlayGui, $NWH::hudContainer);

NWH::Init();
NWH::Update();
}

function NWH::Destroy()
{
deleteObject($NWH::WeapIc on00);
deleteObject($NWH::WeapIc on01);
deleteObject($NWH::WeapIc on02);
deleteObject($NWH::WeapIc on03);
deleteObject($NWH::WeapIc on04);

deleteObject($NWH::AmmoTe xt00);
deleteObject($NWH::AmmoTe xt01);
deleteObject($NWH::AmmoTe xt02);
deleteObject($NWH::AmmoTe xt03);
deleteObject($NWH::AmmoTe xt04);

deleteObject($NWH::PackIc on);

deleteObject($NWH::hudCon tainer);
}


function NWH::Init()
{
$NWH::WeaponList[0] = "Disc Launcher";
$NWH::WeaponList[1] = "Grenade Launcher";
$NWH::WeaponList[2] = "Mortar";
$NWH::WeaponList[3] = "Plasma Gun";
$NWH::WeaponList[4] = "Chaingun";
$NWH::WeaponList[5] = "Blaster";
$NWH::WeaponList[6] = "Laser Rifle";
$NWH::WeaponList[7] = "ELF Gun";

$NWH::AmmoList[0] = "Disc";
$NWH::AmmoList[1] = "Grenade Ammo";
$NWH::AmmoList[2] = "Mortar Ammo";
$NWH::AmmoList[3] = "Plasma Bolt";
$NWH::AmmoList[4] = "Bullet";

$NWH::PackList[0] = "Inventory Station";
$NWH::PackList[1] = "Ammo Station";
$NWH::PackList[2] = "Energy Pack";
$NWH::PackList[3] = "Repair Pack";
$NWH::PackList[4] = "Shield Pack";
$NWH::PackList[5] = "Sensor Jammer Pack";
$NWH::PackList[6] = "Motion Sensor";
$NWH::PackList[7] = "Ammo Pack";
$NWH::PackList[8] = "Pulse Sensor";
$NWH::PackList[9] = "Sensor Jammer";
$NWH::PackList[10] = "Camera";
$NWH::PackList[11] = "Turret";
}

function NWH::Update()
{
%i = 0;
$NWH::CarriedWeapons = 0;
$NWH::MountedPack = "Nekkid";
$NWH::MountedArmor = "Light Male";

%clientId = getManagerId();

$NWH::MountedWeaponID = getMountedItem(0);
if ($NWH::MountedWeaponID == 11) { $NWH::MountedWeapon = "Blaster"; }
else if ($NWH::MountedWeaponID == 13) { $NWH::MountedWeapon = "Chaingun"; }
else if ($NWH::MountedWeaponID == 15) { $NWH::MountedWeapon = "Plasma Gun"; }
else if ($NWH::MountedWeaponID == 17) { $NWH::MountedWeapon = "Grenade Launcher"; }
else if ($NWH::MountedWeaponID == 19) { $NWH::MountedWeapon = "Mortar"; }
else if ($NWH::MountedWeaponID == 21) { $NWH::MountedWeapon = "Disc Launcher"; }
else if ($NWH::MountedWeaponID == 22) { $NWH::MountedWeapon = "Laser Rifle"; }
else if ($NWH::MountedWeaponID == 24) { $NWH::MountedWeapon = "ELF Gun"; }
else if ($NWH::MountedWeaponID == 25) { $NWH::MountedWeapon = "Repair Gun"; }

for (%clear_temp = 0; %clear_temp < 6; %clear_temp++)
{
$NWH::CarriedWeaponList[%clear_temp] = "";
$NWH::CarriedWeaponAmmo[%clear_temp] = "";
}

for (%weapon_count = 0; %weapon_count < 8; %weapon_count++)
{
%weapon_temp = getItemCount($NWH::Weapon List[%weapon_count]);

if (%weapon_temp == 1)
{
$NWH::CarriedWeaponList[%i] = $NWH::WeaponList[%weapon_count];

if ( $NWH::CarriedWeaponList[%i] == $NWH::MountedWeapon) { $NWH::MountedWeaponPositi on = %i; }
if (%weapon_count < 5)
{
$NWH::CarriedWeaponAmmo[%i] = getItemCount($NWH::AmmoLi st[%weapon_count]);
}
else
{
$NWH::CarriedWeaponAmmo[%i] = "~";
}

%i++;
$NWH::CarriedWeapons++;
}
}

for (%pack_count = 0; %pack_count < 12; %pack_count++)
{
%pack_temp = getItemCount($NWH::PackLi st[%pack_count]);
if (%pack_temp == 1) { $NWH::MountedPack = $NWH::PackList[%pack_count]; break; }
}

for (%armor_count = 0; %armor_count < 3; %armor_count++)
{
%armor_temp = getItemCount($NWH::ArmorL ist[%armor_count]);
if (%armor_temp == 1) { $NWH::MountedArmor = $NWH::ArmorList[%armor_count]; break; }
}


NWH::UpdateHud();
}

function NWH::UpdateHud()
{
for (%j = 0; %j < $NWH::CarriedWeapons; %j++)
{
control::setVisible("newWeaponHud_WeapIcon0" @ %j, True);

if (%j == $NWH::MountedWeaponPositi on)
{
control::setVisible("newWeaponHud_AmmoText0" @ %j, True);
}
else
{
control::setVisible("newWeaponHud_AmmoText0" @ %j, False);
}

if (%j == $NWH::MountedWeaponPositi on)
{
control::setValue("newWeaponHud_WeapIcon0" @ %j, "<B0,0:weaponHud\\" @ $NWH::CarriedWeaponList[%j] @ " On.bmp>");
if ($NWH::CarriedWeaponAmmo[%j] == "~")
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<B0,0:weaponHud\\blank1.bm p><B0,0:weaponHud\\Infinity On.bmp>");
}
else
{
if ($NWH::CarriedWeaponAmmo[%j] < 10)
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<B0,0:weaponHud\\blank2.bm p><f0>" @ $NWH::CarriedWeaponAmmo[%j]);
}
else if (($NWH::CarriedWeaponAmmo[%j] > 9) && ($NWH::CarriedWeaponAmmo < 100))
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<B0,0:weaponHud\\blank1.bm p><f0>" @ $NWH::CarriedWeaponAmmo[%j]);
}
else if ($NWH::CarriedWeaponAmmp[%j] > 99)
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<f0>" @ $NWH::CarriedWeaponAmmo[%j]);
}
}
}
else
{
control::setValue("newWeaponHud_WeapIcon0" @ %j, "<B0,0:weaponHud\\" @ $NWH::CarriedWeaponList[%j] @ " Off.bmp>");
if ($NWH::CarriedWeaponAmmo[%j] == "~")
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<B0,0:weaponHud\\blank1.bm p><B0,0:weaponHud\\Infinity Off.bmp>");
}
else
{
if ($NWH::CarriedWeaponAmmo[%j] < 10)
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<B0,0:weaponHud\\blank2.bm p><f1>" @ $NWH::CarriedWeaponAmmo[%j]);
}
else if (($NWH::CarriedWeaponAmmo[%j] > 9) && ($NWH::CarriedWeaponAmmo < 100))
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<B0,0:weaponHud\\blank1.bm p><f1>" @ $NWH::CarriedWeaponAmmo[%j]);
}
else if ($NWH::CarriedWeaponAmmp[%j] > 99)
{
control::setValue("newWeaponHud_AmmoText0" @ %j, "<f1>" @ $NWH::CarriedWeaponAmmo[%j]);
}

}
}
}

if (%j < 5)
{
while (%j < 5)
{
control::setVisible("newWeaponHud_WeapIcon0" @ %j, False);
control::setVisible("newWeaponHud_AmmoText0" @ %j, False);
%j++;
}
}

control::setValue(newWeap onHud_PackIcon, "<B0,0:weaponHud\\"@ $NWH::MountedPack @ ".bmp>");

schedule("NWH::Update();", $NWH::UpdateTime);
}

Moss
02-15-2003, 01:48 AM
mmm, it may be because its 6:47 am or because im still very drunk, but i'd say theres no reason why that shouldnt work for viking ;/

cyclonite
02-15-2003, 01:58 AM
Event::Attach(eventConnec tionAccepted, NWH::Destroy);
Event::Attach(eventConnec tionAccepted, NWH::Create);


Try change those two lines to:
Event::Attach(eventLoadPl ayGui, NWH::Destroy);
Event::Attach(eventLoadPl ayGui, NWH::Create);

Oh, btw, I wrote that script ;)
Also, I did make a Viking version, so if you find the release thread you should be able to download the Viking version. :)

cyclonite
02-15-2003, 02:01 AM
Bah, forgot to turn off smilies in my previous post.

Use my suggested solution if there is no Sytax errors when the script tries to run of course. If there are any errors tell us what lines and should be able to fix it.

-kllr2001-
02-15-2003, 03:09 AM
Originally posted by cyclonite
Oh, btw, I wrote that script ;)

I know

Originally posted by cyclonite
Also, I did make a Viking version, so if you find the release thread you should be able to download the Viking version. :)

Thanks, found it.

Rosco-SS
02-15-2003, 03:17 AM
Event::Attach(eventneedvp script, NWH:convert);

cyclonite
02-15-2003, 03:27 AM
Lol Rosco.

VP has an inbult script porting function :D Neat, I might port it to Stripped :P