Jump to content

My First Script - Will It Work?


EliteKill

Recommended Posts

As a part of my Outcast Stealth Suit, I needed to make a Power-Consumption script. Currently the script is supposed to to remove 1 Fission Battery per day. If you have none, the Suit will be unequipped and will not be equipable until you have more Fission Batteries. If you see any problems or any room for improvements, just post:

 

scn OutcastStealthSuitPower

float fTime
float fTimer
int iPower
int iSuit
int iEquip

begin GameMode
set fTimer to getDayOfWeek
set iSuit to player.getItemCount DLC02ArmorStealthWastelandOutcast
set iEquip to player.getEquipped DLC02ArmorStealthWastelandOutcast
set iPower to player.getItemCount FissionBattery
end


begin OnEquip player
set fTime to getDayOfWeek

ShowMessage OutcastStealthPowerConsumptionOn

if iPower == 0 && iEquip == 1
player.UnEquipItem DLC02ArmorStealthWastelandOutcast 1 0
ShowMessage OutcastStealthPowerInsufficient
endIf

ShowMessage OutcastStealthPowerConsumptionOn

if iPower > 1 && iEquip == 0
player.EquipItem DLC02ArmorStealthWastelandOutcast 0 1
player.UnEquipItem DLC02ArmorStealthWastelandOutcast 0 1
ShowMessage OutcastStealthSuitReady
endIf

if fTimer == fTime + 1 && iPower > 0 && iEquip == 1
player.RemoveItem FissionBattery 1 1
ShowMessage OutcastStealthPowerDecrease
set fTime to getDayOfWeek
endIf

end

Link to comment
Share on other sites

*use short instead of int.

 

	set iSuit to player.getItemCount DLC02ArmorStealthWastelandOutcast
set iEquip to player.getEquipped DLC02ArmorStealthWastelandOutcast

*You probably don't want those in Gamemode, since it'll set those value every frame. And why set iSuit when you aren't using it?

 

*The actual consumption script part should be inside game mode, since onEquip will only run 1x when you equip it.

 

 

if iPower > 1 && iEquip == 0
player.EquipItem DLC02ArmorStealthWastelandOutcast 0 1
player.UnEquipItem DLC02ArmorStealthWastelandOutcast 0 1
ShowMessage OutcastStealthSuitReady
endIf

*What's the logic behind this block? This seems very broken. In game mode, it'll set the iEquip to zero in the beginning since you haven't equipped it. So when you equip it and this part of the script runs, it'll just be unequipped. So when you get back into game mode, iEquip will still be zero. So next time you equip it, it'll just run this part again.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...