Hard Light Productions Forums
Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Wanderer on July 19, 2007, 01:07:18 pm
-
So...
(http://i12.tinypic.com/4vsotv8.jpg)
Phear my scripting!
Short video.. http://video.tinypic.com/player.php?v=4p2ch7a
Personal containment field... :D
-
How did you do that?
-
:yes: ;7
-
That was originally supposed to be a reflection/deflection shield thingye.. To reflect hostile incoming stuff like ship was covered with impenetrable spherical mirror... er... forcefield... thing... Small mistake during the scripting with < and > caused the internal side of the sphere to reflect the shots (ie. collecting every shot) instead of the outer side (which would have reflected every shot).
-
Awesome. It'd make a good idea for some sort of super shield. Both the intended effect and the un-intended effect.
Imagine how'd it look with Subach beams instead. I don't suppose it stops beams, does it?
-
Yeah.. it doesn't stop beams. Mainly because beams do not exist as individual objects in-game. With all other stuff i can simply choose whether i want it to be deflected or not
-
Me likey. :lol: :lol:
-
heh cool. some of the coolest things ive done with scripting were on accident, but that is totally awesome. is it possible to fly those shots inbto an enemy? or will the sf mara get caught in the field too :lol:
-
That's a Ulysses! :p
-
You know what I'm thinking? That would be great for a shield for the Lucifer, except the lasers reflect. :D
-
Yes i was just thinking that. :lol: ;)
-
... This was a bug, I'm sure he's fixed it so that the outside reflects, but not the inside... right?
-
That was originally supposed to be a reflection/deflection shield thingye.. To reflect hostile incoming stuff like ship was covered with impenetrable spherical mirror... er... forcefield... thing... Small mistake during the scripting with < and > caused the internal side of the sphere to reflect the shots (ie. collecting every shot) instead of the outer side (which would have reflected every shot).
oh, you mean like in starfox when a ship does a barrel roll? :D
what ever could ths be for?
-
Weeell... ;)
EDIT:
... This was a bug, I'm sure he's fixed it so that the outside reflects, but not the inside... right?
Yeah
-
Awesome idea! Can we play with it too? ;7
I wonder if ships can bounce off of it?
I have got to learn some scripting.
-
Its mostly just math.. And ships can be made to bounce off too.. though it might some additional data (orientation data). One prob atm is that atleast turret shots which are bounced cant hit the parent ship but they cant hit the parent ship in normal FreeSpace anyway. However this can be changed too - at least for the standard primaries.
Mainly just usage of dot products and vector projection stuff..
#Global Hooks
$Simulation:
[
-- Reflection calculations
vectorFrontDirection = ba.createVector(0,0,1)
booleanReflection = 1
floatMissionTime = mn.getMissionTime()
if floatMissionTime > 0.5 then
objectPlayer = hv.Player
--Do not continue if player does not exist
if objectPlayer:isValid() then
--Continue only if trigger is set
if booleanReflection == 1 then
--Iterate through all the weapons
for k=1,#mn.Weapons do
objectWeapon = mn.Weapons[k]
stringWeaponTeam = objectWeapon.Team.Name
--Do this to all but friendly weapons
--Could be expanded or to set to deflect only certain weapons etc.
if stringWeaponTeam ~= "Friendly" then
--Calculate distance between weapon and ship's centerpoint
vectorWeaponPosition = objectWeapon.Position
vectorPlayerPosition = objectPlayer.Position
floatWeaponDistance = vectorPlayerPosition:getDistance(vectorWeaponPosition)
--Continue only if weapon is close enough to the ship
if floatWeaponDistance < 35 then
--Create reflection normal and calculate impact angle
vectorImpactNormal = vectorWeaponPosition - vectorPlayerPosition
vectorWeaponDirection = objectWeapon.Physics.Velocity
floatImpactAngle = vectorImpactNormal:getDotProduct(vectorWeaponDirection) / (vectorImpactNormal:getMagnitude() * vectorWeaponDirection:getMagnitude())
--Continue only if impact angle is proper
-- < causes the deflective shield (outer side deflects), angle is <90 degs
-- > causes the 'doomsphere'/containment field (inner side deflects), angle is >90 degs
if floatImpactAngle < 0 then
--Some vector math
---Calculate vector projection along the reflection normal for the 'impact vector' and then multiply it by 2 to get proper reflection 'lenght'
floatReflectionModifier = 2 * vectorWeaponDirection:getDotProduct(vectorImpactNormal) / vectorImpactNormal:getDotProduct(vectorImpactNormal)
---Create the proper reflection vector
vectorReflection = floatReflectionModifier * vectorImpactNormal
---101 vector math...
vectorWeaponNewDirection = vectorWeaponDirection - vectorReflection
---Set weapon flight direction and orientation according to the reflection vector.
orientationNewWeapon = vectorWeaponNewDirection:getOrientation()
objectWeapon.Orientation = orientationNewWeapon
floatWeaponVelocity = objectWeapon.Physics:getSpeed()
objectWeapon.Physics.Velocity = floatWeaponVelocity * vectorWeaponNewDirection / vectorWeaponNewDirection:getMagnitude()
end
end
end
end
end
end
end
]
#End
-
So I need a CVS build or something to use this? Or will it work with THREE dot SIX dot NINE?
-
Ah.. no it doesn't work with 3.6.9 builds (or any of the 3.6 builds for that matter)... Practically all scripting is done with HEAD branch builds ATM.
You should be able to use for example http://www.hard-light.net/forums/index.php/topic,44659.0.html C05202007 (HEAD) build - just read the note below the download link. Those builds should eventually become 3.7 builds.
-
Sweetness.
Thanks. :)
EDIT:
Weird, it doesn't seem to work against Tornado missiles? :confused:
-
In some trek games beams are models...
If you make a small tube pof controlled by teh beam data (ie generated as segments like a really fast gatlign gun?) but invisible and wrapped in a regular beam segment background would that work??? teh reflected segemnts should drag teh backgroudn with it no? *runs*...
I'm not high, but I should be! :lol:
-
that almost gave me an idea, but as it turns out, im too tired to think.
-
In some trek games beams are models...
If you make a small tube pof controlled by teh beam data (ie generated as segments like a really fast gatlign gun?) but invisible and wrapped in a regular beam segment background would that work??? teh reflected segemnts should drag teh backgroudn with it no? *runs*...
I'm not high, but I should be! :lol:
It sounds like the GTVA rapid fire laser.
And i think it'd look funny with a beam spinning around the fighter .... like an archon.
Awesome.
-
Yikes! :lol:
Now take this effect and use it for some special sort of shielding... ;) And maybe even somehow make shots for it be generated automatically (could this be done with the "create-weapon" SEXP? I don't know because I haven't used it so far).