static int Player_Give( lua_State *L ) { luaPlayer_t *player = CheckPlayer( L, 1 ); gentity_t *ent = &g_entities[player->clientNum]; const char *type = luaL_checkstring( L, 2 ); int id = luaL_checkinteger( L, 3 ); int value = lua_tointeger( L, 4 ); if ( !Q_stricmp( type, "weapon" ) ) { if ( id == -1 ) { ent->client->ps.stats[STAT_WEAPONS] = ((1 << LAST_USEABLE_WEAPON) - 1) & ~1; } if ( id <= WP_NONE || id >= WP_NUM_WEAPONS ) { return 0; } ent->client->ps.stats[STAT_WEAPONS] |= (1 << id); } else if ( !Q_stricmp( type, "powerup" ) ) { if ( id <= PW_NONE || id >= PW_NUM_POWERUPS ) { return 0; } ent->client->ps.powerups[id] = level.time + value; } else if ( !Q_stricmp( type, "item" ) ) { if ( id == -1 ) { for ( int i = 0; i < HI_NUM_HOLDABLE; i++ ) { ent->client->ps.stats[STAT_HOLDABLE_ITEMS] |= (1 << i); } } if ( id <= HI_NONE || id >= HI_NUM_HOLDABLE ) { return 0; } ent->client->ps.stats[STAT_HOLDABLE_ITEMS] |= (1 << id); } else if ( !Q_stricmp( type, "ammo" ) ) { if ( id == -1 ) { for ( int i = 0; i < AMMO_MAX; i++ ) { ent->client->ps.ammo[i] = ammoMax[i]; } } if ( id <= 0 || id >= AMMO_MAX ) { return 0; } ent->client->ps.ammo[id] = value; } return 0; }
static int Player_GetClientInfo( lua_State *L ) { luaPlayer_t *player = CheckPlayer( L, 1 ); clientInfo_t *ci = &cgs.clientinfo[player->clientNum]; entityState_t *es = &cg_entities[player->clientNum].currentState; score_t *score = NULL; // for ping and other scoreboard information for ( int i = 0; i < cg.numScores; i++ ) { if ( cg.scores[i].client == player->clientNum ) { score = &cg.scores[i]; break; } } lua_newtable( L ); int top = lua_gettop( L ); lua_pushstring( L, "saberName" ); lua_pushstring( L, ci->saberName ); lua_settable( L, top ); lua_pushstring( L, "saber2Name" ); lua_pushstring( L, ci->saber2Name ); lua_settable( L, top ); lua_pushstring( L, "name" ); lua_pushstring( L, ci->name ); lua_settable( L, top ); lua_pushstring( L, "team" ); lua_pushinteger( L, ci->team ); lua_settable( L, top ); lua_pushstring( L, "duelTeam" ); lua_pushinteger( L, ci->duelTeam ); lua_settable( L, top ); lua_pushstring( L, "botSkill" ); lua_pushinteger( L, ci->botSkill ); lua_settable( L, top ); lua_pushstring( L, "icolor1" ); lua_pushinteger( L, ci->icolor1 ); lua_settable( L, top ); lua_pushstring( L, "icolor2" ); lua_pushinteger( L, ci->icolor2 ); lua_settable( L, top ); lua_pushstring( L, "score" ); lua_pushinteger( L, ci->score ); lua_settable( L, top ); lua_pushstring( L, "modelName" ); lua_pushstring( L, ci->modelName ); lua_settable( L, top ); lua_pushstring( L, "skinName" ); lua_pushstring( L, ci->skinName ); lua_settable( L, top ); lua_pushstring( L, "deferred" ); lua_pushboolean( L, !!ci->deferred ); lua_settable( L, top ); lua_pushstring( L, "gender" ); lua_pushinteger( L, ci->gender ); lua_settable( L, top ); if ( score ) { lua_pushstring( L, "ping" ); lua_pushinteger( L, (player->clientNum == cg.clientNum) ? cg.snap->ping : score->ping ); lua_settable( L, top ); lua_pushstring( L, "time" ); lua_pushinteger( L, score->time ); lua_settable( L, top ); lua_pushstring( L, "deaths" ); lua_pushinteger( L, score->deaths ); lua_settable( L, top ); } else { lua_pushstring( L, "ping" ); if ( player->clientNum == cg.clientNum ) lua_pushinteger( L, cg.snap->ping ); else lua_pushnil( L ); lua_settable( L, top ); lua_pushstring( L, "time" ); lua_pushnil( L ); lua_settable( L, top ); lua_pushstring( L, "deaths" ); lua_pushnil( L ); lua_settable( L, top ); } lua_pushstring( L, "rgb1" ); Vector_CreateRef( L, ci->rgb1.r, ci->rgb1.g, ci->rgb1.b ); lua_settable( L, top ); lua_pushstring( L, "rgb2" ); Vector_CreateRef( L, ci->rgb2.r, ci->rgb2.g, ci->rgb2.b ); lua_settable( L, top ); lua_pushstring( L, "skinRGB" ); Vector_CreateRef( L, es->customRGBA[0], es->customRGBA[1], es->customRGBA[2] ); lua_settable( L, top ); return 1; }
static int Player_GetAdminData( lua_State *L ) { luaPlayer_t *player = CheckPlayer( L, 1 ); gentity_t *ent = &g_entities[player->clientNum]; lua_newtable( L ); int top = lua_gettop( L ); lua_pushstring( L, "login" ); lua_pushstring( L, ent->client->pers.adminUser->user ); lua_settable( L, top ); lua_pushstring( L, "password" ); lua_pushstring(L, ent->client->pers.adminUser->password ); lua_settable( L, top ); lua_pushstring( L, "privileges" ); lua_pushinteger(L, ent->client->pers.adminUser->privileges ); lua_settable( L, top ); lua_pushstring( L, "loginmsg" ); lua_pushstring(L, ent->client->pers.adminUser->loginMsg ); lua_settable( L, top ); lua_pushstring( L, "rank" ); lua_pushinteger(L, ent->client->pers.adminUser->rank ); lua_settable( L, top ); lua_pushstring( L, "logineffect" ); lua_pushinteger(L, ent->client->pers.adminUser->logineffect ); lua_settable( L, top ); return 1; }
static int Player_GetUserinfo( lua_State *L ) { luaPlayer_t *player = CheckPlayer( L, 1 ); char userinfo[MAX_INFO_STRING]; const char *info; const char *name = lua_tostring(L, 2); if (lua_isnil(L, 2) || !Q_stricmp(name, "") || !Q_stricmp(name, "-1") || !name ) { trap->GetUserinfo(player->clientNum, userinfo, sizeof(userinfo)); PushInfostring(L, userinfo); return 1; } trap->GetUserinfo( player->clientNum, userinfo, sizeof(userinfo) ); info = Info_ValueForKey(userinfo, name); lua_pushstring(L, info); return 1; }
void Collision::Update(void) { if (pPlayer->GetActive()) { if (pPlayer->GetHit()) { if (!pPlayer->GetExplosionOn()) { if (SafeForPlayer()) { pPlayer->Spawn(); } } } else { CheckUFO(); //Collisions that do not involve the rocks, for player. } } else { bool shotsDone = true; for (int shot = 0; shot < 4; shot++) { if (pPlayer->GetShotActive(shot)) shotsDone = false; } if (shotsDone) pHUD->SetGameOver(true); } CheckLargeRocks(); CheckMedRocks(); CheckSmallRocks(); CheckPlayer(); pHUD->Update(); }
static int Player_ToEntity(lua_State *L){ luaPlayer_t *player = CheckPlayer(L, 1); jpluaEntity_t *ent = &ents[player->clientNum]; Entity_CreateRef(L, ent); return 1; }
//Func: tostring( Player ) //Retn: string representing the Player instance (for debug/error messages) static int Player_ToString( lua_State *L ) { luaPlayer_t *player = CheckPlayer( L, 1 ); lua_pushfstring( L, "Player(%d)", player->clientNum ); return 1; }
//Func: Player1 == Player2 //Retn: boolean value of whether Player1 is the same client as Player2 static int Player_Equals( lua_State *L ) { luaPlayer_t *p1 = CheckPlayer( L, 1 ); luaPlayer_t *p2 = CheckPlayer( L, 2 ); lua_pushboolean( L, (p1->clientNum == p2->clientNum) ? 1 : 0 ); return 1; }
static int Player_ConsolePrint( lua_State *L ) { luaPlayer_t *player = CheckPlayer( L, 1 ); const char *msg = luaL_checkstring( L, 2 ); trap->SendServerCommand( player->clientNum, va( "print \"%s\"", msg ) ); return 0; }
void WaypointReached(uint32 waypointId) { RelocateSummons(); switch (waypointId) { // Finished north path case 52: me->SummonCreature(NPC_VENDOR_TRON, -694.61f, 1460.7f, 90.794f, 2.4f, TEMPSUMMON_TIMED_DESPAWN, TIME_SHOP_STOP+15*IN_MILLISECONDS); SetEscortPaused(true); events.ScheduleEvent(EVENT_RESUME_PATH, TIME_SHOP_STOP); CheckCaravan(); break; // Finished south path case 193: me->SummonCreature(NPC_SUPER_SELLER, -1905.5f, 2463.3f, 61.52f, 5.87f, TEMPSUMMON_TIMED_DESPAWN, TIME_SHOP_STOP+15*IN_MILLISECONDS); SetEscortPaused(true); events.ScheduleEvent(EVENT_RESUME_PATH, TIME_SHOP_STOP); CheckCaravan(); break; // North -> South - hire case 77: SetEscortPaused(true); me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); Talk(SAY_CARAVAN_HIRE); events.ScheduleEvent(EVENT_WAIT_FOR_ASSIST, TIME_HIRE_STOP); break; // Sout -> North - hire case 208: SetEscortPaused(true); if (Creature* rigger = ObjectAccessor::GetCreature(*me, summons[0])) { rigger->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_QUESTGIVER); rigger->AI()->Talk(SAY_CARAVAN_HIRE); } events.ScheduleEvent(EVENT_WAIT_FOR_ASSIST, TIME_HIRE_STOP); break; // North -> South - complete case 103: if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) { if (CheckCaravan()) player->GroupEventHappens(QUEST_BODYGUARD_FOR_HIRE, player); else player->FailQuest(QUEST_BODYGUARD_FOR_HIRE); } _playerGUID = 0; CheckPlayer(); break; // South -> North - complete case 235: if (Player* player = ObjectAccessor::GetPlayer(*me, _playerGUID)) { if (CheckCaravan()) player->GroupEventHappens(QUEST_GIZELTON_CARAVAN, player); else player->FailQuest(QUEST_GIZELTON_CARAVAN); } _playerGUID = 0; CheckPlayer(); break; // North -> South - spawn attackers case 83: case 93: case 100: { if (!_playerGUID) return; ImmuneFlagSet(true, _faction); Creature* cr = NULL; for (uint8 i = 0; i < 4; ++i) { float o = (i*M_PI/2)+(M_PI/4); float x = me->GetPositionX()+cos(o)*15.0f; float y = me->GetPositionY()+sin(o)*15.0f; if (cr = me->SummonCreature((i%2 == 0 ? NPC_KOLKAR_WAYLAYER : NPC_KOLKAR_AMBUSHER), x, y, me->GetMap()->GetHeight(x, y, MAX_HEIGHT), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) cr->AI()->AttackStart(me); } if (cr) { AttackStart(cr); me->CallForHelp(50.0f); } break; } // South -> North - spawn attackers case 221: case 228: case 233: { if (!_playerGUID) return; ImmuneFlagSet(true, _faction); Creature* cr = NULL; for (uint8 i = 0; i < 3; ++i) { float o = i*2*M_PI/3; float x = me->GetPositionX()+cos(o)*10.0f; float y = me->GetPositionY()+sin(o)*10.0f; uint32 entry = NPC_LESSER_INFERNAL; if (i) entry = i == 1 ? NPC_DOOMWARDER : NPC_NETHER; if (cr = me->SummonCreature(entry, x, y, me->GetMap()->GetHeight(x, y, MAX_HEIGHT), 0.0f, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000)) cr->AI()->AttackStart(me); } if (cr) { AttackStart(cr); me->CallForHelp(50.0f); } break; } case 282: events.ScheduleEvent(EVENT_RESTART_ESCORT, 1000); break; } }