Project X Forums



It is currently Sun Apr 28, 2024 2:33 am

All times are UTC




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: Variable Wind
PostPosted: Tue Jan 03, 2012 11:21 pm 
Offline
User avatar

Joined: Mon Jun 21, 2010 2:10 pm
Posts: 43
A small script by me put in a lib. Probably interesting for BnG, Forts and Tower with the RubberWorm windy option.

The wind is changed while the worm is moving. If the worm is on the left of the map, the wind goes right, if the worm is on the right, it goes left. If the worm is in the center, there's no wind.
I put in a multiplicator to let you easily change that effect in the script. By default the maximum wind strength possible inside the map bounds is the default WA wind maximum.

Code:
require utils;

float _windStrength;
float _multiplicator;
               
void VariableWind::Init()
{
    _windStrength = 0.0;
    // Increase the multiplicator to have stronger wind
    _multiplicator = 0.65;
}

override void CTurnGame::Message(CObject* sender, EMType type, int size, CMessageData* data)
{
    // Calculations each frame
    if (type == M_FRAME)
    {
        CWorm *worm = GetCurrentWorm();
        if (worm != NullObj)
        {
            // Calculate wind strength
            _windStrength = (worm->PosX - GS->LevelSX / 2) / GS->LevelSX * -_multiplicator;
            Env->Wind = _windStrength;
            CMessageData* messageData = new CMessageData;
            messageData->fparams[0] = _windStrength;
            Root->Message(Root, M_UPDATEWIND, 4, messageData);   
        }
    }
    super;
}


Attachments:
VariableWind.zip [613 Bytes]
Downloaded 546 times


Last edited by Pac-Man on Wed Jan 04, 2012 3:57 pm, edited 1 time in total.
Top
 Profile  
Reply with quote  
 Post subject: Re: Variable Wind
PostPosted: Wed Jan 04, 2012 3:17 pm 
Offline

Joined: Thu Aug 18, 2011 9:20 am
Posts: 15
This is exactly what I needed! Thanks!


Top
 Profile  
Reply with quote  
 Post subject: Re: Variable Wind
PostPosted: Wed Jan 04, 2012 3:56 pm 
Offline
User avatar

Joined: Mon Jun 21, 2010 2:10 pm
Posts: 43
Also nice for Tower and Forts, I just noticed ;)


Top
 Profile  
Reply with quote  
 Post subject: Re: Variable Wind
PostPosted: Sun Mar 18, 2012 5:00 am 
Offline
User avatar

Joined: Mon Dec 05, 2011 1:14 am
Posts: 242
wicked....

Can think of few good uses for this.......good idea dude.....


Top
 Profile  
Reply with quote  
 Post subject: Re: Variable Wind
PostPosted: Mon Mar 19, 2012 6:58 pm 
Offline
User avatar

Joined: Mon Jun 21, 2010 2:10 pm
Posts: 43
As we saw its nice for windy rubber shopper :P


Top
 Profile  
Reply with quote  
 Post subject: Re: Variable Wind
PostPosted: Thu Nov 22, 2012 4:52 pm 
Offline

Joined: Fri Feb 26, 2010 4:44 pm
Posts: 92
and make variable wind during turn ?


Top
 Profile  
Reply with quote  
 Post subject: Re: Variable Wind
PostPosted: Tue Jul 29, 2014 2:18 pm 
Offline

Joined: Wed Jul 31, 2013 4:03 pm
Posts: 35
Location: Ukraine
interesting script... :)
btw, does this modification better in performance? i mean remembering current worm PosX and avoiding superfluous calculations?
Code:
require utils;

float _windStrength;
float _multiplicator;
int posXLastFrame;
               
void wind::Init()
{
    _windStrength = 0.0;
    // Increase the multiplicator to have stronger wind   
    _multiplicator = 0.65;
}

override void CWorm::Message(CObject* sender, EMType type, int size, CMessageData* data)
{
    super;
    if (this != GetCurrentWorm()) return;
    // Calculations each frame
    if (type == M_FRAME && posXLastFrame != PosX && Root->IsTimerActive())
    {
        // Calculate wind strength
        _windStrength = (PosX - GS->LevelSX / 2) / GS->LevelSX * -_multiplicator;
        Env->Wind = _windStrength;
        CMessageData* messageData = new CMessageData;
        messageData->fparams[0] = _windStrength;
        Root->Message(Root, M_UPDATEWIND, 4, messageData);
        // Remember worm's horizontal position
        posXLastFrame = PosX;   
    }
}
also Root->IsTimerActive() check is also useful i think. there is no need to reset wind if false.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 41 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Skin by Lucas Kane