本文整理汇总了C++中Event::AddFloat方法的典型用法代码示例。如果您正苦于以下问题:C++ Event::AddFloat方法的具体用法?C++ Event::AddFloat怎么用?C++ Event::AddFloat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Event
的用法示例。
在下文中一共展示了Event::AddFloat方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: use
bool HoldableItemProtection::use( void )
{
Event *event;
if ( _owner && !multiplayerManager.checkFlag( MP_FLAG_NO_POWERUPS ) )
{
if ( !_owner->isSubclassOf( Player ) )
return false;
Powerup *powerup;
Player *player;
player = (Player *)_owner;
powerup = Powerup::CreatePowerup( "Protection", "models/item/powerup_protection.tik", player );
event = new Event( EV_Item_SetAmount );
event->AddFloat( 15.0f );
powerup->ProcessEvent( event );
if ( powerup )
{
player->setPowerup( powerup );
return true;
}
}
return false;
}
示例2: Event
//
// Name: ItemPickup()
// Class: Armor
//
// Description: Handles Sentients Picking up armor... In this case, however,
// Only Actors are allowed to actually pick up armor
//
// Parameters: Entity *other - The entity doing the picking up
// qboolean add_to_inventory - Here to make parameters match
//
// Returns: NULL -- This function doesn't actually return the armor, instead
// it has the entity picking it up process and armor event
//
Item *Armor::ItemPickup( Entity *other, qboolean add_to_inventory, qboolean )
{
Sentient *sent;
str realname;
Q_UNUSED(add_to_inventory);
// For right now, we only want players to pick up armor
if ( !other->isSubclassOf( Player ) )
return NULL;
if ( !Pickupable( other ) )
return NULL;
sent = (Sentient*)other;
// Check if we NEED to pick up the armor, if the armor we are about to pick up is
// less than the armor we have, we don't want to pick it up
if ( !_needThisArmor(sent) )
return NULL;
// Handle the actual "Picking Up"
_pickupArmor(sent);
// Give the Sentient the Armor
Event *armorEvent;
armorEvent = new Event(EV_Sentient_GiveArmor);
armorEvent->AddString( item_name.c_str() );
armorEvent->AddFloat( amount );
armorEvent->AddInteger( true );
sent->ProcessEvent(armorEvent);
return NULL; // This doesn't create any items
}
示例3: specificUpdate
void RuneDeathQuad::specificUpdate( float frameTime )
{
Event *event;
if ( _owner )
{
event = new Event( EV_Hurt );
event->AddFloat( frameTime * 5.0f );
event->AddString( "deathQuad" );
_owner->ProcessEvent( event );
}
}
示例4: givePlayerItem
void Powerup::givePlayerItem( Player *player )
{
Powerup *powerup;
const char *modelName;
modelName = gi.NameForNum( edict->s.modelindex );
if ( !modelName )
return;
powerup = Powerup::CreatePowerup( item_name, modelName, player );
Event *event = new Event( EV_Item_SetAmount );
event->AddFloat( amount );
powerup->ProcessEvent( event );
player->setPowerup( powerup );
}
示例5: getDamageTaken
float RuneEmpathyShield::getDamageTaken( Entity *attacker, float damage, int meansOfDeath )
{
float realDamage;
Event *event;
realDamage = damage;
if ( attacker && ( meansOfDeath != MOD_EMPATHY_SHIELD ) )
{
realDamage *= 0.5;
event = new Event( EV_Hurt );
event->AddFloat( realDamage );
event->AddString( "empathyShield" );
attacker->ProcessEvent( event );
}
return realDamage;
}
示例6: ScriptError
//====================
//Player::SpawnActor
//====================
void Player::SpawnActor
(
Event *ev
)
{
Entity *ent;
str name;
str text;
Vector forward;
Vector up;
Vector delta;
Vector v;
int n;
int i;
ClassDef *cls;
Event *e;
if ( ev->NumArgs() < 1 )
{
ScriptError( "Usage: actor [modelname] [keyname] [value]..." );
return;
}
name = ev->GetString( 1 );
if ( !name[ 0 ] )
{
ScriptError( "Must specify a model name" );
return;
}
if ( !strstr( name.c_str(), ".tik" ) )
{
name += ".tik";
}
// create a new entity
SpawnArgs args;
args.setArg( "model", name.c_str() );
cls = args.getClassDef();
if ( cls == &Object::ClassInfo )
{
cls = &Actor::ClassInfo;
}
if ( !cls || !checkInheritance( &Actor::ClassInfo, cls ) )
{
ScriptError( "%s is not a valid Actor", name.c_str() );
return;
}
ent = ( Entity * )cls->newInstance();
e = new Event( EV_Model );
e->AddString( name.c_str() );
ent->PostEvent( e, EV_SPAWNARG );
angles.AngleVectors( &forward, NULL, &up );
v = origin + ( forward + up ) * 40;
e = new Event( EV_SetOrigin );
e->AddVector( v );
ent->PostEvent( e, EV_SPAWNARG );
delta = origin - v;
v = delta.toAngles();
e = new Event( EV_SetAngle );
e->AddFloat( v[ 1 ] );
ent->PostEvent( e, EV_SPAWNARG );
if ( ev->NumArgs() > 2 )
{
n = ev->NumArgs();
for( i = 2; i <= n; i += 2 )
{
e = new Event( ev->GetString( i ) );
e->AddToken( ev->GetString( i + 1 ) );
ent->PostEvent( e, EV_SPAWNARG );
}
}
}
示例7: ExecuteCommand
void ClientServerCommandManager::ExecuteCommand( char *arguments[], int num_arguments )
{
const char *command = arguments[ 0 ];
const char *formatspec;
int k;
char **args = arguments + 1;
Event *ev = new Event( command, EV_NORMAL );
if( ev->eventnum == 0 )
{
delete ev;
return;
}
formatspec = ev->GetFormat();
for( int i = 0, k = 0; k < num_arguments - 1; k++ )
{
const char *argument = args[ i ];
str vec;
if( formatspec[ k ] == '\0' ) {
break;
}
if( argument == NULL || *argument == '\0' ) {
continue;
}
switch( formatspec[ k ] )
{
case 'b':
case 'B':
ev->AddInteger( atoi( argument ) );
i++;
break;
case 's':
case 'S':
ev->AddString( argument );
i++;
break;
case 'i':
case 'I':
ev->AddInteger( atoi( argument ) );
i++;
break;
case 'f':
case 'F':
ev->AddFloat( ( float )atof( argument ) );
i++;
break;
case 'v':
case 'V':
vec = args[ i ];
vec += str( " " ) + args[ i + 1 ];
vec += str( " " ) + args[ i + 2 ];
ev->AddVector( Vector( vec.c_str() ) );
i += 3;
break;
default:
ev->AddString( argument );
i++;
}
}
try
{
ProcessEvent( ev );
}
catch( ScriptException exc )
{
cgi.Printf( exc.string );
}
}