ID:836963
Jun 26 2012, 2:57 pm
|
|
i would like it in my game that only rangers can shoot arrows. the problem with the arrow ability is that a ranger can easily stand at a distance from the mob and use as many arrows as needed. i would like to base the arrow ability on the amount of arrows in the inventory. can i have an example on how i could override the arrow ability to use the arrows in inventory?
|
Jun 26 2012, 4:17 pm
|
|
You'd use the mob's has_item() and consume_item() procs. Both procs take an item type and have an optional second parameter which is the quantity. If you don't specify a quantity, it consumes just one item. This is the ShootArrow definition from the sample game with these checks added. In can_use() you check that they have an arrow and in effect() you consume the arrow.
|
how about for the next update removing an item from inventory when its stacksize is 0. the iron_bar and arrows don't remove.
|
ive just been using the remove_item() proc instead of consume_item() and it works fine.
|
hi D-Cire, yea i can remove an item but the problem is that i don't know in this example where to put the code to remove the item. nevertheless, it would be good if the statesize are removed from the inventory when they reach 0
|
consume_item() should cause the stack to be deleted when its count reaches zero. If it doesn't, that's a bug and it'll be fixed.
|
i tested consume_item() with the arrows. it does not delete when 0. this must be a bug. also, when the iron_bars stack is 0, it does not delete from the inventory
|
Kalster, i mean im not using consume_item(), i use the remove_item() proc, and it deletes the stack for me.
|
This was caused by a bug in remove_item. Sometimes it'd work, sometimes it wouldn't. Consume_item calls remove_item, so that wouldn't fix it. I'll try to post an update this weekend that'll fix this problem.
|
yes i misunderstood your post D-Cire.
Forum_account, how about then the user presses the "i" key, in the framework code, it searches for empty stacks and removes the item from the inventory slot before the inventory is displayed? |
The empty stacks should be removed by consume_item, this was just a bug. It'll be fixed in the next version.
If you'd like to fix this now, here's the updated proc you can put in player-inventory.dm: // returns a list of the instances of the specified quantity of items |
the code below was added to the ability.dm file to get the arrows to work. what i would like to do is add this code to my file. the problem is that every time there is an update, i overwrite this code in the ability.dm file. this code in my file is not working. is there a way to get this arrow code to work outside of the ability.dm file, without copying anything from the ability.dm file?
-----my_file.dm Ability |
In theory you should be able to add the following code in a new file and it will override the function and allow you to retain this functionality throughout updates.
Ability |
The stuff in the demo\ folder isn't really part of the framework, it's just there to show you how to do some things (and to give people something to see/play when they download and run the library). If you want to use something from the demo, the best way is to copy the code into your own project. I try to keep the impact minimal when I make changes to the framework, but when I change the sample game I'm not as careful - if you're relying on that code you might get some unexpected changes.
|