How to de-list weapons without ammo?

Discuss all aspects related to modding Zandronum here.
Post Reply
superpomme
New User
Posts: 4
Joined: Wed Apr 27, 2016 11:59 am

How to de-list weapons without ammo?

#1

Post by superpomme » Wed Apr 27, 2016 12:07 pm

Hi, I'm trying to convert a Gzdoom project to test it in Zandronum, but I need to to only list (and be able to switch to) the weapons that have ammo. In Gzdoom it does this by default, but Is there something that can be added to it to get this working in Zandronum?.

As an explanation, I have lots of things like, for example, the ability to eat, which is a 'weapon', but which I only wan't to be able to switch to when I actually have food for it. In gzdoom, I give all these "weapons" to the player at the start, but they only show up when I have the item for them.

I wrote a loop that checks to see if you have ammo, and then gives/takes away the weapon based on this. It works, but it looks a bit inefficient, so before I go and do that for all of them, I'd like to check if I've missed something simple.

Thanks

Rob
Last edited by superpomme on Wed Apr 27, 2016 6:47 pm, edited 1 time in total.

User avatar
SwordGrunt
Forum Regular
Posts: 377
Joined: Thu Jun 07, 2012 8:43 pm

Re: How to de-weapons without ammo?

#2

Post by SwordGrunt » Wed Apr 27, 2016 5:12 pm

I can't think of a way to make it impossible to switch to these weapons, but it'd be a lot easier if you worked with inventory items instead of weapons. Regardless, ACS should be able to handle that, what are you having trouble with to feel it's inefficient?

superpomme
New User
Posts: 4
Joined: Wed Apr 27, 2016 11:59 am

Re: How to de-weapons without ammo?

#3

Post by superpomme » Wed Apr 27, 2016 6:28 pm

Ah that's a shame - thanks for your help tho.

Well, taking food as an example, I have the weapon "givefood", which uses "foodfoo". This has the ability to eat the food with left click, or throw the food with right click. You can also discard it from the inventory in a different way. I can hackily get it working by having a script that says

if (checkActorinventory((1000 + PlayerNumber()), "foodfoo") > 0)
{GiveActorInventory((1000 + PlayerNumber()), "givefood", ", 1);}
else{takeActorInventory((1000 + PlayerNumber()), "givefood", 1);}

The downside to this, is that it then removes the weapon mid animation (as soon as the weapon uses that ammo)

I can fix this by removing the last line of that, and then having it do the check and the removal from within decorate, as well as adding an extra line to the inventory code that removes it when you discard the item, and that's fine, it will work, but with about 10 of these weapons, its just a lot of extra checks to have to keep constantly looping through if there was possibly going to be some easier way of doing it :)

( it's for this project https://www.youtube.com/watch?v=fJLTgqbC3Lk )

Thanks,

Rob

User avatar
doomista
Forum Regular
Posts: 147
Joined: Sat Mar 07, 2015 6:58 pm
Location: I've been to hell. Twice

Re: How to de-weapons without ammo?

#4

Post by doomista » Thu Apr 28, 2016 7:26 am

superpomme wrote: The downside to this, is that it then removes the weapon mid animation (as soon as the weapon uses that ammo)
Delay would not help? I mean, when player is consuming food, then he shouldn't able to do anything else, so to put all tests to sleep for couple of tics shouldn't hurt.

User avatar
SwordGrunt
Forum Regular
Posts: 377
Joined: Thu Jun 07, 2012 8:43 pm

Re: How to de-list weapons without ammo?

#5

Post by SwordGrunt » Thu Apr 28, 2016 6:01 pm

You could have the weapon not use ammo, and manually remove the inventory item in your animation only when desired. This would also eliminate the need for ACS to remove the weapon entirely. For example:

Code: Select all

actor givefood : weapon
{
[...]
states
{
  Fire:
     FOOD AAAAA 15 HealThing(20)
     FOOD A 0 A_TakeInventory("foodfoo",1)
     FOOD A 0 A_JumpIfInventory("foodfoo",1,1)
     goto Remove
     FOOD A 5
     goto Ready
  Remove:
     FOOD A 1 offset(0,40)
     FOOD A 1 offset(0,48)
     FOOD A 1 offset(0,56)
     FOOD A 1 offset(0,64)
     FOOD A 1 offset(0,72)
     FOOD A 1 offset(0,80)
     FOOD A 0 A_TakeInventory("givefood",1)
     stop
}
}

superpomme
New User
Posts: 4
Joined: Wed Apr 27, 2016 11:59 am

Re: How to de-list weapons without ammo?

#6

Post by superpomme » Thu Apr 28, 2016 7:31 pm

Thanks for the suggestions, A delay might work, but each of the weapons has slightly different timings, and so knowing how long to set the delay for for each of them would potentially be a bit faffy (although, so was the way that I was talking, so that's not a bad idea). thanks

Good suggestion with the removal from decorate - that's actually the way that I went and did it last night. the problem with that was that it doesn't then remove them if thrown from acs (the inventory system that I have), but i will add a removal to that code too.

Thank you both for your help :)

Post Reply