• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Pet System v.1.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Pet system v.1.0
By Striker
Also can be called: Striker's Pet system (SP) :ogre_haosis:

A few words
First of all, i wanna say hello :ogre_haosis:. And comes after is thank you
All hivers, an actual home for me to get started on advances with helps, spells and ideas
Introduce:
As you have know what pet system is
It's a system that make a unit (pet) stay close to its master (owner) after some actions from the owner. Ex: Casting ability, taming, summoning etc..
But, why you should use this?

  1. Hashtables - should be MUI
  2. Easy-implement
  3. Easy-configurable
  4. GUI
  5. Leakless - as far as i know

  1. Do not support levels
    This means even the abilities have its own levels, the implement won't make changes on levels, just giving the same unit type, same pet abilities or so
    To solve this cons, there's a good solution: Combine with an EXP system on pets will give them levels, exp and abilities depend all on you! Giving your pets even more advances. Example: Click
  2. Known Bugs:
    None
  • SP Hashtable
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set SP_Hash = (Last created hashtable)
      • -------- ======================================================= --------
      • -------- Count --------
      • -------- Increasing this will make things easier in setting up the number of units and stuffs --------
      • Set SP_NumberofSpells = (SP_NumberofSpells + 1)
      • -------- Ability --------
      • -------- The ability which suppose to call up the pet should be changed here --------
      • Set SP_SummonAbilities[SP_NumberofSpells] = Summon Teddy (Rexxar)
      • -------- PET --------
      • -------- The pet which will create after spell casted --------
      • Set SP_PetType[SP_NumberofSpells] = Misha (Level 3)
      • -------- Is the pet selectable --------
      • -------- This is one of the options. But for some reasons, pets with this True are somehow stupid --------
      • -------- They sometimes can't find there master if he's quite far away. Could be because of the collosion --------
      • Set SP_Selectable[SP_NumberofSpells] = False
      • -------- Can the pet get damage. If this is True but SP_Selectable is false. Unit will not have locust --------
      • -------- But using another method to avoid player selection --------
      • Set SP_Canbeharm[SP_NumberofSpells] = True
      • -------- Range to Master --------
      • -------- This determines how far the pet is allowed to stay away from the hero --------
      • Set SP_DistancetoOwner[SP_NumberofSpells] = 400.00
      • -------- ======================================================= --------
      • -------- Count --------
      • Set SP_NumberofSpells = (SP_NumberofSpells + 1)
      • -------- Ability --------
      • Set SP_SummonAbilities[SP_NumberofSpells] = Summon Hawk
      • -------- The pet which will create after spell casted --------
      • Set SP_PetType[SP_NumberofSpells] = Spirit Hawk (Level 3)
      • -------- Is the pet selectable --------
      • Set SP_Selectable[SP_NumberofSpells] = False
      • -------- Can the pet get damage. If this is True but SP_Selectable is false. Unit will not have locust --------
      • -------- But using another method to avoid player selection --------
      • Set SP_Canbeharm[SP_NumberofSpells] = False
      • -------- Range to Master --------
      • Set SP_DistancetoOwner[SP_NumberofSpells] = 700.00
      • -------- ======================================================= --------
      • -------- Count --------
      • Set SP_NumberofSpells = (SP_NumberofSpells + 1)
      • -------- Ability --------
      • Set SP_SummonAbilities[SP_NumberofSpells] = Summon Quilbeast
      • -------- The pet which will create after spell casted --------
      • Set SP_PetType[SP_NumberofSpells] = Berserk Quilbeast (Level 4)
      • -------- Is the pet selectable --------
      • Set SP_Selectable[SP_NumberofSpells] = False
      • -------- Can the pet get damage. If this is True but SP_Selectable is false. Unit will not have locust --------
      • -------- But using another method to avoid player selection --------
      • Set SP_Canbeharm[SP_NumberofSpells] = False
      • -------- Range to master --------
      • Set SP_DistancetoOwner[SP_NumberofSpells] = 500.00
      • -------- ======================================================= --------
      • -------- ======================================================= --------
      • Set SP_Error = You can only have one pet
  • SP Summon Pet
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • -------- =========================================== --------
      • Set SP_Pos = (Position of (Triggering unit))
      • Set SP_Owner = (Triggering unit)
      • -------- We get the Custom value in order to have the unit's ID --------
      • Set SP_ID = (Custom value of SP_Owner)
      • For each (Integer A) from 1 to SP_NumberofSpells, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Ability being cast) Equal to SP_SummonAbilities[(Integer A)]
            • Then - Actions
              • -------- What number of array is that ability has?? So We can get its type --------
              • Set SP_SpellType = (Integer A)
              • -------- Now we know it is number "Integer A". Don't worry, it's correct :) --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Load 1 of SP_ID in SP_Hash) Equal to No unit
                • Then - Actions
                  • -------- Say hello to my little friend ==== [Troll's voice] --------
                  • Unit - Create 1 SP_PetType[SP_SpellType] for (Owner of SP_Owner) at SP_Pos facing Default building facing degrees
                  • Set SP_Summoned = (Last created unit)
                  • -------- We get the Custom value in order to have the unit's ID --------
                  • Set SP_ID2 = (Custom value of SP_Summoned)
                  • -------- We save the stuffs --------
                  • -------- This will help us keep track of the values --------
                  • Hashtable - Save SP_DistancetoOwner[(Integer A)] as 1 of SP_ID2 in SP_Hash
                  • Hashtable - Save SP_Canbeharm[(Integer A)] as 4 of SP_ID2 in SP_Hash
                  • Hashtable - Save Handle OfSP_Owner as 2 of SP_ID2 in SP_Hash
                  • Hashtable - Save Handle OfSP_Summoned as 1 of SP_ID in SP_Hash
                  • -------- ======================================================= --------
                  • -------- Add the pet into the pet group --------
                  • Unit Group - Add SP_Summoned to SP_PetGroup
                  • -------- Make him wandering around --------
                  • Unit - Add Wander (Neutral) to SP_Summoned
                  • -------- Here will do some hard work: --------
                  • -------- If selectable is false. Which mean the owner shouldn't be able to select unit ===== It's too clear already =.=' --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • SP_Selectable[(Integer A)] Equal to False
                    • Then - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • SP_Canbeharm[(Integer A)] Equal to False
                        • Then - Actions
                          • -------- Ooohhh... The pet can't be harm because he's False at this boolean --------
                          • -------- Ok... i give you the almighty ability: Locust --------
                          • Unit - Add Locust to SP_Summoned
                        • Else - Actions
                          • -------- Collision off is to prevent stuck on pet's ways --------
                          • Unit - Turn collision for SP_Summoned Off
                          • -------- Oh man... it can be killed, but not selectable. Then... so be this: --------
                          • Trigger - Add to SP Unselectable <gen> the event (Unit - SP_Summoned Is selected)
                    • Else - Actions
                      • -------- Collision off is to prevent stuck on pet's ways --------
                      • Unit - Turn collision for SP_Summoned Off
                • Else - Actions
                  • -------- Hey you cheater! you can't have more than 1 pet --------
                  • Unit - Move (Load 1 of SP_ID in SP_Hash) instantly to SP_Pos
                  • Game - Display to (Player group((Owner of (Triggering unit)))) for 30.00 seconds the text: SP_Error
            • Else - Actions
      • -------- Pets have leaks. Kill them --------
      • Custom script: call RemoveLocation( udg_SP_Pos)
      • -------- Leave this alone if you want pet die with the owner --------
      • Trigger - Add to SP Owner Die <gen> the event (Unit - SP_Owner Dies)
  • SP Pet
    • Events
      • Time - Every 0.01 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in SP_PetGroup and do (Actions)
        • Loop - Actions
          • Set SP_Pet2 = (Picked unit)
          • Set SP_ID2 = (Custom value of SP_Pet2)
          • Set SP_Owner2 = (Load 2 of SP_ID2 in SP_Hash)
          • -------- LEAKS --------
          • Set SP_Points[1] = (Position of SP_Owner2)
          • Set SP_Points[2] = (Position of SP_Pet2)
          • -------- LOAD --------
          • Hashtable - Save Handle OfSP_Points[1] as 6 of SP_ID2 in SP_Hash
          • Hashtable - Save Handle OfSP_Points[2] as 7 of SP_ID2 in SP_Hash
          • -------- Distance --------
          • Set SP_DistanceSaved = (Distance between SP_Points[1] and SP_Points[2])
          • -------- Save to prevent un-MUI --------
          • Hashtable - Save SP_DistanceSaved as 3 of SP_ID2 in SP_Hash
          • Hashtable - Save Handle OfSP_Points[1] as 6 of SP_ID2 in SP_Hash
          • Hashtable - Save Handle OfSP_Points[2] as 7 of SP_ID2 in SP_Hash
          • -------- LOAD --------
          • Set SP_Distance = (Load 3 of SP_ID2 from SP_Hash)
          • Set SP_MaxDist = (Load 1 of SP_ID2 from SP_Hash)
          • Set SP_Points[1] = (Load 6 of SP_ID2 in SP_Hash)
          • Set SP_Points[2] = (Load 7 of SP_ID2 in SP_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • SP_Distance Less than or equal to SP_MaxDist
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (SP_Pet2 is in SP_PetOrdered) Equal to True
                • Then - Actions
                  • Unit - Add Wander (Neutral) to SP_Pet2
                  • Unit Group - Remove SP_Pet2 from SP_PetOrdered
                  • -------- LEAKS --------
                  • -------- LEAKS ========= PAM PAM KILL --------
                  • Custom script: call RemoveLocation( udg_SP_Points[1])
                  • Custom script: call RemoveLocation( udg_SP_Points[2])
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SP_Distance Greater than 1500.00
                • Then - Actions
                  • Unit - Move SP_Pet2 instantly to SP_Points[1]
                  • -------- LEAKS --------
                  • -------- LEAKS ========= PAM PAM KILL --------
                  • Custom script: call RemoveLocation( udg_SP_Points[1])
                  • Custom script: call RemoveLocation( udg_SP_Points[2])
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (SP_Pet2 is in SP_PetOrdered) Equal to False
                    • Then - Actions
                      • Unit - Remove Wander (Neutral) from SP_Pet2
                      • Unit - Order SP_Pet2 to Right-Click SP_Owner2
                      • -------- Adding pet into a group --------
                      • Unit Group - Add SP_Pet2 to SP_PetOrdered
                      • -------- This will prevent the pet get ordered every 0.01 second. Which loop up the animations too many --------
                      • -------- And will make pets look stupid --------
                      • -------- LEAKS --------
                      • -------- LEAKS ========= PAM PAM KILL --------
                      • Custom script: call RemoveLocation( udg_SP_Points[1])
                      • Custom script: call RemoveLocation( udg_SP_Points[2])
                    • Else - Actions
  • SP Pet Die
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in SP_PetGroup) Equal to True
    • Actions
      • Set SP_ID2 = (Custom value of (Triggering unit))
      • -------- LEAKS ========= PAM PAM KILL --------
      • Hashtable - Clear all child hashtables of child SP_ID2 in SP_Hash
      • Hashtable - Clear all child hashtables of child SP_ID in SP_Hash
  • SP Unselectable
    • Events
    • Conditions
    • Actions
      • Selection - Remove (Triggering unit) from selection for (Triggering player)
  • SP Owner Die
    • Events
    • Conditions
    • Actions
      • Set SP_ID = (Custom value of (Triggering unit))
      • -------- Kill the pet --------
      • Unit - Kill (Load 1 of SP_ID in SP_Hash)

Requirements:
Warcraft 3 patch 1.24+ (due to hashtables)
Bribe's unit indexing system (included in map)
How to use:
  • Explaination
    • Events
    • Conditions
    • Actions
      • -------- ======================================================= --------
      • -------- Count --------
      • -------- Increasing this will make things easier in setting up the number of units and stuffs --------
      • Set SP_NumberofSpells = (SP_NumberofSpells + 1)
      • -------- Ability --------
      • -------- The ability which suppose to call up the pet should be changed here --------
      • Set SP_SummonAbilities[SP_NumberofSpells] = Summon Teddy (Rexxar)
      • -------- PET --------
      • -------- The pet which will create after spell casted --------
      • Set SP_PetType[SP_NumberofSpells] = Misha (Level 3)
      • -------- Is the pet selectable --------
      • -------- False will make pets have locust. Which mean unable to select --------
      • Set SP_Selectable[SP_NumberofSpells] = False
      • -------- Range to Master --------
      • -------- This determines how far the pet is allowed to stay away from the hero --------
      • Set SP_DistancetoOwner[SP_NumberofSpells] = 400.00
      • -------- ======================================================= --------
For people who wondering about how the heck this system work as
well as how to load correct keys from hashtable. Read this please

Number | of | Type | Output

1 | SP_ID2 | Real | Distance to Owner
2 | SP_ID2 | Unit | Owner
3 | SP_ID2 | Real | SP_DistancetoOwner[SP_NumberofSpells]
4 | SP_ID2 | Boolean | Can the pet take damage
1 | SP_ID | Unit | Pet of unit which has SP_ID

Just load the correct values like the board above and you will be able
to make things right

Credits:
Bribe (for Unit Indexing system)

Keywords:
pet, system, natural, animal, tame, master, follow, friend
Contents

Just another Warcraft III map (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. 14:14, 28th Aug 2012 Magtheridon96: Instead of having the add pets thing done manually by the user in terms of the indexing, you should allow the user to do stuff like this: Set ability =...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.

14:14, 28th Aug 2012
Magtheridon96: Instead of having the add pets thing done manually by the user in terms of the indexing, you should allow the user to do stuff like this:

  • Set ability = Summon Hawk
  • ...
  • Set Range = 600.00
  • Trigger - Execute Add Pet <gen> (ignoring conditions)
The Add Pet trigger would increase the number of summoning spells by one and set the variables the user just set into your arrays.

It's much more convenient, and encapsulates everything.
 
Level 9
Joined
Aug 7, 2009
Messages
380
@Radamantus:
Thank you for your feedback and suggestion
But what would goes wrong if i use the GUI action: Add ability to unit?
Not saying it's bad your way but i wanna know more details about it :) thanks
And actually, locust swarm will not like this at all. It has its multi-usage :)
@Mag:
Thanks for pointing it out. I'm trying to work out on it
I thought it wouldn't be too "manually". But anyway, i'll try to improve it your way. But one question please:
What if a rare situation happens: They got registered at a same time ? I said it's "rare" :)
So i thought it would be "safer" in plusing array up and things like this
 
Top