DoomRL > Modding
Changing the ammo system?
Autoquark:
Thanks, yaflhdztioxo. Only three of those being hooks are documented on the wiki.
Does being:wear(item) work on weapons, and does it work for items that aren't in the inventory? I'm trying to implement a grenade weapon that is stored in stacks in the inventory but is equipped one at a time. I've got this:
--- Code: ---register_item "hl_grenade" { --delayed explosion requires more hooks
name = "Hand Grenade",
desc = "Good thing you can throw accurately.",
ascii = "*" ,
color = BROWN,
sprite = SPRITE_ROCKET,
glow = {1,0,0,0.5},
level = 6,
weight = 200,
flags = {IF_NONMODABLE, IF_NOAMMO},
firstmsg = "These could come in handy.",
color_id = "generic",
--type specific
type = ITEMTYPE_RANGED,
damage = "5d5",
damagetype = DAMAGE_FIRE,
group = "weapon-rocket",
fire = 10,
acc = 0,
radius = 4,
shots = 0, --setting to 1 leads to x1 being appended to name, which is seriously confusing here
ammo_id = "shell", --not actually used
ammomax = 0,
reload = 10,
shotcost = 0,
altfire = ALT_NONE,
--altfirename = "double shot",
altreload = RELOAD_FULL,
--altreloadname = "dualreload",
--sound_id = "shotgun",
missile = "hl_grenade_missile",
psprite = SPRITE_PLAYER, --the sprite used to represent the player when equipped
OnCreate = function(self)
self:add_property("quantity", 2)
self:add_property("base_name", self.name) --used by test.SetNameFromQuantity
test.SetNameFromQuantity(self)
end,
OnEquipCheck = function(self, equipper)
if self:get_property("quantity") == 1 then return true end
self:set_property("quantity", self:get_property("quantity") - 1)
test.SetNameFromQuantity(self)
local spawned = item.new(items[self.id].nid) --spawn a new grenade item with 1 quantity
spawned:set_property("quantity", 1) --set quantity
test.SetNameFromQuantity(spawned)
if player:wear(spawned) == true then ui.msg("success") else ui.msg("fail") end --equip the new item
return false --don't equip this item
end,
}
--- End code ---
When I attempt to equip a stack of more than 1 grenade, I get the message "success", the size of the stack decreases by 1 but the grenade isn't equipped. Equipping a single grenade works.
Also, it turns out that being.inv:add() does work on monsters. Thanks SPTX for suggesting that - I thought I'd tried it before but evidently not.
EDIT: What sound IDs exist that are appropriate for explosions?
SPTX:
--- Quote from: Autoquark on April 11, 2013, 06:25 ---EDIT: What sound IDs exist that are appropriate for explosions?
--- End quote ---
I'll bounce on that asking for a full list of sound IDs.
yaflhdztioxo:
If I inadvertently end up providing info that's both useful and not on the wiki please put it up. I would myself but the time... it is not there.
Autoquark:
--- Quote from: yaflhdztioxo on April 11, 2013, 16:39 ---If I inadvertently end up providing info that's both useful and not on the wiki please put it up. I would myself but the time... it is not there.
--- End quote ---
I'll try to do that.
What is it that determines if shottyman applies to a weapon? I assume it's the IF_SHOTGUN flag for shotguns, but is there a new flag for rocket launchers?
SPTX:
It's the IF_SHOTGUN flag indeed, the rocket launcher has it for that matter.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version