Next is a set of fireworks, coming in a handy disposable launcher. I figure I'll make a variant Anarchist Hornet and give this to them. Should give the player a minor heart attack before they realize that the fireworks don't do any damage.

I ever made this thing, but it's virtual weapon and not tracking. And used for celebration for YourCORP building, but got cut because I think it's too embrassing.Next is a set of fireworks, coming in a handy disposable launcher. I figure I'll make a variant Anarchist Hornet and give this to them. Should give the player a minor heart attack before they realize that the fireworks don't do any damage.
Code: Select all
<Events>
<OnFireWeapon>
(if (eq (itmGetData gItem 'fire) 0)
(block (
(angle (+ aFireAngle (% 10 (unvGetTick))))
)
(objSetData gItem "turnDirection" 'angle)
)
)
</OnFireWeapon>
</Events>
Code: Select all
<ItemType UNID="&moreBullet;"
name= "more bullet"
attributes= "commonwealth, majorItem"
level= "1"
frequency= "common"
value= "190000"
mass= "10000"
description= "Shoots bullets that shoot bullets."
>
<Image imageID="&rsItemsEI1;" imageX="96" imageY="0" imageWidth="96" imageHeight="96"/>
<Weapon
type= "missile"
damage= "kinetic:1d5"
fireRate= "15"
missileSpeed= "20"
lifetime= "50"
interaction= "0"
powerUse= "80"
effect= "&efKineticBoltDefault;"
sound= "&snRecoillessCannon;"
>
</Weapon>
<Events>
<OnFireWeapon>
(block (
(shot (sysCreateWeaponFire &moreBullet; gSource aFirePos aFireAngle 20 aTargetObj '('fireEffect 'soundEffect) aWeaponBonus))
)
(objSetEventHandler shot &moreBullet;)
(sysAddObjRecurringTimerEvent 10 shot "OnTime")
)
</OnFireWeapon>
<OnTime>
(if (gr (objGetProperty gSource 'lifeLeft) 0)
(block (
(vel (objGetVel gSource))
(speed (sysVectorSpeed vel))
(velAngle (sysVectorAngle vel))
(theta (+ velAngle 90))
(phi (- velAngle 90))
)
(objIncVel (sysCreateWeaponFire &moreBullet; gSource (objGetPos gSource) theta speed aTargetObj '('fireEffect 'soundEffect) aWeaponBonus) (objGetVel gSource))
(objIncVel (sysCreateWeaponFire &moreBullet; gSource (objGetPos gSource) phi speed aTargetObj '('fireEffect 'soundEffect) aWeaponBonus) (objGetVel gSource)
)
)
(printTo 'console (objGetProperty gSource 'lifeLeft))
)
</OnTime>
</Events>
</ItemType>
Code: Select all
(objSetProperty shot1 'sourceObj (objGetProperty gSource 'sourceObj))
Which is odd, as "sourceObj" is listed as a valid property of missiles.OnTime [kinetic damage]: Invalid property [sourceObj] ### (objSetProperty "shot1" "sourceObj" (objGetProperty gSource "sourceObj")) ###
Thank you! That's really helpful; it's not always easy to find relevant resources, especially when you don't expect them to exist.NMS wrote: ↑Tue Mar 20, 2018 9:47 amThese are really neat! So you got the "sprinkler" working the way you wanted? Because there are several issues with the code you posted for that which I could get into.
The wiki is not kept perfectly up to date, but it does have a lot of useful information. For instance, the weapon page has info about weapon events.
Code: Select all
<ItemType UNID="&rotaryLaser;"
name= "rotary laser"
attributes= "commonwealth, majorItem"
level= "1"
frequency= "common"
value= "190000"
mass= "10000"
description= "Like a sprinkler system, made of fire."
>
<Image imageID="&rsItemsEI1;" imageX="96" imageY="0" imageWidth="96" imageHeight="96"/>
<Weapon
type= "missile"
damage= "laser:2d5"
fireRate= "2"
lifetime= "50"
powerUse= "80"
effect= "&efLaserBeamDefault;"
sound= "&snLaserCannon;"
>
</Weapon>
<Events>
<OnFireWeapon>
(block (
(tOff (* 10 (sin (/ (unvGetTick) 5))))
(angle (+ aFireAngle tOff))
(shot (sysCreateWeaponFire &rotaryLaser; gSource aFirePos angle 100 aTargetObj '('fireEffect 'soundEffect) aWeaponBonus))
)
(objSetItemData gSource gItem 'fire 1)
)
</OnFireWeapon>
</Events>
</ItemType>