home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 56 / CDPowerplay56Disc2.iso / demos / blade / data1.cab / Program_Executable_Files / Lib / Change.py < prev    next >
Encoding:
Text File  |  2000-10-27  |  2.2 KB  |  85 lines

  1. import Bladex
  2. import Actions
  3.  
  4. def ChangeObject(person,object,finish_func):
  5.     char = Bladex.GetEntity (person)
  6.     char.Data.obj_used = object
  7.     char.Data.hand = 0
  8.     char.Data.FinishAnm = finish_func    
  9.  
  10.     if char.InvRight == "":
  11.         GetObject(person)
  12.     else:
  13.         if Actions.IsRightHandStandardObject(person):
  14.             GetObject(person)
  15.             if Actions.TryDropRight(person):    
  16.                 Actions.DropReleaseEventHandler(person, "DropRightEvent")
  17.             #if not char.InvRight:
  18.             
  19.         else:
  20.             char.AddAnmEventFunc("ChangeREvent",Actions.ToggleWEvent)            
  21.             char.LaunchAnmType("Chg_r")    
  22.             char.Data.o_hand = char.InvRight
  23.             char.Data.hand = 1
  24.             char.AnmEndedFunc=GetObject
  25.  
  26. def GetObject(entity):    
  27.     char = Bladex.GetEntity(entity)
  28.     #char.LaunchAnmType("bag")
  29.     #char.AddAnmEventFunc("ChangeREvent",GetingFetiche)
  30.     char.AddAnmEventFunc("ChangeREvent",GetingObject)
  31.     if char.Kind[0] == "D":
  32.         char.LaunchAnmType("Dwf_bag")
  33.     else:
  34.         char.LaunchAnmType("Kgt_bag")
  35.  
  36.  
  37. def GetingObject(entity,event):
  38.     char = Bladex.GetEntity(entity)
  39.     inv = char.GetInventory()                
  40.     inv.LinkRightHand(char.Data.obj_used)
  41.     char.AnmEndedFunc=FinishAnm
  42.     
  43. def FinishAnm(entity):
  44.     char = Bladex.GetEntity(entity)
  45.     char.Data.FinishAnm(entity,char.Data.obj_used)
  46.  
  47. def Keep(ent,event):
  48.     char = Bladex.GetEntity(ent)
  49.     inv = char.GetInventory()
  50.     inv.LinkRightHand("None")
  51.  
  52.  
  53. def Toggle(ent,event):
  54.     Actions.ToggleWEvent(ent,"ChangeREvent")
  55.     #char = Bladex.GetEntity(ent)
  56.     #inv = char.GetInventory()    
  57.     #inv.LinkRightHand(char.Data.o_hand)
  58.  
  59. def RestoreHand(entity,launch):
  60.     char = Bladex.GetEntity(entity)
  61.     inv = char.GetInventory()
  62.  
  63.     if (launch):
  64.         if (launch == 2):
  65.             object = Bladex.GetEntity(char.InvRight)            
  66.             impulse = char.Rel2AbsVector(-1000.0 * object.Mass, -1000.0 * object.Mass, 0.0)
  67.             object.Impulse(impulse[0],impulse[1],impulse[2])
  68.  
  69.         if (char.Data.hand):
  70.             char.LaunchAnmType("Chg_r")
  71.             char.AddAnmEventFunc("ChangeREvent",Toggle)
  72.  
  73.         inv.RemoveObject(char.InvRight)
  74.     else:
  75.         if (char.Data.hand):
  76.             char.LaunchAnmType("Chg_r")
  77.             char.AddAnmEventFunc("ChangeREvent",Toggle)
  78.         else:
  79.             if char.Kind[0] == "D":
  80.                 char.LaunchAnmType("Dwf_bag")
  81.             else:
  82.                 char.LaunchAnmType("Kgt_bag")
  83.             char.AddAnmEventFunc("ChangeREvent",Keep)
  84.  
  85.     inv.LinkRightHand("None")