Jump to content

Rhino: Making it more fragile


Recommended Posts

I'll put my thinking hat on and let you know :mrgreen: .

EDIT

Ok, this is what I came up with. It may not be the best solution but it gets the job done. What I basically did is delegate the explosion event to the server script. The full modified code is listed below. You'll notice I didn't make any significant changes, just moved the code to the body of the server script.

Server

  
EFFECTIVE_RANGE = 10 
EXPLOSION_DAMAGE = 5 
  
function onClientExplosion(x, y, z) 
  local tX, tY, tZ = 0, 0, 0 
  local distance3D = 0 
  local health = 0 
  local damage = 0 
  for _, vehicle in ipairs((getElementsByType("vehicle", getRootElement()) or {})) do 
    if (getVehicleID(vehicle) == 432) then 
      tX, tY, tZ = getElementPosition(vehicle) 
      health = getElementHealth(vehicle) or 0 
      distance3D = getDistanceBetweenPoints3D(x, y, z, tX, tY, tZ) or 0 
      if (distance3D < EFFECTIVE_RANGE) then 
        damage = EXPLOSION_DAMAGE * (EFFECTIVE_RANGE - distance3D) 
        if (health - damage > 0) then 
          setElementHealth(vehicle, health - damage) 
        end 
      end 
    end 
  end 
end 
  
addEvent("onClientExplosion", true) 
addEventHandler("onClientExplosion", getRootElement(), onClientExplosion) 
  

Client

  
BULLET_DAMAGE = 10 
  
function onClientExplosion(x, y, z, type) 
  local vehicle = false 
  if (getElementType(source) == "player") then 
    vehicle = getPlayerOccupiedVehicle(source) 
    if (vehicle) then 
      if (getVehicleID(vehicle) == 432 and getVehicleController(vehicle) == getLocalPlayer()) then 
        triggerServerEvent("onClientExplosion", getRootElement(), x, y, z) 
      end 
    end 
  end 
end 
  
function onClientPlayerWeaponFire(weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement) 
  local health = 0 
  if (isElement(hitElement)) then 
    if (getElementType(hitElement) == "vehicle") then 
      if (getVehicleID(hitElement) == 432) then 
        health = getElementHealth(hitElement) or 0 
        if (health - BULLET_DAMAGE > 0) then 
          setElementHealth(hitElement, health - BULLET_DAMAGE) 
        end 
      end 
    end 
  end 
end 
  
addEventHandler("onClientExplosion", getRootElement(), onClientExplosion, true) 
addEventHandler("onClientPlayerWeaponFire", getLocalPlayer(), onClientPlayerWeaponFire, false) 
  

Link to comment

Ok, I have it now and looks good. However, again I only tested it alone... =/

If it doesn't work, I use the RC Cam method. (which I actually already made today until I saw your post... xD)

Anyway, Rhino's seem balanced now compared to other vehicles. Now I only yet have to solve Anti-Tank balance. But that's none of the community's worries. :P

EDIT: Ok, it's getting more and more balanced! Thanks Ace, the gamemode is playable now beside some huge bugs :P

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...