void gkGrabNode::update(gkScalar tick) { gkPickNode::update(tick); if (GET_SOCKET_VALUE(THROW_OBJECT)) { ThrowObject(); } }
void ai_miserys_bubble(Object *o) { Object *target; switch(o->state) { case 0: { // find the Toroko object we are to home in on target = mbubble_find_target(); if (!target) { o->state = 9999; return; } o->xmark = target->x - (6 << CSF); o->ymark = target->y - (6 << CSF); ThrowObject(o, o->xmark, o->ymark, 0, (2 << CSF)); o->state = 1; // correct values: 0x3F0, 0xAE NX_LOG("Computed toss values xi: 0x%x, 0x%x\n", o->xinertia, o->yinertia); NX_LOG("Target x/y: 0x%x, 0x%x\n", target->x, target->y); } case 1: ANIMATE(1, 0, 1); if (abs(o->x - o->xmark) <= (3 << CSF) && \ abs(o->y - o->ymark) <= (3 << CSF)) { o->state = 2; o->frame = 2; sound(SND_BUBBLE); if ((target = mbubble_find_target())) target->invisible = true; } break; case 2: { ANIMATE(1, 2, 3); o->xinertia -= 0x20; o->yinertia -= 0x20; LIMITX(0x5FF); LIMITY(0x5FF); if (o->y < -1000) o->Delete(); } break; } }
//----------------------------------------------------------------------------- // HandleAnimEvent - catches the NPC-specific messages // that occur when tagged animation frames are played. //----------------------------------------------------------------------------- void CNPC_Dog::HandleAnimEvent( animevent_t *pEvent ) { if ( pEvent->event == AE_DOG_THROW ) { ThrowObject( pEvent->options ); return; } if ( pEvent->event == AE_DOG_PICKUP || pEvent->event == AE_DOG_CATCH || pEvent->event == AE_DOG_PICKUP_NOEFFECT ) { if ( pEvent->event == AE_DOG_PICKUP_NOEFFECT ) m_bBeamEffects = false; else m_bBeamEffects = true; PickupOrCatchObject( pEvent->options ); return; } BaseClass::HandleAnimEvent( pEvent ); }
//------------------------------------------------------------------------ void CThrow::Update(float frameTime, uint32 frameId) { CSingle::Update(frameTime, frameId); if (m_firing) { if (!m_pulling && !m_throwing && !m_thrown) { if(m_hold_timer > 0.0f) { m_hold_timer -= frameTime; if (m_hold_timer < 0.0f) { m_hold_timer = 0.0f; } } } else if (m_throwing && m_throw_time <= 0.0f) { CActor *pOwner = m_pWeapon->GetOwnerActor(); m_pWeapon->HideItem(true); if (m_throwableId) { IEntity *pEntity = gEnv->pEntitySystem->GetEntity(m_throwableId); if (pEntity) { if (m_throwableAction) { m_throwableAction->execute(m_pWeapon); } IPhysicalEntity *pPE = pEntity->GetPhysics(); if (pPE && (pPE->GetType() == PE_RIGID || pPE->GetType() == PE_PARTICLE)) { ThrowObject(pEntity, pPE); } else if (pPE && (pPE->GetType() == PE_LIVING || pPE->GetType() == PE_ARTICULATED)) { ThrowLivingEntity(pEntity, pPE); } } } else if (!m_netfiring) { ThrowGrenade(); } m_throwing = false; } else if (m_thrown && m_throw_time <= 0.0f) { m_pWeapon->SetBusy(false); m_pWeapon->HideItem(false); int ammoCount = m_pWeapon->GetAmmoCount(m_pShared->fireparams.ammo_type_class); if (ammoCount > 0) { m_pWeapon->PlayAction(m_pShared->throwactions.next); } else if (m_pShared->throwparams.auto_select_last) { static_cast<CPlayer *>(m_pWeapon->GetOwnerActor())->SelectLastItem(true); } m_firing = false; m_throwing = false; m_thrown = false; } m_throw_time -= frameTime; if (m_throw_time < 0.0f) { m_throw_time = 0.0f; } m_pWeapon->RequireUpdate(eIUS_FireMode); } }
void ai_dragon_zombie(Object *o) { if (o->hp < 950 && o->state < 50) { sound(SND_BIG_CRASH); SmokeClouds(o, 8, 4, 4); o->SpawnPowerups(); o->flags &= ~FLAG_SHOOTABLE; o->damage = 0; o->frame = 5; // dead o->state = 50; // dead } switch(o->state) { case 0: case 1: // ready { ANIMATE(30, 0, 1); if (--o->timer < 0) // can fire again yet? { if (pdistlx(112 << CSF)) // player in range? { o->state = 2; o->timer = 0; } } } break; case 2: // flashing, prepare to fire { FACEPLAYER; o->timer++; o->frame = (o->timer & 2) ? 2 : 3; if (o->timer > 30) o->state = 3; } break; case 3: { o->state = 4; o->timer = 0; o->frame = 4; // save point we'll fire at--these enemies don't update // the position of their target for each shot o->xmark = player->x; o->ymark = player->y; } case 4: { o->timer++; if (o->timer < 40 && (o->timer % 8) == 1) { Object *fire = SpawnObjectAtActionPoint(o, OBJ_DRAGON_ZOMBIE_SHOT); ThrowObject(fire, o->xmark, o->ymark, 6, 0x600); sound(SND_SNAKE_FIRE); } if (o->timer > 60) { o->state = 1; o->frame = 0; o->timer = random(100, 200); // random time till can fire again } } break; } }
// like EmFireAngledShot, but it's throws an already existing object // instead of spawning a new one void ThrowObjectAtPlayer(Object *o, int rand_variance, int speed) { ThrowObject(o, player->x, player->y, rand_variance, speed); }