Quantcast
Channel: ZDoom
Viewing all articles
Browse latest Browse all 3391

Scripting • Cigarette Script Questions

$
0
0
Hello, I'm trying to implement a sanity system into my mod. You lose sanity during certain events, and you can regain sanity by smoking cigarettes and drinking whiskey. The sanity itself is just an inventory item, but right now I'm working on the implementation of the cigarettes. I mostly have the functional, but my attempt to get the cigarette items to spawn is failing.

There are two kinds of cigarettes, filtered and unfiltered, with different potencies. I don't want to give the player a full pack every time, and so to avoid having to define 8 different new actors for each type of cigarette and each degree of fullness, I tried to implement an args-based spawner to do this. Unfortunately, it doesn't do anything at all.

Code:

Actor Sanity : Inventory {Tag "Sanity"Inventory.MaxAmount 100 // Sets the max amount that can be held in the inventory}ACTOR CigaretteCooldown : PowerupGiver{Powerup.Type "PowerCigaretteCooldown"+AUTOACTIVATE}ACTOR PowerCigaretteCooldown : Powerup{Powerup.Duration -30}ACTOR Cigarettes1 : CustomInventory{//$Title Pack of Filtered Cigarettes//$Category Items+INVENTORY.KEEPDEPLETED+INVENTORY.INVBARInventory.Icon CIG1A0Inventory.PickupSound "misc/inventorypickup"Inventory.UseSound "misc/invuse"Inventory.Pickupmessage "I found a pack of filtered cigarettes..."Inventory.Amount 1Inventory.MaxAmount 20States{Spawn:CIG1 A -1StopUse:TNT1 A 0 A_JumpIfInventory("Sanity", 0, "SanFull")TNT1 A 0 A_JumpIfInventory("PowerCigaretteCooldown", 1, "DontSmoke")TNT1 A -1 ACS_NamedExecuteAlways("Filtered_Cigarettes")StopSanFull:TNT1 A 0 A_Print("I don't feel like smoking right now...")FailDontSmoke:TNT1 A 0 A_Print("I just smoked, I should wait...")Fail}}Actor Cigarettes2 : Cigarettes1{//$Title Pack of Unfiltered MentholsInventory.Icon CIG2A0Inventory.Pickupmessage "I found a pack of unfiltered menthols..."States{Spawn:CIG2 A -1StopUse:TNT1 A 0 A_JumpIfInventory("Sanity", 0, "SanFull")TNT1 A 0 A_JumpIfInventory("PowerCigaretteCooldown", 1, "DontSmoke")TNT1 A -1 ACS_NamedExecuteAlways("Unfiltered_Cigarettes")StopSanFull:TNT1 A 0 A_Print("I don't feel like smoking right now...")FailDontSmoke:TNT1 A 0 A_Print("I just smoked, I should wait...")Fail}}Actor CigaretteSmoker : CustomInventory{ States{Spawn:TNT1 A -1StopPickup:TNT1 A 25 A_FireCustomMissile("CigaretteSmoke",random(2,-2),0,0,0)TNT1 A 25 A_FireCustomMissile("CigaretteSmoke",random(2,-2),0,0,0)TNT1 A 25 A_FireCustomMissile("CigaretteSmoke",random(2,-2),0,0,0)TNT1 A 25 A_FireCustomMissile("CigaretteSmoke",random(2,-2),0,0,0)Stop  }}Actor CigaretteSmoke{   Radius 0   Height 1   Speed 3   VSpeed 5   +RANDOMIZE   PROJECTILE   RENDERSTYLE TRANSLUCENT   ALPHA 0.35   States   {   Spawn:SMKE ABCDEFGH 2Stop    }}Actor CigaretteButtSpawn : CustomInventory{ States{Spawn:TNT1 A -1StopPickup:TNT1 A 0 A_FireCustomMissile("CigaretteButtSpawner",0,0,0,1)Stop  }}ACTOR CigaretteButtSpawner{States{Spawn:TNT1 AA 1 A_CustomMissile("CigButt",random(2,-2),0,0,0)Stop}}ACTOR CigButt{Speed 7BounceFactor 0.4Mass 1ReactionTime 70PROJECTILE+DOOMBOUNCE-NOGRAVITY-NOBLOCKMAPStates{Spawn:   CIGF ABCD 2 A_Countdown   Goto Spawn+1Death:   CIGF A 0 A_Jump(64,4)   CIGF A 0 A_Jump(85,4)   CIGF A 0 A_Jump(128,4)   CIGF A 350   Stop   CIGF B 350   Stop   CIGF C 350   Stop   CIGF D 350   Stop}}Actor CigPackSpawner 272{States{Spawn:TNT1 A 0 A_JumpIf(Args[1] == 1, "Filtered")TNT1 A 0 A_JumpIf(Args[1] == 2, "Unfiltered")LoopFiltered:TNT1 A 0 A_JumpIf(Args[2] == 1, "QuarterFiltered")TNT1 A 0 A_JumpIf(Args[2] == 2, "HalfFiltered")TNT1 A 0 A_JumpIf(Args[2] == 3, "ThirdFiltered")TNT1 A 0 A_JumpIf(Args[2] == 4, "FullFiltered")LoopQuarterFiltered:TNT1 A 0 A_DropItem("Cigarettes1", 5)StopHalfFiltered:TNT1 A 0 A_DropItem("Cigarettes1", 10)StopThirdFiltered:TNT1 A 0 A_DropItem("Cigarettes1", 15)StopFullFiltered:TNT1 A 0 A_DropItem("Cigarettes1", 20)StopUnfiltered:TNT1 A 0 A_JumpIf(Args[2] == 1, "QuarterUnfiltered")TNT1 A 0 A_JumpIf(Args[2] == 2, "HalfUnfiltered")TNT1 A 0 A_JumpIf(Args[2] == 3, "ThirdUnfiltered")TNT1 A 0 A_JumpIf(Args[2] == 4, "FullUnfiltered")LoopQuarterUnfiltered:TNT1 A 0 A_DropItem("Cigarettes2", 5)StopHalfUnfiltered:TNT1 A 0 A_DropItem("Cigarettes2", 10)StopThirdUnfiltered:TNT1 A 0 A_DropItem("Cigarettes2", 15)StopFullUnfiltered:TNT1 A 0 A_DropItem("Cigarettes2", 20)Stop  }}
This is all I have for my implementation, I'm not sure where the failure arises, it simply doesn't spawn them with no other sign of failure. Could anyone please help me?

Statistics: Posted by Doominer441 — Fri Mar 01, 2024 9:02 am



Viewing all articles
Browse latest Browse all 3391

Trending Articles