inrange(point.y, pos.y, pos.y + dim.height, HLINES(size.y))) {
lua::setEntity(&e);
a.attack.script("effect");
+ if (pos.x < point.x) {
+ e.component<Direction>()->x = -0.1;
+ e.component<Direction>()->y = 0.1;
+ } else {
+ e.component<Direction>()->x = 0.1;
+ e.component<Direction>()->y = 0.1;
+ }
if (a.attack.effect.size() > 0)
effects.emplace_back(point, a.attack.effect);
//ParticleSystem::addMultiple(15, ParticleType::DownSlash,
// make the entity wander
// TODO initialX and range?
if (entity.has_component<Wander>()) {
+ auto dim = entity.component<Solid>();
float aggro = 0;
+ vec2 self (position.x + dim->width / 2, position.y + dim->height / 2);
LuaList vars = {
LuaVariable("vely", direction.y),
LuaVariable("velx", direction.x),
LuaVariable("playerx", ppos.x),
LuaVariable("playery", ppos.y),
- LuaVariable("selfx", position.x),
- LuaVariable("selfy", position.y),
+ LuaVariable("selfx", self.x),
+ LuaVariable("selfy", self.y),
LuaVariable("aggro", aggro)
};
entity.component<Wander>()->script(aggro ? "hostile" : "update", vars);
if (hasAggro)
entity.component<Aggro>()->yes = aggro > 0 ? 1 : 0;
+
+ position.x = self.x - dim->width / 2;
+ position.y = self.y - dim->height / 2;
}
}
});
<Dialog name="Bob">
<text id="0" nextid="1">
- <!--<give name="Hunters Bow" count="1"/>
+ <give name="Hunters Bow" count="1"/>
<give name="Arrow" count="50"/>
- <option name="Yes"/>-->
<give name="Wood Sword" count="1"/>
<content>
Hey there! The name's Bob. Good to see you've finally woken up from your nap by the cliff there... lol
countdown = 0
update = function()
+ if (velx < 0 and math.abs(selfx - playerx) < 150) then
+ aggro = 1
+ end
+
if (countdown == 0) then
countdown = math.random(3000, 5000)
velx = math.random(-1, 1) * 0.005
end
hostile = function()
+ if (playerx <= selfx) then
+ velx = -0.01
+ else
+ velx = 0.01
+ end
+ if (math.abs(playerx - selfx) < 50) then
+ attack(selfx, selfy)
+ end
end
</Wander>
<Aggro/>
<Solid />
<Physics />
<Name value="birb" />
+ <Health value="60" />
<Wander>
countdown = 0
onetime = 0