コード例 #1
0
ファイル: Scene.cpp プロジェクト: carriercomm/ArxLibertatis
bool VisibleSphere(const Vec3f & pos, float radius) {
	
	if(fartherThan(pos, ACTIVECAM->orgTrans.pos, ACTIVECAM->cdepth*0.5f + radius))
		return false;

	long room_num = ARX_PORTALS_GetRoomNumForPosition(pos);

	if (room_num>=0)
	{
		Sphere sphere;
		sphere.origin = pos;
		sphere.radius = radius;
							
		EERIE_FRUSTRUM_DATA & frustrums = RoomDraw[room_num].frustrum;

		if (FrustrumsClipSphere(frustrums, sphere))
			return false;
	}

	return true;
}
コード例 #2
0
ファイル: MiniMap.cpp プロジェクト: Gladius1/ArxLibertatis
void MiniMap::validatePlayerPos(int currentLevel, long blockPlayerControls, ARX_INTERFACE_BOOK_MODE bookMode) {
	
	m_currentLevel = currentLevel;
	
	if(!blockPlayerControls) {
		
		float req;
		
		if((m_player->Interface & INTER_MAP) && (!(m_player->Interface & INTER_COMBATMODE)) && (bookMode == BOOKMODE_MINIMAP)) {
			req = 20.f;
		} else {
			req = 80.f;
		}
		
		if(fartherThan(Vec2f(m_playerLastPosX, m_playerLastPosZ), Vec2f(m_player->pos.x, m_player->pos.z), req)) {
			m_playerLastPosX = m_player->pos.x;
			m_playerLastPosZ = m_player->pos.z;
			validatePos();
		}
	}
}
コード例 #3
0
ファイル: Spells09.cpp プロジェクト: fourks/ArxLibertatis
void CMassParalyse::Update(unsigned long _ulTime)
{
    ulCurrentTime += _ulTime;

    if (ulCurrentTime < ulDuration)
    {
        int	nb = inter.nbmax, nb2;

        while (nb--)
        {
            if (inter.iobj[nb])
            {
                if(!fartherThan(ePos, inter.iobj[nb]->pos, fRayon)) {
                    nb2 = iNbParalyse;

                    while (nb2--)
                    {
                        if (tabparalyse[nb2].id == nb) break;
                    }

                    if (nb2 < 0)
                    {
                        tabparalyse[iNbParalyse].id = nb;
                        tabparalyse[iNbParalyse].paralyse = new CParalyse();
                        (tabparalyse[iNbParalyse].paralyse)->Create(4, 50, 200.f, 150.f, &inter.iobj[nb]->pos, 10000);
                        iNbParalyse++;
                    }
                }
            }
        }

        nb = iNbParalyse;

        while (nb--)
        {
            tabparalyse[nb].paralyse->Update(_ulTime);
        }
    }
}
コード例 #4
0
ファイル: Damage.cpp プロジェクト: byouloh/ArxLibertatis
void ARX_DAMAGES_ForceDeath(Entity * io_dead, Entity * io_killer) {
	
	if(io_dead->mainevent == "dead") {
		return;
	}

	Entity * old_sender = EVENT_SENDER;
	EVENT_SENDER = io_killer;

	if(io_dead == DRAGINTER)
		Set_DragInter(NULL);

	if(io_dead == FlyingOverIO)
		FlyingOverIO = NULL;

	if((MasterCamera.exist & 1) && (MasterCamera.io == io_dead))
		MasterCamera.exist = 0;

	if((MasterCamera.exist & 2) && (MasterCamera.want_io == io_dead))
		MasterCamera.exist = 0;

	lightHandleDestroy(io_dead->dynlight);
	lightHandleDestroy(io_dead->halo.dynlight);
	
	//Kill all speeches

	ARX_NPC_Behaviour_Reset(io_dead);

	ARX_SPEECH_ReleaseIOSpeech(io_dead);

	//Kill all Timers...
	ARX_SCRIPT_Timer_Clear_For_IO(io_dead);

	if(io_dead->mainevent != "dead") {
		if(SendIOScriptEvent(io_dead, SM_DIE) != REFUSE && ValidIOAddress(io_dead)) {
			io_dead->infracolor = Color3f::blue;
		}
	}
	
	if (!ValidIOAddress(io_dead))
		return;

	ARX_SCRIPT_SetMainEvent(io_dead, "dead");

	if(fartherThan(io_dead->pos, ACTIVECAM->orgTrans.pos, 3200.f)) {
		io_dead->animlayer[0].ctime = 9999999;
		io_dead->animBlend.lastanimtime = 0;
	}

	std::string killer;

	if(io_dead->ioflags & IO_NPC)
		io_dead->_npcdata->weaponinhand = 0;

	ARX_INTERACTIVE_DestroyDynamicInfo(io_dead);

	if(io_killer == entities.player()) {
		killer = "player";
	} else {
		if(io_killer)
			killer = io_killer->idString();
	}

	for(size_t i = 1; i < entities.size(); i++) {
		const EntityHandle handle = EntityHandle(i);
		Entity * ioo = entities[handle];

		if(ioo == io_dead)
			continue;

		if(ioo && (ioo->ioflags & IO_NPC)) {
			if(ValidIONum(ioo->targetinfo))
				if(entities[ioo->targetinfo] == io_dead) {
					EVENT_SENDER = io_dead; 
					Stack_SendIOScriptEvent(entities[handle], SM_NULL, killer, "target_death");
					ioo->targetinfo = EntityHandle(TARGET_NONE);
					ioo->_npcdata->reachedtarget = 0;
				}

			if(ValidIONum(ioo->_npcdata->pathfind.truetarget))
				if(entities[ioo->_npcdata->pathfind.truetarget] == io_dead) {
					EVENT_SENDER = io_dead; 
					Stack_SendIOScriptEvent(entities[handle], SM_NULL, killer, "target_death");
					ioo->_npcdata->pathfind.truetarget = EntityHandle(TARGET_NONE);
					ioo->_npcdata->reachedtarget = 0;
				}
		}
	}

	io_dead->animlayer[1].cur_anim = NULL;
	io_dead->animlayer[2].cur_anim = NULL;
	io_dead->animlayer[3].cur_anim = NULL;

	if(io_dead->ioflags & IO_NPC) {
		io_dead->_npcdata->lifePool.current = 0;

		if(io_dead->_npcdata->weapon) {
			Entity * ioo = io_dead->_npcdata->weapon;
			if(ValidIOAddress(ioo)) {
				ioo->show = SHOW_FLAG_IN_SCENE;
				ioo->ioflags |= IO_NO_NPC_COLLIDE;
				ioo->pos = ioo->obj->vertexlist3[ioo->obj->origin].v;
				ioo->velocity = Vec3f(0.f, 13.f, 0.f);
				ioo->stopped = 0;
			}
		}
	}

	EVENT_SENDER = old_sender;
}
コード例 #5
0
ファイル: Light.cpp プロジェクト: bowlofstew/ArxLibertatis
void TreatBackgroundDynlights() {

    ARX_PROFILE_FUNC();

    for(size_t i = 0; i < MAX_LIGHTS; i++) {
        EERIE_LIGHT *light = GLight[i];

        if(light && (light->extras & EXTRAS_SEMIDYNAMIC)) {

            float fMaxdist = player.m_telekinesis ? 850 : 300;

            if(!fartherThan(light->pos, ACTIVECAM->orgTrans.pos, fMaxdist)) {
                ComputeLight2DPos(light);
            } else {
                light->m_screenRect.max.x = -1;
                light->m_screenRect.min.x = 1;
            }

            if(!light->m_ignitionStatus) {
                // just extinguished
                if(lightHandleIsValid(light->m_ignitionLightHandle)) {
                    lightHandleGet(light->m_ignitionLightHandle)->exist = 0;
                    light->m_ignitionLightHandle = LightHandle();

                    for(size_t l = 0; l < entities.size(); l++) {
                        const EntityHandle handle = EntityHandle(l);
                        Entity * e = entities[handle];

                        if(e && (e->ioflags & IO_MARKER)) {
                            Vec3f _pos2 = GetItemWorldPosition(e);
                            if(!fartherThan(light->pos, _pos2, 300.f)) {
                                SendIOScriptEvent(e, SM_CUSTOM, "douse");
                            }
                        }
                    }
                }
            } else {
                // just light up
                if(!lightHandleIsValid(light->m_ignitionLightHandle)) {
                    for(size_t l = 0; l < entities.size(); l++) {
                        const EntityHandle handle = EntityHandle(l);
                        Entity * e = entities[handle];

                        if(e && (e->ioflags & IO_MARKER)) {
                            Vec3f _pos2 = GetItemWorldPosition(e);
                            if(!fartherThan(light->pos, _pos2, 300.f)) {
                                SendIOScriptEvent(e, SM_CUSTOM, "fire");
                            }
                        }
                    }

                    light->m_ignitionLightHandle = GetFreeDynLight();
                }

                if(lightHandleIsValid(light->m_ignitionLightHandle)) {
                    EERIE_LIGHT *dynamicLight = lightHandleGet(light->m_ignitionLightHandle);

                    dynamicLight->pos          = light->pos;
                    dynamicLight->fallstart    = light->fallstart;
                    dynamicLight->fallend      = light->fallend;
                    dynamicLight->m_isIgnitionLight  = true;
                    dynamicLight->intensity    = light->intensity;
                    dynamicLight->ex_flaresize = light->ex_flaresize;
                    dynamicLight->extras       = light->extras;
                    dynamicLight->duration     = std::numeric_limits<long>::max();

                    dynamicLight->rgb = light->rgb - light->rgb * light->ex_flicker * randomColor3f() * 0.5f;

                    dynamicLight->rgb = componentwise_max(dynamicLight->rgb, Color3f::black);
                    RecalcLight(dynamicLight);
                }
            }
        }
    }

    for(size_t i = 0; i < MAX_DYNLIGHTS; i++) {
        EERIE_LIGHT * el = &DynLight[i];

        if(el->exist && el->duration) {
            float tim = (float)float(arxtime) - (float)el->time_creation;
            float duration = (float)el->duration;

            if(tim >= duration) {
                float sub = framedelay * 0.001f;

                el->rgb.r -= sub;
                el->rgb.g -= sub;
                el->rgb.b -= sub;

                if(el->rgb.r < 0)
                    el->rgb.r = 0.f;

                if(el->rgb.g < 0)
                    el->rgb.g = 0.f;

                if(el->rgb.b < 0)
                    el->rgb.b = 0.f;

                if(el->rgb.r + el->rgb.g + el->rgb.b == 0) {
                    el->exist = 0;
                    el->duration = 0;
                }
            }
        }
    }
}
コード例 #6
0
ファイル: Physics.cpp プロジェクト: Dimoks/ArxLibertatis_fork
static bool IsFULLObjectVertexInValidPosition(PHYSICS_BOX_DATA * pbox, EERIEPOLY *& collisionPoly) {

	float rad = pbox->radius;
	
	// TODO copy-paste background tiles
	int tilex = int(pbox->vert[0].pos.x * ACTIVEBKG->Xmul);
	int tilez = int(pbox->vert[0].pos.z * ACTIVEBKG->Zmul);
	int radius = std::min(1, short(rad * (1.0f/100)) + 1);
	
	int minx = std::max(tilex - radius, 0);
	int maxx = std::min(tilex + radius, ACTIVEBKG->Xsize - 1);
	int minz = std::max(tilez - radius, 0);
	int maxz = std::min(tilez + radius, ACTIVEBKG->Zsize - 1);
	
	for(int z = minz; z <= maxz; z++)
	for(int x = minx; x <= maxx; x++) {
		EERIE_BKG_INFO & eg = ACTIVEBKG->fastdata[x][z];
		
		for(long k = 0; k < eg.nbpoly; k++) {
			EERIEPOLY & ep = eg.polydata[k];
			
			if(ep.area > 190.f
			   && !(ep.type & POLY_WATER)
			   && !(ep.type & POLY_TRANS)
			   && !(ep.type & POLY_NOCOL)
			) {
				if(fartherThan(ep.center, pbox->vert[0].pos, rad + 75.f))
					continue;
				
				for(long kk = 0; kk < pbox->nb_physvert; kk++) {
					float radd = 4.f;

					if(!fartherThan(pbox->vert[kk].pos, ep.center, radd)
					   || !fartherThan(pbox->vert[kk].pos, ep.v[0].p, radd)
					   || !fartherThan(pbox->vert[kk].pos, ep.v[1].p, radd)
					   || !fartherThan(pbox->vert[kk].pos, ep.v[2].p, radd)
					   || !fartherThan(pbox->vert[kk].pos, (ep.v[0].p + ep.v[1].p) * .5f, radd)
					   || !fartherThan(pbox->vert[kk].pos, (ep.v[2].p + ep.v[1].p) * .5f, radd)
					   || !fartherThan(pbox->vert[kk].pos, (ep.v[0].p + ep.v[2].p) * .5f, radd)
					) {
						collisionPoly = &ep;
						return false;
					}
					
					// Last addon
					for(long kl = 1; kl < pbox->nb_physvert; kl++) {
						if(kl != kk) {
							Vec3f pos = (pbox->vert[kk].pos + pbox->vert[kl].pos) * .5f;
							
							if(!fartherThan(pos, ep.center, radd)
							   || !fartherThan(pos, ep.v[0].p, radd)
							   || !fartherThan(pos, ep.v[1].p, radd)
							   || !fartherThan(pos, ep.v[2].p, radd)
							   || !fartherThan(pos, (ep.v[0].p + ep.v[1].p) * .5f, radd)
							   || !fartherThan(pos, (ep.v[2].p + ep.v[1].p) * .5f, radd)
							   || !fartherThan(pos, (ep.v[0].p + ep.v[2].p) * .5f, radd)
							) {
								collisionPoly = &ep;
								return false;
							}
						}
					}
				}
				
				if(IsObjectVertexCollidingPoly(pbox, ep)) {
					collisionPoly = &ep;
					return false;
				}
			}
		}
	}

	return true;
}
コード例 #7
0
ファイル: Light.cpp プロジェクト: bsxf-47/ArxLibertatis
void TreatBackgroundDynlights() {
	
	ARX_PROFILE_FUNC();
	
	for(size_t i = 0; i < g_staticLightsMax; i++) {
		EERIE_LIGHT * light = g_staticLights[i];
		
		if(light && (light->extras & EXTRAS_SEMIDYNAMIC)) {
			
			float fMaxdist = player.m_telekinesis ? 850 : 300;
			
			if(!fartherThan(light->pos, g_camera->m_pos, fMaxdist)) {
				ComputeLight2DPos(light);
			} else {
				light->m_screenRect = Rectf(1, 0, -1, 0); // Intentionally invalid
			}
			
			if(!light->m_ignitionStatus) {
				
				// just extinguished
				EERIE_LIGHT * dynLight = lightHandleGet(light->m_ignitionLightHandle);
				if(dynLight) {
					dynLight->m_exists = false;
					light->m_ignitionLightHandle = LightHandle();
					for(size_t l = 0; l < entities.size(); l++) {
						const EntityHandle handle = EntityHandle(l);
						Entity * e = entities[handle];
						if(e && (e->ioflags & IO_MARKER)) {
							Vec3f _pos2 = GetItemWorldPosition(e);
							if(!fartherThan(light->pos, _pos2, 300.f)) {
								SendIOScriptEvent(NULL, e, SM_CUSTOM, "douse");
							}
						}
					}
				}
				
			} else {
				
				// just light up
				if(!lightHandleGet(light->m_ignitionLightHandle)) {
					for(size_t l = 0; l < entities.size(); l++) {
						const EntityHandle handle = EntityHandle(l);
						Entity * e = entities[handle];
						if(e && (e->ioflags & IO_MARKER)) {
							Vec3f _pos2 = GetItemWorldPosition(e);
							if(!fartherThan(light->pos, _pos2, 300.f)) {
								SendIOScriptEvent(NULL, e, SM_CUSTOM, "fire");
							}
						}
					}
					light->m_ignitionLightHandle = GetFreeDynLight();
				}
				
				EERIE_LIGHT * dynamicLight = lightHandleGet(light->m_ignitionLightHandle);
				if(dynamicLight) {
					dynamicLight->pos          = light->pos;
					dynamicLight->fallstart    = light->fallstart;
					dynamicLight->fallend      = light->fallend;
					dynamicLight->m_isIgnitionLight  = true;
					dynamicLight->intensity    = light->intensity;
					dynamicLight->ex_flaresize = light->ex_flaresize;
					dynamicLight->extras       = light->extras;
					dynamicLight->duration     = GameDurationMs(std::numeric_limits<long>::max());
					
					dynamicLight->rgb = light->rgb - light->rgb * light->ex_flicker * randomColor3f() * 0.5f;
					
					dynamicLight->rgb = componentwise_max(dynamicLight->rgb, Color3f::black);
					RecalcLight(dynamicLight);
				}
			}
		}
	}

	for(size_t i = 0; i < g_dynamicLightsMax; i++) {
		EERIE_LIGHT * el = &g_dynamicLights[i];

		if(el->m_exists && el->duration != 0) {
			const GameDuration elapsed = g_gameTime.now() - el->creationTime;
			const GameDuration duration = el->duration;

			if(elapsed >= duration) {
				float sub = g_gameTime.lastFrameDuration() / GameDurationMs(1000);

				el->rgb.r -= sub;
				el->rgb.g -= sub;
				el->rgb.b -= sub;

				if(el->rgb.r < 0)
					el->rgb.r = 0.f;

				if(el->rgb.g < 0)
					el->rgb.g = 0.f;

				if(el->rgb.b < 0)
					el->rgb.b = 0.f;

				if(el->rgb.r + el->rgb.g + el->rgb.b == 0) {
					el->m_exists = false;
					el->duration = 0;
				}
			}
		}
	}
}
コード例 #8
0
ファイル: Light.cpp プロジェクト: lemmel/ArxLibertatis
//*************************************************************************************
//*************************************************************************************
void TreatBackgroundDynlights()
{
    long n;

    for (size_t i = 0; i < MAX_LIGHTS; i++)
    {
        if ((GLight[i] != NULL) && (GLight[i]->extras & EXTRAS_SEMIDYNAMIC))
        {
            float fMaxdist = 300;

            if (Project.telekinesis) fMaxdist = 850;

            if(!fartherThan(GLight[i]->pos, ACTIVECAM->pos, fMaxdist)) {
                ComputeLight2DPos(GLight[i]);
            }

            if (GLight[i]->status == 0)
            {
                // vient de s'éteindre
                if (GLight[i]->tl > 0)
                {
                    DynLight[GLight[i]->tl].exist = 0;
                    GLight[i]->tl = -1;
                    Vec3f _pos2;

                    for (long l = 0; l < inter.nbmax; l++)
                    {
                        if ((inter.iobj[l] != NULL) &&
                                (inter.iobj[l]->ioflags & IO_MARKER))
                        {
                            GetItemWorldPosition(inter.iobj[l], &_pos2);

                            if(!fartherThan(GLight[i]->pos, _pos2, 300.f)) {
                                SendIOScriptEvent(inter.iobj[l], SM_CUSTOM, "douse");
                            }
                        }
                    }
                }
            }
            else
            {
                // vient de s'allumer
                if (GLight[i]->tl <= 0)
                {
                    Vec3f _pos2;

                    for (long l = 0; l < inter.nbmax; l++)
                    {
                        if ((inter.iobj[l] != NULL) &&
                                (inter.iobj[l]->ioflags & IO_MARKER))
                        {
                            GetItemWorldPosition(inter.iobj[l], &_pos2);

                            if(!fartherThan(GLight[i]->pos, _pos2, 300.f)) {
                                SendIOScriptEvent(inter.iobj[l], SM_CUSTOM, "fire");
                            }
                        }
                    }

                    GLight[i]->tl = GetFreeDynLight();
                }

                n = GLight[i]->tl;

                if (n != -1)
                {
                    DynLight[n].pos.x		=	GLight[i]->pos.x;
                    DynLight[n].pos.y		=	GLight[i]->pos.y;
                    DynLight[n].pos.z		=	GLight[i]->pos.z;
                    DynLight[n].exist		=	1;
                    DynLight[n].fallstart	=	GLight[i]->fallstart;
                    DynLight[n].fallend		=	GLight[i]->fallend;
                    DynLight[n].type		=	TYP_SPECIAL1;
                    DynLight[n].intensity	=	GLight[i]->intensity;
                    DynLight[n].ex_flaresize =	GLight[i]->ex_flaresize;
                    DynLight[n].extras		=	GLight[i]->extras;
                    DynLight[n].duration = std::numeric_limits<long>::max();

                    DynLight[n].rgb.r = GLight[i]->rgb.r - GLight[i]->rgb.r * GLight[i]->ex_flicker.r * rnd() * ( 1.0f / 2 );
                    DynLight[n].rgb.g = GLight[i]->rgb.g - GLight[i]->rgb.g * GLight[i]->ex_flicker.g * rnd() * ( 1.0f / 2 );
                    DynLight[n].rgb.b = GLight[i]->rgb.b - GLight[i]->rgb.b * GLight[i]->ex_flicker.b * rnd() * ( 1.0f / 2 );

                    if (DynLight[n].rgb.r < 0.f) DynLight[n].rgb.r = 0.f;

                    if (DynLight[n].rgb.g < 0.f) DynLight[n].rgb.g = 0.f;

                    if (DynLight[n].rgb.b < 0.f) DynLight[n].rgb.b = 0.f;

                    DynLight[n].rgb255.r = DynLight[n].rgb.r * 255.f;
                    DynLight[n].rgb255.g = DynLight[n].rgb.g * 255.f;
                    DynLight[n].rgb255.b = DynLight[n].rgb.b * 255.f;

                    DynLight[n].falldiff = DynLight[n].fallend - DynLight[n].fallstart;
                    DynLight[n].falldiffmul = 1.f / DynLight[n].falldiff;
                    DynLight[n].precalc = DynLight[n].intensity * GLOBAL_LIGHT_FACTOR;
                }
            }
        }

    }
}
コード例 #9
0
ファイル: Anchors.cpp プロジェクト: HerculesCE/ArxLibertatis
static void AnchorData_Create_Links_Original_Method(EERIE_BACKGROUND * eb) {
	
	Vec3f p1, p2; 
	long count = 0;
	long per;
	long lastper = -1;
	long total = eb->Zsize * eb->Xsize;

	for(long j = 0; j < eb->Zsize; j++)
	for(long i = 0; i < eb->Xsize; i++) {
		per = count / total * 100.f;
		
		if(per != lastper) {
			LogInfo << "Anchor Links Generation: %" << per;
			lastper = per;
		}
		
		count++;
		EERIE_BKG_INFO * eg = &eb->fastdata[i][j];
		long precise = 0;
		
		for(long kkk = 0; kkk < eg->nbpolyin; kkk++) {
			EERIEPOLY * ep = eg->polyin[kkk];
			
			if(ep->type & POLY_PRECISE_PATH) {
				precise = 1;
				break;
			}
		}
		
		
		for(long k = 0; k < eg->nbianchors; k++) {
			long ii = glm::clamp(i - 2, 0l, eb->Xsize - 1l);
			long ia = glm::clamp(i + 2, 0l, eb->Xsize - 1l);
			long ji = glm::clamp(j - 2, 0l, eb->Zsize - 1l);
			long ja = glm::clamp(j + 2, 0l, eb->Zsize - 1l);
			
			for(long j2 = ji; j2 <= ja; j2++)
			for(long i2 = ii; i2 <= ia; i2++) {
				EERIE_BKG_INFO * eg2 = &eb->fastdata[i2][j2];
				long precise2 = 0;
				
				for(long kkk = 0; kkk < eg2->nbpolyin; kkk++) {
					EERIEPOLY * ep2 = eg2->polyin[kkk];
					
					if(ep2->type & POLY_PRECISE_PATH) {
						precise2 = 1;
						break;
					}
				}
				
				for(long k2 = 0; k2 < eg2->nbianchors; k2++) {
					// don't treat currently treated anchor
					if(eg->ianchors[k] == eg2->ianchors[k2])
						continue;
					
					p1 = eb->anchors[eg->ianchors[k]].pos;
					p2 = eb->anchors[eg2->ianchors[k2]].pos;
					p1.y += 10.f;
					p2.y += 10.f;
					long _onetwo = 0;
					bool treat = true;
					float _dist = glm::distance(p1, p2);
					float dd = glm::distance(Vec2f(p1.x, p1.z), Vec2f(p2.x, p2.z));
					
					if(dd < 5.f)
						continue;
					
					if(dd > 200.f)
						continue; 
					
					if(precise || precise2) {
						if(_dist > 120.f)
							continue;
					} else if(_dist > 200.f) {
						continue;
					}
					
					if(glm::abs(p1.y - p2.y) > dd * 0.9f)
						continue;
					
					IO_PHYSICS ip;
					ip.startpos = ip.cyl.origin = p1;
					ip.targetpos = p2;
					
					ip.cyl.height = eb->anchors[eg->ianchors[k]].height; 
					ip.cyl.radius = eb->anchors[eg->ianchors[k]].radius;
					
					long t = 2;
					
					//TODO check for dead code CFLAG_SPECIAL
					if(ANCHOR_ARX_COLLISION_Move_Cylinder(&ip, NULL, 20, CFLAG_CHECK_VALID_POS | CFLAG_NO_INTERCOL | CFLAG_EASY_SLIDING | CFLAG_NPC | CFLAG_JUST_TEST | CFLAG_EXTRA_PRECISION)) {
						if(fartherThan(Vec2f(ip.cyl.origin.x, ip.cyl.origin.z), Vec2f(ip.targetpos.x, ip.targetpos.z), 25.f)) { 
							t--;
						} else {
							_onetwo = 1;
						}
					} else {
						t--;
					}
					
					if(t == 1) {
						ip.startpos = ip.cyl.origin = p2;
						ip.targetpos = p1;
						
						ip.cyl.height = eb->anchors[eg2->ianchors[k2]].height;
						ip.cyl.radius = eb->anchors[eg2->ianchors[k2]].radius; 
						
						//CFLAG_SPECIAL
						if(ANCHOR_ARX_COLLISION_Move_Cylinder(&ip, NULL, 20, CFLAG_CHECK_VALID_POS | CFLAG_NO_INTERCOL | CFLAG_EASY_SLIDING | CFLAG_NPC | CFLAG_JUST_TEST | CFLAG_EXTRA_PRECISION | CFLAG_RETURN_HEIGHT)) {
							if(fartherThan(Vec2f(ip.cyl.origin.x, ip.cyl.origin.z), Vec2f(ip.targetpos.x, ip.targetpos.z), 25.f)) {
								t--;
							} else {
								_onetwo |= 2;
							}
						} else {
							t--;
						}
					} else {
						t--;
					}
					
					if(t <= 0)
						treat = false;
					else
						treat = true;
					
					if(treat) {
						if(_onetwo) {
							AddAnchorLink(eb, eg->ianchors[k], eg2->ianchors[k2]);
							AddAnchorLink(eb, eg2->ianchors[k2], eg->ianchors[k]);
						}
					}
				}
			}
		}
	}
	
	EERIE_PATHFINDER_Create();
}
コード例 #10
0
void DouseSpell::Launch()
{
	m_duration = ArxDurationMs(500);
	
	Vec3f target;
	if(m_hand_group != ActionPoint()) {
		target = m_hand_pos;
	} else {
		target = m_caster_pos;
		target.y -= 50.f;
	}
	
	float fPerimeter = 400.f + m_level * 30.f;
	
	CheckForIgnition(Sphere(target, fPerimeter), 0, 1);
	
	for(size_t ii = 0; ii < g_staticLightsMax; ii++) {
		EERIE_LIGHT * light = g_staticLights[ii];
		
		if(!light || !(light->extras & EXTRAS_EXTINGUISHABLE)) {
			continue;
		}
		
		if(!(light->extras & EXTRAS_SEMIDYNAMIC)
		  && !(light->extras & EXTRAS_SPAWNFIRE)
		  && !(light->extras & EXTRAS_SPAWNSMOKE)) {
			continue;
		}
		
		if(!light->m_ignitionStatus) {
			continue;
		}
		
		if(!fartherThan(target, light->pos, fPerimeter)) {
			m_lights.push_back(ii);
		}
	}
	
	if(player.torch && closerThan(target, player.pos, fPerimeter)) {
		ARX_PLAYER_ClickedOnTorch(player.torch);
	}
	
	for(size_t k = 0; k < MAX_SPELLS; k++) {
		SpellBase * spell = spells[SpellHandle(k)];
		
		if(!spell) {
			continue;
		}
		
		switch(spell->m_type) {
			
			case SPELL_FIREBALL: {
				Vec3f pos = spell->getPosition();
				float radius = std::max(m_level * 2.f, 12.f);
				if(closerThan(target, pos, fPerimeter + radius)) {
					spell->m_level -= m_level;
					if(spell->m_level < 1) {
						spells.endSpell(spell);
					}
				}
				break;
			}
			
			case SPELL_FIRE_FIELD: {
				Vec3f pos = spell->getPosition();
				if(closerThan(target, pos, fPerimeter + 200)) {
					spell->m_level -= m_level;
					if(spell->m_level < 1) {
						spells.endSpell(spell);
					}
				}
				break;
			}
			
			default: break;
		}
	}
}
コード例 #11
0
void IgnitSpell::Launch()
{
	m_duration = ArxDurationMs(500);
	
	if(m_hand_group != ActionPoint()) {
		m_srcPos = m_hand_pos;
	} else {
		m_srcPos = m_caster_pos - Vec3f(0.f, 50.f, 0.f);
	}
	
	EERIE_LIGHT * light = dynLightCreate();
	if(light) {
		light->intensity = 1.8f;
		light->fallend   = 450.f;
		light->fallstart = 380.f;
		light->rgb       = Color3f(1.f, 0.75f, 0.5f);
		light->pos       = m_srcPos;
		light->duration  = ArxDurationMs(300);
	}
	
	float fPerimeter = 400.f + m_level * 30.f;
	
	m_lights.clear();
	m_elapsed = ArxDuration_ZERO;
	
	CheckForIgnition(Sphere(m_srcPos, fPerimeter), 1, 1);
	
	for(size_t ii = 0; ii < g_staticLightsMax; ii++) {
		EERIE_LIGHT * light = g_staticLights[ii];
		
		if(!light || !(light->extras & EXTRAS_EXTINGUISHABLE)) {
			continue;
		}
		
		if(m_caster == EntityHandle_Player && (light->extras & EXTRAS_NO_IGNIT)) {
			continue;
		}
		
		if(!(light->extras & EXTRAS_SEMIDYNAMIC)
		  && !(light->extras & EXTRAS_SPAWNFIRE)
		  && !(light->extras & EXTRAS_SPAWNSMOKE)) {
			continue;
		}
		
		if(light->m_ignitionStatus) {
			continue;
		}
		
		if(!fartherThan(m_srcPos, light->pos, fPerimeter)) {
			
			T_LINKLIGHTTOFX entry;
			
			entry.m_targetLight = ii;
			
			EERIE_LIGHT * light = dynLightCreate(entry.m_effectLight);
			if(light) {
				light->intensity = Random::getf(0.7f, 2.7f);
				light->fallend = 400.f;
				light->fallstart = 300.f;
				light->rgb = Color3f(1.f, 1.f, 1.f);
				light->pos = light->pos;
			}
		
			m_lights.push_back(entry);
		}
	}
	
	for(size_t n = 0; n < MAX_SPELLS; n++) {
		SpellBase * spell = spells[SpellHandle(n)];
		
		if(!spell) {
			continue;
		}
		if(spell->m_type == SPELL_FIREBALL) {
			Vec3f pos = static_cast<FireballSpell *>(spell)->getPosition();
			
			float radius = std::max(m_level * 2.f, 12.f);
			if(closerThan(m_srcPos, pos, fPerimeter + radius)) {
				spell->m_level += 1;
			}
		}
	}
}
コード例 #12
0
void DouseSpell::Launch()
{
	m_duration = 500;
	
	Vec3f target;
	if(m_hand_group >= 0) {
		target = m_hand_pos;
	} else {
		target = m_caster_pos;
		target.y -= 50.f;
	}
	
	float fPerimeter = 400.f + m_level * 30.f;
	
	CheckForIgnition(target, fPerimeter, 0, 1);
	
	for(size_t ii = 0; ii < MAX_LIGHTS; ii++) {
		EERIE_LIGHT * light = GLight[ii];
		
		if(!light || !(light->extras & EXTRAS_EXTINGUISHABLE)) {
			continue;
		}
		
		if(!(light->extras & EXTRAS_SEMIDYNAMIC)
		  && !(light->extras & EXTRAS_SPAWNFIRE)
		  && !(light->extras & EXTRAS_SPAWNSMOKE)) {
			continue;
		}
		
		if(!light->m_ignitionStatus) {
			continue;
		}
		
		if(!fartherThan(target, light->pos, fPerimeter)) {
			T_LINKLIGHTTOFX entry;
			
			entry.iLightNum = ii;
			entry.poslight = light->pos;
			m_lights.push_back(entry);
		}
	}
	
	if(player.torch && closerThan(target, player.pos, fPerimeter)) {
		ARX_PLAYER_ClickedOnTorch(player.torch);
	}
	
	for(size_t k = 0; k < MAX_SPELLS; k++) {
		SpellBase * spell = spells[SpellHandle(k)];
		
		if(!spell) {
			continue;
		}
		
		switch(spell->m_type) {
			
			case SPELL_FIREBALL: {
				CSpellFx * pCSpellFX = spell->m_pSpellFx;
				if(pCSpellFX) {
					CFireBall * pCF = (CFireBall *)pCSpellFX;
					float radius = std::max(m_level * 2.f, 12.f);
					if(closerThan(target, pCF->eCurPos,
					              fPerimeter + radius)) {
						spell->m_level -= m_level;
						if(spell->m_level < 1) {
							spells.endSpell(spell);
						}
					}
				}
				break;
			}
			
			case SPELL_FIRE_FIELD: {
				Vec3f pos;
				if(GetSpellPosition(&pos, spell)) {
					if(closerThan(target, pos, fPerimeter + 200)) {
						spell->m_level -= m_level;
						if(spell->m_level < 1) {
							spells.endSpell(spell);
						}
					}
				}
				break;
			}
			
			default: break;
		}
	}
}
コード例 #13
0
void IgnitSpell::Launch()
{
	m_duration = 500;
	
	if(m_hand_group != -1) {
		m_srcPos = m_hand_pos;
	} else {
		m_srcPos = m_caster_pos - Vec3f(0.f, 50.f, 0.f);
	}
	
	LightHandle id = GetFreeDynLight();
	if(lightHandleIsValid(id)) {
		EERIE_LIGHT * light = lightHandleGet(id);
		
		light->intensity = 1.8f;
		light->fallend   = 450.f;
		light->fallstart = 380.f;
		light->rgb       = Color3f(1.f, 0.75f, 0.5f);
		light->pos       = m_srcPos;
		light->duration  = 300;
	}
	
	float fPerimeter = 400.f + m_level * 30.f;
	
	m_lights.clear();
	m_elapsed = 0;
	
	CheckForIgnition(m_srcPos, fPerimeter, 1, 1);
	
	for(size_t ii = 0; ii < MAX_LIGHTS; ii++) {
		EERIE_LIGHT * light = GLight[ii];
		
		if(!light || !(light->extras & EXTRAS_EXTINGUISHABLE)) {
			continue;
		}
		
		if(m_caster == PlayerEntityHandle && (light->extras & EXTRAS_NO_IGNIT)) {
			continue;
		}
		
		if(!(light->extras & EXTRAS_SEMIDYNAMIC)
		  && !(light->extras & EXTRAS_SPAWNFIRE)
		  && !(light->extras & EXTRAS_SPAWNSMOKE)) {
			continue;
		}
		
		if(light->m_ignitionStatus) {
			continue;
		}
		
		if(!fartherThan(m_srcPos, light->pos, fPerimeter)) {
			
			T_LINKLIGHTTOFX entry;
			
			entry.iLightNum = ii;
			entry.poslight = light->pos;
		
			entry.idl = GetFreeDynLight();
		
			if(lightHandleIsValid(entry.idl)) {
				EERIE_LIGHT * light = lightHandleGet(entry.idl);
				
				light->intensity = 0.7f + 2.f * rnd();
				light->fallend = 400.f;
				light->fallstart = 300.f;
				light->rgb = Color3f(1.f, 1.f, 1.f);
				light->pos = entry.poslight;
			}
		
			m_lights.push_back(entry);
		}
	}
	
	for(size_t n = 0; n < MAX_SPELLS; n++) {
		SpellBase * spell = spells[SpellHandle(n)];
		
		if(!spell) {
			continue;
		}
		if(spell->m_type == SPELL_FIREBALL) {
			CSpellFx * pCSpellFX = spell->m_pSpellFx;
			if(pCSpellFX) {
				CFireBall * pCF = (CFireBall *)pCSpellFX;
				float radius = std::max(m_level * 2.f, 12.f);
				if(closerThan(m_srcPos, pCF->eCurPos,
				              fPerimeter + radius)) {
					spell->m_level += 1;
				}
			}
		}
	}
}