lawfirm.cc 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /********************************************************************** <BR>
  2. This file is part of Crack dot Com's free source code release of
  3. Golgotha. <a href="http://www.crack.com/golgotha_release"> <BR> for
  4. information about compiling & licensing issues visit this URL</a>
  5. <PRE> If that doesn't help, contact Jonathan Clark at
  6. golgotha_source@usa.net (Subject should have "GOLG" in it)
  7. ***********************************************************************/
  8. #include "player.hh"
  9. #include "objs/def_object.hh"
  10. #include "lisp/li_class.hh"
  11. #include "lisp/li_init.hh"
  12. static li_int_class_member income_rate("income_rate"),
  13. counter("counter"), reset_time("reset_time");
  14. static li_float_class_member commision("commision");
  15. li_object *g1_lawfirm_think(li_object *o, li_environment *env)
  16. {
  17. g1_dynamic_object_class *me=g1_dynamic_object_class::get(li_car(o,env),env);
  18. if (!counter())
  19. {
  20. counter()=reset_time();
  21. int take_away_total=0;
  22. for (int i=0; i<G1_MAX_PLAYERS; i++)
  23. if (i!=me->player_num)
  24. {
  25. int take_away=income_rate();
  26. if (g1_player_man.get(i)->money() + take_away<0)
  27. take_away=-g1_player_man.get(i)->money();
  28. g1_player_man.get(i)->money() += take_away;
  29. take_away_total-=take_away;
  30. }
  31. if (take_away_total>0)
  32. g1_player_man.get(me->player_num)->money() += i4_f_to_i(take_away_total * commision());
  33. }
  34. else counter()--;
  35. me->request_think();
  36. return 0;
  37. }
  38. li_automatic_add_function(g1_lawfirm_think, "lawfirm_think");