WB Coding how do i create an ammo type that fit a particular kind of weapons?

正在查看此主题的用户

dcmmivan123

Recruit
like say: ammo 7.62mm for ak-47, ammo 5mm for mp5. a particular kind of weapons that can fire when that type of ammo is equipped.

Edit: hello who put this to solved?
i know ppl said that there only 3 kind of ammo bolt,arrow and bullet and you can't create new one
what if i create a new itm_bolt call it 7.62mm bullet, the bullet have max_ammo(30). if the weapon the player is wielding not an ak-47 then ammo set to 0?
and i don't know how to do it.
 
由板主最后编辑:
解决方案
Use slot system + mission template triggers to check the ammo

firstly, define a slot for item called "slot_item_ammo"

secondly, you can check the players weapon in mission_templates
You can use agent_get_wield_item to get the player current using weapon, and then get the ammo item by using item_get_slot from this weapon, then check the player's inventory, if there is ammo but not suitable for this weapon, record them firstly and remove them, so that the player's ammo is 0 when player don't have the suitable ammo.
When player switch to another weapon, check the player inventory and check the items you removed, if there is ammo in player inventory, the ammo is right, if there is suitable ammo but removed in last checked, restore them...
Sorry, I missclicked once when moving your thread to the Q&A board.

Regarding your question: You can have only three different kinds of ammo as you found out by yourself. If you want to have a special ammo which disappears if the player has not a specific weapon, you would probably need to write some triggers for that. Perhaps you find someone doing this for you, I wouldn't count on it though.
 
点赞 0
Use slot system + mission template triggers to check the ammo

firstly, define a slot for item called "slot_item_ammo"

secondly, you can check the players weapon in mission_templates
You can use agent_get_wield_item to get the player current using weapon, and then get the ammo item by using item_get_slot from this weapon, then check the player's inventory, if there is ammo but not suitable for this weapon, record them firstly and remove them, so that the player's ammo is 0 when player don't have the suitable ammo.
When player switch to another weapon, check the player inventory and check the items you removed, if there is ammo in player inventory, the ammo is right, if there is suitable ammo but removed in last checked, restore them.

player only have 4 weapon slots, so you will only record three unsuitable ammo item in one check (1 weapon + 3 ammos, there is no necessary to check the backpack, we can't use them directly in the game, we only check the weapon slots) under the worst situation which means player don't have suitable ammo for current wield weapon.

You can use a trooper to store these things, you can this like "trp_ammo_removed_array", once you remove unsuitable item, you need to add the ammo item id to this trooper like this:
插入代码块:
troop_set_slot, trp_ammo_removed_array, :check_index, :ammo_item_id

You can use this to check the whote array:
插入代码块:
try_for_range, ":check_index", 0, 4
  troop_get_slot, ":removed_ammo_item_id", trp_ammo_removed_array, ":check_index"
  ... do other things ...
try_end
 
最后编辑:
点赞 0
解决方案
后退
顶部 底部