Analysis of a scripting mistake with the parameters of ProjectileData::onCollision that has plagued Blockland for years
Queuenard f241782e56 Most likely cause: T3D stock | 2 months ago | |
---|---|---|
README.md | 2 months ago |
Incorrect packaging of ProjectileData::onCollision has plagued Blockland for years...
This common mistake will make the push broom only able to push players upwards.
I did a search on the files in Kenko's archive and found a huge amount of addons with this issue.
This is an example of correct code:
package gc_MeleePackage
{
function ProjectileData::onCollision(%data, %obj, %col, %fade, %pos, %normal, %velocity)
{
%obj.hitObject = 1;
if (%col.isDodging)
{
%obj.explode();
return;
}
return parent::onCollision(%data, %obj, %col, %fade, %pos, %normal, %velocity);
}
};
This is an example of incorrect code:
package gc_MeleePackage
{
function ProjectileData::onCollision(%data, %obj, %col, %fade, %pos, %normal)
{
%obj.hitObject = 1;
if (%col.isDodging)
{
%obj.explode();
return;
}
return parent::onCollision(%data, %obj, %col, %fade, %pos, %normal);
}
};
The 7th velocity parameter is missing. The default game declares the original function as such:
function ProjectileData::onCollision (%this, %obj, %col, %fade, %pos, %normal, %velocity)
The most likely cause of this longstanding issue is that stock Torque Game Engine does/did not have this parameter, so because Blockland's scripts were obfuscated, developers copied the parameter list out of the Torque 3D manual from 2014:
These addons do it correctly with at least 7 parameters:
Retail/Brick/Brick_Breakable.zip
Server.cs: function ProjectileData::onCollision(%data, %proj, %hit, %a, %hitPos, %hitDir, %start)
Retail/GameMode/Gamemode_Terror_Town.zip
server.cs: function ProjectileData::onCollision(%this,%proj,%hit,%a,%b,%c,%d,%e){
Retail/Item/Item_Conans_Drinks.zip
server.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal, %velocity)
Retail/Item/Item_DPSMeter.zip
server.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal, %vel) {
Retail/Script/Script_MinigamePlusPlus.zip
server.cs: function ProjectileData::onCollision(%this, %proj, %col, %int, %pos, %dir, %pos2)
Retail/Server/Server_MinigamePlusPlus.zip
server.cs: function ProjectileData::onCollision(%this, %proj, %col, %int, %pos, %dir, %pos2)
Retail/Server/Server_ModTerCollision.zip
server.cs: //function ProjectileData::onCollision(%this, %proj, %col, %fade, %pos, %normal, %velocity)
Retail/Support/Support_FastProjectiles.zip
support_staticHitscan.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal, %velocity)
support_staticProjectile.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal, %velocity)
Retail/Weapon/Weapon_NewCreepKill.zip
server.cs:function ProjectileData::onCollision(%a, %b, %c, %d, %e, %f, %g){
Retail/Weapon/Weapon_PaintballGuns.zip
Weapon_PaintballGunBlue.cs: function ProjectileData::onCollision(%this,%proj,%col,%fade,%pos,%normal,%a,%b,%c)
All of these addons do it incorrectly:
Retail/Ai/AI_Archer.zip
AI_MINIArcherstill.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
AI_Archer.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
AI_Archerstill.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
AI_MINIArcher.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Ai/Ai_BadspotPirate.zip
Ai_BadspotPirate.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Ai/Ai_Clockwork.zip
Ai_Clockwork.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Ai/Ai_NaziS.zip
Ai_naziS.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Ai/Ai_Ninja.zip
Ai_Ninja.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Ai/AI_SentryMCT.zip
AI_Turret.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
AI_TurretDP.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Ai/Ai_Soldier_Pack.zip
Ai_Soldier.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Ai_SoldierSMG.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Ai_SoldierSniper.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Ai/Ai_Swordsman.zip
Ai_swordsman.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Event/Event_lastProjectile.zip
LastProj.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%norm)
Retail/Event/Event_SpecialItems.zip
Event_SpecialItems.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/GameMode/Gamemode_BlockBastion.zip
scripts/classes/engineer/type_sentry.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/GameMode/Gamemode_Breaker.zip
game.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/GameMode/Gamemode_Cyblock.zip
Gamemode_Zombie/Zombie_Overwrite.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/GameMode/Gamemode_Stranded.zip
Base.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal)
Retail/GameMode/Gamemode_zombie.zip
Zombie_Overwrite.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Item/Item_SnapBuilds.zip
server.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal){
Retail/Script/Script_Blockrace.zip
Script_classsystem.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal){
Retail/Script/Script_ShapeMaker.zip
server.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Server/Server_Barricade.zip
server.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%norm)
Retail/Support/Support_BulletHoles.zip
BulletDecals.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal)
Retail/System/TezMods_CityRP.zip
Datablocks.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal)
Retail/Tool/Tool_AxePickaxe.zip
server.cs: function ProjectileData::onCollision(%data,%obj,%col,%fade,%pos,%normal)
Retail/Tool/Tool_Props.zip
propcmds.cs: function ProjectileData::onCollision(%data, %player, %col, %fade, %pos, %normal)
Retail/Vehicle/Vehicle_Arrow.zip
Vehicle_Arrow.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Weapon/Weapon_880_Rifle.zip
Ai_SniperNazi.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Weapon/Weapon_Advanced_pack.zip
Support_GenericScripts.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal)
Retail/Weapon/Weapon_C4Explosive.zip
C4.cs: function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%norm)
Retail/Weapon/Weapon_Dueling_Swords.zip
shield.cs: function ProjectileData::onCollision(%data, %obj, %col, %fade, %pos, %normal) {
Retail/Weapon/Weapon_MPSubmachine.zip
Ai_SMGNazi.cs:function ProjectileData::onCollision(%this,%obj,%col,%fade,%pos,%normal)
Retail/Weapon/Weapon_The_New_Halo_Pack.zip
Support_HomingWeapons.cs: function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %normal)
Additionally, these addons with errors were not found in the archive but I encountered these addons in other contexts:
Pirate Adventure - Weapon_FlintlockWeapons/melee.cs
function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %norm)
Pirate Adventure, Crown's Jailbreak, New Year's 2023 and 2024 - Event_AdvHolo/Holograms.cs
function ProjectileData::onCollision(%this, %obj, %col, %fade, %pos, %norm)
To find packages that have a function, run the following:
dumpFunctionsMatch("*", ProjectileData, onCollision);