hello, I´m making a bomberman mod, and the game is still showing me script errors. Here´s the script:
local BOWSER_HIT_RADIUS = 1500
local bowser_hit_pending = false
local bowser_watch_frames = 0
local king_bobomb_hit_pending = false
local whomp_king_hit_pending = false
local eyerok_hit_pending = false
local function bowser_bomb_explode(o)
if o == nil then return end
spawn_non_sync_object(id_bhvBowserBombExplosion, E_MODEL_BOWSER_FLAMES, o.oPosX, o.oPosY, o.oPosZ,
function(ex)
if ex ~= nil then ex.oTimer = 8 end
end)
spawn_non_sync_object(id_bhvBobombExplosion, E_MODEL_EXPLOSION, o.oPosX, o.oPosY, o.oPosZ,
function(ex)
if ex ~= nil then end
end)
play_sound(SOUND_GENERAL_BOWSER_BOMB_EXPLOSION, gGlobalSoundSource)
set_camera_shake_from_point(SHAKE_POS_LARGE, o.oPosX, o.oPosY, o.oPosZ)
local bowser = obj_get_nearest_object_with_behavior_id(o, id_bhvBowser)
if bowser ~= nil then
local dist = dist_between_objects(o, bowser)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
bowser_hit_pending = true
bowser_watch_frames = 10
end
end
local kingBobomb = obj_get_nearest_object_with_behavior_id(o, id_bhvKingBobomb)
if kingBobomb ~= nil then
local dist = dist_between_objects(o, kingBobomb)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
king_bobomb_hit_pending = true
end
end
local whompKing = obj_get_nearest_object_with_behavior_id(o, id_bhvWhompKing)
if whompKing ~= nil then
local dist = dist_between_objects(o, whompKing)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
whomp_king_hit_pending = true
end
end
local eyerok = obj_get_nearest_object_with_behavior_id(o, id_bhvEyerok)
if eyerok ~= nil then
local dist = dist_between_objects(o, eyerok)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
eyerok_hit_pending = true
end
end
end
local function bowser_hit_loop(b)
if b == nil then return end
if bowser_hit_pending then
bowser_hit_pending = false
if b.oAction ~= 4 then
if b.oHealth and b.oHealth > 0 then
b.oHealth = b.oHealth - 1
end
if b.oHealth and b.oHealth <= 0 then
b.oAction = 4
else
b.oAction = 12
end
b.oSubAction = 0
b.oTimer = 0
end
end
end
local function king_bobomb_hit_loop(b)
if b == nil then return end
if king_bobomb_hit_pending then
king_bobomb_hit_pending = false
b.oAction = 4
b.oSubAction = 0
b.oTimer = 0
b.oVelY = -5.0
end
end
local function whomp_king_hit_loop(b)
if b == nil then return end
if whomp_king_hit_pending then
whomp_king_hit_pending = false
if b.oHealth and b.oHealth > 0 then
b.oHealth = b.oHealth - 1
end
b.oAction = 3
b.oSubAction = 0
b.oTimer = 0
end
end
local function eyerok_hit_loop(b)
if b == nil then return end
if eyerok_hit_pending then
eyerok_hit_pending = false
if b.oHealth and b.oHealth > 0 then
b.oHealth = b.oHealth - 1
end
b.oAction = 2
b.oSubAction = 0
b.oTimer = 0
end
end
hook_behavior(id_bhvBowser, OBJ_LIST_GENACTOR, false, nil, bowser_hit_loop)
hook_behavior(id_bhvKingBobomb, OBJ_LIST_GENACTOR, false, nil, king_bobomb_hit_loop)
hook_behavior(id_bhvWhompKing, OBJ_LIST_GENACTOR, false, nil, whomp_king_hit_loop)
hook_behavior(id_bhvEyerok, OBJ_LIST_GENACTOR, false, nil, eyerok_hit_loop)
local function big_bomb_init(o)
if o == nil then return end
o.oFlags = OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
o.oGravity = 2.5
o.oFriction = 0.8
o.oBuoyancy = 1.3
network_init_object(o, true, {})
end
local function big_bomb_loop(o)
if o == nil or gNetworkPlayers[0] == nil then return end
if o.globalPlayerIndex == nil then
o.globalPlayerIndex = gNetworkPlayers[0].globalIndex
end
if o.globalPlayerIndex ~= gNetworkPlayers[0].globalIndex then return end
o.oVelY = o.oVelY - 2.5
o.oPosX = o.oPosX + o.oForwardVel * sins(o.oMoveAngleYaw)
o.oPosZ = o.oPosZ + o.oForwardVel * coss(o.oMoveAngleYaw)
o.oPosY = o.oPosY + o.oVelY
local floor_y = find_floor_height(o.oPosX, o.oPosY + 100, o.oPosZ)
if floor_y == nil then
floor_y = o.oPosY - 1000
end
if o.oPosY <= floor_y or o.oTimer > 150 then
if o.oPosY < floor_y then o.oPosY = floor_y end
bowser_bomb_explode(o)
obj_mark_for_deletion(o)
end
end
local id_bhvBombermanBigBomb = hook_behavior(nil, OBJ_LIST_DEFAULT, true, big_bomb_init, big_bomb_loop, "bhvBombermanBigBomb")
local bomb_cooldown = 0
local l_hold_frames = 0
local bigbombframes = 75
local function throw_bomb_update(m)
if m == nil or m.playerIndex ~= 0 or m.controller == nil then return end
if bomb_cooldown > 0 then
bomb_cooldown = bomb_cooldown - 1
end
local b_pressed = (m.controller.buttonPressed & B_BUTTON) ~= 0
local l_held = (m.controller.buttonDown & L_TRIG) ~= 0
if l_held then
l_hold_frames = l_hold_frames + 1
else
l_hold_frames = 0
end
if b_pressed and l_held then
if bomb_cooldown == 0 and m.heldObj == nil then
local use_big_bobomb = l_hold_frames >= bigbombframes
l_hold_frames = 0
local bomb
if use_big_bobomb then
bomb = spawn_sync_object(
id_bhvBombermanBigBomb,
E_MODEL_BOWSER_BOMB,
m.pos.x, m.pos.y + 60, m.pos.z,
function(o)
if o ~= nil and gNetworkPlayers[0] ~= nil then
o.globalPlayerIndex = gNetworkPlayers[0].globalIndex
o.oForwardVel = 40.0
o.oVelY = 15.0
o.oMoveAngleYaw = m.faceAngle.y
end
end
)
else
bomb = spawn_sync_object(
id_bhvBobomb,
E_MODEL_BLACK_BOBOMB,
m.pos.x, m.pos.y + 60, m.pos.z,
function(o) end
)
if bomb ~= nil then
m.heldObj = bomb
bomb.oHeldState = HELD_HELD
bomb.oForwardVel = 40.0
bomb.oVelY = 15.0
bomb.oMoveAngleYaw = m.faceAngle.y
bomb.oHeldState = HELD_THROWN
m.heldObj = nil
end
end
if bomb ~= nil then
set_mario_action(m, ACT_PUNCHING, 0)
bomb_cooldown = 15
end
end
end
end
local BOWSER_HIT_RADIUS = 1500
local bowser_hit_pending = false
local bowser_watch_frames = 0
local king_bobomb_hit_pending = false
local whomp_king_hit_pending = false
local eyerok_hit_pending = false
local function bowser_bomb_explode(o)
if o == nil then return end
spawn_non_sync_object(id_bhvBowserBombExplosion, E_MODEL_BOWSER_FLAMES, o.oPosX, o.oPosY, o.oPosZ,
function(ex)
if ex ~= nil then ex.oTimer = 8 end
end)
spawn_non_sync_object(id_bhvBobombExplosion, E_MODEL_EXPLOSION, o.oPosX, o.oPosY, o.oPosZ,
function(ex)
if ex ~= nil then end
end)
play_sound(SOUND_GENERAL_BOWSER_BOMB_EXPLOSION, gGlobalSoundSource)
set_camera_shake_from_point(SHAKE_POS_LARGE, o.oPosX, o.oPosY, o.oPosZ)
local bowser = obj_get_nearest_object_with_behavior_id(o, id_bhvBowser)
if bowser ~= nil then
local dist = dist_between_objects(o, bowser)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
bowser_hit_pending = true
bowser_watch_frames = 10
end
end
local kingBobomb = obj_get_nearest_object_with_behavior_id(o, id_bhvKingBobomb)
if kingBobomb ~= nil then
local dist = dist_between_objects(o, kingBobomb)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
king_bobomb_hit_pending = true
end
end
local whompKing = obj_get_nearest_object_with_behavior_id(o, id_bhvWhompKing)
if whompKing ~= nil then
local dist = dist_between_objects(o, whompKing)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
whomp_king_hit_pending = true
end
end
local eyerok = obj_get_nearest_object_with_behavior_id(o, id_bhvEyerok)
if eyerok ~= nil then
local dist = dist_between_objects(o, eyerok)
if dist ~= nil and dist < BOWSER_HIT_RADIUS then
eyerok_hit_pending = true
end
end
end
local function bowser_hit_loop(b)
if b == nil then return end
if bowser_hit_pending then
bowser_hit_pending = false
if b.oAction ~= 4 then
if b.oHealth and b.oHealth > 0 then
b.oHealth = b.oHealth - 1
end
if b.oHealth and b.oHealth <= 0 then
b.oAction = 4
else
b.oAction = 12
end
b.oSubAction = 0
b.oTimer = 0
end
end
end
local function king_bobomb_hit_loop(b)
if b == nil then return end
if king_bobomb_hit_pending then
king_bobomb_hit_pending = false
b.oAction = 4
b.oSubAction = 0
b.oTimer = 0
b.oVelY = -5.0
end
end
local function whomp_king_hit_loop(b)
if b == nil then return end
if whomp_king_hit_pending then
whomp_king_hit_pending = false
if b.oHealth and b.oHealth > 0 then
b.oHealth = b.oHealth - 1
end
b.oAction = 3
b.oSubAction = 0
b.oTimer = 0
end
end
local function eyerok_hit_loop(b)
if b == nil then return end
if eyerok_hit_pending then
eyerok_hit_pending = false
if b.oHealth and b.oHealth > 0 then
b.oHealth = b.oHealth - 1
end
b.oAction = 2
b.oSubAction = 0
b.oTimer = 0
end
end
hook_behavior(id_bhvBowser, OBJ_LIST_GENACTOR, false, nil, bowser_hit_loop)
hook_behavior(id_bhvKingBobomb, OBJ_LIST_GENACTOR, false, nil, king_bobomb_hit_loop)
hook_behavior(id_bhvWhompKing, OBJ_LIST_GENACTOR, false, nil, whomp_king_hit_loop)
hook_behavior(id_bhvEyerok, OBJ_LIST_GENACTOR, false, nil, eyerok_hit_loop)
local function big_bomb_init(o)
if o == nil then return end
o.oFlags = OBJ_FLAG_UPDATE_GFX_POS_AND_ANGLE
o.oGravity = 2.5
o.oFriction = 0.8
o.oBuoyancy = 1.3
network_init_object(o, true, {})
end
local function big_bomb_loop(o)
if o == nil or gNetworkPlayers[0] == nil then return end
if o.globalPlayerIndex == nil then
o.globalPlayerIndex = gNetworkPlayers[0].globalIndex
end
if o.globalPlayerIndex ~= gNetworkPlayers[0].globalIndex then return end
o.oVelY = o.oVelY - 2.5
o.oPosX = o.oPosX + o.oForwardVel * sins(o.oMoveAngleYaw)
o.oPosZ = o.oPosZ + o.oForwardVel * coss(o.oMoveAngleYaw)
o.oPosY = o.oPosY + o.oVelY
local floor_y = find_floor_height(o.oPosX, o.oPosY + 100, o.oPosZ)
if floor_y == nil then
floor_y = o.oPosY - 1000
end
if o.oPosY <= floor_y or o.oTimer > 150 then
if o.oPosY < floor_y then o.oPosY = floor_y end
bowser_bomb_explode(o)
obj_mark_for_deletion(o)
end
end
local id_bhvBombermanBigBomb = hook_behavior(nil, OBJ_LIST_DEFAULT, true, big_bomb_init, big_bomb_loop, "bhvBombermanBigBomb")
local bomb_cooldown = 0
local l_hold_frames = 0
local bigbombframes = 75
local function throw_bomb_update(m)
if m == nil or m.playerIndex ~= 0 or m.controller == nil then return end
if bomb_cooldown > 0 then
bomb_cooldown = bomb_cooldown - 1
end
local b_pressed = (m.controller.buttonPressed & B_BUTTON) ~= 0
local l_held = (m.controller.buttonDown & L_TRIG) ~= 0
if l_held then
l_hold_frames = l_hold_frames + 1
else
l_hold_frames = 0
end
if b_pressed and l_held then
if bomb_cooldown == 0 and m.heldObj == nil then
local use_big_bobomb = l_hold_frames >= bigbombframes
l_hold_frames = 0
local bomb
if use_big_bobomb then
bomb = spawn_sync_object(
id_bhvBombermanBigBomb,
E_MODEL_BOWSER_BOMB,
m.pos.x, m.pos.y + 60, m.pos.z,
function(o)
if o ~= nil and gNetworkPlayers[0] ~= nil then
o.globalPlayerIndex = gNetworkPlayers[0].globalIndex
o.oForwardVel = 40.0
o.oVelY = 15.0
o.oMoveAngleYaw = m.faceAngle.y
end
end
)
else
bomb = spawn_sync_object(
id_bhvBobomb,
E_MODEL_BLACK_BOBOMB,
m.pos.x, m.pos.y + 60, m.pos.z,
function(o) end
)
if bomb ~= nil then
m.heldObj = bomb
bomb.oHeldState = HELD_HELD
bomb.oForwardVel = 40.0
bomb.oVelY = 15.0
bomb.oMoveAngleYaw = m.faceAngle.y
bomb.oHeldState = HELD_THROWN
m.heldObj = nil
end
end
if bomb ~= nil then
set_mario_action(m, ACT_PUNCHING, 0)
bomb_cooldown = 15
end
end
end
end