Here is what I have with the Use abuse. It works.
Code: Select all
class soaBinocular : soaPickup {
bool binocUsed;
action void W_equipBinoc(void) {
if ( player == null ) {
return;
}
let pawn = wastelandRanger(self);
TextureID id_I_BNC2 = TexMan.CheckForTexture("I_BNC2", 0, 0);
pawn.selectedWeapon = Weapon(pawn.player.readyWeapon);
A_GiveInventory("binoc_weapon", 1);
A_SelectWeapon("binoc_weapon");
A_Overlay(7, "Binoc");
invoker.binocUsed = true;
invoker.icon = id_I_BNC2;
}
action void W_RemoveBinoc(void) {
if ( player == null ) {
return;
}
let pawn = wastelandRanger(self);
TextureID id_I_BNC1 = TexMan.CheckForTexture("I_BNC1", 0, 0);
A_SelectWeapon(pawn.selectedWeapon.GetClassName(), SWF_SELECTPRIORITY);
A_TakeInventory("binoc_weapon", 1);
A_ClearOverlays(7, 7);
invoker.binocUsed = false;
invoker.icon = id_I_BNC1;
}
Default {
//$Category "SoA/Items"
//$Color 17
//$Title "Dalekohled"
+INVENTORY.INVBAR
Tag "$T_Binocular";
Inventory.Icon "I_BNCL";
//Inventory.Amount 1;
//Inventory.MaxAmount 2;
Mass mass_binoc;
Scale 0.4;
}
States {
Spawn:
DUMM A -1;
Stop;
Use:
TNT1 A 0 {
if ( !invoker.binocUsed ) {
return resolveState("Equip");
} else {
return resolveState("Unequip");
}
return resolveState(null);
}
Fail;
Equip:
TNT1 A 0 W_equipBinoc();
Fail;
Unequip:
TNT1 A 0 W_RemoveBinoc();
Fail;
Binoc:
RBPY ABCD 4;
loop;
}
}
Code: Select all
class soaBinocular : soaPickup {
bool binocUsed;
override bool Use(bool Pickup) {
TextureID id_I_BNC2 = TexMan.CheckForTexture("I_BNC2", 0, 0);
TextureID id_I_BNC1 = TexMan.CheckForTexture("I_BNC1", 0, 0);
let pawn = wastelandRanger(owner);
if ( !binocUsed ) { //equip binocular
pawn.selectedWeapon = Weapon(pawn.player.readyWeapon);
pawn.A_GiveInventory("binoc_weapon", 1);
pawn.A_SelectWeapon("binoc_weapon");
self.A_Overlay(7, "Binoc");
self.binocUsed = true;
self.icon = id_I_BNC2;
} else { //unequip binocular
pawn.A_SelectWeapon(pawn.selectedWeapon.GetClassName(), SWF_SELECTPRIORITY);
pawn.A_TakeInventory("binoc_weapon", 1);
self.A_ClearOverlays(7, 7);
self.binocUsed = false;
self.icon = id_I_BNC1;
}
return false; //do not use the item
}
Default {
//$Category "SoA/Items"
//$Color 17
//$Title "Dalekohled"
+INVENTORY.INVBAR
Tag "$T_Binocular";
Inventory.Icon "I_BNCL";
//Inventory.Amount 1;
//Inventory.MaxAmount 2;
Mass mass_binoc;
Scale 0.4;
}
States {
Spawn:
DUMM A -1;
Stop;
Use:
TNT1 A 0;
Stop;
Binoc:
RBPY ABCD 4;
loop;
}
}