Commit 87c2184ea7b9e39857266aeb5d005cd2c7837c50

Authored by dg
1 parent fd20d7fd

Walking on a level changer popups a flyer to notify you

git-svn-id: http://svn.net-core.org/repos/t-engine4@5177 51575b47-30f0-44d4-a5cc-537603b46e54
... ... @@ -87,7 +87,7 @@ end
87 87
88 88 --- Get the known status for the given actor
89 89 function _M:knownBy(actor)
90   - return self.known_by[actor]
  90 + return self.known_by[actor] or self.all_know
91 91 end
92 92
93 93 --- Can we disarm this trap?
... ...
... ... @@ -24,8 +24,9 @@ module(..., package.seeall, class.inherit(engine.Generator))
24 24
25 25 function _M:init(zone, map, level, data)
26 26 engine.Generator.init(self, zone, map, level)
  27 + self.data = data
27 28 self.grid_list = zone.grid_list
28   - self.floor = self:resolve("floor")
  29 + self.floor = self:resolve("floor") or self:resolve(".")
29 30 self.up = self:resolve("up")
30 31 end
31 32
... ...
... ... @@ -77,6 +77,8 @@ _M.temporary_values_conf.combat_spellspeed = "mult0"
77 77 -- Damage cap takes the lowest
78 78 _M.temporary_values_conf.flat_damage_cap = "lowest"
79 79
  80 +_M.projectile_class = "mod.class.Projectile"
  81 +
80 82 function _M:init(t, no_default)
81 83 -- Define some basic combat stats
82 84 self.energyBase = 0
... ... @@ -3740,7 +3742,7 @@ function _M:on_project(tx, ty, who, t, x, y, damtype, dam, particles)
3740 3742 end
3741 3743
3742 3744 -- LOS check (this is also caught by canProject)
3743   - if not t.pass_terain and not t.pass_block_sight then
  3745 + if not t.pass_terain and not t.pass_block_sight and who.hasLOS then
3744 3746 if not who:hasLOS(tx, ty) then
3745 3747 return true
3746 3748 end
... ...
... ... @@ -316,7 +316,6 @@ function _M:loaded()
316 316 engine.GameTurnBased.loaded(self)
317 317 engine.interface.GameMusic.loaded(self)
318 318 engine.interface.GameSound.loaded(self)
319   - Actor.projectile_class = "mod.class.Projectile"
320 319 Zone:setup{
321 320 npc_class="mod.class.NPC", grid_class="mod.class.Grid", object_class="mod.class.Object", trap_class="mod.class.Trap",
322 321 on_setup = function(zone)
... ...
... ... @@ -35,6 +35,8 @@ module(..., package.seeall, class.inherit(
35 35 engine.interface.ActorTalents
36 36 ))
37 37
  38 +_M.projectile_class = "mod.class.Projectile"
  39 +
38 40 function _M:init(t, no_default)
39 41 t.encumber = t.encumber or 0
40 42
... ...
... ... @@ -188,7 +188,11 @@ function _M:describeFloor(x, y)
188 188 end
189 189
190 190 local g = game.level.map(x, y, game.level.map.TERRAIN)
191   - if g and g.change_level then game.logPlayer(self, "#YELLOW_GREEN#There is "..g.name:a_an().." here (press '<', '>' or right click to use).") end
  191 + if g and g.change_level then
  192 + game.logPlayer(self, "#YELLOW_GREEN#There is "..g.name:a_an().." here (press '<', '>' or right click to use).")
  193 + local sx, sy = game.level.map:getTileToScreen(x, y)
  194 + game.flyers:add(sx, sy, 60, 0, -1.5, ("Level change (%s)!"):format(g.name), colors.simple(colors.YELLOW_GREEN), true)
  195 + end
192 196 end
193 197
194 198 function _M:move(x, y, force)
... ...
... ... @@ -33,8 +33,16 @@ function _M:move(x, y, force)
33 33
34 34 local moved = engine.Projectile.move(self, x, y, force)
35 35 if moved and not force and ox and oy and (ox ~= self.x or oy ~= self.y) and config.settings.tome.smooth_move > 0 then
36   - self:setMoveAnim(ox, oy, config.settings.tome.smooth_move)
  36 + self:setMoveAnim(ox, oy, config.settings.tome.smooth_move, self.project and self.project.def and self.project.def.typ.blur_move)
37 37 end
38 38
39 39 return moved
40 40 end
  41 +function _M:tooltip(x, y)
  42 + local tstr = tstring("Projectile: ", self.name)
  43 +
  44 + if config.settings.cheat then
  45 + tstr:add(true, "UID: ", tostring(self.uid), true, "Coords: ", tostring(x), "x", tostring(y))
  46 + end
  47 + return tstr
  48 +end
... ...
... ... @@ -21,6 +21,7 @@ require "engine.class"
21 21 require "engine.Trap"
22 22 require "engine.interface.ActorProject"
23 23 require "engine.interface.ObjectIdentify"
  24 +local Faction = require "engine.Faction"
24 25
25 26 module(..., package.seeall, class.inherit(
26 27 engine.Trap,
... ... @@ -28,7 +29,10 @@ module(..., package.seeall, class.inherit(
28 29 engine.interface.ActorProject
29 30 ))
30 31
  32 +_M.projectile_class = "mod.class.Projectile"
  33 +
31 34 function _M:init(t, no_default)
  35 + self.faction = "enemies"
32 36 engine.Trap.init(self, t, no_default)
33 37 engine.interface.ObjectIdentify.init(self, t)
34 38 engine.interface.ActorProject.init(self, t)
... ... @@ -50,6 +54,12 @@ function _M:tooltip()
50 54 end
51 55 end
52 56
  57 +--- What is our reaction toward the target
  58 +-- See Faction:factionReaction()
  59 +function _M:reactionToward(target)
  60 + return Faction:factionReaction(self.faction, target.faction)
  61 +end
  62 +
53 63 --- Can we disarm this trap?
54 64 function _M:canDisarm(x, y, who)
55 65 if not engine.Trap.canDisarm(self, x, y, who) then return false end
... ...
... ... @@ -976,7 +976,7 @@ newDamageType{
976 976 tmp[target] = true
977 977 DamageType:get(DamageType.PHYSICAL).projector(src, x, y, DamageType.PHYSICAL, dam.dam)
978 978 if target:checkHit(src:combatPhysicalpower(), target:combatPhysicalResist(), 0, 95, 15) and target:canBe("knockback") then
979   - target:knockback(src.x, src.y, dam.dist)
  979 + target:knockback(dam.x or src.x, dam.y or src.y, dam.dist)
980 980 target:crossTierEffect(target.EFF_OFFBALANCE, src:combatPhysicalpower())
981 981 game.logSeen(target, "%s is knocked back!", target.name:capitalize())
982 982 else
... ...
... ... @@ -47,21 +47,69 @@ newEntity{ base = "TRAP_COMPLEX",
47 47 walls[#walls+1] = {x=i, y=j}
48 48 end
49 49 end
50   - if #walls == 0 then game.level.map:remove(i, j, engine.Map.TRAP) return end
  50 + if #walls == 0 then game.level.map:remove(x, y, engine.Map.TRAP) return end
51 51
52 52 local spot = rng.table(walls)
53 53 local l = line.new(spot.x, spot.y, x, y)
54 54 self.spawn_x, self.spawn_y = l()
55 55 print("Boulder trap spawn", self.spawn_x, self.spawn_y)
56 56 self.x, self.y = x, y
  57 + self.on_added = nil
57 58 end,
58 59 str = resolvers.mbonus(200, 30),
59 60 dam = resolvers.mbonus_level(300, 5),
60   - combatAttackStr = function(self) return self.str end,
  61 + combatPhysicalpower = function(self) return mod.class.interface.Combat:rescaleCombatStats(self.str) end,
61 62 triggered = function(self, x, y, who)
62 63 if not self.spawn_x then return end
63   - local tg = {name="huge boulder", type="bolt", range=5, x=self.spawn_x, y=self.spawn_y, speed=2, display={image="trap/trap_big_boulder_01.png"}}
64   - self:projectile(tg, x, y, engine.DamageType.PHYSKNOCKBACK, {dam=self.dam, dist=3})
  64 + local tg = {name="huge boulder", type="bolt", range=core.fov.distance(x, y, self.spawn_x, self.spawn_y), x=self.spawn_x, y=self.spawn_y, speed=2, display={image="trap/trap_big_boulder_01.png"}, blur_move=4}
  65 + self:projectile(tg, x, y, engine.DamageType.PHYSKNOCKBACK, {dam=self.dam, dist=3, x=self.spawn_x, y=self.spawn_y})
65 66 return true
66 67 end,
67 68 }
  69 +
  70 +newEntity{ base = "TRAP_COMPLEX",
  71 + subtype = "arcane",
  72 + name = "spinning beam", image = "trap/trap_glyph_explosion_01_64.png",
  73 + detect_power = 6, disarm_power = 6,
  74 + rarity = 3, level_range = {1, 30},
  75 + color_r=40, color_g=220, color_b=0,
  76 + message = "@Target@ walks on a trap, the beam intensifies.",
  77 + on_added = function(self, level, x, y)
  78 + self.x, self.y = x, y
  79 + self.rad = rng.range(2, 8)
  80 + local tries = {}
  81 + local list = {i=1}
  82 + local sa = rng.range(0, 359)
  83 + local dir = rng.percent(50) and 1 or -1
  84 + for a = sa, sa + 359 * dir, dir do
  85 + local rx, ry = math.floor(math.cos(math.rad(a)) * self.rad), math.floor(math.sin(math.rad(a)) * self.rad)
  86 + if not tries[rx] or not tries[rx][ry] then
  87 + tries[rx] = tries[rx] or {}
  88 + tries[rx][ry] = true
  89 + list[#list+1] = {x=rx+x, y=ry+y}
  90 + end
  91 + end
  92 + self.list = list
  93 + game.level:addEntity(self)
  94 + self.on_added = nil
  95 + end,
  96 + all_know = true,
  97 + dam = resolvers.mbonus_level(300, 5),
  98 + triggered = function(self, x, y, who)
  99 + if self:reactionToward(who) < 0 then self.dam = self.dam * 1.5 end
  100 + return true
  101 + end,
  102 + canAct = false,
  103 + energy = {value=0},
  104 + act = function(self)
  105 + local x, y = self.list[self.list.i].x, self.list[self.list.i].y
  106 + self.list.i = util.boundWrap(self.list.i + 1, 1, #self.list)
  107 +
  108 + local tg = {type="beam", range=self.rad, friendlyfire=false}
  109 + self:project(tg, x, y, engine.DamageType.ARCANE, self.dam, nil)
  110 + local _ _, x, y = self:canProject(tg, x, y)
  111 + game.level.map:particleEmitter(self.x, self.y, math.max(math.abs(x-self.x), math.abs(y-self.y)), "mana_beam", {tx=x-self.x, ty=y-self.y})
  112 +
  113 + self:useEnergy()
  114 + end,
  115 +}
... ...