static void logo_blit(video_adapter_t *adp, int x, int y) { int d, l, o, p; int last_origin = -1; for (o = 0, p = y * bpsl + x; p > banksize; p -= banksize) o += banksize; SET_ORIGIN(adp, o); for (d = 0; d < logo_img_size; d += logo_w) { if (p + logo_w < banksize) { bcopy(logo_img + d, vid + p, logo_w); p += bpsl; } else if (p < banksize) { l = banksize - p; bcopy(logo_img + d, vid + p, l); SET_ORIGIN(adp, (o += banksize)); bcopy(logo_img + d + l, vid, logo_w - l); p += bpsl - banksize; } else { p -= banksize; SET_ORIGIN(adp, (o += banksize)); bcopy(logo_img + d, vid + p, logo_w); p += bpsl; } } }
static void warp_update(video_adapter_t *adp) { int i, j, k, n, o, p; int last_origin = -1; for (i = 1, k = 0, n = SPP*8; i < 5; i++, n /= 2) { for (j = 0; j < n; j++, k++) { p = (star[k] / scrw) * bpsl + (star[k] % scrw); o = 0; while (p > banksize) { p -= banksize; o += banksize; } SET_ORIGIN(adp, o); vid[p] = 0; star[k] += i; if (star[k] > scrw*scrh) star[k] -= scrw*scrh; p = (star[k] / scrw) * bpsl + (star[k] % scrw); o = 0; while (p > banksize) { p -= banksize; o += banksize; } SET_ORIGIN(adp, o); vid[p] = i; } } }
static int rain_saver(video_adapter_t *adp, int blank) { int i, j, o, p, pl; u_char temp; int last_origin = -1; if (blank) { /* switch to graphics mode */ if (blanked <= 0) { pl = splhigh(); vidd_set_mode(adp, scrmode); vidd_load_palette(adp, rain_pal); vidd_set_border(adp, 0); blanked++; vid = (u_char *)adp->va_window; banksize = adp->va_window_size; bpsl = adp->va_line_width; splx(pl); for (i = 0; i < bpsl*scrh; i += banksize) { SET_ORIGIN(adp, i); if ((bpsl * scrh - i) < banksize) bzero(vid, bpsl * scrh - i); else bzero(vid, banksize); } SET_ORIGIN(adp, 0); for (i = 0, o = 0, p = 0; i < scrw; i += 2, p += 2) { if (p > banksize) { p -= banksize; o += banksize; SET_ORIGIN(adp, o); } vid[p] = 1 + (random() % MAX); } o = 0; p = 0; for (j = 1; j < scrh; j++) for (i = 0, p = bpsl * (j - 1) - o; i < scrw; i += 2, p+= 2) { while (p > banksize) { p -= banksize; o += banksize; } SET_ORIGIN(adp, o); temp = (vid[p] < MAX) ? 1 + vid[p] : 1; if (p + bpsl < banksize) { vid[p + bpsl] = temp; } else { SET_ORIGIN(adp, o + banksize); vid[p + bpsl - banksize] = temp; } } } /* update display */ rain_update(adp); } else { blanked = 0; } return (0); }
void bmodMotionState::setWorldTransform(const btTransform &worldTrans) { //don't affect immovable objects if(obj->getRigidBody()->isStaticOrKinematicObject()) return; Vector origin = Vector((float*)(worldTrans.getOrigin().m_floats)); btVector3 btAngles; MatrixEuler(worldTrans.getBasis(), btAngles); Vector angles = Vector((float*)btAngles.m_floats); btRigidBody * body = obj->getRigidBody(); Vector velocity; Vector avelocity; if(!body->getDeactivationTime()) { velocity = Vector((float*)body->getLinearVelocity().m_floats); btVector3 btAvelocity = body->getAngularVelocity(); avelocity = Vector(-btAvelocity[1], btAvelocity[2], btAvelocity[0]) * SIMD_DEGS_PER_RAD; } std::list<int> * entities = obj->getEntities(); for(std::list<int>::iterator it = entities->begin(); it != entities->end(); ++it) { edict_t * entity = INDEXENT(*it); SET_ORIGIN(entity, origin); entity->v.angles = angles; entity->v.velocity = velocity; entity->v.avelocity = avelocity; } }
// ns_giveiteM(id,"item"); static cell AMX_NATIVE_CALL ns_giveitem(AMX *amx, cell *params) { CreatePlayerPointer(amx,params[1]); char *classname = MF_GetAmxString(amx,params[2],0,NULL); if (!player->IsConnected()) { return 0; } if (player->GetPev()->deadflag > 0) { return 0; } edict_t *object=CREATE_NAMED_ENTITY(ALLOC_STRING2(classname)); if (!object) { MF_LogError(amx, AMX_ERR_NATIVE, "Error creating entity \"%s\"", classname); return 0; } SET_ORIGIN(object,player->GetPev()->origin); // move to player gpGamedllFuncs->dllapi_table->pfnSpawn(object); // emulate spawn object->v.flags |= FL_ONGROUND; // make it think it's touched the ground gpGamedllFuncs->dllapi_table->pfnThink(object); // gpGamedllFuncs->dllapi_table->pfnTouch(object,player->GetEdict()); // give it to the player return 1; }
void ParaThink( edict_t *pent ) { // Since we are thinking, we must be respawning the parachute item. // also play respawn sound // it sucks to look at other peoples code and not know what the f**k is going on cause they didnt comment it... // this way if i (or someone else) sees this they will be able to figure out whats happening #ifdef DEBUGLOG fp=fopen("para.txt","a"); fprintf(fp, "Parachute thinking!\n"); fclose(fp); #endif pent->v.nextthink = gpGlobals->time + 5; // dont think again until someone takes me if ( pent->v.effects & EF_NODRAW ) { // changing from invisible state to visible. EMIT_SOUND_DYN2( pent, CHAN_WEAPON, "items/suitchargeok1.wav", 1, ATTN_NORM, 0, 150 ); pent->v.effects &= ~EF_NODRAW; pent->v.effects |= EF_MUZZLEFLASH; // when items respawn they make a single frame flash // enable touching again pent->v.solid = SOLID_TRIGGER; SET_ORIGIN( pent , pent->v.origin ); } }
static void fire_update(video_adapter_t *adp) { int x, y; int o, p; int last_origin = -1; /* make a new bottom line */ for (x = 0, y = scrh; x < scrw; x++) buf[x + (y * bpsl)] = random() % 160 + 96; /* fade the flames out */ for (y = 0; y < scrh; y++) { for (x = 0; x < scrw; x++) { buf[x + (y * scrw)] = (buf[(x + 0) + ((y + 0) * scrw)] + buf[(x - 1) + ((y + 1) * scrw)] + buf[(x + 0) + ((y + 1) * scrw)] + buf[(x + 1) + ((y + 1) * scrw)]) / 4; if (buf[x + (y * scrw)] > 0) buf[x + (y * scrw)]--; } } /* blit our buffer into video ram */ for (y = 0, p = 0, o = 0; y < scrh; y++, p += bpsl) { while (p > banksize) { p -= banksize; o += banksize; } SET_ORIGIN(adp, o); if (p + scrw < banksize) { bcopy(buf + y * scrw, vid + p, scrw); } else { bcopy(buf + y * scrw, vid + p, banksize - p); SET_ORIGIN(adp, o + banksize); bcopy(buf + y * scrw + (banksize - p), vid, scrw - (banksize - p)); p -= banksize; o += banksize; } } }
edict_t *ParaSpawnItem( edict_t *pent ) { // Spawns the parachute on the ground that people can pick up to "get" a parachute // item_parachute edict_t *pent2 = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); entvars_t *pev = VARS( pent2 ); if (pent) { pev->origin = pent->v.origin; pev->angles = pent->v.angles; } SET_ORIGIN( pent2 , pev->origin ); // for now don't take damage pev->takedamage = DAMAGE_NO; pev->max_health = 20; pev->health = 20; //pev->owner = pent; // Call the SPAWN routine to set more stuff KeyValueData kvd; kvd.fHandled = FALSE; kvd.szClassName = NULL; kvd.szKeyName = "classname"; kvd.szValue = "item_avparachute"; (*other_gFunctionTable.pfnKeyValue)( pent2, &kvd ); kvd.fHandled = FALSE; pev->movetype = MOVETYPE_TOSS; pev->solid = SOLID_TRIGGER; pev->effects &= ~EF_NODRAW; pev->iuser1 = 1; DROP_TO_FLOOR( pent2 ); SET_MODEL(pent2, "models/w_longjump.mdl"); UTIL_SetSize(pev, Vector(-16, -16, 0), Vector(16, 16, 16)); pev->nextthink = gpGlobals->time + 0.1; return pent2; }
static cell AMX_NATIVE_CALL entity_set_origin(AMX *amx, cell *params) { int iEnt = params[1]; CHECK_ENTITY_SIMPLE(iEnt); edict_t *pEnt = INDEXENT2(iEnt); cell *vVector = MF_GetAmxAddr(amx, params[2]); REAL fX = amx_ctof(vVector[0]); REAL fY = amx_ctof(vVector[1]); REAL fZ = amx_ctof(vVector[2]); Vector vOrigin = Vector(fX, fY, fZ); SET_SIZE(pEnt, pEnt->v.mins, pEnt->v.maxs); SET_ORIGIN(pEnt, vOrigin); return 1; }
static cell AMX_NATIVE_CALL set_user_origin(AMX *amx, cell *params) // set_user_origin(index, origin[3]); = 2 arguments { // Sets user origin. // params[1] = index // params[2] = origin // Check index CHECK_PLAYER(params[1]); // Fetch player pointer edict_t *pPlayer = MF_GetPlayerEdict(params[1]); cell *newVectorCell = MF_GetAmxAddr(amx, params[2]); SET_SIZE(pPlayer, pPlayer->v.mins, pPlayer->v.maxs); SET_ORIGIN(pPlayer, Vector((float)newVectorCell[0], (float)newVectorCell[1], (float)newVectorCell[2])); return 1; }
void AddNodeEntity(const Vector &origin, int effects) { edict_t *pNode = CREATE_ENTITY(); if (g_fIsMetamod) { CALL_GAME_ENTITY(PLID, "info_node", VARS(pNode)); } else { info_node(VARS(pNode)); } pNode->v.classname = MAKE_STRING("info_node"); SET_ORIGIN(pNode, origin); pNode->v.rendercolor.x = 255; pNode->v.rendercolor.y = 255; pNode->v.rendercolor.z = 0; pNode->v.rendermode = kRenderTransAdd; pNode->v.movetype = MOVETYPE_NONE; pNode->v.solid = SOLID_TRIGGER; SET_SIZE(ENT(&pNode->v), Vector(-8, -8, -8), Vector(8, 8, 8)); pNode->v.renderfx = kRenderFxNoDissipation; pNode->v.renderamt = 255; pNode->v.scale = 0.2; SET_MODEL(ENT(pNode), "sprites/glow02.spr"); pNode->v.effects = effects; }
void NPC::Spawn(Vector origin) { pev->solid = SOLID_BBOX; pev->takedamage = DAMAGE_AIM; pev->deadflag = DEAD_NO; pev->health = pev->max_health; pev->fixangle = true; SET_SIZE(GetEntity(), g_npcSize[0], g_npcSize[1]); SET_ORIGIN(GetEntity(), origin); m_pmodel = null; DROP_TO_FLOOR(GetEntity()); pev->animtime = gpGlobals->time; pev->nextthink = m_nextThinkTime = gpGlobals->time + 0.2f; m_frameInterval = gpGlobals->time; m_iDamage = false; SetEntityAction(GetIndex(), m_npcTeam, 1); m_workNPC = true; }
bool RadioCreate( edict_t *pEntity ) { // Create the radio and stick to the wall entvars_t *pPev = VARS( pEntity ); if (pPev->iuser1 > 0) return 0; // make sure we dont already have a radio int radiocount = 0; int i = 1; char *pClassname; edict_t *frontEnt; for (i; i < 1025; i++) { frontEnt = INDEXENT ( i ); if (frontEnt) { pClassname = (char *)STRING(frontEnt->v.classname); if (FStrEq("building_radio", pClassname)) { if (frontEnt->v.euser4 == pEntity) { radiocount++; } } } } if (AdminLoggedIn[ENTINDEX(pEntity)] == 0) { if (radiocount >= 2) { ClientPrint( pPev, HUD_PRINTTALK, "* Cant have more than 2 radios!\n"); return 0; } } UTIL_MakeVectors( pPev->v_angle + pPev->punchangle ); Vector vecSrc = GetGunPosition( pEntity ); Vector vecAiming = gpGlobals->v_forward; TraceResult tr; UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, pEntity , &tr ); if (tr.flFraction < 1.0 || AdminLoggedIn[ENTINDEX(pEntity)]) { if (tr.pHit && !(tr.pHit->v.flags & FL_CONVEYOR) && (FStrEq((char *)STRING(tr.pHit->v.classname), "worldspawn") || FStrEq((char *)STRING(tr.pHit->v.classname), "func_wall") || AdminLoggedIn[ENTINDEX(pEntity)] || FStrEq((char *)STRING(tr.pHit->v.classname), "building_dancemachine"))) // Make sure it isnt a conveyor! { Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal ); if ((angles.x > 30 || angles.x < -30) && AdminLoggedIn[ENTINDEX(pEntity)] == 0) { ClientPrint( pPev, HUD_PRINTTALK, "* Can't place radios on floors or cielings!\n"); return 0; } // Create the camera here! Vector vecOri = tr.vecEndPos + tr.vecPlaneNormal * 14; //Vector vecOri = tr.vecEndPos + tr.vecPlaneNormal * 15; int maxdist = (int)CVAR_GET_FLOAT("sa_radiospread"); // make sure we arent placing it within 400 units of another radio for (i=1; i < 1025; i++) { frontEnt = INDEXENT ( i ); if (frontEnt) { pClassname = (char *)STRING(frontEnt->v.classname); if (FStrEq("building_radio", pClassname)) { if ((frontEnt->v.origin - vecOri).Length() < maxdist && AdminLoggedIn[ENTINDEX(pEntity)] == 0) { ClientPrint( pPev, HUD_PRINTTALK, "* Can't place a radio so close to another radio!\n"); return 0; } } } } KeyValueData kvd; //edict_t *pent = CREATE_ENTITY(); //edict_t *pent = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); edict_t *tEntity; tEntity = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); entvars_t *pRunOnPev; pRunOnPev = VARS(tEntity); char buf[80]; sprintf( buf, "%s", "building_radio"); // Set the KEYVALUES here! kvd.fHandled = FALSE; kvd.szClassName = NULL; kvd.szKeyName = "classname"; kvd.szValue = buf; DispatchKeyValue( tEntity, &kvd ); // place this in front pRunOnPev->origin = vecOri; SET_ORIGIN( tEntity , vecOri ); pRunOnPev->angles = angles; //DispatchSpawn( ENT( pRunOnPev ) ); pRunOnPev->solid = SOLID_BBOX; SET_MODEL( ENT( pRunOnPev ) , "avatar-x/avadd16.avfil"); UTIL_SetSize( pRunOnPev, Vector( -2, -2 ,-2) - (tr.vecPlaneNormal * 15), Vector(2, 2, 16) - (tr.vecPlaneNormal * 15)); pRunOnPev->takedamage = DAMAGE_YES; pRunOnPev->max_health = 40 + 10000; pRunOnPev->health = 40 + 10000; pRunOnPev->euser4 = pEntity; /* edict_t *pent; pent = CREATE_NAMED_ENTITY(MAKE_STRING("xen_tree")); entvars_t *pv = VARS( pent ); pv->origin = vecOri; SET_ORIGIN(pent, vecOri); kvd.fHandled = FALSE; kvd.szClassName = NULL; kvd.szKeyName = "classname"; kvd.szValue = "xen_tree"; DispatchKeyValue( pent, &kvd ); DispatchSpawn(pent); //pev->angles = angles; */ //pev->iuser1 = angles.y; //pv->vuser3 = angles; // for now don't take damage //pev->takedamage = DAMAGE_YES; //pev->max_health = 40 + 10000; //pev->health = 40 + 10000; /* // Call the SPAWN routine to set more stuff kvd.fHandled = FALSE; kvd.szClassName = NULL; kvd.szKeyName = "classname"; kvd.szValue = "building_radio"; //DispatchKeyValue( pent, &kvd ); kvd.fHandled = FALSE; */ RadioSpawn( tEntity ); return 1; } else { ClientPrint( pPev, HUD_PRINTTALK, "* Couldn't place radio here!\n"); return 0; } } else { ClientPrint( pPev, HUD_PRINTTALK, "* Couldn't place radio here!\n"); } return 0; }
void UTIL_SetOrigin( entvars_t *pev, const Vector &vecOrigin ) { edict_t *ent = ENT(pev); if ( ent ) SET_ORIGIN( ent, vecOrigin ); }
void UTIL_SetOrigin( entvars_t *pev, const Vector &vecOrigin ) { SET_ORIGIN(ENT(pev), vecOrigin ); }
bool DanceCreateMachine( Vector cent, edict_t *pEntity, const char *dancename) { entvars_t *pPev = VARS( pEntity ); KeyValueData kvd; edict_t *tEntity; tEntity = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); entvars_t *pev; pev = VARS(tEntity); // Set the KEYVALUES here! kvd.fHandled = FALSE; kvd.szClassName = NULL; kvd.szKeyName = "classname"; kvd.szValue = "building_dancemachine"; DispatchKeyValue( tEntity, &kvd ); // place this in front pev->origin = cent; pev->solid = SOLID_BBOX; SET_ORIGIN( tEntity , cent ); //pev->angles = angles; pev->solid = SOLID_BBOX; SET_MODEL( ENT( pev ) , "models/sphere.mdl"); UTIL_SetSize( pev, Vector( -16, -16 , -16), Vector(16, 16, 16) ); pev->takedamage = DAMAGE_NO; pev->max_health = 40 + 10000; pev->health = 40 + 10000; pev->euser4 = pEntity; pev->movetype = MOVETYPE_FLY; // play deploy sound EMIT_SOUND_DYN2( tEntity, CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM , 0, 100); pev->nextthink = gpGlobals->time + 1; pev->avelocity.y = 50; sprintf( EntData[ENTINDEX(tEntity)].digitgroup, "%s", dancename); if (FStrEq(Cmd_Argv(2), "rot")) { // rotates. get the distance, angular speed, and initial angle pev->iuser1 = atoi(Cmd_Argv(3)); pev->fuser1 = atof(Cmd_Argv(4)); pev->iuser3 = atoi(Cmd_Argv(5)); // mark original origin pev->vuser1 = pEntity->v.origin; pev->avelocity.y = 0; } return 0; }
bool DanceCreate( edict_t *pEntity ) { // Create the dance machine entvars_t *pPev = VARS( pEntity ); if (AdminLoggedIn[ENTINDEX(pEntity)] == 0) { ClientPrint( pPev, HUD_PRINTTALK, "* Admin only feature\n"); return 0; } UTIL_MakeVectors( pPev->v_angle + pPev->punchangle ); Vector vecSrc = GetGunPosition( pEntity ); Vector vecAiming = gpGlobals->v_forward; TraceResult tr; UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, pEntity , &tr ); //if (tr.flFraction < 1.0) //{ Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal ); // Create the paper here! KeyValueData kvd; edict_t *tEntity; tEntity = CREATE_NAMED_ENTITY(MAKE_STRING("info_target")); entvars_t *pRunOnPev; pRunOnPev = VARS(tEntity); // Set the KEYVALUES here! kvd.fHandled = FALSE; kvd.szClassName = NULL; kvd.szKeyName = "classname"; kvd.szValue = "building_dancemachine"; DispatchKeyValue( tEntity, &kvd ); // place this in front Vector vecOri = tr.vecEndPos; pRunOnPev->origin = vecOri; pRunOnPev->solid = SOLID_BBOX; SET_ORIGIN( tEntity , vecOri ); pRunOnPev->angles = angles; pRunOnPev->solid = SOLID_BBOX; SET_MODEL( ENT( pRunOnPev ) , "models/sphere.mdl"); UTIL_SetSize( pRunOnPev, Vector( -16, -16 , -16), Vector(16, 16, 16) ); pRunOnPev->takedamage = DAMAGE_NO; pRunOnPev->max_health = 40 + 10000; pRunOnPev->health = 40 + 10000; pRunOnPev->euser4 = pEntity; pRunOnPev->movetype = MOVETYPE_FLY; //DROP_TO_FLOOR( tEntity ); // play deploy sound EMIT_SOUND_DYN2( tEntity, CHAN_VOICE, "weapons/mine_deploy.wav", 1.0, ATTN_NORM , 0, 100); //unOnPev->iuser2 = pRunOnPev->euser4->v.team; // Set the team this radio belongs to pRunOnPev->nextthink = gpGlobals->time + 1; pRunOnPev->avelocity.y = 50; sprintf( EntData[ENTINDEX(tEntity)].digitgroup, "%s", Cmd_Argv(1)); if (FStrEq(Cmd_Argv(2), "rot")) { // rotates. get the distance, angular speed, and initial angle pRunOnPev->iuser1 = atoi(Cmd_Argv(3)); pRunOnPev->fuser1 = atof(Cmd_Argv(4)); pRunOnPev->iuser3 = atoi(Cmd_Argv(5)); // mark original origin pRunOnPev->vuser1 = pEntity->v.origin; pRunOnPev->avelocity.y = 0; } return 0; }