User Tools

Site Tools


crpl:docs:destroy

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
crpl:docs:destroy [2013/02/04 08:49] – Format changes grauniadcrpl:docs:destroy [2021/02/05 11:43] (current) – Rmoved discussion tag Karsten75
Line 1: Line 1:
-~~DISCUSSION~~+
 <- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#unit_commands|Unit Commands]] <- [[crpl:crplreference| CRPL reference]] <- [[crpl:crplreference#unit_commands|Unit Commands]]
 =====  Destroy  ===== =====  Destroy  =====
  
 ^ Arguments ^ Result ^ Notation ^ ^ Arguments ^ Result ^ Notation ^
-|Unit UID to Destroy, Explosion Mode (0,1,2)| |%%n1 n2--%%|+|Unit UID to Destroy, Explosion Mode (0,1,2,3)| |''n1 n2 --''|
  
  
Line 11: Line 11:
 WARNING: ENSURE YOU HAVE SAVED THE MAP BEFORE CALLING THIS!  WARNING: ENSURE YOU HAVE SAVED THE MAP BEFORE CALLING THIS! 
 This call will destroy the unit!  This call will destroy the unit! 
-For the explosion mode argument,  0 means no explosion,  +For the explosion mode argument,  0 means no explosion and no sound,  
-1 means a small soundless flash, 2 or higher means a full explosion with sound.+1 means a small soundless flash, 2 means a full explosion with sound, 3 means full explosion but no sound. 
 + 
 +**Note:** If Destroy is called on SELF, the script will stop at that line. Any code after won't be executed. 
 + 
 +<color #ed1c24>Bug warning:</color> There is some issue when deleting a docked guppy or a guppy base, the Destroy function is called again on the next pair of numbers on the stack and can potentially destroy another unit! I recommend using the SafeDestroy function from the example when deleting guppies, strafers or bobmers just to be safe.
 === Examples === === Examples ===
-<code>+<code prpl>
 $targetX:0 $targetX:0
 $targetY:0 $targetY:0
Line 21: Line 25:
  
 once once
- self CONST_CREATEPZ 0 SetUnitAttribute + SetUnitAttribute(self CONST_CREATEPZ false) 
- <-targetX <-targetY <-speed QueueMove+ QueueMove(<-targetX <-targetY <-speed)
 endonce endonce
  
-GetQueuedMoveCount eq0 if+if (GetQueuedMoveCount eq0)
  #Done  #Done
- self 0 Destroy+ Destroy(self 2)
   
- CurrentCoords <-payload SetCreeper+ SetCreeper(CurrentCoords <-payload)
 endif endif
 +
 +# Gets around the bug with guppies and works for other units as well
 +:SafeDestroy # uid mode -
 +    ->SD_Mode
 +    ->SD_Uid
 +    StackSize ->SD_Size # stack size without the arguments
 +    -1 -1 # extra pair of arguments to be consumed if needed
 +    <-SD_Uid <-SD_Mode Destroy # this may or may not consume the additinal arguments
 +    StackSize <-SD_Size do # remove extra arguments if not consumed by Destroy
 +        pop
 +    loop
 </code>  </code> 
crpl/docs/destroy.1359985774.txt.gz · Last modified: 2014/10/01 15:02 (external edit)