Changeset 126


Ignore:
Timestamp:
Mar 18, 2008, 11:22:51 PM (14 years ago)
Author:
Sam Hocevar
Message:
  • Implement game_object::set_tint, get_tint, set_team and get_team, as well as the corresponding set_object_tint, get_object_tint, set_object_team and get_object_team LISP functions. They'll be useful for CTF mode.

Inspired by Abuse Win32 changelog from February 18, 2001:

  • Changed lisp function (set_player_color x) to

(set_object_tint x)

  • Added lisp function (get_object_tint)

Inspired by Abuse Win32 changelog from February 17, 2001:

  • Added lisp function (set_player_color x) to switch player

to color number x
see chat.lsp for details

Location:
abuse/trunk/src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • abuse/trunk/src/clisp.cpp

    r124 r126  
    127127  l_fields=make_find_symbol("fields");
    128128  l_FIRE=make_find_symbol("FIRE");
    129   l_fire_object=make_find_symbol("fire_object");
    130129  l_fire_object=make_find_symbol("fire_object");
    131130  l_cop_dead_parts=make_find_symbol("cop_dead_parts");  set_symbol_value(l_difficulty,l_hard);
     
    484483  add_c_bool_fun("time_for_next_level",0,0,   293);
    485484  add_c_bool_fun("reset_kills",0,0,           294);
    486   add_c_bool_fun("set_game_name",1,1,         295);  // name
     485  add_c_bool_fun("set_game_name",1,1,         295);  // server game name
    487486  add_c_bool_fun("set_net_min_players",1,1,   296);
     487
     488  add_c_bool_fun("set_object_tint", 1, 1,    1001);  // set_object_tint
     489  add_c_function("get_object_tint", 0, 0,    1002);  // get_object_tint
     490  add_c_bool_fun("set_object_team", 1, 1,    1003);  // set_object_team
     491  add_c_function("get_object_team", 0, 0,    1004);  // get_object_tint
    488492
    489493
     
    23202324        main_net_cfg->min_players=lnumber_value(CAR(args));
    23212325    } break;
    2322 
    2323 
     2326    case 1001: // (set_object_tint)
     2327      if(current_object->Controller)
     2328        current_object->Controller->set_tint(lnumber_value(CAR(args)));
     2329      else
     2330        current_object->set_tint(lnumber_value(CAR(args)));
     2331      break;
     2332    case 1002: //(get_object_tint)
     2333      if(current_object->Controller)
     2334        return current_object->Controller->get_tint();
     2335      else
     2336        return current_object->get_tint();
     2337      break;
     2338    case 1003: //(set_object_team)
     2339      if(current_object->Controller)
     2340        current_object->Controller->set_team(lnumber_value(CAR(args)));
     2341      else
     2342        current_object->set_team(lnumber_value(CAR(args)));
     2343      break;
     2344    case 1004: //(get_object_team)
     2345      if(current_object->Controller)
     2346        return current_object->Controller->get_team();
     2347      else
     2348        return current_object->get_team();
     2349      break;
    23242350    default :
    23252351      printf("Undefined c function %ld\n",number);
  • abuse/trunk/src/cop.cpp

    r124 r126  
    755755      p_ref r1(ret);
    756756
    757       push_onto_list(new_lisp_number(bot->controller()->player_number),ret);
     757      push_onto_list(new_lisp_number(bot->get_tint()),ret);
    758758
    759759      if (bot->lvars[special_power]==SNEAKY_POWER)
    760760      {
    761761    if (bot->lvars[used_special_power]==0)
    762       player_draw(top_just_fired,bot->controller()->player_number);
     762      player_draw(top_just_fired,bot->get_tint());
    763763    else if (bot->lvars[used_special_power]<15)
    764764      o->draw_trans(bot->lvars[used_special_power],16);
     
    818818    {
    819819      case NO_POWER :
    820       { player_draw(just_fired,o->controller()->player_number); } break;
     820      { player_draw(just_fired,o->get_tint()); } break;
    821821
    822822      case HEALTH_POWER :
    823823      {
    824     player_draw(just_fired,o->controller()->player_number);
     824    player_draw(just_fired,o->get_tint());
    825825    if (o->controller() && o->controller()->local_player())
    826826      cache.img(S_health_image)->put_image(screen,o->controller()->cx2-20,
     
    842842    }
    843843
    844     player_draw(just_fired,o->controller()->player_number);
     844    player_draw(just_fired,o->get_tint());
    845845    o->state=(character_state)old_state;
    846846    if (o->controller() && o->controller()->local_player())
     
    862862    }
    863863
    864     player_draw(just_fired,o->controller()->player_number);
     864    player_draw(just_fired,o->get_tint());
    865865    o->state=(character_state)old_state;
    866866
     
    872872      {
    873873    if (o->lvars[used_special_power]==0)
    874       player_draw(just_fired,o->controller()->player_number);
     874      player_draw(just_fired,o->get_tint());
    875875    else if (o->lvars[used_special_power]<15)
    876876      o->draw_trans(o->lvars[used_special_power],16);
     
    10211021    for (i=0;i<tp;i++)
    10221022    {
    1023       int color=lnumber_value(lget_array_element(symbol_value(l_player_text_color),sorted_players[i]->player_number));
     1023      int color=lnumber_value(lget_array_element(symbol_value(l_player_text_color),sorted_players[i]->get_tint()));
    10241024      sprintf(msg,"%3ld %s",(long)sorted_players[i]->kills,sorted_players[i]->name);
    10251025      if (sorted_players[i]==local)
     
    10621062  {
    10631063    enum { NAME_LEN=18 } ;
    1064     int color=lnumber_value(lget_array_element(symbol_value(l_player_text_color),v->player_number));
     1064    int color=lnumber_value(lget_array_element(symbol_value(l_player_text_color),v->get_tint()));
    10651065    char max_name[NAME_LEN];
    10661066    strncpy(max_name,v->name,NAME_LEN-1);
  • abuse/trunk/src/extend.cpp

    r124 r126  
    6363  for (int i=0;i<tobjs;i++) if (objs[i]==o) return;
    6464  o->set_flags(o->flags()|KNOWN_FLAG);
     65  if(_team != -1)
     66    o->set_team(_team);
     67  if(_tint != -1)
     68    o->set_tint(_tint);
    6569  tobjs++;
    6670  objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"Object list");
     
    126130  Aistate=Aistate_time=0;
    127131  Hp=Mp=Fmp=0;
     132  _tint = -1;
     133  _team = -1;
    128134  grav_on=1;
    129135  targetable_on=1;
  • abuse/trunk/src/extend.hpp

    r124 r126  
    3232class simple_object
    3333{
    34   public :
     34public:
    3535  int8_t Fade_dir;
    3636  uint8_t Fade_count,Fade_max;
     
    4242  uint16_t Hp,Mp,Fmp;
    4343  int8_t Frame_dir;
    44 
     44  int _tint, _team;
    4545
    4646  uint8_t tobjs,tlights;
  • abuse/trunk/src/innet.cpp

    r124 r126  
    523523                strcpy(f->next->name,join_list->name);
    524524                o->set_controller(f->next);
    525            
     525                f->next->set_tint(f->next->player_number);
    526526                if (start)
    527527                current_level->add_object_after(o,start);
  • abuse/trunk/src/objects.cpp

    r124 r126  
    442442}
    443443
    444 int game_object::can_hurt(game_object *who)     // collision checking will ask first to see if you
    445 {
    446   int is_attacker=current_level->is_attacker(this);
    447   // it's you against them!  Damage only if it you are attacking or they are attacking you
    448   // I.E. don't let them hurt themselves, this can change if you over-ride this virtual function
    449 
    450   if (who->hurtable() && (is_attacker || current_level->is_attacker(who) || hurt_all()))
    451     return 1;
    452   else return 0;
     444// collision checking will ask first to see if you
     445int game_object::can_hurt(game_object *who)
     446{
     447    int is_attacker = current_level->is_attacker(this);
     448
     449    // it's you against them!  Damage only if it you are attacking or they are
     450    // attacking you, ie. don't let them hurt themselves. This can change if
     451    // you override this virtual function
     452
     453    if(who->hurtable()
     454        && ((_team == -1) || (_team != who->get_team()))
     455        && (is_attacker || current_level->is_attacker(who) || hurt_all()))
     456        return 1;
     457
     458    return 0;
    453459}
    454460
    455461void game_object::note_attack(game_object *whom)
    456462{
    457   return ;  // nevermind
     463    return; // nevermind
    458464}
    459465
     
    470476                int32_t push_xvel, int32_t push_yvel)
    471477{
     478  // No friendly fire
     479  if((_team != -1) && (_team == from->get_team()))
     480    return;
    472481
    473482  void *d=figures[otype]->get_fun(OFUN_DAMAGE);
  • abuse/trunk/src/objects.hpp

    r124 r126  
    128128  int ty(int y) { return y-picture()->height()+1; }
    129129  void defaults();
     130
    130131  game_object(int Type, int load=0);
     132  ~game_object();
     133
    131134  int is_playable() { return hurtable(); }
    132135  void add_power(int amount);
     
    147150  game_object *copy();
    148151  void change_aitype(int new_type);
    149   ~game_object();
     152
     153  int get_tint() { return _tint; }
     154  void set_tint(int tint)
     155  {
     156    for(int i = 0; i < tobjs; i++)
     157      get_object(i)->_tint = tint;
     158    _tint = tint;
     159  }
     160  int get_team() { return _team; }
     161  void set_team(int team)
     162  {
     163    for(int i = 0; i < tobjs; i++)
     164      get_object(i)->_team = team;
     165    _team = team;
     166  }
    150167} ;
    151168
  • abuse/trunk/src/view.cpp

    r124 r126  
    264264  if (local_player())
    265265    sbar.associate(this);
     266  set_tint(number);
     267  set_team(-1);
    266268  sbar.need_refresh();
    267269}
     
    860862      focus->x=start->x;
    861863      focus->y=start->y;
    862       dprintf("reset position to %d %d\n",start->x,start->y);
     864      dprintf("reset player position to %d %d\n",start->x,start->y);
    863865    }
    864866    focus->set_state(stopped);
     867    focus->set_tint(_tint);
     868    focus->set_team(_team);
    865869    memset(weapons,0xff,total_weapons*sizeof(int32_t));
    866870    memset(last_weapons,0xff,total_weapons*sizeof(int32_t));
     
    12531257  } while (cmd!=SCMD_END_OF_PACKET);
    12541258}
     1259
     1260void view::set_tint(int tint)
     1261{
     1262    if(tint < 0)
     1263        tint = 0;
     1264    _tint = tint;
     1265    focus->set_tint(tint);
     1266}
     1267
     1268int view::get_tint()
     1269{
     1270    return _tint;
     1271}
     1272
     1273void view::set_team(int team)
     1274{
     1275    if(team < 0)
     1276        team = 0;
     1277    _team = team;
     1278    focus->set_team(team);
     1279}
     1280
     1281int view::get_team()
     1282{
     1283    return _team;
     1284}
     1285
  • abuse/trunk/src/view.hpp

    r124 r126  
    4747  int god;                                // :) if you believe in such things
    4848  int player_number;
     49  int _tint, _team;
    4950
    5051  int draw_solid;                         // -1 if don't draw solid
     
    6869
    6970  short ambient;                        // ambient lighting setting, used by draw
     71
    7072  int32_t pan_x,pan_y,no_xleft,no_xright,no_ytop,no_ybottom,
    7173       last_x,last_y,last_last_x,last_last_y,view_percent;
     
    7678
    7779  view(game_object *Focus, view *Next, int number);
     80  ~view();
     81
    7882  void draw_character_damage();           // draws the characters 'status' on the viewer
    7983
     
    116120  int32_t set_view_var_value(int num, int32_t x);
    117121  void configure_for_area(area_controller *a);
    118   ~view();
    119 } ;
     122
     123  void set_tint(int);
     124  int get_tint();
     125  void set_team(int);
     126  int get_team();
     127};
    120128
    121129extern view *player_list;
Note: See TracChangeset for help on using the changeset viewer.