Difference between revisions of "Message"

From Project X Wiki
Jump to: navigation, search
 
(minor updates)
Line 42: Line 42:
 
*Next we iterate through every [[CObject]] to find every worm, excluding the ones of the team that fired the mine.
 
*Next we iterate through every [[CObject]] to find every worm, excluding the ones of the team that fired the mine.
 
*In the last part we check the distance between the mine and each non-friendly worm, and if its close enough, activate the mine.
 
*In the last part we check the distance between the mine and each non-friendly worm, and if its close enough, activate the mine.
 +
 +
== The Secret to Success Kindness ==
 +
 +
Take a look at these simple but powerful words from the Dalai Lama, Kindness and a good heart are the foundation for success in this life, progress on the spiritual path, and the fulfillment of our aspirations. Our need for them is not limited to any specific time, place, society, or culture.
 +
 +
[[http://goodvillenews.com/The-Secret-to-Success-Kindness-qClIIA.html The Secret to Success Kindness]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== Behind the Beautiful Forevers ==
 +
 +
For two decades, and currently at The New Yorker, youve written about the distribution of opportunity, and the means by which people might get out of poverty, in America. What inspired you to start asking the same kinds of questions in India?
 +
 +
[[http://goodvillenews.com/Behind-the-Beautiful-Forevers-YtCKM3.html Behind the Beautiful Forevers]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== 5 Principles for Inner Transformation at Work ==
 +
 +
People go to work to sustain themselves and produce value in the world. Yet work environments can also be stressful, filled with challenging responsibilities and personalities, and feel misaligned with our most deeply cherished values. Instead of sustaining us, the workplace can sometimes feel simply draining, and at worst, unwholesome for both ourselves and the world.
 +
 +
[[http://goodvillenews.com/5-Principles-for-Inner-Transformation-at-Work-TTklKV.html 5 Principles for Inner Transformation at Work]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== What Is Your Legacy? Living A Meaningful life ==
 +
 +
I want the world to be better because I was here. I want my life, I want my work, my family, I want it to mean something and if you are not making someone elses life better then you are wasting your time Will Smith
 +
 +
[[http://goodvillenews.com/What-Is-Your-Legacy-Living-A-Meaningful-life-oBtnrB.html What Is Your Legacy? Living A Meaningful life]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]
 +
 +
== How To Make Peace With Imperfection ==
 +
 +
If you look closely at a tree youll notice its knots and dead branches, just like our bodies. What we learn is that beauty and imperfection go together wonderfully. Matthew Fox
 +
 +
[[http://goodvillenews.com/How-To-Make-Peace-With-Imperfection-AOuD91.html How To Make Peace With Imperfection]]
 +
 +
[[http://goodvillenews.com/wk.html GoodvilleNews.com - good, positive news, inspirational stories, articles]]

Revision as of 13:24, 2 August 2012

Up one category:
CObject
void CObject::Message(CObject *sender, EMType Type, int MSize, CMessageData *MData);

The Message function is one key element in the process of scripting.

This function is invoked for every CObject class and derivate objects each time an "event" occurs in the game, the nature of which is determined by variable EMType Type.

Overriding this function allows you to program objects and general game behaviour when certain "events" take place.

In the next example we override the function Message of class CMine, to make a "friendly" mine:

override void CMine::Message(CObject* sender, EMType Type, int MSize, CMessageData* MData)
{
 super;
 if (Type != M_FRAME) return;
 
 for (local i = 1; i < Env->Objs.Count - 1; i+=1)
 {
   local obj = Env->Objs.Objs[i];
   
   if (obj == NullObj) continue;
   if (obj->ClType != OC_Worm) continue;
   
   local worm = CWorm(obj);
   if (ShootData.Team == worm->WormTeam) continue;
   
   
   
   if (DistBetweenObjs(obj, this) < 65)
   {
     PrintMessage(111);
     Active = 1;
     nPulses = 1;
     break;
   }; 
 };
};
  • In this override, we first execute the original function, then we check if Type is equal to M_FRAME, such message is sent to every CObject once per physics step, for other message types, see EMType.
  • If the condition is not true, then we call operator return, because we only want to override the function when we receive a M_FRAME type message.
  • Next we iterate through every CObject to find every worm, excluding the ones of the team that fired the mine.
  • In the last part we check the distance between the mine and each non-friendly worm, and if its close enough, activate the mine.

The Secret to Success Kindness

Take a look at these simple but powerful words from the Dalai Lama, Kindness and a good heart are the foundation for success in this life, progress on the spiritual path, and the fulfillment of our aspirations. Our need for them is not limited to any specific time, place, society, or culture.

[The Secret to Success Kindness]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

Behind the Beautiful Forevers

For two decades, and currently at The New Yorker, youve written about the distribution of opportunity, and the means by which people might get out of poverty, in America. What inspired you to start asking the same kinds of questions in India?

[Behind the Beautiful Forevers]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

5 Principles for Inner Transformation at Work

People go to work to sustain themselves and produce value in the world. Yet work environments can also be stressful, filled with challenging responsibilities and personalities, and feel misaligned with our most deeply cherished values. Instead of sustaining us, the workplace can sometimes feel simply draining, and at worst, unwholesome for both ourselves and the world.

[5 Principles for Inner Transformation at Work]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

What Is Your Legacy? Living A Meaningful life

I want the world to be better because I was here. I want my life, I want my work, my family, I want it to mean something and if you are not making someone elses life better then you are wasting your time Will Smith

[What Is Your Legacy? Living A Meaningful life]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]

How To Make Peace With Imperfection

If you look closely at a tree youll notice its knots and dead branches, just like our bodies. What we learn is that beauty and imperfection go together wonderfully. Matthew Fox

[How To Make Peace With Imperfection]

[GoodvilleNews.com - good, positive news, inspirational stories, articles]