Gamesnert Posted June 16, 2008 Share Posted June 16, 2008 I have a server that is INTENDED to become a army vs. criminals server. But the army's rhino is just indestructible except for flame damage. Is it possible to make it a lot more vulnerable to specific weapon kinds? F.e. Rockets and Hunter's machinegun for a bit? Link to comment
robhol Posted June 16, 2008 Share Posted June 16, 2008 the event "onVehicleDamage" MIGHT help, but I'm not sure if it registers as damage unless you do use fire... worth a shot. Of course, specializing it to one or two weps only will take some doing, but if I'm not mistaken, explosions should work too? Link to comment
Gamesnert Posted June 16, 2008 Author Share Posted June 16, 2008 Explosions do not work, that's the problem. Oh well, i'll try your trick tomorrow. Any other suggestions are welcome in the meantime. Link to comment
tma Posted June 16, 2008 Share Posted June 16, 2008 Can't you just trap the onVehicleDamage() event and use the 'loss' parameter passed in to further increase the damage by using setElementHealth() ? Link to comment
Gamesnert Posted June 17, 2008 Author Share Posted June 17, 2008 (edited) Hmmm... I'll try. But I think there will still be a problem concerning what RobHol said: "but I'm not sure if it registers as damage unless you do use fire..." Honestly, I don't think so. But never shot, never hit. So I'll try. EDIT: I fear I was right... It doesn't get any damage at all, only from flames that get out of rockets when fired at close range, flamethrower/molotov or bad driving... Even satchel charges can't destroy a Rhino. So anyone got another idea? Edited June 17, 2008 by Guest Link to comment
Winky Posted June 17, 2008 Share Posted June 17, 2008 onClientPlayerFire can detect wich element is hit... Link to comment
Gamesnert Posted June 17, 2008 Author Share Posted June 17, 2008 I can't find out how I can let it check for if a rocket launcher hits it. It's projectile as well as weapon don't seem to function with onClientPlayerWeaponFire. And what if it detected it has been hit? How do I let that vehicle(rhino) get damage? Link to comment
tma Posted June 17, 2008 Share Posted June 17, 2008 I'm confused. Your're right about it doesn't work - but it does sometimes ? I put this in server-side: addEventHandler("onVehicleDamage",getRootElement(), function(loss) setElementHealth(source,0) end ) and I can punch a tank to make it instantly burn. I can hit it with a rocket but only at close quarter; I can't hit it with an AK47 at all ? Is this event bugged or does it only consistently work for car collisions ? (i.e. not being shot at). Or is this problematic because firing is essentially client-side and this event is server-side ? Link to comment
Mr.Hankey Posted June 17, 2008 Share Posted June 17, 2008 i think it's just that like in other games (e.g Crysis) bullets just have no effect on tanks at all... Link to comment
Gamesnert Posted June 17, 2008 Author Share Posted June 17, 2008 TMA's code indeed is a little... Sensitive Luckily it is still invulnerable to Miniguns, what I would like to keep. They just need to get damage from the rockets. Not being destroyed with 1 rocket... That's pretty retarded. So anyone got an idea of making it a little less retarded? And for Rhino only? Thanks. Link to comment
tma Posted June 17, 2008 Share Posted June 17, 2008 Something like this would double the damage on the rhino (untested): addEventHandler("onVehicleDamage",getRootElement(), function(loss) if getVehicleID(source) == 432 then setElementHealth(source,getElementHealth(source) - loss) end end ) Link to comment
50p Posted June 18, 2008 Share Posted June 18, 2008 I haven't tried so I can't say it will work for tanks: http://development.mtasa.com/index.php? ... amageProof This functions makes a vehicle damage proof, so it won't take damage from bullets, hits, explosions or fire. It seems that tank is not DamageProof, but maybe it will change the tanks stats. Link to comment
Gamesnert Posted June 18, 2008 Author Share Posted June 18, 2008 Something like this would double the damage on the rhino (untested): addEventHandler("onVehicleDamage",getRootElement(), function(loss) if getVehicleID(source) == 432 then setElementHealth(source,getElementHealth(source) - loss) end end ) Great! Now the flames atleast can stop it in notime! Only problem now still is how to make it destructable for other weapons... Thanks anyway, the server will atleast improve a quite a bit from this. Thanks. But still looking for another script though. And of the setVehicleDamageProof: it didn't work... Link to comment
eAi Posted June 18, 2008 Share Posted June 18, 2008 We may be able to make the event triggered for bullets vs the tank. Link to comment
Gamesnert Posted June 18, 2008 Author Share Posted June 18, 2008 So the Rhino does get damage from much, except for bullets? Link to comment
Gamesnert Posted August 5, 2008 Author Share Posted August 5, 2008 I now understand how they did it in battlefield 69. A bit of a laugh though... LOL. They pasted a RC cam on the tank... Here's the (partial) code: addEventHandler ("onVehicleEnter", root, function ( player, seat, jacked ) if getVehicleID(source) == 476 then triggerClientEvent (player, "rustlerEnter", player ) local x, y, z = getElementPosition(source) local rotX, rotY, rotZ = getVehicleRotation(source) bomb1 = createObject( 3790, x, y, z - 1, rotZ - 90, rotY, rotZ) attachElementToElement (bomb1, source, 0, 0, -1.2, 0, 0, -1.5 ) elseif getVehicleID(source) == 432 then local x, y, z = getElementPosition (source) if not (pot[source]) then pot[source] = createVehicle (594, x + 3, y, z) attachElementToElement (pot[source], source, 0, 4, 0.5, 0, 0, 0) setElementParent (pot[source], source) setElementHealth (pot[source], 2000) setElementHealth (source, 2000) setElementAlpha (pot[source], 0) end triggerClientEvent (getVehicleOccupant(source), "damageVehicle", source ) triggerClientEvent (getVehicleOccupant(source), "enterRhino", source ) elseif getVehicleID(source) == 520 or getVehicleID(source) == 425 then triggerClientEvent (getVehicleOccupant(source), "enterRhino", source ) elseif getVehicleID(source) == 578 then if getTeamName(getPlayerTeam(player)) == "Ally" then for k,v in pairs(axisBlip) do setElementVisibleTo(v, root, true) end elseif getTeamName(getPlayerTeam(player)) == "Axis" then for k,v in pairs(allyBlip) do setElementVisibleTo(v, root, true) end end end end) addEventHandler ("onVehicleDamage", getRootElement(), function (loss) if getVehicleID(source) == 594 then local tank = getElementParent (source) if ( getVehicleOccupant(tank) ~= false ) then triggerClientEvent (getVehicleOccupant(tank), "damageVehicle", source, loss ) end setElementHealth (tank, getElementHealth(source)) end end) Also the solution to how to let the Rhino's front lights work... LOL. Link to comment
Ace_Gambit Posted August 6, 2008 Share Posted August 6, 2008 Here's a simple alternative to make a rhino receive damage from explosions. EFFECTIVE_RANGE = 10 EXPLOSION_DAMAGE = 5 function onClientExplosion(x, y, z, type) 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 addEventHandler("onClientExplosion", getRootElement(), onClientExplosion, true) Link to comment
Gamesnert Posted August 6, 2008 Author Share Posted August 6, 2008 Client side? Can it be server side? Anyway, looks allright. I'll see what I'll do against Rhinoesh > Link to comment
Ace_Gambit Posted August 6, 2008 Share Posted August 6, 2008 Client side? Can it be server side? Anyway, looks allright. I'll see what I'll do against Rhinoesh > Yes, that is kind of an issue with this code. But I'll put my thinking hat on and see what I can do to make this work for all clients. Link to comment
haybail Posted August 6, 2008 Share Posted August 6, 2008 I was going to say, isnt that easy? you just put a triggerServerSide before setElementHealth. but that would be very bad, if there were 20 people nearby one explosion maybe you could put a cooldown serverside to ignore all the extra incoming clients. Link to comment
Ace_Gambit Posted August 6, 2008 Share Posted August 6, 2008 Forget what I said earlier. This code might actually work since the onClientExplosion event seems to trigger for the creators' view port only and setElementHealth is synchronized for both client and server code. EDIT: I did some testing (with 2 computers) and the damage factor is applied only once because the explosion event is not triggered when the creator is not the local player (or at least initiator). Link to comment
Ace_Gambit Posted August 6, 2008 Share Posted August 6, 2008 So that means..? This means that when a player is firing a rocket at the tank it will receive damage once (from that particular rocket). And damage caused by an explosion is synchronized meaning that you do not need an explicit server side call to set the tanks' health. EDIT: So basically this is all the code you need to provide very basic support for controlled tank damage. Client EFFECTIVE_RANGE = 10 EXPLOSION_DAMAGE = 5 BULLET_DAMAGE = 10 function onClientExplosion(x, y, z, type) 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 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) Server DAMAGE_LOSS = 5 function onVehicleDamage(loss) local health = 0 if (isElement(source)) then health = getElementHealth(source) or 0 if (health - DAMAGE_LOSS > 0) then setElementHealth(hitElement, health - DAMAGE_LOSS) end end end addEventHandler("onVehicleDamage", getRootElement(), onVehicleDamage, true) Link to comment
Gamesnert Posted October 11, 2008 Author Share Posted October 11, 2008 Ok so I have been using this for a while now, but now since I do it on a public server, I see it doesn't work most of the time... The rhino's can only damage themselves on this server, while on my own it worked correctly... I've been trying to edit things, resetting to default, reediting again, resetting, editing and nothing actually helped... Any ideas? =/ I'm also doing different damage per type, but well that's not a thing to worry about... I more would like to know why this doesn't work... =/ Link to comment
Ace_Gambit Posted October 11, 2008 Share Posted October 11, 2008 (edited) Ok so I have been using this for a while now, but now since I do it on a public server, I see it doesn't work most of the time... The rhino's can only damage themselves on this server, while on my own it worked correctly...I've been trying to edit things, resetting to default, reediting again, resetting, editing and nothing actually helped... Any ideas? =/ I'm also doing different damage per type, but well that's not a thing to worry about... I more would like to know why this doesn't work... =/ Yeah, I feel your pain. I think I know what the problem is. It seems like (but I am not 100% sure) onClientExplosion is only triggered if you are the creator of the explosion (which in a way does make sense). I never thought about it. Edited October 11, 2008 by Guest Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now