Exemplo n.º 1
0
void ARX_PATH_UpdateAllZoneInOutInside() {
	
	ARX_PROFILE_FUNC();
	
	arx_assert(entities.player());
	
	static size_t count = 1;
	
	long f = glm::clamp(static_cast<long>(g_framedelay), 10l, 50l);
	
	if(count >= entities.size()) {
		count = 1;
	}

	if(entities.size() > 1) {
		for(long tt = 0; tt < f; tt++) {
			const EntityHandle i = EntityHandle(count);
			Entity * io = entities[i];
			
			if(   count < entities.size()
			   && io
			   && io->ioflags & (IO_NPC | IO_ITEM)
			   && io->show != SHOW_FLAG_MEGAHIDE
			) {
				arx_assert(io->show != SHOW_FLAG_DESTROYED);
				ARX_PATH * current = ARX_PATH_CheckInZone(io);
				ARX_PATH * last = io->inzone;
				
				if(!last && !current) { // Not in a zone
				} else if(last == current) { // Stayed inside last zone
					if(io->show != io->inzone_show) {
						EntityEnteringCurrentZone(io, current);
					}
				} else if(last && !current) { // Leaving last zone
					EntityLeavingLastZone(io, last);
				} else if(!last) { // Entering current zone
					EntityEnteringCurrentZone(io, current);
				} else { // Changed from last to current zone
					EntityLeavingLastZone(io, last);
					EntityEnteringCurrentZone2(io, current);
				}
				
				io->inzone = current;
			}
			
			count++;
			
			if(count >= entities.size())
				count = 1;
		}
	}

	// player check*************************************************
	{
		ARX_PATH * current = ARX_PATH_CheckPlayerInZone();
		ARX_PATH * last = player.inzone;

		if(!last && !current) { // Not in a zone
		} else if(last == current) { // Stayed inside last zone
		} else if(last && !current) { // Leaving last zone
			
			SendIOScriptEvent(NULL, entities.player(), SM_LEAVEZONE, last->name);
			CHANGE_LEVEL_ICON = NoChangeLevel;
			
			if(!last->controled.empty()) {
				EntityHandle t = entities.getById(last->controled);
				if(t != EntityHandle()) {
					ScriptParameters parameters;
					parameters.push_back("player");
					parameters.push_back(last->name);
					SendIOScriptEvent(NULL, entities[t], SM_CONTROLLEDZONE_LEAVE, parameters);
				}
			}
			
		} else if(!last) { // Entering current zone
			
			SendIOScriptEvent(NULL, entities.player(), SM_ENTERZONE, current->name);
			
			if(current->flags & PATH_AMBIANCE && !current->ambiance.empty()) {
				ARX_SOUND_PlayZoneAmbiance(current->ambiance, ARX_SOUND_PLAY_LOOPED, current->amb_max_vol * 0.01f);
			}
			
			if(current->flags & PATH_FARCLIP) {
				g_desiredFogParameters.flags |= GMOD_ZCLIP;
				g_desiredFogParameters.zclip = current->farclip;
			}
			
			if(current->flags & PATH_RGB) {
				g_desiredFogParameters.flags |= GMOD_DCOLOR;
				g_desiredFogParameters.depthcolor = current->rgb;
			}
			
			if(!current->controled.empty()) {
				EntityHandle t = entities.getById(current->controled);
				if(t != EntityHandle()) {
					ScriptParameters parameters;
					parameters.push_back("player");
					parameters.push_back(current->name);
					SendIOScriptEvent(NULL, entities[t], SM_CONTROLLEDZONE_ENTER, parameters);
				}
			}
			
		} else { // Changed from last to current zone
			
			if(!last->controled.empty()) {
				EntityHandle t = entities.getById(last->controled);
				if(t != EntityHandle()) {
					ScriptParameters parameters;
					parameters.push_back("player");
					parameters.push_back(last->name);
					SendIOScriptEvent(NULL, entities[t], SM_CONTROLLEDZONE_LEAVE, parameters);
				}
			}
			
			if(!last->controled.empty()) {
				EntityHandle t = entities.getById(current->controled);
				if(t != EntityHandle()) {
					ScriptParameters parameters;
					parameters.push_back("player");
					parameters.push_back(current->name);
					SendIOScriptEvent(NULL, entities[t], SM_CONTROLLEDZONE_ENTER, parameters);
				}
			}
			
		}

		player.inzone = current;
	}
	
	JUST_RELOADED = 0;
}
Exemplo n.º 2
0
void ARX_PATH_UpdateAllZoneInOutInside() {
	
	arx_assert(entities.player());
	
	static size_t count = 1;
	
	long f = glm::clamp(static_cast<long>(framedelay), 10l, 50l);
	
	if(count >= entities.size()) {
		count = 1;
	}

	if(entities.size() > 1)
		for(long tt = 0; tt < f; tt++) {
			const EntityHandle i = EntityHandle(count);
			Entity * io = entities[i];
			

			if(count < entities.size()
			   && io
			   && io->ioflags & (IO_NPC | IO_ITEM)
			   && io->show != SHOW_FLAG_MEGAHIDE
			) {
				arx_assert(io->show != SHOW_FLAG_DESTROYED);
				ARX_PATH * p = ARX_PATH_CheckInZone(io);
				ARX_PATH * op = io->inzone;

				if(op == NULL && p == NULL)
					goto next; // Not in a zone

				if(op == p) { // Stayed inside Zone OP
					if(io->show != io->inzone_show) {
						io->inzone_show = io->show;
						goto entering;
					}
				}
				else if ((op != NULL) && (p == NULL)) // Leaving Zone OP
				{
					SendIOScriptEvent(io, SM_LEAVEZONE, op->name);

					if(!op->controled.empty()) {
						EntityHandle t = entities.getById(op->controled);

						if(t != EntityHandle::Invalid) {
							std::string str = io->idString() + ' ' + op->name;
							SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, str);
						}
					}
				}
				else if ((op == NULL) && (p != NULL)) // Entering Zone P
				{
					io->inzone_show = io->show;
				entering:

					if(JUST_RELOADED && (p->name == "ingot_maker" || p->name == "mauld_user")) {
						ARX_DEAD_CODE(); // TODO remove JUST_RELOADED global
					} else {
						SendIOScriptEvent(io, SM_ENTERZONE, p->name);

						if(!p->controled.empty()) {
							EntityHandle t = entities.getById(p->controled);

							if(t != EntityHandle::Invalid) {
								std::string params = io->idString() + ' ' + p->name;
								SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, params);
							}
						}
					}
				} else {
					SendIOScriptEvent(io, SM_LEAVEZONE, op->name);

					if(!op->controled.empty()) {
						EntityHandle t = entities.getById(op->controled);

						if(t != EntityHandle::Invalid) {
							std::string str = io->idString() + ' ' + op->name;
							SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, str);
						}
					}

					io->inzone_show = io->show;
					SendIOScriptEvent(io, SM_ENTERZONE, p->name);

					if(!p->controled.empty()) {
						EntityHandle t = entities.getById(p->controled);

						if(t != EntityHandle::Invalid) {
							std::string str = io->idString() + ' ' + p->name;
							SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, str);
						}
					}
				}

				io->inzone = p;
			}

		next:
			count++;

			if(count >= entities.size())
				count = 1;
		}

	// player check*************************************************
	{
		ARX_PATH * p = ARX_PATH_CheckPlayerInZone();
		ARX_PATH * op = player.inzone;

		if((op == NULL) && (p == NULL))
			goto suite; // Not in a zone

		if(op == p) // Stayed inside Zone OP
		{
		
		}
		else if(op != NULL && p == NULL) // Leaving Zone OP
		{
			SendIOScriptEvent(entities.player(), SM_LEAVEZONE, op->name);
			CHANGE_LEVEL_ICON = -1;

			if(!op->controled.empty()) {
				EntityHandle t = entities.getById(op->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, "player " + op->name);
				}
			}
		}
		else if ((op == NULL) && (p != NULL)) // Entering Zone P
		{
			SendIOScriptEvent(entities.player(), SM_ENTERZONE, p->name);

			if(p->flags & PATH_AMBIANCE && !p->ambiance.empty())
				ARX_SOUND_PlayZoneAmbiance(p->ambiance, ARX_SOUND_PLAY_LOOPED, p->amb_max_vol * ( 1.0f / 100 ));

			if(p->flags & PATH_FARCLIP) {
				desired.flags |= GMOD_ZCLIP;
				desired.zclip = p->farclip;
			}

			if (p->flags & PATH_REVERB)
			{
			}

			if(p->flags & PATH_RGB) {
				desired.flags |= GMOD_DCOLOR;
				desired.depthcolor = p->rgb;
			}

			if(!p->controled.empty()) {
				EntityHandle t = entities.getById(p->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, "player " + p->name);
				}
			}
		} else {
			if(!op->controled.empty()) {
				EntityHandle t = entities.getById(op->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, "player " + p->name);
				}
			}

			if(!op->controled.empty()) {
				EntityHandle t = entities.getById(p->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, "player " + p->name);
				}
			}
		}

		player.inzone = p;
	}

	
suite:
	JUST_RELOADED = 0;
}
Exemplo n.º 3
0
void ARX_PATH_UpdateAllZoneInOutInside() {
	
	ARX_PROFILE_FUNC();
	
	arx_assert(entities.player());
	
	static size_t count = 1;
	
	long f = glm::clamp(static_cast<long>(framedelay), 10l, 50l);
	
	if(count >= entities.size()) {
		count = 1;
	}

	if(entities.size() > 1)
		for(long tt = 0; tt < f; tt++) {
			const EntityHandle i = EntityHandle(count);
			Entity * io = entities[i];
			

			if(count < entities.size()
			   && io
			   && io->ioflags & (IO_NPC | IO_ITEM)
			   && io->show != SHOW_FLAG_MEGAHIDE
			) {
				arx_assert(io->show != SHOW_FLAG_DESTROYED);
				ARX_PATH * current = ARX_PATH_CheckInZone(io);
				ARX_PATH * last = io->inzone;

				if(!last && !current) { // Not in a zone
				} else if(last == current) { // Stayed inside last zone
					if(io->show != io->inzone_show) {
						io->inzone_show = io->show;
						goto entering;
					}
				} else if(last && !current) { // Leaving last zone
					SendIOScriptEvent(io, SM_LEAVEZONE, last->name);

					if(!last->controled.empty()) {
						EntityHandle t = entities.getById(last->controled);

						if(t != EntityHandle::Invalid) {
							std::string str = io->idString() + ' ' + last->name;
							SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, str);
						}
					}
				} else if(!last && current) { // Entering current zone
					io->inzone_show = io->show;
				entering:

					if(JUST_RELOADED && (current->name == "ingot_maker" || current->name == "mauld_user")) {
						ARX_DEAD_CODE(); // TODO remove JUST_RELOADED global
					} else {
						SendIOScriptEvent(io, SM_ENTERZONE, current->name);

						if(!current->controled.empty()) {
							EntityHandle t = entities.getById(current->controled);

							if(t != EntityHandle::Invalid) {
								std::string params = io->idString() + ' ' + current->name;
								SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, params);
							}
						}
					}
				} else { // Changed from last to current zone
					SendIOScriptEvent(io, SM_LEAVEZONE, last->name);

					if(!last->controled.empty()) {
						EntityHandle t = entities.getById(last->controled);

						if(t != EntityHandle::Invalid) {
							std::string str = io->idString() + ' ' + last->name;
							SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, str);
						}
					}

					io->inzone_show = io->show;
					SendIOScriptEvent(io, SM_ENTERZONE, current->name);

					if(!current->controled.empty()) {
						EntityHandle t = entities.getById(current->controled);

						if(t != EntityHandle::Invalid) {
							std::string str = io->idString() + ' ' + current->name;
							SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, str);
						}
					}
				}

				io->inzone = current;
			}
			
			count++;

			if(count >= entities.size())
				count = 1;
		}

	// player check*************************************************
	{
		ARX_PATH * current = ARX_PATH_CheckPlayerInZone();
		ARX_PATH * last = player.inzone;

		if(!last && !current) { // Not in a zone
		} else if(last == current) { // Stayed inside last zone
		} else if(last && !current) { // Leaving last zone
			SendIOScriptEvent(entities.player(), SM_LEAVEZONE, last->name);
			CHANGE_LEVEL_ICON = -1;

			if(!last->controled.empty()) {
				EntityHandle t = entities.getById(last->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, "player " + last->name);
				}
			}
		} else if(!last && current) { // Entering current zone
			SendIOScriptEvent(entities.player(), SM_ENTERZONE, current->name);

			if(current->flags & PATH_AMBIANCE && !current->ambiance.empty())
				ARX_SOUND_PlayZoneAmbiance(current->ambiance, ARX_SOUND_PLAY_LOOPED, current->amb_max_vol * ( 1.0f / 100 ));

			if(current->flags & PATH_FARCLIP) {
				desired.flags |= GMOD_ZCLIP;
				desired.zclip = current->farclip;
			}

			if (current->flags & PATH_REVERB)
			{
			}

			if(current->flags & PATH_RGB) {
				desired.flags |= GMOD_DCOLOR;
				desired.depthcolor = current->rgb;
			}

			if(!current->controled.empty()) {
				EntityHandle t = entities.getById(current->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, "player " + current->name);
				}
			}
		} else { // Changed from last to current zone
			if(!last->controled.empty()) {
				EntityHandle t = entities.getById(last->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_LEAVE, "player " + current->name);
				}
			}

			if(!last->controled.empty()) {
				EntityHandle t = entities.getById(current->controled);

				if(t != EntityHandle::Invalid) {
					SendIOScriptEvent(entities[t], SM_CONTROLLEDZONE_ENTER, "player " + current->name);
				}
			}
		}

		player.inzone = current;
	}
	
	JUST_RELOADED = 0;
}