Share Pastebin
Guest
Public paste!

Untitled

By: a guest | Mar 18th, 2010 | Syntax: None | Size: 1.36 KB | Hits: 40 | Expires: Never
Copy text to clipboard
  1. //! zinc
  2.  
  3. library Footman {      
  4.  
  5.     struct Footman {    
  6.         unit u;
  7.         real x;
  8.         real y;
  9.        
  10.         static method create (unit u) -> thistype {
  11.             thistype f = Footman.allocate();
  12.             f.u = u;
  13.             f.x = GetUnitX();
  14.             f.y = GetUnitY();
  15.             return f;
  16.         }
  17.        
  18.         method Kill() {
  19.             KillUnit(this.u);
  20.         }
  21.        
  22.         method ScrambleLocation() {
  23.              SetUnitX( this.u, this.x + GetRandomReal(0,100) );
  24.              SetUnitY( this.u, this.y + GetRandomReal(0,100) );
  25.              
  26.        
  27.         }        
  28.     }    
  29.    
  30.     Footman foot;
  31.    
  32.     function ChatHandlerAction() {
  33.         foot.Kill();
  34.     }
  35.    
  36.     function SChatHandlerAction(){
  37.         foot.ScrambleLocation();
  38.         }
  39.    
  40.    
  41.     function onInit() {
  42.         trigger chatHandler = CreateTrigger();
  43.         trigger scramblerChatHandler = CreateTrigger();
  44.         TriggerRegisterPlayerChatEvent( chatHandler, Player( 0 ), "kill", true );
  45.         TriggerRegisterPlayerChatEvent( scramblerChatHandler, Player( 0 ), "scramble", true );
  46.         TriggerAddAction( chatHandler, function ChatHandlerAction );
  47.         TriggerAddAction( scramblerChatHandler, function SChatHandlerAction );
  48.        
  49.         foot = Footman.create( gg_unit_hfoo_0001 );
  50.     }
  51. }
  52.  
  53. //! endzinc