 |   |  |  |
| "Graveyard" Resources which were not approved are moved to this section. |
12-30-2007, 07:08 AM
|
#1 (permalink)
|
Old and Wise Member......
Join Date: Jan 2007
Posts: 41
|
[vjass] ORTS - Orc_Tamer's Recipe System 2.0
Here a basic script using structs and methods to combine items into 1.
Changelog:
Version: 2.0 (Added New Function Arguments and Optimized Coding)
Version: 1.0 (Fixed minor bug)
//===========================================================================// OTRS (Orc_Tamer's Recipe System)// Recipe System that allows you to make recipe items for you easier.// Author: Orc_Tamer// Date: 01.December.2007//// How to implement:// Requires JASS NewGen World Editor// Just copy this trigger to your map.//===========================================================================library RecipeFunction struct RecipeItems integer item0_id integer item1_id integer item2_id integer item3_id integer item4_id integer item5_id integer item6_id integer item7_id unit u item item1 = null item item2 = null item item3 = null item item4 = null item item5 = null item item6 = null method CheckItems2 takes nothing returns nothing local integer this_id local integer i = 0 loop set this_id = GetItemTypeId (UnitItemInSlot (.u, i )) if this_id == .item0_id then set .item1 = UnitItemInSlot (.u, i ) elseif this_id == .item1_id then set .item2 = UnitItemInSlot (.u, i ) endif set i = i + 1 exitwhen i >= bj_MAX_INVENTORY endloop if .item1 != null and .item2 != null then call RemoveItem (.item1 ) call RemoveItem (.item2 ) call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u, "overhead")) call UnitAddItemById (.u, .item2_id ) set .item1 = null set .item2 = null set .u = null endif endmethod method CheckItems3 takes nothing returns nothing local integer this_id local integer i = 0 loop set this_id = GetItemTypeId (UnitItemInSlot (.u, i )) if this_id == .item0_id then set .item1 = UnitItemInSlot (.u, i ) elseif this_id == .item1_id then set .item2 = UnitItemInSlot (.u, i ) elseif this_id == .item2_id then set .item3 = UnitItemInSlot (.u, i ) endif set i = i + 1 exitwhen i >= bj_MAX_INVENTORY endloop if .item1 != null and .item2 != null and .item3 != null then call RemoveItem (.item1 ) call RemoveItem (.item2 ) call RemoveItem (.item3 ) call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u, "overhead")) //adds a special effect call UnitAddItemById (.u, .item3_id ) set .item1 = null set .item2 = null set .item3 = null set .u = null endif endmethod method CheckItems4 takes nothing returns nothing local integer this_id local integer i = 0 loop set this_id = GetItemTypeId (UnitItemInSlot (.u, i )) if this_id == .item0_id then set .item1 = UnitItemInSlot (.u, i ) elseif this_id == .item1_id then set .item2 = UnitItemInSlot (.u, i ) elseif this_id == .item2_id then set .item3 = UnitItemInSlot (.u, i ) elseif this_id == .item3_id then set .item4 = UnitItemInSlot (.u, i ) endif set i = i + 1 exitwhen i >= bj_MAX_INVENTORY endloop if .item1 != null and .item2 != null and .item3 != null and .item4 != null then call RemoveItem (.item1 ) call RemoveItem (.item2 ) call RemoveItem (.item3 ) call RemoveItem (.item4 ) call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u, "overhead")) call UnitAddItemById (.u, .item4_id ) set .item1 = null set .item2 = null set .item3 = null set .item4 = null set .u = null endif endmethod method CheckItems5 takes nothing returns nothing local integer this_id local integer i = 0 loop set this_id = GetItemTypeId (UnitItemInSlot (.u, i )) if this_id == .item0_id then set .item1 = UnitItemInSlot (.u, i ) elseif this_id == .item1_id then set .item2 = UnitItemInSlot (.u, i ) elseif this_id == .item2_id then set .item3 = UnitItemInSlot (.u, i ) elseif this_id == .item3_id then set .item4 = UnitItemInSlot (.u, i ) elseif this_id == .item4_id then set .item5 = UnitItemInSlot (.u, i ) endif set i = i + 1 exitwhen i >= bj_MAX_INVENTORY endloop if .item1 != null and .item2 != null and .item3 != null and .item4 != null and .item5 != null then call RemoveItem (.item1 ) call RemoveItem (.item2 ) call RemoveItem (.item3 ) call RemoveItem (.item4 ) call RemoveItem (.item5 ) call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u, "overhead")) call UnitAddItemById (.u, .item5_id ) set .item1 = null set .item2 = null set .item3 = null set .item4 = null set .item5 = null set .u = null endif endmethod method CheckItems6 takes nothing returns nothing local integer this_id local integer i = 0 loop set this_id = GetItemTypeId (UnitItemInSlot (.u, i )) if this_id == .item0_id then set .item1 = UnitItemInSlot (.u, i ) elseif this_id == .item1_id then set .item2 = UnitItemInSlot (.u, i ) elseif this_id == .item2_id then set .item3 = UnitItemInSlot (.u, i ) elseif this_id == .item3_id then set .item4 = UnitItemInSlot (.u, i ) elseif this_id == .item4_id then set .item5 = UnitItemInSlot (.u, i ) elseif this_id == .item5_id then set .item6 = UnitItemInSlot (.u, i ) endif set i = i + 1 exitwhen i >= bj_MAX_INVENTORY endloop if .item1 != null and .item2 != null and .item3 != null and .item4 != null and .item5 != null and .item6 != null then call RemoveItem (.item1 ) call RemoveItem (.item2 ) call RemoveItem (.item3 ) call RemoveItem (.item4 ) call RemoveItem (.item5 ) call RemoveItem (.item6 ) call DestroyEffect (AddSpecialEffectTarget ("Abilities\\Spells\\Items\\AIem\\AIemTarget.mdl",.u, "overhead")) call UnitAddItemById (.u, .item6_id ) set .item1 = null set .item2 = null set .item3 = null set .item4 = null set .item5 = null set .item6 = null set .u = null endif endmethodendstructfunction Recipe2 takes unit hero, integer i1, integer i2, integer ni returns nothing local RecipeItems IS=RecipeItems.create () set IS.item0_id = i1 set IS.item1_id = i2 set IS.item2_id = ni set IS.u = hero call IS.CheckItems2 () call IS.destroy ()endfunctionfunction Recipe3 takes unit hero, integer i1, integer i2, integer i3, integer ni returns nothing local RecipeItems IS=RecipeItems.create () set IS.item0_id = i1 set IS.item1_id = i2 set IS.item2_id = i3 set IS.item3_id = ni set IS.u = hero call IS.CheckItems3 () call IS.destroy ()endfunctionfunction Recipe4 takes unit hero, integer i1, integer i2, integer i3, integer i4, integer ni returns nothing local RecipeItems IS=RecipeItems.create () set IS.item0_id = i1 set IS.item1_id = i2 set IS.item2_id = i3 set IS.item3_id = i4 set IS.item4_id = ni set IS.u = hero call IS.CheckItems4 () call IS.destroy ()endfunctionfunction Recipe5 takes unit hero, integer i1, integer i2, integer i3, integer i4, integer i5, integer ni returns nothing local RecipeItems IS=RecipeItems.create () set IS.item0_id = i1 set IS.item1_id = i2 set IS.item2_id = i3 set IS.item3_id = i4 set IS.item4_id = i5 set IS.item5_id = ni set IS.u = hero call IS.CheckItems5 () call IS.destroy ()endfunctionfunction Recipe6 takes unit hero, integer i1, integer i2, integer i3, integer i4, integer i5, integer i6, integer ni returns nothing local RecipeItems IS=RecipeItems.create () set IS.item0_id = i1 set IS.item1_id = i2 set IS.item2_id = i3 set IS.item3_id = i4 set IS.item4_id = i5 set IS.item5_id = i6 set IS.item6_id = ni set IS.u = hero call IS.CheckItems6 () call IS.destroy ()endfunctionendlibrary
This is an example you can use:
GUI:
 RecipeGUI   Events   Conditions   Actions    Custom script: call Recipe2(GetTriggerUnit(),'rde1','rde2','rde3')    Custom script: call Recipe3(GetTriggerUnit(),'afac','spsh','ajen','bgst')    Custom script: call Recipe4(GetTriggerUnit(),'ratc','rat6','rat9','bspd','modt')    Custom script: call Recipe5(GetTriggerUnit(),'ofro','olig','oven','ocor','oslo','sor9')    Custom script: call Recipe6(GetTriggerUnit(),'pghe','pgma','pdiv','pomn','pres','pnvu','infs') JASS:
function Trig_RecipeChecking_Actions takes nothing returns nothing call Recipe2 (GetTriggerUnit (), 'rde1', 'rde2', 'rde3') call Recipe3 (GetTriggerUnit (), 'afac', 'spsh', 'ajen', 'bgst') call Recipe4 (GetTriggerUnit (), 'ratc', 'rat6', 'rat9', 'bspd', 'modt') call Recipe5 (GetTriggerUnit (), 'ofro', 'olig', 'oven', 'ocor', 'oslo', 'sor9') call Recipe6 (GetTriggerUnit (), 'pghe', 'pgma', 'pdiv', 'pomn', 'pres', 'pnvu', 'infs')endfunctionfunction InitTrig_RecipeJASS takes nothing returns nothing local trigger t = CreateTrigger () call TriggerRegisterAnyUnitEventBJ ( t, EVENT_PLAYER_UNIT_PICKUP_ITEM ) call TriggerAddAction ( t, function Trig_RecipeChecking_Actions )endfunction
Enjoy :)
Demo Map Added! Check It Out!
__________________
Ahoy! Me Hardies
|
|
|
01-02-2008, 10:57 PM
|
#2 (permalink)
|
User
Join Date: Oct 2006
Posts: 51
|
__________________
-Oninuva
Gamerz-Forum Admin
|
|
|
01-08-2008, 09:24 AM
|
#3 (permalink)
|
Pro Jasser (Really pro)
Join Date: Dec 2007
Posts: 48
|
__________________
call ExecuteFunc("Destroy your brains")
|
|
|
01-18-2008, 09:14 PM
|
#4 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
There's no advantage to use structs here, and it will force people to get JassNewGen. (Maybe that last bit isn't so bad :P)
Also, you could do this easily with an item array, and always having 6 item-id parameters for the recipe function; let people leave unused ones as 0. (And write some wrappers if you're concerned newbs may not get it)
|
|
|
02-06-2008, 11:10 PM
|
#5 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
|
|
|
03-11-2008, 01:55 PM
|
#6 (permalink)
|
User
Join Date: Jan 2007
Posts: 59
|
Quote:
Originally Posted by WildField
Too complex system.....
|
+1
I just dont get why u use vjass if it can be done without it.
And i think it not worth to get it unless u have less then 50 recipe items.
But still gj
|
|
|
03-13-2008, 11:55 PM
|
#7 (permalink)
|
Spell and Map Moderator
The Helpful Personage
Join Date: Jan 2005
Posts: 4,261
|
This system is horriadly unefficent.
The ammount of opperations it runs is past exesive to do something which is simple enough to make oneself.
Basically, it will probably be more efficent (and so better) to use a simple if tree system as this might even hit the opt limate if used improperly.
I can not deny that it is a nice script, just it is not the most efficent for its task.
|
|
|
08-01-2008, 07:09 AM
|
#8 (permalink)
|
iRawr
Join Date: Dec 2005
Posts: 8,349
|
Graveyarded due to lack of activity on the part of the author.
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|  |  |  |  |   |  |
|