TemplarAsh Posted March 23, 2014 Posted March 23, 2014 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 Quote
ZioRed Posted March 23, 2014 Posted March 23, 2014 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). Quote ?? FRANCESCO CROCETTI ?? http://skaredcreations.com
cassius Posted March 23, 2014 Posted March 23, 2014 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. Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++
TemplarAsh Posted March 23, 2014 Author Posted March 23, 2014 Hi guys, Yes I saw both of these lines of code but was uncertain on how they actually worked. I will try both options and report back. Thank you for helping me. ~Ash Quote
TemplarAsh Posted March 24, 2014 Author Posted March 24, 2014 Hi All, Well after messing around with this for quite some time, I still cannot figure this out so any new suggestions are welcomed I will keep trying... Quote
TemplarAsh Posted March 24, 2014 Author Posted March 24, 2014 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 Quote
Recommended Posts
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.