Sign up Calendar Latest Topics
 
 
 


Reply
  Author   Comment  
locqust

Avatar / Picture

Registered:
Posts: 70
Reply with quote  #1 
Hi all,

I'm trying to create a deflector pulse weapon that fires off three or four pulses and damages all enemies shields in range. ( I guess like a localised EMP torp)
I have the basics working and have the events looking out for the ranges of enemy ships to the player ship but I can't seem to read the enemy shield strength and then reduce it by a set amount with every pulse. Can anyone help?


<event name_arme="Fire Pulse" id_arme="becb492a-9a29-42c6-8928-0c47191c6ae9" parent_id_arme="d26dd2ce-2dd8-410a-91e7-2959a7a00daf">
  <if_timer_finished name="EPulse" />
  <if_variable name="EPulse" comparator="EQUALS" value="1.0" />
  <if_variable name="EPulsing" comparator="LESS" value="4.0" />
  <set_variable name="EPulsing" value="EPulsing+1" />
  <set_timer name="EPulse" seconds="5" />
</event>
<event name_arme="K1" id_arme="f29cffb2-9095-47e7-8301-3021cf6d5c35" parent_id_arme="76eb4347-bf99-4251-a649-682dd9ef566f">
  <if_distance name1="Endevour" name2="K1" comparator="LESS_EQUAL" value="1000.0" />
  <if_timer_finished name="EPulse" />
  <if_variable name="EPulsing" comparator="LESS" value="4.0" />
  <if_variable name="EPulse" comparator="EQUALS" value="1.0" />
  <if_object_property property="shieldStateFront" name="K1" comparator="GREATER_EQUAL" value="K1Front+500" />
  <if_object_property property="shieldStateBack" name="K1" comparator="GREATER_EQUAL" value="K1Back+500" />
  <set_variable name="K1Front" value="K1Front-20" />
  <set_variable name="K1Back" value="K1Back-20" />
  <set_object_property property="shieldStateFront" value="K1Front" name="K1" />
  <set_object_property property="shieldStateBack" value="K1Back" name="K1" />
</event>

ryleyra

Registered:
Posts: 3,008
Reply with quote  #2 
Well, its simply not possible to read an object property and copy it into a variable. There is no command to do that. I'm not sure what your code is intending to do, but from what I can tell, you're comparing the shield strength to a value (which is not defined and probably 0) +500, and if it is greater, subtracting 20 from the value and assigning it to the shield strength. (So -20)

What you probably want to do is compare to an absolute value, and if it is in that range, subtract 20 from it. For example:


<event> (I'm just editing out the "name_arme" stuff, it's just for the Mission Editor's use)
  <if_object_property property="shieldStateFront" name="K1" comparator="LESS" value="500" />
  <if_object_property property="shieldStateFront" name="K1" comparator="GREATER_EQUAL" value="480" />
  <set_object_property property="shieldStateFront" value="460" name="K1" />
</event>
<event
  <if_object_property property="shieldStateFront" name="K1" comparator="LESS" value="480" />
  <if_object_property property="shieldStateFront" name="K1" comparator="GREATER_EQUAL" value="460" />
  <set_object_property property="shieldStateFront" value="440" name="K1" />
</event>
<event
  <if_object_property property="shieldStateFront" name="K1" comparator="LESS" value="460" />
  <if_object_property property="shieldStateFront" name="K1" comparator="GREATER_EQUAL" value="440" />
  <set_object_property property="shieldStateFront" value="420" name="K1" />
</event>

and so on

That's awkward, though, and will probably take up a lot of lines of code. (You need to continue it all the way down from 500 to 20. Bleh) It also doesn't subtract 20 from the shield strength, it "floors" it, at a multiple of 20 and then subtracts 20. That will actually result in a subtraction of around 40. (But at least it won't drift back up as its shields regenerate and just "floor" it to the same multiple of 20 again)

I THINK this will work, but I'm not entirely sure. Maybe you might try it out:

  <addto_object_property property="shieldStateFront" value="-20" name="K1" />

addto_object_property should be the command to allow you to perform arithmetic on an object property. However, I'm not sure it can be used with a negative number. Try it and see.

If you really want to copy an object property to a variable, you have to use a self-adjusting counter to "shadow" that property. For example:

<event
  <if_object_property property="shieldStateFront" name="K1" comparator="LESS" value="K1Front" />
  <set_variable name="K1Front" value="K1Front-1" />
</event>
<event
  <if_object_property property="shieldStateFront" name="K1" comparator="GREATER" value="K1Front" />
  <set_variable name="K1Front" value="K1Front+1" />
</event>

Over time, that event loop will adjust "K1Front" until it is equal to shieldStateFront of K1. If K1 takes shield damage, it will take a couple of cycles for K1Front to count down and match it. You can speed it up by using K1Front-5 or K1Front-10 instead of K1Front-1, but that will reduce the "granularity" of the tracking and limit it to the nearest multiple of 5 or 10 respectively. (That is, if KI's shields are 203, K1Front will be either 200 or 205, or even switching between the two)

You can make your deflector pulse weapon work, though, by subtracting 20 from K1Front and using set_object_property, as in your example.
locqust

Avatar / Picture

Registered:
Posts: 70
Reply with quote  #3 
So I got it working, in a fashion. I couldn't get it to knock the shields down in strength, I think because the shadow variable couldn't catch up to the shield value quick enough and maintain the granularity. So I switched it to damaging the shield generators themselves and as that value starts from 0 I could get it working.



<event>
  <if_timer_finished name="EPulse" />
  <if_variable name="EPulse" comparator="EQUALS" value="1.0" />
  <if_variable name="EPulsing" comparator="LESS_EQUAL" value="4.0" />
  <set_variable name="EPulsing" value="EPulsing+1" />
  <set_timer name="EPulse" seconds="5" />
</event>
<event>
  <if_exists name="K1" />
  <if_object_property property="systemDamageFrontShield" name="K1" comparator="LESS_EQUAL" value="K1Front" />
  <set_variable name="K1Front" value="K1Front-10" />
</event>
And so on for front greater than, rear greater than and rear less than...
<event>
  <if_exists name="K1" />
  <if_distance name1="Endevour" name2="K1" comparator="LESS_EQUAL" value="1000.0" />
  <if_timer_finished name="EPulse" />
  <if_variable name="EPulse" comparator="EQUALS" value="1.0" />
  <set_object_property property="systemDamageFrontShield" value="K1Front+15" name="K1" />
  <set_object_property property="systemDamageBackShield" value="K1Back+15" name="K1" />
</event>


Thanks Ryleyra!
Mike Substelny

Avatar / Picture

Administrator
Registered:
Posts: 2,404
Reply with quote  #4 
That is a good solution.

Your script could also affect ShieldMaxStateFront and ShiendMaxStateBack. In one version of Havoc in the Hamak Sector I use that to make the enemy ships start with low shields that built up slowly over time. It worked well.

__________________
"The Admiralty had demanded six ships; the economists offered four; and we finally compromised on eight."
- Winston Churchill
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.