Item Equipment System(Jass)

Post Reply
User avatar
Site Admin
Site Admin
Posts: 202
Joined: Sat Sep 15, 2018 1:57 pm
Location: Florida, U.S.A.
Website: http://chaosrealm.co/memberlist.php?mod ... rofile&u=2
Discord: https://discord.gg/BUEZkef
Twitch: https://www.twitch.tv/enalias
Contact:

Item Equipment System(Jass)

#1

Post by Enalias »

What's this system used for?

It is used to prevent heroes to have 2 or more items of the same type.

Code:
Spoiler
Show
//****************************
// Vuen's RPG Item System
// version 1.0
//***************************


function isWeapon takes integer t returns boolean
if t == 'S001' then
elseif t == 'S002' then
elseif t == 'STF1' then
elseif t == 'STF2' then
elseif t == 'S003' then
elseif t == 'STF3' then
elseif t == 'S004' then
elseif t == 'S005' then
else
return false
endif
return true
endfunction

function isArmor takes integer t returns boolean
if t == 'A001' then
elseif t == 'A002' then
elseif t == 'A003' then
elseif t == 'A004' then
elseif t == 'A005' then
else
return false
endif
return true
endfunction

function isHelmet takes integer t returns boolean
if t == 'H001' then
elseif t == 'H002' then
elseif t == 'H003' then
elseif t == 'H004' then
else
return false
endif
return true
endfunction

function isShield takes integer t returns boolean
if t == 'SH01' then
elseif t == 'SH02' then
elseif t == 'SH03' then
else
return false
endif
return true
endfunction

function isGloves takes integer t returns boolean
if t == 'MAN1' then
elseif t == 'MAN2' then
elseif t == 'MAN3' then
elseif t == 'MAN4' then
elseif t == 'MAN5' then
elseif t == 'MAN6' then
else
return false
endif
return true
endfunction


function isBoots takes integer t returns boolean
if t == 'BOT0' then
elseif t == 'BOT1' then
elseif t == 'BOT2' then
else
return false
endif
return true
endfunction

function ShowItemError takes string str returns nothing
call DisplayTextToForce( GetForceOfPlayer(GetOwningPlayer(GetManipulatingUnit())), "|cffffcc00" + str + "|r")
endfunction

function Trig_ItemSystem_Actions takes nothing returns nothing
local integer it
local integer ut
local integer i
set it = GetItemTypeId(GetManipulatedItem())
set ut = GetUnitTypeId(GetManipulatingUnit())

if isWeapon(it) then
set i = 1
loop
exitwhen i > UnitInventorySizeBJ(GetManipulatingUnit())
if isWeapon(GetItemTypeId(UnitItemInSlotBJ(GetManipulatingUnit(), i))) and not(UnitItemInSlotBJ(GetManipulatingUnit(), i) == GetManipulatedItem()) then
call UnitRemoveItemFromSlotSwapped( i, GetManipulatingUnit() )
call UnitDropItemSlotBJ( GetManipulatingUnit(), GetManipulatedItem(), i )
call ShowItemError("You may only carry one Weapon at a time.")
endif
set i = i + 1
endloop
endif

if isArmor(it) then
set i = 1
loop
exitwhen i > UnitInventorySizeBJ(GetManipulatingUnit())
if isArmor(GetItemTypeId(UnitItemInSlotBJ(GetManipulatingUnit(), i))) and not(UnitItemInSlotBJ(GetManipulatingUnit(), i) == GetManipulatedItem()) then
call UnitRemoveItemFromSlotSwapped( i, GetManipulatingUnit() )
call UnitDropItemSlotBJ( GetManipulatingUnit(), GetManipulatedItem(), i )
call ShowItemError("You may only carry one Armor at a time.")
endif
set i = i + 1
endloop
endif

if isHelmet(it) then
set i = 1
loop
exitwhen i > UnitInventorySizeBJ(GetManipulatingUnit())
if isHelmet(GetItemTypeId(UnitItemInSlotBJ(GetManipulatingUnit(), i))) and not(UnitItemInSlotBJ(GetManipulatingUnit(), i) == GetManipulatedItem()) then
call UnitRemoveItemFromSlotSwapped( i, GetManipulatingUnit() )
call UnitDropItemSlotBJ( GetManipulatingUnit(), GetManipulatedItem(), i )
call ShowItemError("You may only carry one Helmet at a time.")
endif
set i = i + 1
endloop
endif

if isShield(it) then
set i = 1
loop
exitwhen i > UnitInventorySizeBJ(GetManipulatingUnit())
if isShield(GetItemTypeId(UnitItemInSlotBJ(GetManipulatingUnit(), i))) and not(UnitItemInSlotBJ(GetManipulatingUnit(), i) == GetManipulatedItem()) then
call UnitRemoveItemFromSlotSwapped( i, GetManipulatingUnit() )
call UnitDropItemSlotBJ( GetManipulatingUnit(), GetManipulatedItem(), i )
call ShowItemError("You may only carry one Shield at a time.")
endif
set i = i + 1
endloop
endif

if isGloves(it) then
set i = 1
loop
exitwhen i > UnitInventorySizeBJ(GetManipulatingUnit())
if isGloves(GetItemTypeId(UnitItemInSlotBJ(GetManipulatingUnit(), i))) and not(UnitItemInSlotBJ(GetManipulatingUnit(), i) == GetManipulatedItem()) then
call UnitRemoveItemFromSlotSwapped( i, GetManipulatingUnit() )
call UnitDropItemSlotBJ( GetManipulatingUnit(), GetManipulatedItem(), i )
call ShowItemError("You may only carry one pair of Gloves at a time.")
endif
set i = i + 1
endloop
endif

if isBoots(it) then
set i = 1
loop
exitwhen i > UnitInventorySizeBJ(GetManipulatingUnit())
if isBoots(GetItemTypeId(UnitItemInSlotBJ(GetManipulatingUnit(), i))) and not(UnitItemInSlotBJ(GetManipulatingUnit(), i) == GetManipulatedItem()) then
call UnitRemoveItemFromSlotSwapped( i, GetManipulatingUnit() )
call UnitDropItemSlotBJ( GetManipulatingUnit(), GetManipulatedItem(), i )
call ShowItemError("You may only carry one pair of Boots at a time.")
endif
set i = i + 1
endloop
endif
endfunction

//===========================================================================
function InitTrig_ItemSystem takes nothing returns nothing
set gg_trg_ItemSystem = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_ItemSystem, EVENT_PLAYER_UNIT_PICKUP_ITEM )
call TriggerAddAction( gg_trg_ItemSystem, function Trig_ItemSystem_Actions )
endfunction
How to import?

-Copy the trigger and paste it in your map.
-This trigger is set for my map so you will have to create new items and replace the ID's.
Spoiler
Show
Image
Here's an example on how to delete a class:
Spoiler
Show
ImageImage
How to create a new class?

Create something like this above the ShowitemError function:
Spoiler
Show
Image
Then something like this below it:
Spoiler
Show
You do not have the required permissions to view the files attached to this post.
Post Reply

Return to “Systems”