Jump to content

Monster which can count ammo of player is it possible?


Recommended Posts

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 by LorddRaptorr

Share this post


Link to post

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.

Share this post


Link to post

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 by LorddRaptorr

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...