NEED RPG HELP

For fulfilled maps that most likely don't work on the latest patch (1.24 or later).

Moderator: Cheaters

User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: NEED RPG HELP

Post by Xantan »

Shafter wrote:can u give me a set up trigger for that function? im not good with variables..
I'd probably stop working on an rpg then. just imo
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: NEED RPG HELP

Post by Aero »

There's a few ways to do this--all involving triggers.

Easiest way is to make all weapons Campaign type, shields Miscellaneous type (They can be whichever item types you want, but they all have to be the same)

For the trigger...

Create a new trigger called "OnlyOne" <-- Must be exactly as seen
Click the trigger, then go to the menus at top and hit "Edit" then "Convert to custom text"

Next, delete all the custom script in the trigger and put in

Code: Select all

//CONFIGURATION
constant function ShieldType takes nothing returns itemtype
return ITEM_TYPE_CAMPAIGN  //Replace "CAMPAIGN" with your shield type ie: "ARTIFACT" for example
endfunction

constant function WeaponType takes nothing returns itemtype
return ITEM_TYPE_PERMANENT //Replace "MISCELLANEOUS" with your weapon type ie: "PERMANENT"
endfunction                //Try not to use "MISCELLANEOUS" --> Seems to cause errors

constant function WeaponErrorMessage takes nothing returns string
return "You're already wielding a weapon!" //Replace the message in "" with the desired message
endfunction

constant function ShieldErrorMessage takes nothing returns string
return "You're already wielding a shield!" //Replace the message in "" with the desired message
endfunction
//ENDCONFIGURATION

function SimulateError takes player p, string s returns nothing
local sound e=CreateSoundFromLabel("InterfaceError",false,false,false,10,10)
if GetLocalPlayer()==p then
if (s!="") and (s!=null) then
call ClearTextMessages()
call DisplayTimedTextToPlayer(p,0.52,-1.00,2.00,"|cffffcc00"+s+"|r")
endif
call StartSound(e)
endif
call KillSoundWhenDone(e)
set e=null
endfunction

function CheckInventory takes nothing returns boolean
return GetItemType(GetManipulatedItem())==ShieldType() or GetItemType(GetManipulatedItem())==WeaponType()
endfunction

function DenyWeaponShield takes nothing returns nothing
local unit u=GetTriggerUnit()
local item i=GetManipulatedItem()
local itemtype it=GetItemType(i)
local integer l=0
local item q
loop
exitwhen l>5
set q=UnitItemInSlot(u,l)
if GetItemType(UnitItemInSlot(u,l))==it and i!=q then
call SetItemPosition(i,GetUnitX(u),GetUnitY(u)) 
if it==ShieldType() then
call SimulateError(GetOwningPlayer(u),ShieldErrorMessage())
else
call SimulateError(GetOwningPlayer(u),WeaponErrorMessage())
endif
endif
set l=l+1
endloop
set u=null
set i=null
set it=null
endfunction

function InitTrig_OnlyOne takes nothing returns nothing
set gg_trg_OnlyOne=CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_OnlyOne,EVENT_PLAYER_UNIT_PICKUP_ITEM)
call TriggerAddCondition(gg_trg_OnlyOne,Condition(function CheckInventory))
call TriggerAddAction(gg_trg_OnlyOne,function DenyWeaponShield)
endfunction
Use the configuration settings at the top to set it up.
Enjoy
User avatar
Xantan
Honorary wc3edit.net Traitor
Posts: 2507
Joined: February 1st, 2007, 4:11 pm
Location: NEVADA

Re: NEED RPG HELP

Post by Xantan »

Nice GUI Aero. :)
User avatar
Aero
Forum Staff
Posts: 829
Joined: January 28th, 2007, 8:10 pm
Title: JASS Programmer
Location: Canada

Re: NEED RPG HELP

Post by Aero »

GUI is teh nooblar

I couldn't help it