Hero + Item Snippets

Status
Not open for further replies.
I

IKilledKEnny

Guest
Submissions

Hey I made this quick system to help people get players allied when they type massage with 2 triggers only. Map is attached if you don't want to read the Triggers and explanation. :D

http://www.thehelper.net/forums/showthread.php?t=52027


Things needed:
  • Warcraft III: The Frozen Throne (Expansion).​

Variables:
  • 1 Player Group variable no array (AllyPF)
  • 2 String variables with array equal to maximum num of players (12)(AllyStringColor, AllyStringName)
  • Integer Variable no array (Integer)

Code:
Setting Up Triggers
    Events
        Map initialization
    Conditions
    Actions
        Set AllyPF = (All players matching ((((Matching player) controller) Equal to User) and (((Matching player) slot status) Equal to Is playing)))
        Player Group - Pick every player in AllyPF and do (Actions)
            Loop - Actions
                Set AllyStringName[(Player number of (Picked player))] = (Name of (Picked player))
                Trigger - Add to Actual Trigger <gen> the event (Player - (Picked player) types a chat message containing -Ally  as A substring)
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Red
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Blue
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Teal
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Purple
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Yellow
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Orange
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Green
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Pink
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Grey
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Light Blue
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Dark Green
        Set Integer = (Integer + 1)
        Set AllyStringColor[Integer] = Brown
        Custom script:   call DestroyForce(udg_AllyPF)
        Custom script:   call DestroyTrigger(GetTriggeringTrigger())

Code:
Actual Trigger
    Events
    Conditions
    Actions
        For each (Integer A) from 1 to 12, do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        Or - Any (Conditions) are true
                            Conditions
                                (Integer((Substring((Entered chat string), 7, 8)))) Equal to (Integer A)
                                (Substring((Entered chat string), 7, 22)) Equal to AllyStringName[(Integer A)]
                                (Substring((Entered chat string), 7, 17)) Equal to AllyStringColor[(Integer A)]
                    Then - Actions
                        Player - Make (Triggering player) treat (Player((Integer A))) as an Ally with shared vision
                    Else - Actions

What it would do, is in just 17.4 KB / 4 MB 3 things:
A.
When player writes: -Ally Num
He'll ally immediatly with the player that is that number (example: "-ally 3", player will immediatly ally with teal".

B.
When player writes: -Ally Color
He'll immediatly ally with the player that is that color. (Example: "-ally teal", player will immediatly ally with teal).

C.
When player writes: -Ally Name
He'll immediatly ally with that player that has that name (Example"-Ally TealLover" Assuming teal got this name player would ally with him).

Hope you enjoyed, move this theard if needed. Feedback is welcomed.

http://www.thehelper.net/forums/showthread.php?t=52027
 

Attachments

  • Simple Ally System ~IKilledKEnny~.w3x
    17.4 KB · Views: 348

DuckieKing

Elitist Through and Through
Reaction score
51
I was asked to repost my script with more comments, so here goes! (Be sure to read the comments on function FindHost_Cache first!)
JASS:
function FindHost takes nothing returns nothing
  local integer a=0
  set udg_Host=Player(0)  // sets host to red, to start us off
  loop
    exitwhen a&gt;11
    if udg_HostCheck[GetPlayerId(udg_Host)]&lt;udg_HostCheck[a] then  // checks if the current global player Host has fewer &quot;host credits&quot; than the player being looped
      set udg_Host=Player(a)  // if the looped player has more &quot;host credits&quot; than the current global player Host, the looped player is set as the new Host
    endif
  set a=a+1
  endloop
endfunction

function FindHost_Cache takes nothing returns nothing
  local gamecache gc=InitGameCache(&quot;temp.w3v&quot;)
  local integer a=0
  local integer b
  loop  // this loop is required, because this script is not reliable unless done many times; with some (slow) hosts it will fail 1/3 of the time
    exitwhen a&gt;9
    call StoreInteger(gc, &quot;map&quot;, &quot;host&quot;, GetPlayerId(GetLocalPlayer()))  // this stores for every player their own player Id, so it&#039;s different for every player...
    call TriggerSyncStart()
    call SyncStoredInteger(gc, &quot;map&quot;, &quot;host&quot;)  // so we sync it up, and most of the time it will sync to the HOST&#039;S PLAYER ID
    call TriggerSyncReady()
    set b=GetStoredInteger(gc, &quot;map&quot;, &quot;host&quot;)  // we set b to the variable synced by the last few lines
    set udg_HostCheck<b>=udg_HostCheck<b>+1  // this line gives the person whose Id is &#039;b&#039; one &quot;host credit&quot;
    set a=a+1
  endloop
  call ExecuteFunc(&quot;FindHost&quot;)  // starts the function that sets the host, go to function FindHost
  call FlushGameCache(gc)  // taking care of leaks, not totally necessary as this runs only once, ideally
  set gc=null  // and this line saves less than 1kb, but we like to remove all leaks
endfunction

function InitTrig_FindHost takes nothing returns nothing
  set gg_trg_FindHost=CreateTrigger()
  call TriggerRegisterTimerEvent(gg_trg_FindHost, 0.00, false)
  call TriggerAddAction(gg_trg_FindHost, function FindHost_Cache)
endfunction</b></b>


Add a trigger: FindHost
Make it custom script (Edit/Convert to Custom Text)
Add two globals: Player "Host" and integer array "HostCheck"
This is not perfect and in extreme cases it will fail. You can increase the number of loops to be even surer, but it does have some kind of delay. With 10 loops it tends to take about 5 seconds or less.
Note that although I wrote the actual script, the idea to sync local players' Ids was given to me by the shaman of Clan BoM.
 

Andrewgosu

The Silent Pandaren Helper
Reaction score
716
Here is a little JASS sniplet, which counts how many items of same type a certain unit has. Useful, if you want to make item recipes, which require more than one instance of a certain item.

function CountSameItems takes unit a, item t returns integer

Place this into your maps header.

JASS:
function CountSameItems takes unit a, item t returns integer
    local integer p = UnitInventorySize(a)
    local integer i = 0
    local integer h = 0
    loop
        exitwhen i &gt; p
        if ( GetItemTypeId(UnitItemInSlot( a, i )) == GetItemTypeId(t) ) then
            set h = h + 1
        endif
        set i = i + 1
    endloop
    return h
endfunction


And use "Custom script" action to call it.

TmpInt
- global integer variable.

Code:
Count Items
    Events
        Unit - A unit Acquires an item
    Conditions
        (Item-type of (Item being manipulated)) Equal to Claws of Attack +15
    Actions
        Custom script:   set udg_TmpInt = CountSameItems( GetTriggerUnit(),  GetManipulatedItem() )
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                TmpInt Equal to 3
            Then - Actions
                For each (Integer A) from 1 to 3, do (Actions)
                    Loop - Actions
                        Item - Remove (Item carried by (Triggering unit) of type Claws of Attack +15)
                Hero - Create Claws of Attack +50 and give it to (Triggering unit)
            Else - Actions
 

Vulcansurge

Ultra Cool Member
Reaction score
27
ITEM UPGRADING SYSTEM - By Vulcansurge

Custom Script:
Code:
function PlayerMsg takes player p, string s returns nothing
  call DisplayTextToPlayer(p,0,0,s)
endfunction

Actual Trigger:
JASS:
//============================================================================
//                              BASIC LASER
//============================================================================
function Trig_UpgradeBasicLaserJASS_Actions takes nothing returns nothing
  local integer l = 0
  local unit u = GetManipulatingUnit()
  local item i = GetManipulatedItem()
  local player p = GetOwningPlayer(u)
  local item iu

  local integer ut = 5    //UT = TOTAL UPGRADES:
  local integer array uc  //  - make sure to copy more rawcodes when
  local integer array ul  //    adding more or less upgrades.
    set ul[1]=&#039;I00H&#039;      //
    set ul[2]=&#039;I00D&#039;      //UL = ITEM RAWCODES:
    set ul[3]=&#039;I00E&#039;      //  - use ctrl + d in item editor to find these.
    set ul[4]=&#039;I00F&#039;      //  - must use &quot;I00X&quot; format.
    set ul[5]=&#039;I00G&#039;      //
    set uc[1]=700         //UC = UPGRADE COSTS:
    set uc[2]=800         //  - there should be one less than the total
    set uc[3]=900         //    number of levels, because the last level
    set uc[4]=1000        //    is not upgradeable.

  loop
  set l=l+1
  exitwhen l==ut
  if (GetItemTypeId(i)==ul[l]) then
    if (GetPlayerState(p,PLAYER_STATE_RESOURCE_GOLD)&gt;=uc[l]) then
      call AdjustPlayerStateBJ(-uc[l],p, PLAYER_STATE_RESOURCE_GOLD)
      call PlayerMsg(p,&quot;|cFF0000FFNote:|r Your item is being upgraded&quot;)
      call UnitRemoveItemSwapped(i,u)
      call RemoveItem(i)
      call UnitAddItemByIdSwapped(&#039;I00C&#039;,u)
      set iu = GetLastCreatedItem()
      call TriggerSleepAction(10.00)
      call UnitRemoveItemSwapped(iu,u)
      call RemoveItem(iu)
      call UnitAddItemByIdSwapped(ul[(l+1)],u) 
    else
      call PlayerMsg(p,&quot;|cFF0000FFNote:|r You need more gold to upgrade this item&quot;)
    endif
  endif
  endloop 
endfunction
//===========================================================================
function InitTrig_UpgradeBasicLaserJASS takes nothing returns nothing
    set gg_trg_UpgradeBasicLaserJASS = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_UpgradeBasicLaserJASS, EVENT_PLAYER_UNIT_USE_ITEM )
    call TriggerAddAction( gg_trg_UpgradeBasicLaserJASS, function Trig_UpgradeBasicLaserJASS_Actions )
endfunction


Test Map:
 

Attachments

  • ItemUpgrader - System Testmapv2.w3x
    22.7 KB · Views: 344
S

Storm

Guest
[System] My Item Stack

My Item Stack​
This is triggered when a unit picks up or buys an item with the classification "Purchasable," but does not work if the inventory is full. Certain permanent items, such as "Claws of Attack", are not meant to be stacked, and may bug you game up if you try to stack them :p

NAME THE TRIGGER "Stack Items" FOR THIS TO WORK IF YOU ARE GOING TO COPY + PASTE!!!

JASS:

function Trig_Stack_Items takes nothing returns nothing
local integer a = 0
local item i = GetManipulatedItem()
local item m
if (GetItemType(i) != ITEM_TYPE_PERMANENT) then
    loop
    exitwhen a &gt; 5
        set m = UnitItemInSlot(GetTriggerUnit(),a)
        if (( GetItemTypeId(m) == GetItemTypeId(i)) and (m != i)) then
        call SetItemCharges(m,(GetItemCharges(m) + GetItemCharges(i)))
        call RemoveItem(i)
        endif
    set a = a + 1
    endloop
endif
endfunction

//===========================================================================
function InitTrig_Stack_Items takes nothing returns nothing
set gg_trg_Stack_Items = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Stack_Items, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_Stack_Items, function Trig_Stack_Items )
endfunction

Edit: Changed functions. Updated Map file.
If there's anything wrong with this trigger please tell.
Demo:
 

Attachments

  • ItemStacking.w3x
    12.4 KB · Views: 320
Status
Not open for further replies.
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top