Jump to content

[Help] Final Fantasy mod - soon character mod comming on workshop


Recommended Posts

Hello everyone. This is my first of what i hope will be many threats. I'm currently working on my first mod, it's working already and it looks great, it's a final fantasy character with amazing magical ítems and  equipment. I don't wanna spoil the surprise, i think people may like it as much as i enjoyed making it and using it. Today i'm here because i'm really new in this moding world, and at first it's a little overwhelming, but then eveything kinds of starts making sense.

So i will really appreciate if you could help me with your experience, i promise it's gonna be worth it.

I apologize in advance for my english spelling, it's not my main lenguaje.

 

Phase 1: (This phase is done, but i'm adding a few extras) 

  • Ítem behavior i wanna implemet:

- Teleport when hitting a target from the distance. (towards the target) (Done)
- Electrical damage when hittng. (Done)
- Nightvision (Done)
- Gaining sanity from killing creatures that are strong enough to fight back (Done)
- Special personal armor. (working on it)
- Special personal head equippable. (working on it)
- Other minor features got implemented here, the detailed list will be in the published mod.

 

Phase 2: (Currently working here, after done, the mod will be published and i will start working on the next phase)

This phase is about implementing ítems that will use MP each time you use them since "phase 3", but in this phase they will have a cooldown instead. So far this is the list, may add more in the future:

- Usable ítem that makes a lighting strike to enemy. (In progress)
- Usable ítem that makes a meteor strike to enemy. (In progress)
- Usable ítem that heals you (health restore) (In progress)
- Usable ítem makes sword's fall from the sky to attack an enemy, will have a long cooldown (similar to the Gilgamesh mod) (in progress)
- Usable ítem that makes explosive bubbles (similar to the jutsu mod, the bubble jutsu) (In progress)
- Usable ítem that will freeze everyone on your range of view. (In progress)
- Will make more MP based ítems.

This ítems will have a cooldown in phase 2, since phase 2 will not have the MP bar yet, because i'm new in this and it might take a while before i figure out how to make it all work.

Phase 3 (will change how magic Works in phase 2, will be implemented via update)

  • Mp bar system (Haven't started with this) yet

 As seen in the final fantasy series, and every RPG game ever, i wanna add a "MP" bar. MP will be a parameter used when attacking with magic, such as the lightning magical attack that i will implement into an ítem in phase 2. MP will recharge with time, and having no MP will make you unable to use magic until it loads, as well as not having enough MP required to use a certain magic.

The jutsu mod is a good example of what i wanna do with the MP bar, jutsu mod uses a chakra bar instead when you use jutsus. The big difference is that my ítems will be unlimited (not expendables), your only impediment will be the MP bar since you got to wait till it loads. I have to thank the justsu's mod creator, since his mod was the one that inspired me to make my own original mod.

Phase 4: (The most ambicious one, implemented via updates)

  • Personal assistance companion (Haven't started with this yet)
  • Special character transformation with limited time. (Probably triggered by a key, or an ítem)
  • Summoning companions such as Ifrit, Odin, Shiva and others from the Final Fantasy series. (They will banish after some time or certain conditions)

 This character is gonna have a companion that will not fight (since you are the powerful warrior and protector of your companion), still thinking what is gonna be this companion's behavior, but first step is gonna be implementing the companion and see it working, then i'll add features. 


Thank you in advance for helping me, i promise this mod is gonna be a really fun character to use.

Special thanks to @rezecib and @DarkXero, your well deserved credit will be in the mod's workshop and forum once it's published. This mod wouldn't be possible without you.

Mods that inspired me to make this one: Jutsu mod, Musha mod, Gilgamesh mod.

Edited by Jpianist
Link to comment
Share on other sites

6 hours ago, DarkXero said:

Here I incorporated the blinking from Zoro, the nightvision from my posts, and the sanity gain from stuff that isn't a small creature.

test_sword.zip

Omg @DarkXero you're amazing, thanks, i'll try it and tell you how it worked for me. I'll definitely add you as a colaborator when my mod is done. This far i have you and @rezecib, i feel so lucky i got help from such awesome people. Thanks you! Gonna work on the mod now.

EDIT: After trying the codes from the mod you sended me, i'm very happy because most of them worked (actually everything, but need to do some changes).

- Nightvision Works 100% and no changes need to be done in my mod.

- Bliking gave me a "nil value" error, but your code helped me to understand where the codes for blinking had to be placed, so i copied zoro's blinking code from the modmain.lua to mine and it Works perfectly now. This is how it looks now:

AddPlayerPostInit(function(inst)
	-- Sword nightvision
	inst.discordnightvision = GLOBAL.net_bool(inst.GUID, "player.discordnightvision", "discordnightvisiondirty")
	inst.discordnightvision:set(false)
	inst:DoTaskInTime(0, OnInitNightVision)
	-- Combat blinking
   if inst.components.combat == nil then
        return
    end
	if GLOBAL.TheWorld.ismastersim then
		local old_start = inst.components.combat.StartAttack
		inst.components.combat.StartAttack = function(self)
			old_start(self)
			local target = self.target
			local weapon = self:GetWeapon()
			if target and weapon and weapon.components.weapon.blinking then
				local distance = math.sqrt(self.inst:GetDistanceSqToInst(self.target))
				local hitrange = weapon.components.weapon.hitrange
				if distance > hitrange then
					local smoke1 = GLOBAL.SpawnPrefab("maxwell_smoke")
					local smoke2 = GLOBAL.SpawnPrefab("maxwell_smoke")
					local sx, sy, sz = self.inst.Transform:GetWorldPosition()
					smoke1.Transform:SetPosition(sx, sy, sz)
					local fx, fy, fz = target.Transform:GetWorldPosition()
					local q = (distance - hitrange + 0.2) / distance
					local dx = sx - q * (sx - fx)
					local dy = sy - q * (sy - fy)
					local dz = sz - q * (sz - fz)
					inst.Transform:SetPosition(dx, dy, dz)
					smoke2.Transform:SetPosition(dx, dy, dz)
				end
			end
		end
	end
end)

- The sanity gain however, works perfectly, but i want to change it. With the current code if i kill spiders i do not gain sanity, so i'm wondering which mobs has the smallcreature's tag. I want to include spiders and other creatures that are able to fight back. But exclude weak creatures such as butterflies and rabbits, since they don't fight back.

- About the electric damage, i found you added this code:

    inst.components.weapon:SetElectric()

What does this code do? I included it into my mod but not sure what it does, i'm not exactly noticing any difference.

Edited by Jpianist
Link to comment
Share on other sites

15 hours ago, Jpianist said:

Bliking gave me a "nil value" error, but your code helped me to understand where the codes for blinking had to be placed, so i copied zoro's blinking code from the modmain.lua to mine and it Works perfectly now.

Oh yes, I was moving the blinking code around. It seems I forgot a line.

_StartAttack(self)
local owner = self.inst
local target = self.target
local weapon = self:GetWeapon()
if target and weapon and weapon.components.weapon.blinking then

The owner variable is nil if there's no self.inst assignation. Initially, owner existed because I used the blink code on the equip function.

If you add the "local owner = self.inst" to my code, then it will work.

15 hours ago, Jpianist said:

The sanity gain however, works perfectly, but i want to change it. With the current code if i kill spiders i do not gain sanity, so i'm wondering which mobs has the smallcreature's tag.

Notepad++ has a built-in function called "Find in Files". It reads files and tells you if there are string matches.

Searching for "AddTag("smallcreature")", you will find that

bees, bernie, birds, butterfly, catcoon, cave spiders, eyeplant, frog, grass gekko, pet lavae, mandrake, mole, mosquito, pengull, rabbit, smallbird, spider

are prefab files with that AddTag string.

Spiders also have the tag "monster", so you can do this check instead:

if IsValidVictim(victim) and (not victim:HasTag("smallcreature") or victim:HasTag("monster")) then

And now the check will pass for spiders.

15 hours ago, Jpianist said:

What does this code do? I included it into my mod but not sure what it does, i'm not exactly noticing any difference.

Gives your weapon a electric stimuli.

Which means that if you hit a lightning goat with the sword, you will charge it (as if hit by lightning).

I assumed you wanted that, since there is no "elemental specific" damage.

Getting hit by lightning or burned by fire deal the same kind of damage.

The difference between damage is like the difference between being hit by a bee and a deerclops.

Edited by DarkXero
Link to comment
Share on other sites

13 minutes ago, DarkXero said:

Oh yes, I was moving the blinking code around. It seems I forgot a line.


_StartAttack(self)
local owner = self.inst
local target = self.target
local weapon = self:GetWeapon()
if target and weapon and weapon.components.weapon.blinking then

The owner variable is nil if there's no self.inst assignation. Initially, owner existed because I used the blink code on the equip function.

If you add the "local owner = self.inst" to my code, then it will work.

Oh allright, i'll try that now. Thanks :D

14 minutes ago, DarkXero said:

Notepad++ has a built-in function called "Find in Files". It reads files and tells you if there are string matches.

Searching for "AddTag("smallcreatures")", you will find that

bees, bernie, birds, butterfly, catcoon, cave spiders, eyeplant, frog, grass gekko, pet lavae, mandrake, mole, mosquito, pengull, rabbit, smallbird, spider

are prefab files with that AddTag string.

Yeah i know about the Find in Files function, it's essencial for mods, but is also important looking for the right commands, i tried that but didn't find the answer because i used "smallcreatures" insted of "AddTag("smallcreatures")" which makes more sense. Now i know how to find what tags means, thank you.

19 minutes ago, DarkXero said:

Spiders also have the tag "monster", so you can do this check instead:


if IsValidVictim(victim) and (not victim:HasTag("smallcreature") or victim:HasTag("monster")) then

And now the check will pass for spiders.

Oh so now i understand how to modify this code, just add more "or" inside the () in the "if" sentence. Like this:

if IsValidVictim(victim) and (not victim:HasTag("smallcreature") or victim:HasTag("monster") or not victim:HasTag("prey") or not victim:HasTag("wall")) ) then

Is the code right? (i used random tags just to check if i understood how to add tags to the code)

24 minutes ago, DarkXero said:

Gives your weapon a electric stimuli.

Which means that if you hit a lightning goat with the sword, you will charge it (as if hit by lightning).

I assumed you wanted that, since there is no "elemental specific" damage.

Getting hit by lightning or burned by fire deal the same kind of damage.

The difference between damage is like the difference between being hit by a bee and a deerclops.

There is no elemental specific damage? Hmmm, what about paralyzing the enemy with electricity when i hit it? But not in every hit but with a %, like for example, a 25% chance of paralyzing with electricity.

Link to comment
Share on other sites

1 hour ago, Jpianist said:

but didn't find the answer because i used "smallcreatures" insted of "AddTag("smallcreatures")" which makes more sense

I screwed up too. "smallcreature" is fine, "smallcreatures" is not. Because the tag doesn't have that "s".

1 hour ago, Jpianist said:

Is the code right?

Yes. There's an extra ) at the end.

if IsValidVictim(victim) and (not victim:HasTag("smallcreature") 
	or victim:HasTag("monster") or 
	not victim:HasTag("prey") or 
	not victim:HasTag("wall")) then

You can also write the block like this.

1 hour ago, Jpianist said:

There is no elemental specific damage? Hmmm, what about paralyzing the enemy with electricity when i hit it? But not in every hit but with a %, like for example, a 25% chance of paralyzing with electricity.

Well there are many ways to "stun" a monster.

The dragonfly can get "stunned", the archery mod of Zupalex has arrows that allow you to "stun" monsters.

Here's an example:

local stuntime = 5

local function ShowStunFX(target)
	local x, y, z = target.Transform:GetWorldPosition()
	local fx = SpawnPrefab("shock_fx")
	fx.Transform:SetPosition(x, y, z)
end

local function StartStun(target)
	if target.sg ~= nil and not target.sg:HasStateTag("frozen") and target.sg.sg.states.hit ~= nil then
		target.sg:GoToState("hit")
	end
	ShowStunFX(target)
	target:AddTag("discordstunned")
	target:StopBrain()
end

local function StopStun(target)
	target:RemoveTag("discordstunned")
	target:RestartBrain()
end

local function onattack(inst, attacker, target)
	local chance = math.random()
	if chance < 0.25 then
		if target ~= nil and target.components.health ~= nil and not target.components.health:IsDead() then
			if not target:HasTag("discordstunned") then
				StartStun(target)
				target:DoTaskInTime(stuntime, StopStun)
			end
		end
	end
end

-- inside fn()
inst:AddComponent("weapon")
inst.components.weapon:SetOnAttack(onattack)

 

Link to comment
Share on other sites

@DarkXero That codes looks great, it goes into myweapon.lua right?

Also, this lines stands for the seconds of the stunned effect, right?

local stuntime = 5

And this one sets the %

if chance < 0.25 then

So "if chance < 0.50 then" would be 50%, for example.

Man, thanks to you the mod it's actually making a lot of progress, you're amazing. I hope i get to be half as good as you someday. I'm starting to understand more and more. Did you started doing DST mods knowing so much or did you also were a noob that got pro with time? (just curious to see if it's possible for me to become better)

Link to comment
Share on other sites

9 minutes ago, Jpianist said:

Also, this lines stands for the seconds of the stunned effect, right?

Yes. That variable holds the number of seconds used in

target:DoTaskInTime(stuntime, StopStun)

so that the stun stops after the number of seconds defined.

9 minutes ago, Jpianist said:

And this one sets the %

Yes. math.random() returns a random number between 0 and 1.

So there's a 25% chance that the chance variable is less than 0.25.

10 minutes ago, Jpianist said:

Did you started doing DST mods knowing so much or did you also were a noob that got pro with time?

Both. I have programming experience, so I know how to get around stuff.

You may know how to work with Lua, but you have to understand what is going on the game to make sense of it.

Like solving a jigsaw puzzle.

Link to comment
Share on other sites

@DarkXero i just tried the stuning but it doesn't seem to triger, i tried stuning spiders and tailbirds, and also for testing i used < 0.90 so i could be sure it wasn't because of %.

Maybe is because i also got this in fn?

inst.components.weapon.onattack = onattack

besides ofc the one you gave me

inst.components.weapon:SetOnAttack(onattack)

i'm using this function with the "inst.components.weapon.onattack = onattack" that i already had.

local function onattack(inst, owner, target)
    if not target:HasTag("wall") then
        owner.components.sanity:DoDelta(0.2)
    end
end

I'm guessing that i shouldn't have two "onattack" functions... what about merging your code with this one, like this?

local function onattack(inst, attacker, target, owner)
    local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner
    if not target:HasTag("wall") then
        owner.components.sanity:DoDelta(0.2)
    end
	local chance = math.random()
	if chance < 0.25 then
		if target ~= nil and target.components.health ~= nil and not target.components.health:IsDead() then
			if not target:HasTag("discordstunned") then
				StartStun(target)
				target:DoTaskInTime(stuntime, StopStun)
			end
		end
	end
end

I had the nil value problem at first, but then added the line "local owner = inst.components.inventoryitem and inst.components.inventoryitem.owner" and it started to work, now i get sanity for every hit (0.2), stun enemies with a 25% chance and gain sanity if they die and not smallcreatures. Thanks @DarkXero, i can move on to the next phase now, which is:

  • Mp bar system.

Btw, i know i'm adding a lot of sanity stuff to the mod, but the character i'm making is literally insane and loves to kill, so i got to add a lot of sanity features. :D

Now i'm gonna start analysing mods like the jutsu mode to implement a special bar and make special ítems that uses that bar's energy to work. Once i got that working i'll publish the mod and start working on phase 3 which is the companion. Now that phase 1 is done i'm closer to publishing. Thanks a lot @DarkXero. if i get stuck in something from the phase 2 i'll look for help again, i can't bother people without trying first, is not right and is not my style. I ask for help only when i feel hopeless :D

Edited by Jpianist
Link to comment
Share on other sites

On 21/8/2016 at 9:04 PM, Jpianist said:

I'm guessing that i shouldn't have two "onattack" functions...

Correct, because

inst.components.weapon.onattack = onattack

and

inst.components.weapon:SetOnAttack(onattack)

do the same thing. And if you do

local var = 1
var = 2
var = 3

then you lose the 1 and the 2 (which are numbers, but the same applies to functions, they are "values").

Link to comment
Share on other sites

Sorry i didn't reply to this message @DarkXero, i'm still trying to fully understand it :lol:

What i had to do to make it work was eliminating one of them (since like you said they do the same), and also, use only one "local function onattack", so i mixed your stuning code with the gaining sanity when hitting someone without the tag "Wall" and they both work perfectly. :D

I wanted to ask you something, could you please give me a sample ítem that when used freezes everyone around my screen BUT myselft? An usable ítem without being equippable, and with a really short animation like rising the arms or something, so it looks like he's conjuring something. Of course i mean an existing game animation, like the animation when you use a spell with a staff or something similar.

I found this topic in the fórum search which is the most similar:

But instead of a staff, just an usable ítem non equippable. Also need exactly the same thing but a healing one that gives 20hp. Both need to have cooldown before being able to use them again, since i still haven't implemented the MP bar which will take over the cooldown. Freeze ítem with 10 seconds of cooldown and healing 15 seconds. It will be awesome if you could make the cooldown configurable, with at least 3 options, but if it's a lot to ask then it's ok.

I'm sorry for bothering you, i already know how the char.lua, myequipableweapon.lua, modmain.lua and modinfo.lua Works, but a nonequippable usable ítem (with infinite uses) seems off my limits. Once i understand how they work it will be simplier for me to just edit them and modify their behavior.

Thanks a lot in advance Dark! This is for the phase 2 ítems.

Edited by Jpianist
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...