Jump to content

[Help needed] Dracula character mod

Recommended Posts

Hi there !
So, I'm building a new character mod of my own, but I'm not a real expert in coding and I get a few problems at the moment, so I started this post to reach for the help of better modders.
My char is Dracula, a vampire that has been tricked by Maxwell.
His stats : 
125 Health
200 Sanity
150 Hunger
The char is created, with anims etc thanks to th ESTC.
Now, to the special abilities part :
Dracula is carnivore, because he needs blood and plants don't have blood.Because he needs blood, even monster food doesn't bother him.
He's been a very long time in the dark, so dark doesn't drain his sanity, he even gets sanity from it.
He gets hot sooner than other characters beause of his fragile skin.
Because he hates light, his sanity goes a bit down in day light.
When Dracula goes under 30 HP, he transforms into a big bat. The bat should work a bit like the werebeaver : the inventory is dropped, hud hidden, etc.

The bat has a bloodlust-meter, that goes down with time and up by killing things / eating meat on the ground or living insects.
If the bloodlust goes down to 0, the player dies, but if it goes back to max, he turns back into a vampire.
I am looking in woodie's and werebeaver's prefabs files, but I'm struggling a bit to get things to work.
I uploaded the zip file with all the mod files in case you want to look at it. 
To do list (help needed) : 

-Maxwell's smoke cloud when transforming into bat form/ vampire form
-Replace "Gnaw" with "Bite" when in bat form.
-Custom color hud when in bat form. Bloodlust is working but badge doesn't show up.

-Bite pigs to restore hunger. Biting pigs may transform them into werepigs.


Bugs to fix :

-When going left/right hair gets out of the hat, I have to fix that on the hair files.


Images of the character : post-263820-0-61034600-1426952676_thumb.

Thanks for reading, and for the help you could provide me.  :-)


Link to comment
Share on other sites

Just a little update on this post, I worked on the bloodlust of the char but I'm having a problem :

In my file bloodlust.lua I would like to make a reference to "inst.components.health.currenthealth" from the character, but this doesn't as is, because it isn't in the modmain. I tried calling it dracula to but doesn't work either.


Here is the code that causes trouble :

elseif not self.isbat and dracula.components.health.currenthealth <= 35 then				self.is_bat = true				

I took most of the stuff from the beaverness.lua script file, but as this mechanism is slightly different I need a bit of help. I probably need something to tell the script to go back to the dracula.lua file to get the health component value, but I just don't know how and can't find it.

Link to comment
Share on other sites

Here comes another update, got the bloodlust file not to crash the game, but it doesn't work at all, sadly. Dracula now becomes a bat properly but can't go back to his original form. Any advice on that particular issue? The .zip file has been updated so someone can look into this hopefully.

Link to comment
Share on other sites

Hmm... I can see a couple of things wrong in the code, as it stands.


The first that I think you should deal with is your use of the Health component INSIDE your bloodlust component.  I'm not sure why you're trying to add a component (inside another new component) that already exists on the new component's owner.  Component.


Hah, let me rephrase <.<


Instead of importing the health component into your bloodlust component, use the health component that already exists on your character.  You can access it from any bloodlust method via: self.inst.components.health

(self.inst always refers to a component's "owner" or "parent")


The way it's currently set up creates a new health component inside the bloodlust component, but that health component isn't linked to anything, it just kinda sits there unchanging.



A very useful tool that you may want to add to your component is a debug string.  You can add one very easily like so:

function Bloodlust:GetDebugString()    return self.current .. "/" .. self.max .. "  is_bat? " .. self.is_batend

Now, whenever the player is set as the debug entity( SetDebugEntity(GetPlayer()) via console ), you'll be able to see those values change in real time.  Press backspace to enable the debug overlay.



As for why your bat isn't turning back into Dracula, you aren't telling the player to transform back anywhere!  Your bloodlust component is calling onbecomeperson, and all that function is doing is pushing an event.  You don't have anything listening for that event, though.


In the case of Woodie, SGwerebeaver listens for the event so that it can first play the transformation animation before turning him back into human form.  I would suggest you do the same.


Inside your events object in SGbat_form.lua, add something along these lines:

    EventHandler("transform_person", function(inst) inst.sg:GoToState("transform_dracula") end),

Then create a state that plays your transform-back-into-dracula animation, and call inst.components.bloodlust.makeperson(inst) when it finishes.


Important: If you do this, you'll need to change the following lines from your dracula prefab:

	inst:AddComponent("bloodlust")	inst.components.bloodlust.makeperson = becomedracula (inst)	inst.components.bloodlust.makebat = becomebat_form (inst)	inst:ListenForEvent("healthdelta", transform)

When storing a function reference in another variable(or a property on an object, or a field on a table, whatever you want to call it), you need to omit the () parentheses.  () specifically tells Lua to execute the function, rather than just reference the function.  Those lines should read:

	inst.components.bloodlust.makeperson = becomedracula	inst.components.bloodlust.makebat = becomebat_form
Link to comment
Share on other sites

Many thanks ! Now the characters efficiently comes back from bat form :grin:

Now the problems are mainly the bloodlust badge not showing up, and the hud not coming back when becoming dracula.


So I think I know why this is happening, mainly because I'm trying to go though the hud.lua but my widget isn't initialized in it, problem is I don't know how to work around this issue.

I should probably try to use the widget.lua and/or badge.lua files but I don't event know where to start.



I fixed the lootdropper crash, which was occuring because there was no lootdropper field for the character.


As for the hud not coming back, the bloodlust:isbat isn't working well and is always returning a true, so that's why it doesn't work. I "resolved" this by not calling this and calling the inst.bat_form instead.


File has been updated if you want to check !

Link to comment
Share on other sites

For the record, people wouldn't like it as much as "Dracula", but I totally would have named him Wladislav(or some variation of that), considering Dracula lore came from that surrounding the Vlad the Impaler (from the epithet Dracul, which translates roughly to "the Dragon").  He wrote his name as Wladislaus Dragwlya. :D

Link to comment
Share on other sites

Yeah, naming him with a W would totally go along with the other character's names, and I was looking for a less "classic" name for him, so I'll consider something like that !

Eat anim has been fixed, but I ran on another bug that I fixed : bloodlust was still depleting when dracula, and dracula died at 0 bloodlust. Fixed this by stopping the bloodlust effect !


Also, I had a game crash telling me that game was trying to perform arithmetic on foostep in SGwilson (a nil value), when hit while running.. I think I have to make another stategraph based on SGwilson for dracula form. 


I'm getting an error too while being hit too much (char goes to transform state but has suffered too much already and so the game tries to index field bloodlustbadge which is a nil value at that moment), so char cannot transform properly.. :(

Link to comment
Share on other sites

Ok so I tried fixing the foosteps crash by making a new SGdracula based on SGwilson, and adding the bat transforms states etc, but this is not working. Instead of trying to do this before enterint bat form, it just does it when going back to dracula form, char'ss body not appearing and the camera is stuck at close distance.

I don't get why it won't work, stategraph is loaded in dracula.lua, works on entering the game so the problem must be on the transitions I guess ...


Here is what I added in SGdracula, in the functions event and state (I commented those lines because they make the game unplayable for now) :

 -- EventHandler("transform_bat", function(inst, data)        -- if inst.components.bloodlust then            -- TheCamera:SetDistance(14)            -- inst.sg:GoToState("bat_form")        -- end    -- end),
-- State{        -- name = "bat_form",        -- tags = {"busy"},        -- onenter = function(inst)			-- inst.components.bloodlust.doing_transform = true            -- inst.Physics:Stop()             -- inst.components.playercontroller:Enable(false)                       -- inst.AnimState:PlayAnimation("transform_pre")            -- inst.components.health:SetInvincible(true)        -- end,                -- onexit = function(inst)			-- if not inst.components.bloodlust:IsBat() then				-- inst.components.bloodlust.makebat(inst)			-- end			-- inst.components.health:SetInvincible(false)			-- inst.components.playercontroller:Enable(true)			-- inst.components.bloodlust.doing_transform = false        -- end,        -- events =        -- {            -- EventHandler("animover", function(inst)	            -- inst.components.bloodlust.makebat(inst)                -- inst.sg:GoToState("transform_pst")            -- end ),        -- }     -- },
Link to comment
Share on other sites

Not a helpful reply here, but I saw this in the forum's sidebar under recent topics and clicked through.


WOW. This sounds awesome. He transforms into a bat??? O_____O


(I never use mods and dunno how to use them. So this is first time I dropped by this forum section. Hello~ *runs away again*)

Link to comment
Share on other sites

Hey, I'm back from the grave, and I decided to work again on this mod I had bandoned ! I resolved the foosteps issue I had, and now you can transform into bat/die in bat form without crashing. I'mlooking around to find some help to get the badge working but I really can't understand how to do that for now.


I have also found a workaround to enable the bat to eat living insects and get some bloodlust from it, so that's that done also. :)

Link to comment
Share on other sites

Got the badge to work just fine ! But in the same time, the bat just doesn't come back into dracula.... again :(

Well, I've almost fixed the issue but it seems like SGbat_form can't see the event transform_person yet

Also, I figured a way to add nightvision, and the sanity loss at day too !


I'm still re-uploading the dracula.zip so anyone can try it, or help me figure out what the problem is about the transforming back.

Link to comment
Share on other sites

Well, all problems have been solved ! The anim of the bat transforming back to dracula works again. I'm changing the name to Wladislaus as suggested by Corrosive, thank you for that, and I'll do some artwork back again, I don't like the way the character look right now anymore. I also added a new mechanic that increases the life/sanity/hunger given back when you transform into dracula thanks to the number of killed things in bat form.

I'll re-upload the final file soon, when I'll be satisfied with the artwork.

I also may add a function to bite the pigs to get back some hunger later, and maybe they could turn into werepigs by doing that too

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

Please be aware that the content of this thread may be outdated and no longer applicable.

  • Create New...