Why doesnt this weapon work?

Discuss all aspects related to modding Zandronum here.
Post Reply
CtrlAltDestory
 
Posts: 29
Joined: Fri Dec 28, 2012 5:17 am

Why doesnt this weapon work?

#1

Post by CtrlAltDestory » Mon Jan 07, 2013 10:10 am

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
  }
}
Last edited by CtrlAltDestory on Tue Jan 08, 2013 1:10 am, edited 1 time in total.

Catastrophe
Retired Staff / Community Team Member
Posts: 2569
Joined: Sat Jun 02, 2012 2:44 am

RE: Why does this weapon work?

#2

Post by Catastrophe » Mon Jan 07, 2013 2:24 pm

I'm assuing takeweapons doesnt work?

CtrlAltDestory
 
Posts: 29
Joined: Fri Dec 28, 2012 5:17 am

RE: Why does this weapon work?

#3

Post by CtrlAltDestory » Tue Jan 08, 2013 1:11 am

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...

ZzZombo
Forum Regular
Posts: 323
Joined: Mon Jun 11, 2012 12:11 pm
Location: Ravenholm

RE: Why doesnt this weapon work?

#4

Post by ZzZombo » Mon Jan 14, 2013 4:11 pm

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.

Llewellyn
Forum Regular
Posts: 578
Joined: Mon Jul 02, 2012 7:12 am

RE: Why doesnt this weapon work?

#5

Post by Llewellyn » Mon Jan 14, 2013 6:16 pm

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
  }
}
Last edited by Llewellyn on Mon Jan 14, 2013 6:33 pm, edited 1 time in total.

Post Reply