Animation-CobCallins: Difference between revisions

From Spring
Jump to navigationJump to search
No edit summary
No edit summary
Line 14: Line 14:


====Killed(severity, corpsetype)====
====Killed(severity, corpsetype)====
Called when the unit is killed. Severity indicates how many percent of the unit's hit points were dealt by the final blow. Corpsetype basically indicates the number of times the unit and its corpses are destroyed; for example, corpsetype = 3 acts as if the unit is destroyed, the corpse is destroyed, and the corpse's corpse is destroyed. If it runs out of corpses nothing is left behind.
Called when the unit is killed. Severity indicates how many percent of the unit's hit points were dealt by the final blow. Corpsetype basically indicates the number of times the unit and its corpses are destroyed; for example, corpsetype = 3 acts as if the unit is destroyed, the corpse is destroyed, and the corpse's corpse is destroyed. If it runs out of corpses nothing is left behind. Set corpsetype to the desired value.


===Movement===
===Movement===
Line 32: Line 32:
===Weapons===
===Weapons===


For weapons, X means either the number of the weapon, or "Primary", "Secondary", or "Tertiary". I recommend using numbers wherever possible.
For weapons, X means either the number of the weapon, or "Primary", "Secondary", or "Tertiary" (don't put "Weapon" for these). I recommend using numbers, since it's cleaner and you can use more than three weapons that way.


====AimWeaponX(heading, pitch)====
====AimWeaponX(heading, pitch)====
Called every ~0.5s when the unit is aiming the weapon at a target. This is used to turn a unit's turrets toward the target. Return 1 when the weapon is ready to fire. Alternately, return 0 if you don't want the weapon to fire (you can use this to disable weapons).
Called every ~0.5s when the unit is aiming the weapon at a target. This is used to turn a unit's turrets toward the target. Return 1 when the weapon is ready to fire. Alternately, return 0 if you don't want the weapon to fire (you can use this to disable weapons).
====AimFromWeaponX(piecenum)====
You should set piecenum to a piece of the model; LOS is traced from the here to the target to see if the weapon can fire.
====QueryWeaponX(piecenum)====
You should set piecenum to a piece of the model. The shot starts from this piece of the model. LOS is also traced from here to the target to see if a weapon can fire. Make sure this is a piece on the weapon's turret. Not doing this right can cause headaches; example: http://trac.caspring.org/wiki/GunsJammingOnShips


====FireWeaponX()====
====FireWeaponX()====
Called whenever the trigger is pulled on a weapon. This occurs before the first shot in a burst (only).
Called whenever the trigger is pulled on a weapon. This occurs before the ''first'' shot in a burst/projectile salvo (only).


====ShotX()====
====ShotX()====
Called before every shot a weapon fires. This includes burst and projectile tags. This happens after FireWeaponX(), even for the first shot.
Called before every shot a weapon fires. This includes burst and projectile tags. This happens after FireWeaponX(), even for the first shot.

Revision as of 21:37, 27 May 2008

Source

Callins are listed near the end of this file: https://spring.clan-sy.com/svn/spring/trunk/rts/Sim/Units/COB/CobFile.cpp

Callins

General

Create()

Called when the unit is created (not finished).

Activate()/Deactivate()

Called when the unit is turned on/off.

Killed(severity, corpsetype)

Called when the unit is killed. Severity indicates how many percent of the unit's hit points were dealt by the final blow. Corpsetype basically indicates the number of times the unit and its corpses are destroyed; for example, corpsetype = 3 acts as if the unit is destroyed, the corpse is destroyed, and the corpse's corpse is destroyed. If it runs out of corpses nothing is left behind. Set corpsetype to the desired value.

Movement

StartMoving()/StopMoving()

Called when the unit starts/stops moving. This includes rotation, so don't be surprised if StartMoving() sometimes gets called when a unit starts aiming at a target.

SetSFXOccupy(terraintype)

Supposedly called when the unit changes terrain type, although it didn't work last time I tried it? Maybe I was using it wrong. terraintype: 0 = transported, 1 = sea, 2 = deep sea (greater than 5 water depth and unit is upright), 4 = land.

SetDirection(direction)

Used only for wind generators. Gives the direction of the wind.

SetSpeed(speed)

Used for wind generators, tidals, and mexes. Basically more resources = higher speed.

Weapons

For weapons, X means either the number of the weapon, or "Primary", "Secondary", or "Tertiary" (don't put "Weapon" for these). I recommend using numbers, since it's cleaner and you can use more than three weapons that way.

AimWeaponX(heading, pitch)

Called every ~0.5s when the unit is aiming the weapon at a target. This is used to turn a unit's turrets toward the target. Return 1 when the weapon is ready to fire. Alternately, return 0 if you don't want the weapon to fire (you can use this to disable weapons).

AimFromWeaponX(piecenum)

You should set piecenum to a piece of the model; LOS is traced from the here to the target to see if the weapon can fire.

QueryWeaponX(piecenum)

You should set piecenum to a piece of the model. The shot starts from this piece of the model. LOS is also traced from here to the target to see if a weapon can fire. Make sure this is a piece on the weapon's turret. Not doing this right can cause headaches; example: http://trac.caspring.org/wiki/GunsJammingOnShips

FireWeaponX()

Called whenever the trigger is pulled on a weapon. This occurs before the first shot in a burst/projectile salvo (only).

ShotX()

Called before every shot a weapon fires. This includes burst and projectile tags. This happens after FireWeaponX(), even for the first shot.