Beispiel #1
0
/*
===============
ED_CallSpawn

Finds the spawn function for the entity and calls it
===============
*/
void ED_CallSpawn (edict_t * ent)
{
	spawn_t *s;
	gitem_t *item;
	int i;

	if (!ent->classname)
	{
		gi.dprintf ("ED_CallSpawn: NULL classname\n");
		return;
	}

	// zucc - BD's item replacement idea
	CheckItem (ent);

	// check item spawn functions
	for (i = 0, item = itemlist; i < game.num_items; i++, item++)
	{
		if (!item->classname)
			continue;
		if (!strcmp (item->classname, ent->classname))
		{			// found it
			//FIREBLADE
			if (!teamplay->value || teamdm->value || ctf->value == 2)
			{
			//FIREBLADE
				if (item->flags == IT_AMMO || item->flags == IT_WEAPON
				|| item->flags == IT_FLAG /*|| item->flags == IT_ITEM || item->flags == IT_POWERUP*/)
					SpawnItem (ent, item);
			}
			else if (ctf->value && item->flags == IT_FLAG)
			{
				SpawnItem (ent, item);
			}

			return;
		}
	}

	// check normal spawn functions
	for (s = spawns; s->name; s++)
	{
		if (!strcmp (s->name, ent->classname))
		{			// found it
			s->spawn (ent);
			return;
		}
	}
	//AQ2:TNG - Igor adding wp_flags/itm_flags
	if (strcmp (ent->classname, "freed") != 0)
	{
		gi.dprintf ("%s doesn't have a spawn function\n", ent->classname);
	}
	//AQ2:TNG End adding flags
}
Beispiel #2
0
void CheckItem(edict_t *ent, gitem_t *item)
{
        int i;
        
        for(i = 0;i < ITEM_SWITCH_COUNT; i++)
        {
                //If it's a null entry, bypass it
                if(!sp_item[i][0])
                        continue;
                //Do the passed ent and our list match?
                if(strcmp(ent->classname,sp_item[i][0])==0)
                {
                        //Yep. Replace the Q2 entity with our own.
                        ent->classname = item->classname = sp_item[i][1];
//FIREBLADE                     
                        if (!teamplay->value)
                        {
//FIREBLADE
                                SpawnItem(ent,item);
                        }
                        //We found it, so don't waste time looking for more.
                        //gi.bprintf(PRINT_HIGH,"Found %s\nReplaced with %s\n",ent->classname,test);
                        return;
                }
        }
}
Beispiel #3
0
void ItemManager::MainLoop(HDC hdc){
	static int cnt;

	itemhdc = hdc;
	if (cnt >= SpawnInterval){
		SpawnItem();

		cnt = 0;
	}
	
	cnt++;
	//DebugStringVal("%d", cnt, hdc, 100, 80, 20);

	//敵の移動。キャラとの判定。消滅など。
	for (int i = 0; i < Maxitem; i++){
		if (iobj[i]){
//			DebugStringVal("%d", (int)iobj[i]->hit_itemcheck(), itemhdc, 100, 80 + (i + 1) * 20, 20);

			iobj[i]->chara_strc(plstats);
			iobj[i]->item_scroll(scroll_x, scroll_y);
			 itemtype = iobj[i]->hit_itemcheck();
			iobj[i]->Item_paint(hdc);
			if (iobj[i]->get_onActive() == 0){
				iobj[i].reset();
				break;
			}
		}
	}
}
Beispiel #4
0
/*
===============
ED_CallSpawn

Finds the spawn function for the entity and calls it
===============
*/
void ED_CallSpawn(edict_t *ent)
{
    const spawn_t   *s;
    const gitem_t   *item;
    int     i;

    if (!ent->classname) {
        gi.dprintf("%s: NULL classname\n", __func__);
        return;
    }

    // check item spawn functions
    for (i = 0, item = g_itemlist; i < ITEM_TOTAL; i++, item++) {
        if (!item->classname)
            continue;
        if (!strcmp(item->classname, ent->classname)) { // found it
            SpawnItem(ent, (gitem_t *)item);
            return;
        }
    }

    // check normal spawn functions
    for (s = g_spawns; s->name; s++) {
        if (!strcmp(s->name, ent->classname)) { // found it
            s->spawn(ent);
            return;
        }
    }

//  gi.dprintf ("%s doesn't have a spawn function\n", ent->classname);
    G_FreeEdict(ent);
}
Beispiel #5
0
/*
===============
ED_CallSpawn

Finds the spawn function for the entity and calls it
===============
*/
void ED_CallSpawn (edict_t *ent)
{
	spawn_t	*s;
	gitem_t	*item;
	int		i;

	if (!ent->classname)
	{
		gi.dprintf ("ED_CallSpawn: NULL classname\n");
		return;
	}

	// check item spawn functions
	for (i=0,item=itemlist ; i<game.num_items ; i++,item++)
	{
		if (!item->classname)
			continue;
		if (!strcmp(item->classname, ent->classname))
		{	// found it
			SpawnItem (ent, item);
			return;
		}
	}

	// check normal spawn functions
	for (s=spawns ; s->name ; s++)
	{
		if (!strcmp(s->name, ent->classname))
		{	// found it
			s->spawn (ent);
			return;
		}
	}
	gi.dprintf ("%s doesn't have a spawn function\n", ent->classname);
}
Beispiel #6
0
void Location::AddItem(CurrentItem* currentItem)
{
	char query[256];

	sprintf(query, "INSERT INTO CurrentItem(baseId, x, y, locationId) VALUES(%d, %d, %d, %d)", currentItem->base->id, currentItem->x, currentItem->y, currentItem->currentLocation->id);
	sqlite3_exec(Game::instance->db, query, NULL, NULL, NULL);
	SpawnItem(currentItem);
}
Beispiel #7
0
void SP_briefcase(edict_t *self)
{
	if (!self->count)
		level.ctb_time = 180;
	else
		level.ctb_time = self->count;

    SpawnItem(self,FindItemByClassname("briefcase"));
}
Beispiel #8
0
//Initialization from DB (Editor, Server)
CurrentCharacter::CurrentCharacter(SqliteResult sqliteResult, Location* location) :
	CurrentMapObject<Character>::CurrentMapObject(sqliteResult, Game::instance->resources->characters, Game::instance->resources->charactersCount, location)
{
	movingX = x;
	movingY = y;

	strcpy(login, sqliteResult.strings["login"].c_str());
	strcpy(password, sqliteResult.strings["password"].c_str());

	hp = 100;

	char query[256];
	int rowsCount;
	std::vector<SqliteResult> sqliteResultsChildren;

	if (node)
		setTitle(login);

	//CurrentItems
	sprintf(query, "SELECT * FROM CurrentItem WHERE locationId=0 AND currentCharacterId=%d", id);
	sqliteResultsChildren = SqliteGetRows(Game::instance->db, query);
	currentItems = NULL;
	currentItemsCount = 0;
	rowsCount = sqliteResultsChildren.size();
	while (currentItemsCount < rowsCount)
	{
		SpawnItem(new CurrentItem(sqliteResultsChildren[currentItemsCount], NULL, this));
	}

	//CurrentQuests
	sprintf(query, "SELECT * FROM CurrentQuest WHERE currentCharacterId=%d", id);
	sqliteResultsChildren = SqliteGetRows(Game::instance->db, query);
	currentQuests = NULL;
	currentQuestsCount = 0;
	rowsCount = sqliteResultsChildren.size();
	while (currentQuestsCount < rowsCount)
	{
		currentQuestsCount++;
		currentQuests = (CurrentQuest**)realloc(currentQuests, currentQuestsCount * sizeof(CurrentQuest*));
		currentQuests[currentQuestsCount - 1] = new CurrentQuest(sqliteResultsChildren[currentQuestsCount - 1], this);
	}

	//CurrentSkills
	sprintf(query, "SELECT * FROM CurrentSkill WHERE currentCharacterId=%d", id);
	sqliteResultsChildren = SqliteGetRows(Game::instance->db, query);
	currentSkills = NULL;
	currentSkillsCount = 0;
	rowsCount = sqliteResultsChildren.size();
	while (currentSkillsCount < rowsCount)
	{
		SpawnSkill(new CurrentSkill(sqliteResultsChildren[currentSkillsCount], this));
	}
}
Beispiel #9
0
CurrentItem* CurrentCharacter::AddItem(Item* base, int count)
{
	char query[256];

	sprintf(query, "INSERT INTO CurrentItem(baseId, x, y, locationId, currentCharacterId, `count`) VALUES(%d, 0, 0, NULL, %d, %d)", base->id, this->id, count);
	sqlite3_exec(Game::instance->db, query, NULL, NULL, NULL);
	sprintf(query, "SELECT * FROM CurrentItem WHERE id=%d", sqlite3_last_insert_rowid(Game::instance->db));
	SqliteResult sqliteResult = SqliteGetRows(Game::instance->db, query)[0];
	CurrentItem* currentItem = new CurrentItem(sqliteResult, NULL, this);
	SpawnItem(currentItem);
	return currentItem;
}
Beispiel #10
0
/*
===============
ED_CallSpawn

Finds the spawn function for the entity and calls it
===============
*/
void ED_CallSpawn (edict_t *ent)
{
        spawn_t *s;
        gitem_t *item;
        int             i;

        if (!ent->classname)
        {
                gi.dprintf ("ED_CallSpawn: NULL classname\n");
                return;
        }

        // check item spawn functions
        for (i=0,item=itemlist ; i<game.num_items ; i++,item++)
        {
                if (!item->classname)
                        continue;
                if (!strcmp(item->classname, ent->classname))
                {       // found it
//FIREBLADE
                        if (!teamplay->value)
                        {
//FIREBLADE
                                if ( item->flags == IT_AMMO || item->flags == IT_WEAPON )
                                        SpawnItem (ent, item);
                        }
                
                        return;
                }
                // zucc - BD's item replacement idea
                else 
                {
                        CheckItem(ent, item);
                }
        }


        // check normal spawn functions
        for (s=spawns ; s->name ; s++)
        {
                if (!strcmp(s->name, ent->classname))
                {       // found it
                        s->spawn (ent);
                        return;
                }
        }
        gi.dprintf ("%s doesn't have a spawn function\n", ent->classname);
}
Beispiel #11
0
void Room::RespawnItems() {
	std::vector<GameEntity*> currentItems = items_->GetEntityVector();
	std::map<int, int> items_to_add;
	for (int i : original_items_) {
		items_to_add.insert(std::pair<int, int>(i, i));

	}

	for (GameEntity* i : currentItems) {
		items_to_add.erase(((Item* )i)->GetMasterId());
	}

	for (std::pair<int, int> i : items_to_add) {
		SpawnItem(i.second);
	}
}
Beispiel #12
0
void
InitClientCoopPersistant(edict_t *ent) // FS: Give some of this back on respawn
{
	gclient_t *client;
	gitem_t *item;
	edict_t *it_ent;

	if (!ent || !ent->client)
		return;
	if (!coop->intValue)
		return;

	client = ent->client;
	client->pers.max_bullets = 200;
	client->pers.max_shells = 100;
	client->pers.max_rockets = 50;
	client->pers.max_grenades = 50;
	client->pers.max_cells = 200;
	client->pers.max_slugs = 50;

	switch(client->resp.coop_respawn.ammoUpgrade)
	{
		case COOP_BACKPACK:
			item = FindItem("ammo pack");
			break;
		case COOP_BANDOLIER:
			item = FindItem("bandolier");
			break;
		default:
			item = NULL;
			break;
	}

	if (item)
	{
		it_ent = G_Spawn();
		it_ent->classname = item->classname;
		SpawnItem(it_ent, item);
		Touch_Item(it_ent, ent, NULL, NULL);

		if (it_ent->inuse)
		{
			G_FreeEdict(it_ent);
		}
	}
}
Beispiel #13
0
/*
===============
ED_CallSpawn

Finds the spawn function for the entity and calls it
===============
*/
void ED_CallSpawn (edict_t *ent)
{
	spawn_t	*s;
	gitem_t	*item;
	int		i;

	// Lazarus: if this fails, edict is freed.

	if (!ent->classname)
	{
		gi.dprintf ("ED_CallSpawn: NULL classname\n");
		G_FreeEdict(ent);
		return;
	}

	// Lazarus: Preserve original angles for movewith stuff 
	//          before G_SetMoveDir wipes 'em out
	VectorCopy(ent->s.angles, ent->org_angles);

	// check item spawn functions
	for (i=0,item=itemlist ; i<game.num_items ; i++,item++)
	{
		if (!item->classname)
			continue;
		if (!strcmp(item->classname, ent->classname))
		{	// found it
			SpawnItem (ent, item);
			return;
		}
	}

	// check normal spawn functions
	for (s=spawns ; s->name ; s++)
	{
		if (!strcmp(s->name, ent->classname))
		{	// found it
			s->spawn (ent);
			return;
		}
	}
	gi.dprintf ("%s doesn't have a spawn function\n", ent->classname);
	G_FreeEdict(ent);
}
Beispiel #14
0
/*
* G_CallSpawn
* 
* Finds the spawn function for the entity and calls it
*/
bool G_CallSpawn( edict_t *ent )
{
	spawn_t	*s;
	gsitem_t	*item;

	if( !ent->classname )
	{
		if( developer->integer )
			G_Printf( "G_CallSpawn: NULL classname\n" );
		return false;
	}

	if( ( item = G_ItemForEntity( ent ) ) != NULL )
	{
		SpawnItem( ent, item );
		return true;
	}

	// racesow - Give gametype definitions precedence over C ones
	// see if there's a spawn definition in the gametype scripts
	ent->scriptSpawned = G_asCallMapEntitySpawnScript( ent->classname, ent );
	if( ent->scriptSpawned ) {
		return true; // handled by the script
	}

	// check normal spawn functions
	for( s = spawns; s->name; s++ )
	{
		if( !Q_stricmp( s->name, ent->classname ) )
		{
			s->spawn( ent );
			return true;
		}
	}
	// !racesow

	if( sv_cheats->integer || developer->integer ) // mappers load their maps with devmap
		G_Printf( "%s doesn't have a spawn function\n", ent->classname );

	return false;
}
void SARInventoryItemWidget::Construct(const FArguments& InArgs)
{
	PlayerController = InArgs._PlayerController;
	InventoryItem = InArgs._InventoryItem;
	Inventory = InArgs._Inventory;
	Equipment = InArgs._Equipment;

	TextColor = FSlateColor(FLinearColor(1, 0, 0, 1));
	SlotType = InArgs._SlotType;
	SlotName = InArgs._SlotName;
	//	EquipmentSlot = InArgs._EquipmentSlot;
	InventoryItem = InArgs._InventoryItem;
	LootedObject = InArgs._LootedObject;

	ItemInThisSlot = nullptr;

	SpawnItem();

	ChildSlot
		[

			SNew(SBorder)
			.BorderBackgroundColor(FSlateColor(FLinearColor(1, 0, 0, 1)))
			[
				SNew(SOverlay)
				+ SOverlay::Slot()
				[
					SNew(SImage)
					.Image(this, &SARInventoryItemWidget::GetImage)
				]
				+ SOverlay::Slot()
					[
						SNew(STextBlock)
						.Text(SlotName)
					]
			]
		];
}
Beispiel #16
0
/*QUAKED dm_tag_token (.3 .3 1) (-16 -16 -16) (16 16 16)
The tag token for deathmatch tag games.
*/
void SP_dm_tag_token (edict_t *self)
{
	if(!(deathmatch->value))
	{
		G_FreeEdict(self);	
		return;
	}

	if(gamerules && (gamerules->value != 2))
	{
		G_FreeEdict(self);	
		return;
	}

	// store the tag token edict pointer for later use.
	tag_token = self;
	tag_count = 0;

	self->classname = "dm_tag_token";
	self->model = "models/items/tagtoken/tris.md2";
	self->count = 1;
	SpawnItem (self, FindItem ("Tag Token"));
}
Beispiel #17
0
BOOL CGambleSystem::DefaultItemToStore(playerCharacter_t* pPc, storeStruct_t* pMakestore)
{
	if ( pMakestore == NULL)
		return FALSE;				
	
	
	int ItemPos				=0;	
	
	for( int StorePageIdx = 0; StorePageIdx < MAX_NUMBER_OF_STORE_ITEM_PAGE; StorePageIdx ++ )
	{	
		
		int PageRegCount	=0;
		
		
		for( int SlotIdx = 0; SlotIdx < MAX_NUMBER_OF_STORE_GENERATE_ITEM ; SlotIdx ++ )
		{
			ItemPos = pMakestore->itemNumber;
			
			if ( ItemPos < 0 || ItemPos >= MAX_NUMBER_OF_STORE_ITEM)				
				return FALSE;
			
			InitItem( &pMakestore->item[ItemPos].item );			
			int itemTableIdx = pMakestore->defaultItem[StorePageIdx].itemIndex[SlotIdx];
			
			if ( itemTableIdx < 0 || itemTableIdx >= MAX_NUMBER_OF_ITEM_TABLE)
				continue;	
			
			SpawnItem ( &pMakestore->item[ItemPos].item, itemTableIdx );
			
			pMakestore->item[ItemPos].page		= StorePageIdx;			
			pMakestore->item[ItemPos].maxNumber = pMakestore->defaultItem[StorePageIdx].itemNumber[SlotIdx];
			pMakestore->item[ItemPos].curNumber = pMakestore->defaultItem[StorePageIdx].itemNumber[SlotIdx];			
			
			
			int Selecteditemidx = SelectCollectedItem(&pMakestore->item[ItemPos]);					
			
			
			
			float AddPrice = (rand() %( (int)g_logic.GamblePriceRate ) )* 0.01;								
			int CalPrice = 0;
			
			
			
			if ( pMakestore->item[ItemPos].item.itemTableIdx == QUESTION_MARK_ITEM_TABLE_IDX)
			{												
				pPc->RegGamblePrice[ItemPos]	= g_itemTable[QUESTION_MARK_ITEM_TABLE_IDX].gambleCost;
				pMakestore->item[ItemPos].price = g_itemTable[QUESTION_MARK_ITEM_TABLE_IDX].gambleCost;
			}
			else
			{						
				if ( GTH_Random() > 0.5 )											
				{
					CalPrice = g_itemTable[Selecteditemidx].gambleCost + 
						(int)( ((float)(g_itemTable[Selecteditemidx].gambleCost) * AddPrice ) + 0.5f);
				}
				else
				{
					CalPrice = g_itemTable[Selecteditemidx].gambleCost - 
						(int)( ((float)(g_itemTable[Selecteditemidx].gambleCost) * AddPrice ) + 0.5f);
				}
				
				
				if ( CalPrice < 0)
					CalPrice = 1;
				
				pPc->RegGamblePrice[ItemPos]	= CalPrice;				
				pMakestore->item[ItemPos].price = CalPrice;		
				
			}
			PageRegCount++;
			pPc->RegGambleItems[ItemPos]		= Selecteditemidx;			
			pMakestore->itemNumber++;
			
		}			
	}	 
	return TRUE;
}
Beispiel #18
0
void SP_item_ammo_type_99(edict_t *self)
{
    SpawnItem(self,FindItemByClassname("ammo_type_99"));
}
Beispiel #19
0
void SP_item_ammo_arisakas(edict_t *self)
{
    SpawnItem(self,FindItemByClassname("ammo_arisakas"));
}
Beispiel #20
0
void SP_item_ammo_nambu(edict_t *self)
{
    SpawnItem(self,FindItemByClassname("ammo_nambu"));
}
Beispiel #21
0
void SP_item_ammo_grenades_jpn(edict_t *self)
{
    SpawnItem(self,FindItemByClassname("ammo_grenades_jpn"));
}
Beispiel #22
0
void SP_item_weapon_arisakas(edict_t *self)
{
    SpawnItem(self,FindItemByClassname("weapon_arisakas"));
}
Beispiel #23
0
void SP_item_weapon_type_99(edict_t *self)
{
    SpawnItem(self,FindItemByClassname("weapon_type_99"));
}
Beispiel #24
0
void SP_item_weapon_nambu(edict_t *self)

{
    SpawnItem(self,FindItem("weapon_nambu"));
}
Beispiel #25
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (edict_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			index;
	int			i;
	qboolean	give_all;
	edict_t		*it_ent;

	if (deathmatch->value && !sv_cheats->value)
	{
		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	name = gi.args();

	if (Q_stricmp(name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3)
			ent->health = atoi(gi.argv(2));
		else
			ent->health = ent->max_health;
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		gitem_armor_t	*info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Power Shield") == 0)
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & IT_NOT_GIVEABLE)					// ROGUE
				continue;										// ROGUE
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	}

	it = FindItem (name);
	if (!it)
	{
		name = gi.argv(1);
		it = FindItem (name);
		if (!it)
		{
			gi.cprintf (ent, PRINT_HIGH, "unknown item\n");
			return;
		}
	}

	if (!it->pickup)
	{
		gi.cprintf (ent, PRINT_HIGH, "non-pickup item\n");
		return;
	}

//ROGUE
	if (it->flags & IT_NOT_GIVEABLE)		
	{
		gi.dprintf ("item cannot be given\n");
		return;							
	}
//ROGUE

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (gi.argc() == 3)
			ent->client->pers.inventory[index] = atoi(gi.argv(2));
		else
			ent->client->pers.inventory[index] += it->quantity;
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		// PMM - since some items don't actually spawn when you say to ..
		if (!it_ent->inuse)
			return;
		// pmm
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);
	}
}
uint32 CDestructibleModel::ObjectMessageFn(LPBASECLASS pObject, HOBJECT hSender, ILTMessage_Read *pMsg)
{
	uint32 dwRet = CDestructible::ObjectMessageFn(pObject, hSender, pMsg);

	pMsg->SeekTo(0);
	uint32 messageID = pMsg->Readuint32();
	switch(messageID)
	{
		case MID_DAMAGE:
		{
			if (IsDead() && !m_bCreatedDebris)
			{
                ILTServer* pServerDE = BaseClass::GetServerDE();
				if (!pServerDE) break;

				SpawnItem();
				CreateDebris();
				CreateWorldModelDebris();

				if (m_bCreateExplosion)
				{
					DoExplosion();
				}

				RegisterDestroyedStimulus();

				m_bCreatedDebris = LTTRUE;

				if (m_bRemoveOnDeath)
				{
					pServerDE->RemoveObject(m_hObject);
				}
			}
		}
		break;

		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)pMsg->Readuint32();

			// ConParse does not destroy szMsg, so this is safe
			ConParse parse;
			parse.Init((char*)szMsg);

			while (g_pCommonLT->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (!IsDead())
					{
						if (_stricmp(parse.m_Args[0], "FIRE") == 0)
						{
							char* pTargetName = parse.m_nArgs > 1 ? parse.m_Args[1] : LTNULL;
							DoExplosion(pTargetName);
						}
						else if (_stricmp(parse.m_Args[0], "HIDDEN") == 0)
						{
							// Game Base will take care of the solid and visible flags for us...

							if (parse.m_nArgs > 1 && parse.m_Args[1])
							{
								if ((_stricmp(parse.m_Args[1], "1") == 0) ||
									(_stricmp(parse.m_Args[1], "TRUE") == 0))
								{
									m_bSaveCanDamage = GetCanDamage();
									m_bSaveNeverDestroy = GetNeverDestroy();

									SetCanDamage(LTFALSE);
									SetNeverDestroy(LTTRUE);
								}
								else
								{
									if ((_stricmp(parse.m_Args[1], "0") == 0) ||
										(_stricmp(parse.m_Args[1], "FALSE") == 0))
									{
										SetCanDamage(m_bSaveCanDamage);
										SetNeverDestroy(m_bSaveNeverDestroy);
									}
								}
							}
						}

					}
				}
			}
		}
		break;

		default : break;
	}

	return dwRet;
}
Beispiel #27
0
uint32 CDestructibleModel::ObjectMessageFn(LPBASECLASS pObject, HOBJECT hSender, uint32 messageID, HMESSAGEREAD hRead)
{
	uint32 dwRet = CDestructible::ObjectMessageFn(pObject, hSender, messageID, hRead);

	switch(messageID)
	{
		case MID_DAMAGE:
		{
			if (IsDead() && !m_bCreatedDebris)
			{
                ILTServer* pServerDE = BaseClass::GetServerDE();
				if (!pServerDE) break;

				SpawnItem();
				CreateDebris();
				CreateWorldModelDebris();

				if (m_bCreateExplosion)
				{
					DoExplosion();
				}

				m_bCreatedDebris = LTTRUE;

				if (m_bRemoveOnDeath)
				{
					pServerDE->RemoveObject(m_hObject);
				}
			}
		}
		break;

		case MID_TRIGGER:
		{
			const char* szMsg = (const char*)g_pLTServer->ReadFromMessageDWord(hRead);

			// ConParse does not destroy szMsg, so this is safe
			ConParse parse;
			parse.Init((char*)szMsg);

			while (g_pLTServer->Common()->Parse(&parse) == LT_OK)
			{
				if (parse.m_nArgs > 0 && parse.m_Args[0])
				{
					if (!IsDead())
					{
						if (_stricmp(parse.m_Args[0], "FIRE") == 0)
						{
							char* pTargetName = parse.m_nArgs > 1 ? parse.m_Args[1] : LTNULL;
							DoExplosion(pTargetName);
						}
						else if (_stricmp(parse.m_Args[0], "HIDDEN") == 0)
						{
							uint32 dwFlags = g_pLTServer->GetObjectFlags(m_hObject);

							if (parse.m_nArgs > 1 && parse.m_Args[1])
							{
								if ((_stricmp(parse.m_Args[1], "1") == 0) ||
									(_stricmp(parse.m_Args[1], "TRUE") == 0))
								{
									dwFlags = 0;

									m_bSaveCanDamage = GetCanDamage();
									m_bSaveNeverDestroy = GetNeverDestroy();

									SetCanDamage(LTFALSE);
									SetNeverDestroy(LTTRUE);
								}
								else
								{
									if ((_stricmp(parse.m_Args[1], "0") == 0) ||
										(_stricmp(parse.m_Args[1], "FALSE") == 0))
									{
										dwFlags = m_dwOriginalFlags;
										dwFlags |= FLAG_VISIBLE;

										SetCanDamage(m_bSaveCanDamage);
										SetNeverDestroy(m_bSaveNeverDestroy);
									}
								}

								g_pLTServer->SetObjectFlags(m_hObject, dwFlags);
							}
						}
					}
				}
			}
		}
		break;

		default : break;
	}

	return dwRet;
}
Beispiel #28
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (edict_t *ent)
{
	char		*name;
	gitem_t		*it;
	int			index;
	int			i;
	qboolean	give_all;
	edict_t		*it_ent;
	int     numargs;
	char tryname[256];

	if (deathmatch->value && !sv_cheats->value)
	{
		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	name = gi.args();
	numargs = gi.argc();

	if (Q_stricmp(name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
	{
		if (gi.argc() == 3)
			ent->health = atoi(gi.argv(2));
		else
			ent->health = ent->max_health;
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "weapons") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "ammo") == 0)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "armor") == 0)
	{
		gitem_armor_t	*info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Visor") == 0)
	{
		it = FindItem("Visor");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp(name, "Power Shield") == 0)
	{
		it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);

		if (!give_all)
			return;
	}

	if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	}

	it = FindItem (name);
	if (!it)
	{
		tryname[0] = 0;
		for(numargs = 1; numargs < gi.argc(); numargs++)
		{
			strcat(tryname, gi.argv(numargs));
			it = FindItem (tryname);

			if(it)
			{
				break;
			}

			strcat(tryname, " ");
		}

		if (!it)
		{
			gi.dprintf ("unknown item\n");
			return;
		}

		numargs++;
	}

	if (!it->pickup)
	{
		gi.dprintf ("non-pickup item\n");
		return;
	}

	index = ITEM_INDEX(it);

	if (it->flags & IT_AMMO)
	{
		if (numargs < gi.argc())
			ent->client->pers.inventory[index] = atoi(gi.argv(numargs));
		else
			ent->client->pers.inventory[index] += it->quantity;
	}
	else
	{
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict(it_ent);
	}
}
Beispiel #29
0
/*
==================
Cmd_Give_f

Give items to a client
==================
*/
void Cmd_Give_f (edict_t * ent)
{
	char *name;
	char fixedname[32];
	gitem_t *it;
	int index;
	int i;
	qboolean give_all;
	edict_t *it_ent;
	edict_t etemp;

	if (deathmatch->value && !sv_cheats->value)
	{
		gi.cprintf (ent, PRINT_HIGH, "You must run the server with '+set cheats 1' to enable this command.\n");
		return;
	}

	if (ent->solid == SOLID_NOT)
	{
		gi.cprintf (ent, PRINT_HIGH, "This command can't be used by spectators.\n");
		return;
	}

	Q_strncpyz(fixedname, gi.args (), sizeof(fixedname));
	name = fixedname;
//  name = gi.args ();

	if (Q_stricmp (name, "all") == 0)
		give_all = true;
	else
		give_all = false;

	if (Q_stricmp (gi.argv (1), "health") == 0)
	{
		/*    if (gi.argc() == 3)
		ent->health = atoi(gi.argv(2));
		else
		ent->health = ent->max_health;
		if (!give_all) */
		return;
	}

	if (give_all || Q_stricmp (name, "weapons") == 0)
	{
		for (i = 0; i < game.num_items; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_WEAPON))
				continue;
			ent->client->pers.inventory[i] += 1;
		}
		if (!give_all)
			return;
	}

	if (give_all || Q_stricmp (name, "items") == 0)
	{
		for (i = 0; i < game.num_items; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_ITEM))
				continue;
			etemp.item = it;

			if (ent->client->unique_item_total >= unique_items->value)
				ent->client->unique_item_total = unique_items->value - 1;

			Pickup_Special (&etemp, ent);
		}
		if (!give_all)
			return;
	}


	if (give_all || Q_stricmp (name, "ammo") == 0)
	{
		ent->client->mk23_rds = ent->client->mk23_max;
		ent->client->dual_rds = ent->client->dual_max;
		ent->client->mp5_rds = ent->client->mp5_max;
		ent->client->m4_rds = ent->client->m4_max;
		ent->client->shot_rds = ent->client->shot_max;
		ent->client->sniper_rds = ent->client->sniper_max;
		ent->client->cannon_rds = ent->client->cannon_max;

		for (i = 0; i < game.num_items; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (!(it->flags & IT_AMMO))
				continue;
			Add_Ammo (ent, it, 1000);
		}
		if (!give_all)
			return;
	}

	if (Q_stricmp (name, "armor") == 0)
	{
		/*
		gitem_armor_t   *info;

		it = FindItem("Jacket Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Combat Armor");
		ent->client->pers.inventory[ITEM_INDEX(it)] = 0;

		it = FindItem("Body Armor");
		info = (gitem_armor_t *)it->info;
		ent->client->pers.inventory[ITEM_INDEX(it)] = info->max_count;

		if (!give_all)
		*/
		return;
	}

	if (Q_stricmp (name, "Power Shield") == 0)
	{
		/*it = FindItem("Power Shield");
		it_ent = G_Spawn();
		it_ent->classname = it->classname;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
		G_FreeEdict(it_ent);

		if (!give_all)
		*/
		return;
	}

	/*if (give_all)
	{
		for (i=0 ; i<game.num_items ; i++)
		{
			it = itemlist + i;
			if (!it->pickup)
				continue;
			if (it->flags & (IT_ARMOR|IT_WEAPON|IT_AMMO))
				continue;
			ent->client->pers.inventory[i] = 1;
		}
		return;
	} */

	if (give_all)
		return;

	it = FindItem (name);
	if (!it)
	{
		Q_strncpyz(fixedname, gi.argv (1), sizeof(fixedname));
		name = fixedname;
		//      name = gi.argv (1);
		it = FindItem (name);
		if (!it)
		{
			gi.dprintf ("unknown item\n");
			return;
		}
	}

	if (!(it->flags & (IT_AMMO|IT_WEAPON|IT_ITEM)))
		return;


	if (!it->pickup)
	{
		gi.dprintf ("non-pickup item\n");
		return;
	}


	index = ITEM_INDEX (it);

	if (it->flags & IT_AMMO)
	{
		/*  if (gi.argc() == 5)
			ent->client->pers.inventory[index] = atoi(gi.argv(4));
		else if ( (gi.argc() == 4)  && !(Q_stricmp(it->pickup_name, "12 Gauge Shells")) )
			ent->client->pers.inventory[index] = atoi(gi.argv(3));
		else */
			ent->client->pers.inventory[index] += it->quantity;
	}
	else if (it->flags & IT_ITEM)
	{
		etemp.item = it;
		if (ent->client->unique_item_total >= unique_items->value)
			ent->client->unique_item_total = unique_items->value - 1;

		Pickup_Special (&etemp, ent);
	}
	else
	{
		it_ent = G_Spawn ();
		it_ent->classname = it->classname;
		it_ent->typeNum = it->typeNum;
		SpawnItem (it_ent, it);
		Touch_Item (it_ent, ent, NULL, NULL);
		if (it_ent->inuse)
			G_FreeEdict (it_ent);
	}
}
Beispiel #30
0
void SP_item_weapon_katana(edict_t *self)
{
    SpawnItem(self,FindItemByClassname("weapon_katana"));
}