<?xml version="1.0" encoding="ISO-8859-1"?>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
	<channel>
		<title>LucasForums - Tutorials: Scripting</title>
		<link>http://www.lucasforums.com/</link>
		<description>Tutorials covering scripting. (no posting)</description>
		<language>en</language>
		<lastBuildDate>Thu, 20 Jun 2013 06:54:32 GMT</lastBuildDate>
		<generator>vBulletin</generator>
		<ttl>60</ttl>
		<image>
			<url>http://www.lucasforums.com/images/misc/rss.jpg</url>
			<title>LucasForums - Tutorials: Scripting</title>
			<link>http://www.lucasforums.com/</link>
		</image>
		<item>
			<title>Handy include for Module Building</title>
			<link>http://www.lucasforums.com/showthread.php?t=212284&amp;goto=newpost</link>
			<pubDate>Sat, 25 May 2013 01:34:22 GMT</pubDate>
			<description><![CDATA[Reference this thread (http://www.lucasforums.com/showthread.php?t=212283) for questions 
 
Since I've still got my tutorial forum privileges I figured it would be worth referring this thing here too 
 
A while back (2008 to be precise) I wrote this script for module building, a debugging function...]]></description>
			<content:encoded><![CDATA[<div><font size="1">Reference <a href="http://www.lucasforums.com/showthread.php?t=212283" target="_blank">this thread</a> for questions<br />
<br />
Since I've still got my tutorial forum privileges I figured it would be worth referring this thing here too</font><br />
<br />
A while back (2008 to be precise) I wrote this script for module building, a debugging function in addition to several useful functions which I figure will be more useful to you guys than myself now - It's been a while but IIRC it compiles fine - you just need to use the line:<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left"><font color="DarkOrchid">#include &quot;gm_include&quot;</font></code><hr />
</div>Luckily I documented it, I'm pretty good at forgetting what I write these for so feel free to pick it apart<br />
<div style="margin:20px; margin-top:5px">
	<div class="smallfont" style="margin-bottom:2px">Code:</div>
	<hr /><code style="margin:0px" dir="ltr" style="text-align:left">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; :: Written by Glovemaster - 26/12/08 ::<br />
&nbsp; &nbsp; &nbsp; &nbsp; Quanon and Glovemaster's Scrapyard Games Modification<br />
<br />
&nbsp; &nbsp; &nbsp; &nbsp; <font color="DarkOrchid">gm_include.nss</font><br />
*/<br />
<br />
// Declaring functions... So I can use each function in each<br />
<font color="Lime">void debug(string Message, int Time = FALSE);<br />
vector getRandomVector(float fDistance);<br />
void applyEffectNearObject(int DURATION_TYPE, effect eEffect, object oTarget, float fDistance = 1.0, float fDur = 0.0);<br />
void createVisualEffectsArc(float fDuration, object oStart, location lTarget, int iEffect, int isBeam = TRUE);<br />
int calculateDamage(int nDice, int nDiceSize);<br />
float locationToObject(location lPoint, object oTo);<br />
void checkWeaponSlotsForItem(object oCheck, string itemTag, int requiredCert);</font><br />
<br />
<font color="Cyan">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; -[ debug ]---------------------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; Sends a message to the Party Leader for debugging purposes,<br />
&nbsp; &nbsp; &nbsp; &nbsp; generally to see if some &quot;if&quot; statement has triggered or not.<br />
&nbsp; &nbsp; &nbsp; &nbsp; -------------------------------------------------------------<br />
*/</font><br />
void debug(string Message, int Time = FALSE) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; string TimeNote = &quot;&quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; if (Time) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int Hour = GetTimeHour();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int Minute&nbsp; = GetTimeMinute();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int Second&nbsp; = GetTimeSecond();<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; TimeNote = (Hour &lt; 10 ? &quot;0&quot; : &quot;&quot;) + IntToString(Hour) + &quot;:&quot; +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (Minute&nbsp; &lt; 10 ? &quot;0&quot; : &quot;&quot;) + IntToString(Minute) + &quot;:&quot; +<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (Second&nbsp; &lt; 10 ? &quot;0&quot; : &quot;&quot;) + IntToString(Second) + &quot; &quot;;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; SendMessageToPC(GetFirstPC(), &quot;[ DEBUG &quot; + TimeNote + &quot;]&quot; + Message);<br />
&nbsp; &nbsp; &nbsp; &nbsp; AurPostString(&quot;[ DEBUG &quot; + TimeNote + &quot;]&quot; + Message, 0, 0, 5.0); // Removed I assume, since AFAIK it does nothing.<br />
}<br />
<br />
<font color="Cyan">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; -[ getRandomVector ]-----------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; Get a random vector within fDistance. This is because<br />
&nbsp; &nbsp; &nbsp; &nbsp; GetRandomDestination actually only generates 5 random<br />
&nbsp; &nbsp; &nbsp; &nbsp; destinations and looks crappy in the effect I was going for.<br />
&nbsp; &nbsp; &nbsp; &nbsp; -------------------------------------------------------------<br />
*/</font><br />
vector getRandomVector(float fDistance) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; float fAngle = IntToFloat((Random(361) + (Random(100) / 100))); // Pretty damn random.<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector vRandom = AngleToVector(fAngle);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Annoyingly, vectors can't be multiplyed in KotOR ¬.¬ well I get a compile error so we'll just play it this way:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vRandom.x = vRandom.x * fDistance;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vRandom.y = vRandom.y * fDistance;<br />
&nbsp; &nbsp; &nbsp; &nbsp; return vRandom;<br />
}<br />
<br />
<font color="Cyan">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; -[ applyEffectNearObject ]-----------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; EffectBeam() when set to miss, doesn't actually miss. Or do<br />
&nbsp; &nbsp; &nbsp; &nbsp; anything at all for that matter, Therefore we need to create<br />
&nbsp; &nbsp; &nbsp; &nbsp; a function that does. Also, apparently you can't apply<br />
&nbsp; &nbsp; &nbsp; &nbsp; EffectBeam() to a location? Well we'll use nodes anyway.<br />
&nbsp; &nbsp; &nbsp; &nbsp; -------------------------------------------------------------<br />
*/</font><br />
void applyEffectNearObject(int DURATION_TYPE, effect eEffect, object oTarget, float fDistance = 1.0, float fDur = 0.0) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector vAdd = AngleToVector(GetFacing(oTarget) - 180.0);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vAdd.x = (vAdd.x * fDistance);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vAdd.y = (vAdd.y * fDistance);<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector vNear = getRandomVector(1.0) + vAdd;<br />
&nbsp; &nbsp; &nbsp; &nbsp; object oNode = CreateObject(OBJECT_TYPE_PLACEABLE, &quot;plc_invisible&quot;, Location(vNear, 0.0));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AssignCommand(oNode, DestroyObject(oNode, (fDur + 1.0)));<br />
&nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE, eEffect, oNode, fDur);<br />
}<br />
<br />
<font color="Cyan">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; -[ createVisualEffectsArc ]----------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; Creates an arc of nodes, works better as a beam but over a <br />
&nbsp; &nbsp; &nbsp; &nbsp; short distance then its fine to use visual effects.<br />
&nbsp; &nbsp; &nbsp; &nbsp; Lightning is advised for this as it does not &quot;bend&quot; in an<br />
&nbsp; &nbsp; &nbsp; &nbsp; ugly way. I initially used this for fire but it was rather<br />
&nbsp; &nbsp; &nbsp; &nbsp; crude.<br />
&nbsp; &nbsp; &nbsp; &nbsp; -------------------------------------------------------------<br />
*/</font><br />
void createVisualEffectsArc(float fDuration, object oStart, location lTarget, int iEffect, int isBeam = TRUE) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Right then, we'll have 10 nodes making up the arc.<br />
&nbsp; &nbsp; &nbsp; &nbsp; object oNode, oNode1, oNode2, oNode3, oNode4, oNode5, oNode6, oNode7, oNode8, oNode9, oNode10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float fDistanceOver = locationToObject(lTarget, oStart);<br />
&nbsp; &nbsp; &nbsp; &nbsp; float fGap = fDistanceOver / 10;<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Get the direction to create the arc and change magnitude of the vector to fGap.<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector vDir = GetPosition(oStart) - GetPositionFromLocation(lTarget);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vDir = AngleToVector(VectorToAngle(vDir)); // Seems wierd, I know<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vDir.x = vDir.x * fGap;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vDir.y = vDir.y * fGap;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; // Lets get those nodes made then.<br />
&nbsp; &nbsp; &nbsp; &nbsp; vector vPos;<br />
&nbsp; &nbsp; &nbsp; &nbsp; float fHeight = 1.8;<br />
&nbsp; &nbsp; &nbsp; &nbsp; int i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; for(i = 1; i &lt;= 10; i++) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // Set the node's height.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(i &lt;= 4) { // Going up.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fHeight += 1.0; // Up 1m each time.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i &gt;= 6) { // Going down.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; fHeight -= 1.45; // Down 65cm each time. By my maths: 20cm * 4 is 80cm + our 1.8m is 2.6m<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // divided by 4 more steps and we get 65cm? BTW unto the Americans:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  // its MATHS not MATH you illiterate f*$@ers. -.-<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vPos = vDir;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vPos.x = vPos.x * i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vPos.y = vPos.y * i;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; vPos.z = fHeight;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; oNode = CreateObject(OBJECT_TYPE_PLACEABLE, &quot;plc_invisible&quot;, Location(vPos, 0.0));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; AssignCommand(oNode, DestroyObject(oNode, fDuration + 1.0));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // If only KotOR had arrays. ¬.¬<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if(i == 1) oNode1 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 2) oNode2 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 3) oNode3 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 4) oNode4 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 5) oNode5 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 6) oNode6 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 7) oNode7 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 8) oNode8 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 9) oNode9 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; else if(i == 10) oNode10 = oNode;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; if(isBeam) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effect eBeam = EffectBeam(iEffect, oNode1, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode2, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode2, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(0.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode3, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode3, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(0.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode4, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode4, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(0.6, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode5, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode5, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(0.8, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode6, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode6, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(1.0, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode7, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode7, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(1.2, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode8, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode8, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(1.4, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode9, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; eBeam = EffectBeam(iEffect, oNode9, BODY_NODE_CHEST);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; DelayCommand(1.6, ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eBeam, oNode10, fDuration));<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; else {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; effect eVis = EffectVisualEffect(iEffect);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode1, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode2, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode3, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode4, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode5, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode6, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode7, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode8, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode9, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ApplyEffectToObject(DURATION_TYPE_TEMPORARY, eVis, oNode10, fDuration);<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
}<br />
<br />
<font color="Cyan">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; -[ calculateDamage ]-----------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; Calculates damage to deal using nDice amount of dice with<br />
&nbsp; &nbsp; &nbsp; &nbsp; nDiceSize faces.<br />
&nbsp; &nbsp; &nbsp; &nbsp; -------------------------------------------------------------<br />
*/</font><br />
int calculateDamage(int nDice, int nDiceSize) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; // Calculate a reasonable amount of damage to deal.<br />
&nbsp; &nbsp; &nbsp; &nbsp; int iDamage = 0; // Start off, no damage.<br />
&nbsp; &nbsp; &nbsp; &nbsp; switch(nDiceSize) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 2:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d2(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 3:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d3(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 4:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d4(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 6:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d6(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 8:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d8(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 10:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d10(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 12:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d12(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 20:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d20(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case 100:&nbsp; &nbsp; &nbsp; &nbsp;  iDamage = d100(nDice);&nbsp; &nbsp; &nbsp; &nbsp;  break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; iDamage = Random(nDice * nDiceSize) + 1; // Otherwise just get a random number.<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if (iDamage &lt; nDice) iDamage = nDice; // Not too low ofc. XD<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />
&nbsp; &nbsp; &nbsp; &nbsp; }<br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; return iDamage;<br />
}<br />
<br />
<font color="Cyan">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; -[ locationToObject ]----------------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; Just a quick GetDistanceBetweenLocations() only with a<br />
&nbsp; &nbsp; &nbsp; &nbsp; location and an object.<br />
&nbsp; &nbsp; &nbsp; &nbsp; -------------------------------------------------------------<br />
*/</font><br />
float locationToObject(location lPoint, object oTo) {<br />
&nbsp; &nbsp; &nbsp; &nbsp; location lTo = GetLocation(oTo);<br />
&nbsp; &nbsp; &nbsp; &nbsp; return GetDistanceBetweenLocations(lPoint, lTo);<br />
}<br />
<br />
<font color="Red">/*<br />
&nbsp; &nbsp; &nbsp; &nbsp; -[ checkWeaponSlotsForItem ]---------------------------------<br />
&nbsp; &nbsp; &nbsp; &nbsp; Checks certain weapons slots for an item with itemTag, this<br />
&nbsp; &nbsp; &nbsp; &nbsp; is for Scrapyard Games only.<br />
&nbsp; &nbsp; &nbsp; &nbsp; -------------------------------------------------------------<br />
*/<br />
// Cut this one out since it relied on global vars for SG</font></code><hr />
</div>I've also included the Notepad++ Syntax User Defined Language I threw together to help with writing your scripts. And also wish you all the best with modding and I'm glad to see this community is still going</div>


	<br />
	<div style="padding:5px">

	

	

	

	
		<fieldset class="fieldset">
			<legend>Attached Files</legend>
			<table cellpadding="0" cellspacing="3" border="0">
			<tr>
	<td><img class="inlineimg" src="http://www.lucasforums.com/images/attach/zip.gif" alt="File Type: zip" width="16" height="16" border="0" style="vertical-align:baseline" /></td>
	<td><a href="http://www.lucasforums.com/attachment.php?attachmentid=3053&amp;d=1369507554">Notepad++ Syntax.zip</a> (13.2 KB)</td>
</tr>
			</table>
		</fieldset>
	

	</div>
]]></content:encoded>
			<category domain="http://www.lucasforums.com/forumdisplay.php?f=597">Tutorials: Scripting</category>
			<dc:creator>glovemaster</dc:creator>
			<guid isPermaLink="true">http://www.lucasforums.com/showthread.php?t=212284</guid>
		</item>
	</channel>
</rss>
