Advertisement
epitaque_

Untitled

Jun 29th, 2015
454
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.09 KB | None | 0 0
  1. --The machine gun item
  2.  
  3. --Problem: the RunScript part in OnSpellStart clearly isn't working because the script that it's running is supposed to print a simple message but it doesn't. There are no errors in the console. 
  4.     "item_ak_stickarena"
  5.     {
  6.         "ID"                            "4126"
  7.         "BaseClass"                     "item_datadriven"
  8.         "AbilityBehavior"               "DOTA_ABILITY_BEHAVIOR_POINT | DOTA_ABILITY_BEHAVIOR_CHANNELLED"
  9.         "AbilityUnitTargetTeam"         "DOTA_UNIT_TARGET_TEAM_ENEMY"
  10.         "AbilityUnitTargetType"         "DOTA_UNIT_TARGET_HERO"
  11.         "AbilityUnitDamageType"         "DAMAGE_TYPE_PURE"
  12.         "AbilityChannelTime"            "50"
  13.  
  14.         "AbilityCastAnimation"          "ACT_DOTA_ATTACK"
  15.         "AbilityTextureName"            "item_ak"
  16.         "Model"                         "models/items/sniper/machine_gun_charlie/machine_gun_charlie.vmdl"
  17.         //  Stats
  18.         //-------------------------------------------------------------------------------------------------------------
  19.         "AbilityCastRange"              "%projectile_distance"
  20.         "AbilityCastPoint"              "0.2"
  21.         "AbilityCooldown"               "4"
  22.         "AbilityDamage"                 "150"
  23.  
  24.         //  Item Info
  25.         //-------------------------------------------------------------------------------------------------------------
  26.         "AbilityManaCost"               "0"
  27.         "ItemCost"                      "0"
  28.         "ItemInitialCharges"            "0"
  29.         "ItemDroppable"                 "1"
  30.         "ItemSellable"                  "0"
  31.         "ItemRequiresCharges"           "0"
  32.         "ItemShareability"              "ITEM_NOT_SHAREABLE"
  33.         "ItemDeclarations"              "DECLARE_PURCHASES_TO_TEAMMATES | DECLARE_PURCHASES_TO_SPECTATORS"
  34.        
  35.         "MaxUpgradeLevel"               "1"
  36.         "ItemBaseLevel"                 "1"
  37.        
  38.         "precache"
  39.         {
  40.             "model"                     "models/items/sniper/machine_gun_charlie/machine_gun_charlie.vmdl"
  41.         }
  42.  
  43.         "OnEquip"
  44.         {
  45.             "RunScript"
  46.             {
  47.                 "ScriptFile"            "equip.lua"
  48.                 "Function"              "EquipWeapon"
  49.                 "NewWeaponModel"        "models/items/sniper/machine_gun_charlie/machine_gun_charlie.vmdl"
  50.             }  
  51.         }
  52.  
  53.         "OnUnequip"
  54.         {
  55.             "RunScript"
  56.             {
  57.                 "ScriptFile"            "equip.lua"
  58.                 "Function"              "UnequipWeapon"
  59.             }  
  60.         }
  61.  
  62.         "OnSpellStart"
  63.         {
  64.             "RunScript"
  65.             {
  66.                 "ScriptFile"            "items/ak.lua"
  67.                 "Function"              "InitializeMachineGun"
  68.                 "Target"                "POINT"
  69.                 "TicksBetweenBursts"    "%ticks_between_bursts"
  70.                 "BurstCount"            "%burst_count"
  71.                 "ProjectileSpeed"       "%projectile_speed"
  72.                 "ProjectileDistance"    "%projectile_distance"
  73.                 "ProjectileRadius"      "%projetile_radius"
  74.                 "ThinkInterval"         "%think_interval"
  75.                 "ChannelTime"           "%channel_time"
  76.             }
  77.         }
  78.  
  79.         "OnChannelFinish"
  80.         {
  81.             "RunScript"
  82.             {
  83.                 "ScriptFile"    "items/ak.lua"
  84.                 "Function"      "StopMachineGun"
  85.             }
  86.         }
  87.  
  88.         "OnProjectileHitUnit"
  89.         {
  90.             "Damage"
  91.             {
  92.                 "Target"                "TARGET"
  93.                 "Type"                  "DAMAGE_TYPE_PURE"
  94.                 "Damage"                "%AbilityDamage"
  95.             }
  96.             "FireSound"
  97.             {
  98.                 "EffectName"            "Hero_Sniper.ProjectileImpact"
  99.                 "Target"                "TARGET"
  100.             }
  101.         }
  102.  
  103.         "Modifiers"
  104.         {
  105.             "modifier_item_ak"
  106.             {
  107.                 "Passive"               "1"
  108.                 "IsHidden"              "1"
  109.                 "Attributes"            "MODIFIER_ATTRIBUTE_MULTIPLE"
  110.            
  111.                 "Properties"
  112.                 {
  113.                     "MODIFIER_PROPERTY_MOVESPEED_BONUS_UNIQUE"  "%bonus_movement_speed"
  114.                 }
  115.             }
  116.         }
  117.  
  118.         //  Special
  119.         //-------------------------------------------------------------------------------------------------------------
  120.         "AbilitySpecial"
  121.         {
  122.             "01"
  123.             {
  124.                 "var_type"              "FIELD_INTEGER"
  125.                 "projectile_distance"   "1500"
  126.             }
  127.             "02"
  128.             {
  129.                 "var_type"              "FIELD_INTEGER"
  130.                 "projectile_damage"     "150"
  131.             }
  132.             "03"
  133.             {
  134.                 "var_type"              "FIELD_INTEGER"
  135.                 "projectile_radius"     "30"
  136.             }
  137.             "04"
  138.             {
  139.                 "var_type"              "FIELD_INTEGER"
  140.                 "projectile_speed"      "2000"
  141.             }
  142.             "05"
  143.             {
  144.                 "var_type"              "FIELD_INTEGER"
  145.                 "bonus_movement_speed"  "50"
  146.             }
  147.             "06"
  148.             {
  149.                 "var_type"              "FIELD_INTEGER"
  150.                 "channel_time"          "50"
  151.             }
  152.             "07"
  153.             {
  154.                 "var_type"              "FIELD_INTEGER"
  155.                 "burst_count"           "3"
  156.             }
  157.             "08"
  158.             {
  159.                 "var_type"              "FIELD_FLOAT"
  160.                 "think_interval"        "0.3"
  161.             }
  162.             "09"
  163.             {
  164.                 "var_type"              "FIELD_FLOAT"
  165.                 "ticks_between_bursts"  "2"
  166.             }
  167.  
  168.         }
  169.     }
  170.  
  171. --items/ak.lua
  172. require('libraries/timers')
  173.  
  174. function InitalizeMachineGun(keys)
  175.     print('[STICKARENA] Initalizing Machine Gun')
  176.  
  177.     local caster = keys.caster
  178.  
  179.     caster.ticknumber = 0
  180.  
  181.     Timers:CreateTimer(0.01, -- Start this timer 30 game-time seconds later
  182.     function()
  183.  
  184.         print('[STICKARENA] MachineGunThink')
  185.         if caster.ticknumber * keys.ThinkInterval >= keys.ChannelTime then
  186.             print('[STICKARENA] notice: caster.ticknumber * keys.ThinkInterval >= keys.ChannelTime')
  187.             return
  188.         elseif caster.ticknumber == -1 then
  189.             print('[STICKARENA] notice: caster.ticknumber == -1')
  190.             return
  191.         end
  192.  
  193.         local totalmodulus = keys.TicksBetweenBursts + keys.BurstCount
  194.         local ticknumber = caster.ticknumber
  195.         local interval = ticknumber % totalmodulus
  196.         local ifinterval = keys.BurstCount - 1
  197.  
  198.         --Fire Projectile
  199.         if interval <= ifinterval then
  200.             local vec = keys.target_points[1]
  201.             local diff = vec - caster:GetAbsOrigin()
  202.             diff.z = 0
  203.             local dir = diff:Normalized()
  204.        
  205.             local info =
  206.             {
  207.                 Ability = keys.ability,
  208.                 EffectName = "particles/linear_projectiles/sniper_base_attack.vpcf",
  209.                 vSpawnOrigin = caster:GetAbsOrigin(),
  210.                 fDistance = keys.ProjectileDistance,
  211.                 fStartRadius = keys.ProjectileRadius,
  212.                 fEndRadius = keys.ProjectileRadius,
  213.                 Source = caster,
  214.                 bHasFrontalCone = false,
  215.                 bReplaceExisting = false,
  216.                 iUnitTargetTeam = DOTA_UNIT_TARGET_TEAM_ENEMY,
  217.                 iUnitTargetFlags = DOTA_UNIT_TARGET_FLAG_NONE,
  218.                 iUnitTargetType = DOTA_UNIT_TARGET_HERO + DOTA_UNIT_TARGET_BASIC,
  219.                 fExpireTime = GameRules:GetGameTime() + 10.0,
  220.                 bDeleteOnHit = true,
  221.                 vVelocity = dir * keys.ProjectileSpeed,    
  222.                 bProvidesVision = false,
  223.                 iVisionRadius = 0,
  224.                 iVisionTeamNumber = caster:GetTeamNumber()
  225.             }
  226.             caster:EmitSound("weapons/hero/sniper/projectile_impact01.wav")
  227.             dir = RotatePosition(Vector(0,0,0), QAngle(0,RandomInt(-3,3),0), dir)
  228.             info.vVelocity = dir * keys.ProjectileSpeed
  229.             ProjectileManager:CreateLinearProjectile( info )
  230.         end
  231.  
  232.         caster.ticknumber = caster.ticknumber + 1
  233.         return keys.ThinkInterval -- Rerun this timer
  234.  
  235.     end)
  236. end
  237.  
  238. function MachineGunEnd(keys)
  239.     keys.caster.ticknumber =  -1
  240. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement