Jump to content

Need some help :)


TemplarAsh
 Share

Recommended Posts

Hi all,

 

Currently I have been learning with the Darkness Awaits barbarian player and goblin AI monsters. I have tweaked the Lua files a bit and am happy it works, but I do not know how to tell the goblins that the barbarian has died and to stop attacking him. I tried changing the teamid of the barbarian to 2 after he dies, but that did not work.

 

Is there a way to pass the players health variable to the GoblinAI script to tell him once it is 0 to go idle?

 

Also, now that he can die is there a way to make him respawn? lol

 

Thanks for the help!

 

~Ash

Link to comment
Share on other sites

I'm not a Lua developer (I use C++ only, in LE) but I see you have the property "script" for each entity and in GoblinAI I see that self.target is assigned from the target entity.script, so I think you should be able to access the player health in your GoblinAI using self.target.health

 

@MilitaryG: I see you used/use also the "unnameable", so if you like component system and are using C++ then I could have something that you may find interesting, that is my craft-made complete component system built with the "unnameable" usage pattern (including AddComponent<>, GetComponent<>, GetComponents<>, Awake/Update/LateUpdate/OnGUI/Destroy).

?? FRANCESCO CROCETTI ??

http://skaredcreations.com

Link to comment
Share on other sites

I don;t know lua but in c++ I always set a flag to say each character is alive at start of game." my_character alive = true" Then when they die the value becomes false. The enemy routines will only run if alive = true.

amd quad core 4 ghz / geforce 660 ti 2gb / win 10

Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++

Link to comment
Share on other sites

Success, I figured it out. I am not certain if this is the best way to do this but it works...

 

In the barbarian.lua

 

myVal = 100 --defined at top to keep it from being nil

 

module("a", package.seeall)

 

function GetSomeValue()

return myVal

end

 

if self.health>0 then

self.health = self.health - damage

myVal = self.health

 

Inside the Goblin.lua...

 

require "a"

if (a.GetSomeValue()) <= 0 then return end

 

which skips the attack chunk

 

***Edit: This worked better

 

require "a"

if (a.GetSomeValue()) <= 0 then self.currentState=self.state.idle end

 

~Ash

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...