Page 1 of 1

Why doesnt this weapon work?

Posted: Mon Jan 07, 2013 10:10 am
by CtrlAltDestory
I wanted to try to make something no has made before or atleast that I know of, and It just wont work... Take note that its 2:10AM and It might be just because of sleep but I still want to see if I can get help (Its also not all 0's just because...).

Code: Select all

ACTOR Breifcase : Weapon
{
  Obituary "%o was bludgened by %k's Breifcase."
  Inventory.Pickupmessage "Picked up a Breifcase."
  Tag "Breifcase"
  +WEAPON.MELEEWEAPON
  States
  {
  Ready:
    TNT1 A 1 A_WeaponReady
    Loop
  Deselect:
    TNT1 A 1 A_Lower
    Loop
  Select:
    TNT1 A 1 A_Raise
    Loop
  Fire:
    TNT1 A 4
    TNT1 A 4 A_Punch
    TNT1 A 5
    TNT1 A 4
    TNT1 A 5 A_ReFire
    Goto Ready
  AltFire:
    TNT1 A 0 A_JumpIfInventory("ItemsTaken",1,"GiveWeapons")
    TNT1 A 0 A_JumpIfInventory("ItemsTaken",0,"TakeWeapons")
    Goto Error
  TakeWeapons:
    TNT1 A 1 A_JumpIfInventory("Chainsaw",0,3)
    TNT1 A 1 A_GiveInventory("ChainsawEgg")
    TNT1 A 1 A_TakeInventory("Chainsaw")
    TNT1 A 1 A_JumpIfInventory("Pistol",0,3)
    TNT1 A 1 A_GiveInventory("PistolEgg")
    TNT1 A 1 A_TakeInventory("Pistol")
    TNT1 A 8 A_Print("Items Taken")
    TNT1 A 1 A_GiveInventory("ItemsTaken")
    Goto Ready
  GiveWeapons:
    TNT1 A 1 A_JumpIfInventory("ChainsawEgg",0,3)
    TNT1 A 1 A_GiveInventory("Chainsaw")
    TNT1 A 1 A_TakeInventory("ChainsawEgg")
    TNT1 A 1 A_JumpIfInventory("PistolEgg",0,3)
    TNT1 A 1 A_GiveInventory("Pistol")
    TNT1 A 1 A_TakeInventory("PistolEgg")
    TNT1 A 8 A_Print("Items Given")
    TNT1 A 1 A_TakeInventory("ItemsTaken")
    Goto Ready
  Error:
    TNT1 A 8 A_Print("How the fuck are you seeing this?!")
    Goto Ready
  Spawn:
    CSAW A -1
    Stop
  }
}

ACTOR ChainsawEgg : CustomInventory
{
  +COUNTITEM
  -INVENTORY.INVBAR
  Inventory.Icon "TNT1A0"
  Inventory.PickupMessage ""
  Inventory.DefMaxAmount
  Tag ""
  States
  {
  Spawn:
    TNT1 A 1
    Loop
  }
}

ACTOR PistolEgg : CustomInventory
{
  +COUNTITEM
  -INVENTORY.INVBAR
  Inventory.Icon "TNT1A0"
  Inventory.PickupMessage ""
  Inventory.DefMaxAmount
  Tag ""
  States
  {
  Spawn:
    TNT1 A 1
    Loop
  }
}

ACTOR ItemsTaken : CustomInventory
{
  +COUNTITEM
  -INVENTORY.INVBAR
  Inventory.Icon "TNT1A0"
  Inventory.PickupMessage ""
  Inventory.DefMaxAmount
  Tag ""
  States
  {
  Spawn:
    TNT1 A 1
    Loop
  }
}

RE: Why does this weapon work?

Posted: Mon Jan 07, 2013 2:24 pm
by Catastrophe
I'm assuing takeweapons doesnt work?

RE: Why does this weapon work?

Posted: Tue Jan 08, 2013 1:11 am
by CtrlAltDestory
Catastrophe wrote: I'm assuing takeweapons doesnt work?
AltFire:
TNT1 A 0 A_JumpIfInventory("ItemsTaken",1,"GiveWeapons")
TNT1 A 0 A_JumpIfInventory("ItemsTaken",0,"TakeWeapons")
Goto Error

If it dident work I told it to Goto Error and its going to Error...

RE: Why doesnt this weapon work?

Posted: Mon Jan 14, 2013 4:11 pm
by ZzZombo
Do you try in singleplayer or in multiplayer?

Also, if you want to check whether an actor DOESN'T have an item, you must do something like this:

Code: Select all

//do we have at least one item of type YourItem?
A_JumpIfInventory(YourItem,1,ActorHasItemState)//in your case GiveWeapons
goto ActoHasNoItem//TakeWeapons
Your second check is just redundant since A_JumpIfInventory jumps if the calling actor has EQUAL or more items than in the first parameter. Or, rather, possibly 0 has a special meaning here "jump if the actor has maximum amount of YourItem, don't remember.

RE: Why doesnt this weapon work?

Posted: Mon Jan 14, 2013 6:16 pm
by Llewellyn
Yes when checking for an amount 0 always means "Max amount of" so checking for 1 and 0 is just checking for 1 twice in this case...
And you should probably specify an amount for A_TakeInventory and A_GiveInventory

Try this:

Code: Select all

ACTOR Breifcase : Weapon
{
  Obituary "%o was bludgened by %k's Breifcase."
  Inventory.Pickupmessage "Picked up a Breifcase."
  Tag "Breifcase"
  +WEAPON.MELEEWEAPON
  States
  {
  Ready:
    TNT1 A 1 A_WeaponReady
    Loop
  Deselect:
    TNT1 A 1 A_Lower
    Loop
  Select:
    TNT1 A 1 A_Raise
    Loop
  Fire:
    TNT1 A 4
    TNT1 A 4 A_Punch
    TNT1 A 5
    TNT1 A 4
    TNT1 A 5 A_ReFire
    Goto Ready
  AltFire:
    TNT1 A 0 A_JumpIfInventory("ItemsTaken", 1, "GiveWeapons") //Intentional drop through to TakeWeapons
  TakeWeapons:
    TNT1 A 1 A_JumpIfInventory("Chainsaw",0,3)
    TNT1 A 1 A_GiveInventory("ChainsawEgg")
    TNT1 A 1 A_TakeInventory("Chainsaw")
    TNT1 A 1 A_JumpIfInventory("Pistol",0,3)
    TNT1 A 1 A_GiveInventory("PistolEgg")
    TNT1 A 1 A_TakeInventory("Pistol")
    TNT1 A 8 A_Print("Items Taken")
    TNT1 A 1 A_GiveInventory("ItemsTaken", 1)
    Goto Ready
  GiveWeapons:
    TNT1 A 1 A_JumpIfInventory("ChainsawEgg",0,3)
    TNT1 A 1 A_GiveInventory("Chainsaw")
    TNT1 A 1 A_TakeInventory("ChainsawEgg")
    TNT1 A 1 A_JumpIfInventory("PistolEgg",0,3)
    TNT1 A 1 A_GiveInventory("Pistol")
    TNT1 A 1 A_TakeInventory("PistolEgg")
    TNT1 A 8 A_Print("Items Given")
    TNT1 A 1 A_TakeInventory("ItemsTaken", 1)
    Goto Ready
  Spawn:
    CSAW A -1
    Stop
  }
}

ACTOR ChainsawEgg : CustomInventory
{
  +COUNTITEM
  -INVENTORY.INVBAR
  Inventory.Icon "TNT1A0"
  Inventory.PickupMessage ""
  Inventory.DefMaxAmount
  Tag ""
  States
  {
  Spawn:
    TNT1 A 1
    Loop
  }
}

ACTOR PistolEgg : CustomInventory
{
  +COUNTITEM
  -INVENTORY.INVBAR
  Inventory.Icon "TNT1A0"
  Inventory.PickupMessage ""
  Inventory.DefMaxAmount
  Tag ""
  States
  {
  Spawn:
    TNT1 A 1
    Loop
  }
}

ACTOR ItemsTaken : CustomInventory
{
  +COUNTITEM
  -INVENTORY.INVBAR
  Inventory.Icon "TNT1A0"
  Inventory.PickupMessage ""
  Inventory.MaxAmount 1
  Tag ""
  States
  {
  Spawn:
    TNT1 A 1
    Loop
  }
}