void C_ASW_TeslaTrap::CustomPaint(int ix, int iy, int alpha, vgui::Panel *pUseIcon) { if ( !m_bAssembled ) return; if (C_ASW_Sentry_Base::s_hAmmoFont == vgui::INVALID_FONT) { vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew"); vgui::IScheme *pScheme = vgui::scheme()->GetIScheme(scheme); if (pScheme) C_ASW_Sentry_Base::s_hAmmoFont = vgui::scheme()->GetIScheme(scheme)->GetFont("DefaultSmall", true); } if (C_ASW_Sentry_Base::s_hAmmoFont == vgui::INVALID_FONT || alpha <= 0) return; int nAmmo = MAX( 0, GetAmmo() ); Color textColor( 255, 255, 255, 255 ); if ( nAmmo < 10 ) { textColor = Color( 255, 255, 0, 255 ); } if ( pUseIcon ) { CASW_HUD_Use_Icon *pUseIconPanel = static_cast<CASW_HUD_Use_Icon*>(pUseIcon); float flProgress = (float) nAmmo / (float) GetMaxAmmo(); char szCountText[64]; Q_snprintf( szCountText, sizeof( szCountText ), "%d", MAX( nAmmo, 0 ) ); pUseIconPanel->CustomPaintProgressBar( ix, iy, alpha / 255.0f, flProgress, szCountText, C_ASW_Sentry_Base::s_hAmmoFont, textColor, "#asw_ammo_label" ); } }
bool CBotWeapon::NeedToReload(CBot *pBot) { if (m_iClip1) { return (*m_iClip1 == 0) && (GetAmmo(pBot) > 0); } return false; }
/* bool CBotWeaponGravGun::OutOfAmmo (CBot *pBot) { if (m_pEnt) return (CClassInterface::GravityGunObject(m_pEnt)==NULL); return true; } */ bool CBotWeapon::OutOfAmmo(CBot *pBot) { if (m_pWeaponInfo->IsGravGun() && m_pEnt) return (CClassInterface::GravityGunObject(m_pEnt) == NULL); // if I have something in my clip now // I am okay, otherwise return ammo in list if (m_iClip1 && (*m_iClip1 > 0)) return false; return GetAmmo(pBot) == 0; }
void PLAYER::CollectPowerUp(enum POWERUP_TYPE type, int count) { char* msg = new char[64]; switch(type) { case pwrHealth: SetHealth(GetHealth() + count); sprintf(msg, "Health collected (+%u)\0", count); break; case pwrAmmo: SetAmmo(GetAmmo() + count); sprintf(msg, "Ammo collected (+%u)\0", count); break; case pwrScore: SetScore(GetScore() + count); sprintf(msg, "Score collected (+%u)\0", count); break; } gui->LogOnScreen(msg); }
void ParseSayText (edict_t * ent, char *text) { static unsigned char buf[10240], infobuf[10240]; char *p, *pbuf; p = text; pbuf = buf; *pbuf = 0; while (*p != 0) { if (((ptrdiff_t) pbuf - (ptrdiff_t) buf) > 225) { break; } if (*p == '%') { switch (*(p + 1)) { case 'H': GetHealth (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'A': GetAmmo (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'W': GetWeaponName (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'I': GetItemName (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'T': GetNearbyTeammates (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'M': GetViewedTeammateName (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'E': GetViewedEnemyName (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'F': GetViewedEnemyWeapon (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'G': GetEnemyPosition (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'K': GetLastKilledTarget (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; //AQ2:TNG Slicer - New Location Code /* case 'L': GetOwnPosition (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'S': GetViewedPosition (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; */ case 'S': GetSightedLocation (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; case 'L': GetPlayerLocation (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; //AQ2:TNG Slicer Last Damage Location case 'D': GetLastDamagedPart (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; //AQ2:TNG END //AQ2:TNG Freud Last Player Damaged case 'P': GetLastDamagedPlayers (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; continue; //AQ2:TNG END } } *pbuf++ = *p++; } *pbuf = 0; strncpy (text, buf, 225); text[225] = 0; // in case it's 225 }
void isdf07Mission::CommandShab() { char tempstr[128]; switch (shabState) { case 0: //setup the first batch of enemies shabEnemy1 = BuildObject("fvsent", comp_team, spawn1); shabEnemy2 = BuildObject("fvsent", comp_team, spawn2); Attack(shabEnemy1, shabayev, 1); Attack(shabEnemy2, shabayev, 1); Attack(shabayev, shabEnemy1, 1); shabState++; break; case 1: //do nothing until the first enemy gets killed if (!IsAlive(shabEnemy1)) { if (IsAlive(shabEnemy2)) { Attack(shabayev, shabEnemy2, 1); shabState++; } else { shabState++; } } if (gunTowBuilt) { //If shab can't kill anybody do it for her Damage(shabEnemy1, 3000); if (IsAlive(shabEnemy2)) { Damage(shabEnemy2, 3000); } ClearObjectives(); AddObjective("isdf0707.otf", WHITE); Goto(shabayev, "tree_point", 1); AudioMessage("isdf0728.wav"); shabState = 3; BugFix=GetTime()+60.0f; } break; case 2: //go NEAR the ruin when all of the enemies are killed if ((missionState>8) && (IsAlive(shabEnemy2))) { //If shab can't kill anybody do it for her Damage(shabEnemy2, 3000); } if ((!IsAlive(shabEnemy1)) && (!IsAlive(shabEnemy2)) && (!gunTowBuilt)) { shabEnemy2 = BuildObject("fvsent", 2, spawn1); Attack(shabayev, shabEnemy2, 1); Attack(shabEnemy2, shabayev, 1); } if ((!IsAlive(shabEnemy1)) && (!IsAlive(shabEnemy2)) && (gunTowBuilt)) { ClearObjectives(); AddObjective("isdf0710.otf", WHITE); AudioMessage("isdf0728.wav"); Goto(shabayev, "tree_point", 1); BugFix=GetTime()+20.0f; shabState++; } break; case 3: //hop out of the vehicle when near the ruin if (GetTime()>BugFix) { Goto(shabayev,"tree_point"); BugFix=GetTime()+10.0f; } if (((GetDistance(shabayev, "tree_point") < 25.0)) && ((!IsAlive(enemy1)) || (!IsAlive(enemy2)))) { ClearObjectives(); AudioMessage("isdf0725.wav"); AddObjective("isdf0707.otf", WHITE); justHoped = true; HopOut(shabayev); // SetObjectiveOn(shabOnFoot); hunter= BuildObject("fvsent",comp_team,"hunter"); // Patrol(temp,"hunter_path"); Attack(hunter,shabayev); // blow up shabs craft CameraReady(); reminderTimer=GetTime()+60.0f; shabState++; } break; case 4: oldPlayer=HoppedOutOf(shabOnFoot); // because shab becomes 0 { Vector pos; pos = GetPosition(oldPlayer); CameraObject(oldPlayer,2,5,-7,oldPlayer); LookAt(shabOnFoot, ruins, 1); RemoveObject(oldPlayer); oldPlayer=BuildObject("petank",1,pos); } shabState++; break; case 5: if (movie_counter<70) { CameraObject(oldPlayer,2,2,-7,oldPlayer); movie_counter++; } else { RemoveObject(oldPlayer); Handle temp=BuildObject("ibnav",1,"tree_point"); TranslateString2(tempstr, sizeof(tempstr), "Mission0701"); // Rescue SetObjectiveName(temp,tempstr); SetObjectiveOn(temp); CameraFinish(); shabState++; } break; case 6: //order the player to get out of his vehicle once he gets close if ((!IsAround(shabayev)) && (!ship_blown_up)) { Patrol(hunter,"hunter_path"); SetIndependence(hunter,0); ship_blown_up=true; } if ((!IsAlive(shabOnFoot) && (!shab_dead))) { AudioMessage("isdf0732.wav"); ClearObjectives(); AddObjective("isdf05l1.otf",RED,15.0f); FailMission(GetTime()+5.0f,"isdf05l1.otf"); shab_dead=true; } if (GetTime()>reminderTimer) { AudioMessage("isdf0725.wav"); reminderTimer=GetTime()+60.0f; } if ((GetDistance(shabOnFoot, player) < 50.0)) { //RemoveObject(shabayev); Attack(shabEnemy1,shabayev); Attack(shabEnemy2,shabayev); ClearObjectives(); AudioMessage("isdf0729.wav"); AddObjective("isdf0708.otf", WHITE); shabState++; } break; case 7: //send shab to get the relic if ((!IsAlive(shabOnFoot) && (!shab_dead))) { AudioMessage("isdf0732.wav"); ClearObjectives(); AddObjective("isdf05l1.otf",RED,15.0f); FailMission(GetTime()+5.0f,"isdf05l1.otf"); shab_dead=true; } if (playerOnFoot) { Attack(shabEnemy1,oldPlayer); Attack(shabEnemy2,oldPlayer); Goto(shabOnFoot, ruins, 1); //we should start the patrols here shabState++; } break; case 8: //get shab hurt if ((!IsAlive(shabOnFoot) && (!shab_dead))) { AudioMessage("isdf0732.wav"); ClearObjectives(); AddObjective("isdf05l1.otf",RED,15.0f); FailMission(GetTime()+5.0f,"isdf05l1.otf"); shab_dead=true; } if ((GetDistance(shabOnFoot, ruins) < 20.0f) || (GetDistance(player,ruins)<10.0f)) { if (winMission == false) { AudioMessage("isdf0731.wav"); // wrong file name SucceedMission(GetTime()+5.0f,"isdf07w1.txt"); winMission = true; } } break; case 9: //hide shab break; case 10: //play closing cineractive // The following is an example of how to play a movie in a script. moviePlaying = PlayMovie("temp"); if (!moviePlaying) { missionState++; moviePlaying = true; //IFace_SetInteger("script.mission.state", 1); } break; } if (GetHealth(shabayev) < 0.7f) { //keep shab alive AddHealth(shabayev, 100); } if ((GetAmmo(shabayev)) < 0.5f) { AddAmmo(shabayev, 500); } if ((justHoped) && (!IsAlive(shabOnFoot))) { int i; i=1; // Houston we have a problem } }
void ParseSayText (edict_t * ent, char *text, size_t size) { char buf[PARSE_BUFSIZE + 256] = "\0"; //Parsebuf + chatpuf size char *p, *pbuf; p = text; pbuf = buf; while (*p != 0) { if (*p == '%') { switch (*(p + 1)) { case 'H': GetHealth (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'A': GetAmmo (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'W': GetWeaponName (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'I': GetItemName (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'T': GetNearbyTeammates (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'M': GetViewedTeammateName (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'E': GetViewedEnemyName (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'F': GetViewedEnemyWeapon (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'G': GetEnemyPosition (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'K': GetLastKilledTarget (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; //AQ2:TNG Slicer - New Location Code /* case 'L': GetOwnPosition (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'S': GetViewedPosition (ent, infobuf); strcpy (pbuf, infobuf); pbuf = SeekBufEnd (pbuf); p += 2; break; */ case 'S': GetSightedLocation (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; case 'L': GetPlayerLocation (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; //AQ2:TNG Slicer Last Damage Location case 'D': GetLastDamagedPart (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; //AQ2:TNG END //AQ2:TNG Freud Last Player Damaged case 'P': GetLastDamagedPlayers (ent, pbuf); pbuf = SeekBufEnd (pbuf); p += 2; break; //AQ2:TNG END default: *pbuf++ = *p++; break; } } else { *pbuf++ = *p++; } if (buf[size-1]) { buf[size-1] = 0; break; } } *pbuf = 0; strcpy(text, buf); }
/**\brief Save this Player to an xml node */ xmlNodePtr Player::ToXMLNode(string componentName) { char buff[256]; char *timestamp; xmlNodePtr section = xmlNewNode(NULL, BAD_CAST componentName.c_str()); // Version information snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MAJOR); xmlNewChild(section, NULL, BAD_CAST "version-major", BAD_CAST buff); snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MINOR); xmlNewChild(section, NULL, BAD_CAST "version-minor", BAD_CAST buff); snprintf(buff, sizeof(buff), "%d", EPIAR_VERSION_MICRO); xmlNewChild(section, NULL, BAD_CAST "version-macro", BAD_CAST buff); // Player Stats xmlNewChild(section, NULL, BAD_CAST "name", BAD_CAST GetName().c_str() ); xmlNodePtr planet = xmlNewNode(NULL, BAD_CAST "planet" ); xmlNewChild(planet, NULL, BAD_CAST "name", BAD_CAST lastPlanet.c_str()); snprintf(buff, sizeof(buff), "%d", (int)GetWorldPosition().GetX() ); xmlNewChild(planet, NULL, BAD_CAST "x", BAD_CAST buff ); snprintf(buff, sizeof(buff), "%d", (int)GetWorldPosition().GetY() ); xmlNewChild(planet, NULL, BAD_CAST "y", BAD_CAST buff ); xmlAddChild(section,planet); xmlNewChild(section, NULL, BAD_CAST "model", BAD_CAST GetModelName().c_str() ); xmlNewChild(section, NULL, BAD_CAST "engine", BAD_CAST GetEngineName().c_str() ); snprintf(buff, sizeof(buff), "%d", this->GetCredits() ); xmlNewChild(section, NULL, BAD_CAST "credits", BAD_CAST buff ); // this part is becoming less important and may be removed at some point for(unsigned int i = 0; i < weaponSlots.size(); i++){ xmlNewChild(section, NULL, BAD_CAST "weapon", BAD_CAST GetWeaponSlotContent(i).c_str() ); } // Ammo for(int a=0;a<max_ammo;a++){ if(GetAmmo(AmmoType(a)) != 0 ){ // Don't save empty ammo Nodes snprintf(buff, sizeof(buff), "%d", GetAmmo(AmmoType(a)) ); xmlNodePtr ammo = xmlNewNode(NULL, BAD_CAST "ammo"); xmlNewChild(ammo, NULL, BAD_CAST "type", BAD_CAST Weapon::AmmoTypeToName((AmmoType)a).c_str() ); xmlNewChild(ammo, NULL, BAD_CAST "amount", BAD_CAST buff ); xmlAddChild(section, ammo); } } // Weapon Slots // save info about whichever items players are able to change in their slot configuration (content and firing group) for(unsigned int w=0; w < weaponSlots.size(); w++){ WeaponSlot *slot = &weaponSlots[w]; xmlNodePtr slotPtr = xmlNewNode(NULL, BAD_CAST "weapSlot"); xmlNewChild(slotPtr, NULL, BAD_CAST "name", BAD_CAST GetWeaponSlotName(w).c_str() ); xmlNewChild(slotPtr, NULL, BAD_CAST "content", BAD_CAST GetWeaponSlotContent(w).c_str() ); snprintf(buff, sizeof(buff), "%d", slot->firingGroup); xmlNewChild(slotPtr, NULL, BAD_CAST "firingGroup", BAD_CAST buff); xmlAddChild(section, slotPtr); // saved player data is less structured than model data, so just add it here } // Cargo map<Commodity*,unsigned int> cargo = this->GetCargo(); map<Commodity*,unsigned int>::iterator iter_com; for(iter_com = cargo.begin(); iter_com!=cargo.end(); ++iter_com) { if( !(*iter_com).second ) { continue; // Don't Save empty cargo Nodes } snprintf(buff, sizeof(buff), "%d", (*iter_com).second ); xmlNodePtr ammo = xmlNewNode(NULL, BAD_CAST "cargo"); xmlNewChild(ammo, NULL, BAD_CAST "type", BAD_CAST ((*iter_com).first)->GetName().c_str() ); xmlNewChild(ammo, NULL, BAD_CAST "amount", BAD_CAST buff ); xmlAddChild(section, ammo); } // Outfit list<Outfit*> *outfits = this->GetOutfits(); for( list<Outfit*>::iterator it_w = outfits->begin(); it_w!=outfits->end(); ++it_w ){ xmlNewChild(section, NULL, BAD_CAST "outfit", BAD_CAST (*it_w)->GetName().c_str() ); } // Missions list<Mission*>::iterator iter_mission; for(iter_mission = missions.begin(); iter_mission != missions.end(); ++iter_mission){ xmlAddChild( section, (*iter_mission)->ToXMLNode() ); } // Favor map<Alliance*,int>::iterator iter_favor; for(iter_favor = favor.begin(); iter_favor!=favor.end(); ++iter_favor) { if( !(*iter_favor).second ) { continue; // Don't Save empty favor Nodes } snprintf(buff, sizeof(buff), "%d", (*iter_favor).second ); xmlNodePtr ammo = xmlNewNode(NULL, BAD_CAST "favor"); xmlNewChild(ammo, NULL, BAD_CAST "alliance", BAD_CAST ((*iter_favor).first)->GetName().c_str() ); xmlNewChild(ammo, NULL, BAD_CAST "value", BAD_CAST buff ); xmlAddChild(section, ammo); } // Hired escorts for(list<HiredEscort*>::iterator iter_escort = hiredEscorts.begin(); iter_escort != hiredEscorts.end(); iter_escort++){ // Check that the sprite hasn't already been destroyed. (If it has, leave it out.) ///\todo We should remove the SpriteManager reference here to remove a dependency on global variables. if( (*iter_escort)->spriteID != -1 && SpriteManager::Instance()->GetSpriteByID( (*iter_escort)->spriteID ) != NULL ){ xmlNodePtr hePtr = xmlNewNode(NULL, BAD_CAST "hiredEscort"); xmlNewChild(hePtr, NULL, BAD_CAST "type", BAD_CAST (*iter_escort)->type.c_str() ); snprintf(buff, sizeof(buff), "%d", (*iter_escort)->pay); xmlNewChild(hePtr, NULL, BAD_CAST "pay", BAD_CAST buff); xmlAddChild(section, hePtr); // Don't include spriteID in the XML file, for obvious reasons. } } // Last Load Time snprintf(buff, sizeof(buff), "%d", (int)lastLoadTime ); xmlNewChild(section, NULL, BAD_CAST "lastLoadTime", BAD_CAST buff ); // Save a Human readable comment to explain the Last Load time strcpy( buff, "Last Load: " ); timestamp = ctime( &lastLoadTime ); timestamp[strlen(timestamp)-1] = '\0'; xmlAddChild( section, xmlNewComment( BAD_CAST timestamp)); return section; }
void Player::AddAmmo(const std::string &type, int d) { SetAmmo(type, GetAmmo(type)+d); }