LorddRaptorr Posted December 12, 2023 (edited) Hi. I make new mod and try to add a strategy element. I have barracks which can reproduce unit. As resources i use clip. PROBLEM: Barracks cannot count how many clips have player, and cannot substrackt it Is it possible for monster counted clips and substrackt it? HELP PLEASE! Code Example in Decorate: ACTOR Barracks { Health 1300 Mass 9999 Radius 78 Speed 1 Height 82 MONSTER PainChance "HoldPos", 255 States { Spawn: TNT1 A 0 NoDelay TNT1 A 0 Thing_ChangeTID(0, 2700) BRDT C 1 Goto Spawn+2 //PROBLEM DOWN //////////////// pain.Holdpos: BRDT C 1 { if(CountInv("Clip")>1) //PROBLEM HERE!!!!!! { setstatelabel("Makeunit"); //A_Jump not work but setstatelabel work } else { A_PlaySound("NO"); } } goto Spawn+2 //////////////// Makeunit: BRDT C 30 bright A_SpawnItemEX("Marine",150, 0, 0, 0, 0, 0, 0, 0, 0); Goto Spawn+2 } } Edited December 12, 2023 by LorddRaptorr 0 Quote Share this post Link to post
Kan3 Posted December 13, 2023 Of course it doesn't work, the actor who calls the function will count how many "clips" (bullets) he has, that's why CountInv() has a second argument to allow modders to count items in other actors inventories. Since you're calling the function from the pain state, you can use the monster target pointer to get whatever actor made him enter that pain state, which I presume it will be the player. 1 Quote Share this post Link to post
LorddRaptorr Posted December 13, 2023 (edited) THANK YOU!) ITS WORKING!) if(CountInv("Clip", AAPTR_TARGET)>1) { A_TakeFromTarget("Clip",1,AAPTR_TARGET);//AAPTR_TRACER//subtracts clips from player setstatelabel("Makeunit"); //A_Jump not work but setstatelabel work } Edited December 13, 2023 by LorddRaptorr 1 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.