• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Prevent Cast

Level 31
Joined
Jul 10, 2007
Messages
6,306
This has quite the overhead
struct CastList

Try using an array struct instead.

Also, you should be using a hashtable + unit indexing instead of a linked list to prevent the casting... a linked list is just a really poor choice for this >.>.

Also, these should all be private
JASS:
        thistype next
        thistype prev
        unit caster
        integer abilID
        real cp

And you should have all of your stuff inside the struct. No reason any of it should be outside.

It'd also be neato to have a prevent cast event =).

This might as well go into a module initializer
JASS:
    private function Init takes nothing returns nothing
        local trigger t = CreateTrigger()
        call TriggerRegisterAnyUnitEventBJ(t,EVENT_PLAYER_UNIT_SPELL_CAST)
        call TriggerAddCondition(t,Condition(function onCast))
    endfunction

>.>.

Just try to make it a habit of only using module initializers unless you need your thingie to initialize later =D.

This is bad
call IssueImmediateOrder(c,"stop")

Some abilities don't stop a unit (they keep moving) like berserk.
 
Top