Author Topic: Make vehicle kill players and other vehicles when going above a certain speed  (Read 825 times)

Basically a function to kill players or vehicles that collide with a vehicle if that vehicle is going above a set speed.
I've been loving around with onCollision but the results are very unreliable. I tried this:

Code: [Select]
function LegoFreightvehicle::onCollision(%this, %obj, %col, %vec, %vecLen)
{
%speed2 = vectorLen(%obj.getVelocity());
if(minigameCanDamage(%col,%obj) && isObject(%Col.Client.player) && %speed2 > 5)
{
%Col.kill();
%col.addVelocity("0 0 10");
}
if(%Col.getclassname() $= "AiPlayer")
{
%Col.kill();
%col.addVelocity("0 0 10");
}
if(%Col.getclassname() $= "Armor")
{
%Col.kill();
}
return parent::onCollision(%this, %obj, %col, %vec, %vecLen);
}

Right now it instakills any bots that walk into it, however it only occasionally kills players (the threshold was too high, players work reliably now) and it never kills vehicles.
Thanks in advance.
« Last Edit: January 23, 2017, 03:17:12 PM by TheArmyGuy »

have it check
strPos(%col.getClassName(), "Vehicle") >= 0
and call %col.setDamagePercent(1); or if that isnt a valid function %col.setDamageLevel(%col.getDatablock().maxDamage);

have it check
strPos(%col.getClassName(), "Vehicle") >= 0
and call %col.setDamagePercent(1); or if that isnt a valid function %col.setDamageLevel(%col.getDatablock().maxDamage);
The last thing works, except it sets stuff on fire instead of just instantly blowing it up :(

The last thing works, except it sets stuff on fire instead of just instantly blowing it up :(
add 1 to the damage value and maybr just do vehicle.damage(val)

For some reason vehicles set on fire (not explode) when you set their HP at 0. The best way to do this is:
%vehicle.damage(%source, %position, getWord(%vehicle.getScale(), 2) * %vehicle.getDatablock().maxDamage, %damageType);

If this still does the same process just add 1 to the damage in the 3rd argument in the code I said above.
   -> %vehicle.damage(%source, %position, getWord(%vehicle.getScale(), 2) * %vehicle.getDatablock().maxDamage + 1, %damageType);