Author Topic: Extra weapon function?  (Read 532 times)

I am working on a weapon that moves a player to a special bricks when that weapon kills them, but I am unswore as to how to best add this, I have the coding mainly done fore it but I don't know this one thing:
Code: [Select]
...stateAllowImageChange[5]        = false;
stateWaitForTimeout[5] = true;
stateSequence[5]                = "StopFire";
stateScript[5]                  = "onStopFire";


};

function THEWEPONImage::onXXXXXXX(%target)............
Firstly this is at the end of the script the function section, is this the right place to put the extra coding?

And the other thing is the place I have marked "onXXXXXXX" what should this be (e.g ontargethit, onplayerhit)

The WeaponImage:: functions are usually called from the state scripts you have set. For instance, you have the script for state five there set as onStopFire, which will call ::onStopFire. The ::onFire one is special as a default one has been defined for most weapons - if you set the state script to "onFire" but don't define your own function for it, the default script will spawn a projectile in a straight line belonging to you from the weapon's muzzle point with nothing extra like spread or burst fire.

The arguments to the stateScript functions are always %this (the weapon image datablock), %obj (the player or object who fired it) and %slot. (the slot the image is mounted to, typically 0 for normal use items)

Oh I see now. That just leaves one thing I need to know well two acutely, I have been rifting through a few other codes but none of them affect a player target they all affect bricks so:
Code: [Select]
function THEWEPONprojectile::oncollision(%this,%obj,%col,%fade,%pos,%normal)How should I change this the oncollishon to mean to mean on victim hit?

And all the (%this,%obj,%col,%fade,%pos,%normal) Which one is the player target you hit?


Change it to ProjectileData::damage(%this,%obj,%col,%fade,%pos,%normal) or ProjectileData::radiusDamage(%this, %obj, %col, %distanceFactor, %pos, %damageAmt) (for weapons with a radius damage set) so it automatically checks whether you're damageable/in the same minigame. Look here for an example of the default damage functions.

ProjectileData::damage
%this = projectile datablock
%obj = projectile object
%col = object being damaged
%fade = is the projectile in its 'fade' cycle (the fadeDelay parts in the projectile)
%pos = collision position
%normal = 3-vector perpendicular to the surface it hits

ProjectileData::radiusDamage
%this = projectile datablock
%obj = projectile object
%col = object being damaged
%distanceFactor = ratio of distance to object to explosion to explosion radius (damage or apply effects for less time if you're further away e.g. burning)
%pos = explosion center
%damageAmt = explosion's radius damage (multiply by distance factor for usual applied damage)