Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7674


Ignore:
Timestamp:
Nov 26, 2010, 12:01:53 AM (13 years ago)
Author:
dafrick
Message:

Resolving some stupid bugs and some adding some minor improvements.

Location:
code/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/data/levels/The Time Machine.oxw

    r7673 r7674  
    173173
    174174<!--Creating Spaceships_____________________________________________________________________________________________________________________________________________________________________-->
    175    
    176 <?lua for i=0,5,1 do
    177     y=math.random(-500,500)
    178     z=math.random(-1000,1000)
    179     y2=math.random(-500,500)
    180     z2=math.random(-1000,1000)
    181     health=230
    182     addh=100
    183 ?>
    184    
    185         <EventTrigger name="BotDied" >
    186             <events>
    187                 <trigger>
    188                     <SpaceShip position="-4000,<?lua print(y) ?>,<?lua print(z) ?>" lookat="1000,<?lua print(y) ?>,<?lua print(z) ?>" health=<?lua print(health) ?> maxhealth=<?lua print(health) ?> initialhealth=<?lua print(health) ?> >
    189                         <templates>
    190                             <Template link=spaceshipassff />
    191                          </templates>
    192                           <controller>
    193                             <WaypointPatrolController alertnessradius=1000 team=0 active=1 >
    194                                 <waypoints>
    195                                     <Model mesh="cube.mesh" scale=0 position="1000,<?lua print(math.random(-1000,1000)) ?>,<?lua print(math.random(-1000,1000)) ?>" />
    196                                 </waypoints>
    197                                 <events>
    198                                     <activity>
    199                                         <Trigger mode=or>
    200                                             <EventTrigger invert=true>
    201                                                 <events>
    202                                                     <trigger>
    203                                                         <EventListener event=EnterTimeMachine />
    204                                                     </trigger>
    205                                                 </events>
    206                                             </EventTrigger>
    207                                             <EventTrigger>
    208                                                 <events>
    209                                                     <trigger>
    210                                                         <EventListener event=trigger2 />
    211                                                     </trigger>
    212                                                 </events>
    213                                             </EventTrigger>
    214                                         </Trigger>
    215                                     </activity>
    216                                 </events>
    217                             </WaypointPatrolController>
    218                           </controller>
    219                     </SpaceShip>
    220                 </trigger>
    221             </events>
    222         </EventTrigger>
    223 
    224         <EventTrigger name="BotDied" >
    225             <events>
    226                 <trigger>
    227                     <SpaceShip position="4000,<?lua print(y2) ?>,<?lua print(z2) ?>" lookat="-1000,<?lua print(y2) ?>, <?lua print(z2) ?>" health=<?lua print(health+addh) ?> maxhealth=<?lua print(health+addh) ?> initialhealth=<?lua print(health+addh) ?> >
    228                         <templates>
    229                             <Template link=spaceshippirate />
    230                          </templates>
    231                           <controller>
    232                             <WaypointPatrolController alertnessradius=1000 team=1 active=1 >
    233                                 <waypoints>
    234                                     <Model mesh="cube.mesh" scale=0 position="-1000,<?lua print(math.random(-1000,1000)) ?>, <?lua print(math.random(-1000,1000)) ?>" />
    235                                 </waypoints>
    236                                 <events>
    237                                     <activity>
    238                                         <Trigger mode=or>
    239                                             <EventTrigger invert=true>
    240                                                 <events>
    241                                                     <trigger>
    242                                                         <EventListener event=EnterTimeMachine />
    243                                                     </trigger>
    244                                                 </events>
    245                                             </EventTrigger>
    246                                             <EventTrigger>
    247                                                 <events>
    248                                                     <trigger>
    249                                                         <EventListener event=trigger2 />
    250                                                     </trigger>
    251                                                 </events>
    252                                             </EventTrigger>
    253                                         </Trigger>
    254                                     </activity>
    255                                 </events>
    256                             </WaypointPatrolController>
    257                           </controller>
    258                     </SpaceShip>
    259                 </trigger>
    260             </events>
    261         </EventTrigger>
    262 <?lua end ?>
    263175
    264176<!--Creating Spaceships_____END_____________________________________________________________________________________________________________________________________________________________-->
  • code/trunk/src/modules/objects/ForceField.cc

    r7673 r7674  
    4242    CreateFactory(ForceField);
    4343   
    44     /*static*/ const std::string modeStringNormal_s = "tube";
    45     /*static*/ const std::string modeStringSphere_s = "sphere";
     44    /*static*/ const std::string ForceField::modeTube_s = "tube";
     45    /*static*/ const std::string ForceField::modeSphere_s = "sphere";
    4646
    4747    ForceField::ForceField(BaseObject* creator) : StaticEntity(creator)
     
    5454        this->diameter_ = 500;
    5555        this->length_ = 5000;
    56         this->mode_ = ForceFieldMode::tube;
     56        this->mode_ = forceFieldMode::tube;
    5757    }
    5858
     
    7070        XMLPortParam(ForceField, "length"  , setLength  , getLength  , xmlelement, mode).defaultValues(2000);
    7171        XMLPortParam(ForceField, "mode", setMode, getMode, xmlelement, mode);
     72        COUT(0) << "ForceField created " << this->velocity_ << " " << this->diameter_ << " " << this->radius_ << " " << this->length_ << " " << this->halfLength_ << " " << this->getMode() << std::endl;
    7273    }
    7374
    7475    void ForceField::tick(float dt)
    7576    {
    76         // Iterate over all objects that could possibly be affected by the ForceField.
    77         for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
     77        if(this->mode_ == forceFieldMode::tube)
    7878        {
    79             if(this->mode_ == ForceFieldMode::tube)
     79            // Iterate over all objects that could possibly be affected by the ForceField.
     80            for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    8081            {
    8182                // The direction of the orientation of the force field.
     
    8990                // The object is outside of the length of the ForceField.
    9091                if(distanceVector.length() > this->halfLength_)
    91                     return;
     92                    continue;
    9293
    9394                // The distance of the object form the orientation vector. (Or rather the smallest distance from the orientation vector)
     
    9697                // If the object in a tube of radius diameter/2 around the direction of orientation.
    9798                if(distanceFromDirectionVector >= this->radius_)
    98                     return;
     99                    continue;
    99100
    100101                // Apply a force to the object in the direction of the orientation.
    101102                // The force is highest when the object is directly on the direction vector, with a linear decrease, finally reaching zero, when distanceFromDirectionVector = radius.
    102                 it->applyCentralForce(((this->radius_ - distanceFromDirectionVector)/(this->radius_)) * this->velocity_ * direction);
     103                it->applyCentralForce((this->radius_ - distanceFromDirectionVector)/this->radius_ * this->velocity_ * direction);
    103104            }
    104             else if(this->mode_ == ForceFieldMode::sphere)
     105        }
     106        else if(this->mode_ == forceFieldMode::sphere)
     107        {
     108            // Iterate over all objects that could possibly be affected by the ForceField.
     109            for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it)
    105110            {
    106111                Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition();
     
    117122    void ForceField::setMode(const std::string& mode)
    118123    {
    119         if(mode == ForceField::modeStringTube_s)
    120             this->mode_ = ForceFieldMode::tube;
    121         else if(mode == ForceField::modeStringSphere_s)
    122             this->mode_ = ForceFieldMode::sphere;
     124        if(mode == ForceField::modeTube_s)
     125            this->mode_ = forceFieldMode::tube;
     126        else if(mode == ForceField::modeSphere_s)
     127            this->mode_ = forceFieldMode::sphere;
    123128        else
    124129        {
    125130            COUT(2) << "Wrong mode '" << mode << "' in ForceField. Setting to 'tube'." << std::endl;
    126             this->mode_ = ForceFieldMode::tube;
     131            this->mode_ = forceFieldMode::tube;
    127132        }
    128133    }
     
    132137        switch(this->mode_)
    133138        {
    134             case ForceFieldMode::tube:
    135                 return ForceField::modeStringTube_s;
    136             case ForceFieldMode::sphere:
    137                 return ForceField::modeStringSphere_s;
     139            case forceFieldMode::tube:
     140                return ForceField::modeTube_s;
     141            case forceFieldMode::sphere:
     142                return ForceField::modeSphere_s;
    138143            default:
    139                 return ForceField::modeStringTube_s;
     144                return ForceField::modeTube_s;
    140145        }
    141146    }
  • code/trunk/src/modules/objects/ForceField.h

    r7673 r7674  
    5656    @inGroup Objects
    5757    */
    58     namespace ForceFieldMode
     58    namespace forceFieldMode
    5959    {
    6060        enum Value {
     
    116116
    117117        private:
    118             static const std::string modeStringTube_s;
    119             static const std::string modeStringSphere_s;
     118            static const std::string modeTube_s;
     119            static const std::string modeSphere_s;
    120120       
    121121            float velocity_;
     
    124124            float length_;
    125125            float halfLength_;
    126             ForceFieldMode::Value mode_;
     126            forceFieldMode::Value mode_;
    127127  };
    128128}
Note: See TracChangeset for help on using the changeset viewer.