Clopen

  • Content count

    40
  • Joined

  • Last visited

Community Reputation

6 Neutral

About Clopen

  • Rank
    Junior Member
  1. This is more of a consultation than a direct how-to question. I implemented a feature that temporarily adds a tag to a specific target (can be anything that can do combat), and now I'd like to give this effect some visual representation, but I don't know what. I tried tinting the target red (by setting AnimState:SetMultColour(1, 0.5, 0.5, 1)), and while it worked, I'm not sure it's a good idea - A. because it might not be too noticeable, especially for reddish entities; B. because I think it might clash with other places setting color multipliers; and C... pretty sure I had a C when I started typing this sentence but I forgot it already. O_o I thought maybe to put a ring on the ground around it, but I'm not sure how to do that and it would also need to be scaled based on the target's size. Also I think if I did that then I'd want the back of the ring to be hidden by the character, another something I don't know how to do. Another idea is an aura, but I think just adding a light source would make it difficult to see exactly which entity is the target when there are several around. Also it has gameplay ramifications at night which I'd rather not have. Would be easy to abuse. So any feasible ideas on how to mark the target (and if possible an ideas on how to implement them) would be appreciated. If it helps, it's possible that only specific players will be able to see this marking (I already know how to implement that part). Thanks in advance. =)
  2. I see. Well, alright then. I'll give him a modified version of Wilson's stategraph. Thank you both. =)
  3. Well, sure, I can do that, and yeah, it would work (thanks for the suggestion), but it doesn't feel like the right approach to me. What if I want to add other customization? Do I change Wilson's stategraph and test prefabs for everything? Every character has its own stategraph; there has to be a way to alter a specific state for a specific character.
  4. Oh, you're right. How lovely. =) Thanks. ^_^
  5. I made a new character and I'd like to override a specific state in its stategraph, but nobody else's (namely, I want to change its funnyidle animation to one of the emotes). I managed to override it for everyone,but I don't know how to override it just for him. I'd rather not copy Wilson's stategraph to a new file, make the modification and then assign that stategraph to him, since that would require updating when Wilson's stategraph changes. Thanks in advance. =)
  6. DST has a module called "util" in its scripts bundle which contains various scripting paraphernalia that one may find useful. I'd like to use the weighted_random_choice() function it has, but when I use require "util" to import the code (currently to my modmain file but I plan on moving it out of there shortly) and then use it, I get an error for invoking a nil value. I know I can copy the function, of course but since it's already there and various game scripts use it, I figure there should be a way to import it into a mod environment as well - or am I wrong? Assistance would be appreciated, like always. =)
  7. Yeah, I did the same. I actually found it by looking at Inventory:Equip(). The first line there checks if the equippable item is restricted. Thanks a lot for all your help. I'm pretty sure I'll need it again (e.g. for making only specific entities attackable based on tags, a feature I'm not even close to starting work on yet and for which I'll start a separate topic if I need to). I'm making a pretty big mod with lots of new things and my knowledge of modding DST (and Lua in general, but that's less of a problem) is limited, so I'm bound to run into problems I'll need help with.
  8. Yeah, I saw the GiveItem() function. If you'd told me I had to override it to add something in the middle I'd have chosen to stay with what I have. -_- Regarding your second idea: Using OnPickup() seems like a good idea if I don't want them to be able to have the item at all - which may actually be what I decide eventually, but for now I just want the character to be unable to equip the item, but still have the ability to carry it. I do like your first idea though, of overriding CanTakeItemInSlot(), so I went ahead and tried it, but I've come across a big problem: it seems that CanTakeItemInSlot() is invoked for every inventory slot except equipment slots. I had my injected code accept/deny the item without any regard for the slot parameter and as a result the character is unwilling to put the item in his inventory, but he's willing to equip it. Here's the code, for reference: local function heavy_armor_check(item, slot, owner) print("[Mod] given owner = " .. tostring(owner) .. " , item owner = " .. tostring(item.owner)) print("[Mod] owner.prefab = " .. tostring(owner.prefab) .. " , item.prefab = " .. tostring(item.prefab)) print("[Mod] slot = " .. tostring(slot)) if item == nil or owner == nil then return true end if item:HasTag("heavyarmor") and not owner:HasTag("canequipheavy") then if owner.components.talker then owner.components.talker:Say(GetString(owner, "ARMORTOOHEAVY")) end return false else return true end end local function heavy_armor_check_wrapper(inventory) local oldCanTakeItemInSlot = inventory.CanTakeItemInSlot inventory.CanTakeItemInSlot = function(inv, item, slot) return heavy_armor_check(item, slot, inv.inst) and oldCanTakeItemInSlot(inv, item, slot) end end AddComponentPostInit("inventory", heavy_armor_check_wrapper) If I pick up the tagged item from the ground with the equip slot empty, the character equips the item silently and no "[Mod]" print occurs at all. If I pick it up when I already have something equipped, the character says the ARMORTOOHEAVY line and the item is picked up to my cursor. Same thing happens if I try to place it in the inventory or right-click to unequip it from its equip slot, yet I can place it in the equip slot without problem. However! I have found a different, very simple solution which, in consistence with my recent "how the hell did I miss this" streak, I really should have noticed before. The equippable component has a "restrictedtag" property which only allows character with the specified tag to equip that item, which is precisely what I want. All I had to do was add this to my armor prefab's initialization function: inst.components.equippable.restrictedtag = "canequipheavy" And now only characters who are tagged with "canequipheavy" can equip it. Other characters don't even have "Equip" as a right-click action for it anymore; they can only examine it. Now, since my "heavy armor" thing is a component and not a specific prefab, I just need to add that line to my component's postinit function to apply it to every prefab that has that component and I'm done. Thanks for your help though, Ultroman; it did expose me to some useful things. P.S. The "restrictedtag" property is used in the game for the inactive Bernie.
  9. I'd like to find a way to make a character refuse to equip certain items (based on tags). I've found examples of this in other mods and posts but in all of them the item is equipped, checked and then unequipped if necessary. I got that working, and if I must then I'll keep that, but I would rather have the character refuse to equip it in the first place. I.e.: When right-clicking the equipment (armor) in the inventory, it will not be equipped at all and the character will say something about it - as opposed to what happens now, where it gets equipped, unequipped and then the characters says something about it. When the equipment is picked up and the character's equip slot is empty, it should go into the inventory without being equipped - as opposed to what happens now, where... (same as above) When equipping would cause a currently-equipped item to be unequipped, I'd like for the currently equipped item to remain equipped. In other words, as I said, the character should refuse to equip it, with the behavior you'd expect when that happens. Similarly, rather than using tags, I'd like to make specific items usable only by specific characters. I'm guessing that'll be similar though. Any ideas or leads would be appreciated. =) Edit: Problem solved; see the bottom part of my own reply below.
  10. [Tutorial] Using Extended Sample Character Template

    "[00:04:46]: [string "scripts/util.lua"]:550: Could not find an asset matching images/avatars/avatar_phelps.tex in any of the search paths." You're missing that file. Check that you have an image called "avatar_phelps.png" in images\avatars and make sure you let the autocompiler run its course. You should be able to see it say that it's processing that file, I think. As a general tip, whenever you encounter a crash, search the log file for the first time the word "error" appears and look around there. The line I just copied appears one line above the first time "error" shows in the file.
  11. Thanks everyone. When I saw that the timing was off I decided to just let the periodic task run whenever it wants to as long as it's fast enough (no problem there) and do the logic of progress and ending using starting time, total duration and current time, which is pretty much what @CarlZalph said. I'll manage the rest around that.
  12. Ugh, I don't know what's wrong with me lately. >_< I went over all the code in armor.lua searching for a function to modify the armor durability and somehow I missed that one. I only saw TakeDamage. Thanks. =\
  13. I have two different components that I activate one after the other. One uses DoTaskInTime to schedule a task for 30 seconds from now. The other uses DoPeriodicTask to schedule a task to run every 0.1 seconds over a total of 30 seconds. For some reason, the second task finishes all its iterations in 20 seconds instead of 30 like the first one. The periodic task increases a number value in every iteration, from 0 to 1, in increments of 0.1 / 30. When it reaches 1 it stops. This should take 300 iterations, so with an interval of 0.1 it should take 30 seconds in total. Even if the calculations in my code are wrong, it doesn't change the fact that the periodic task occurs too quickly. I put debug printouts right before starting the periodic task, printing the interval, and in the tick function printing the progress. The server log shows 15 prints per second, 1.5 times faster than it should be (which corresponds to the total time being 2/3 of what it should be). If I increase the interval to 0.5 the total time for the periodic task increases to about 27 seconds. I really have no idea what's going on here and how to fix it. Here's the code for the component (not much here, really): -- Fake component for enabling usage of the recharge -- item slot animation from The Forge local Rechargeable = Class(function(self, inst) self.inst = inst self.percent = 1 self.recharge_time = 0 self.interval = 0 end) local function do_recharge(inst, self) self:SetPercent(math.min(1, self:GetPercent() + self.interval / self:GetRechargeTime())) print("[Mod] Percentage: " .. tostring(self:GetPercent())) if self:GetPercent() == 1 then self:StopRecharging() end end function Rechargeable:GetPercent() return self.percent end function Rechargeable:GetRechargeTime() return self.recharge_time end function Rechargeable:SetPercent(percent) self.percent = percent self.inst:PushEvent("rechargechange", { percent = self.percent }) end function Rechargeable:SetInterval(interval) self.interval = interval end function Rechargeable:SetRechargeTime(recharge_time) self.recharge_time = recharge_time self.inst:PushEvent("rechargetimechange", { t = self.recharge_time }) end function Rechargeable:StartRecharging(starting_percentage) if starting_percentage then self:SetPercent(starting_percentage) end print("[Mod] Starting percentage: " .. tostring(self:GetPercent()) .. " ; Inteval: " .. tostring(self.interval)) if self.recharge_task == nil then self.recharge_task = self.inst:DoPeriodicTask(self.interval, do_recharge, nil, self) end end function Rechargeable:StopRecharging() if self.recharge_task ~= nil then self.recharge_task:Cancel() self.recharge_task = nil end end return Rechargeable And here is the relevant debug output: Like I said, 15 prints per second. What's the problem here and how do I make DoPeriodicTask work like I expect? I would have suspected server load but it's working faster than it should. Thanks in advance.
  14. I have some code that updates the durability of an armor (repairs it) in a timed task. It works, but the durability percentage only updates if I unequip it or equip it again. How do I get the item slot to refresh its state? ... Well, actually, I did get this to work by piggybacking on the "fueled" component's event: inst:PushEvent("percentusedchange", { percent = inst.components.armor:GetPercent() }) But that looks like an underhanded trick that only works since the ItemTile widget calls the same SetPercent function for both and doesn't look very closely at the inventory item that pushed the event. I'd be happier if I could just call a "refresh inventory bar" function or something of the same ilk. Thanks in advance. =)
  15. Oh, you're right. I just automatically assumed it was local because it's a "class" function. Thanks. =)