- Joined
- Feb 11, 2008
- Messages
- 809
A year or two ago i made my first VJASS system ever and sadly i bombed it lol but ive went back and redone alot of the system i just need help making Table by Bribe an optional system to be used and if someone could take a look at my code or even point me to a tutorial on how to make it optional i would like to get it approved.
as you can see its already a lot cleaner than the previous system just need a little more help
heres link to bribes NewTable: http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/
JASS:
library MountSystem
//=============================================================================
//
// Mount System v1.1
// by CHA_Owner
// with help from The_Witcher
//
// ~~~~ HOW TO USE ~~~~
//
// 1) Register all your Mounts by using;
// type ID
// call MountSystem.AddMount('H00A')
//
// 2) To mount a unit just use;
// u = your unit target = target unit mdl = your unit model path
// call MountSystem.MountUnit(u, target, mdl)
//
// 3) Then to dismount a unit you can use;
// u = unit you are currently mounted to
// call MountSystem.DismountUnit(u)
//
// 4) To find out if any units are currently mounted use;
// boolean
// call MountSystem.IsAnyUnitMounted()
//
// To find out if a certain unit is currently mounted use;
// u = unit to check if mounted
// call MountSystem.IsUnitMounted(u)
// this also returns boolean.
//
// 5) To find out how many units are currently mounted use;
// integer
// call MountSystem.HowManyUnitsMounted()
//
// ~~~~ HOW IT WORKS ~~~~
//
// This system simply creates a special effect on the chosen attachment
// point of the target unit of your units model, so it appears as if you have
// mounted the unit, then once you dismount the unit it destroys the special
// effect and returns the mount to its previous state.
//
// ~~~~ REQUIREMENTS ~~~~
//
// JNGP
// Basic Jass Knowledge
//
// ~~~~ OPTIONAL ~~~~
//
// Table library - made by Bribe
//
//==============================================================================
//============================= Setup =======================================
//==============================================================================
//
globals
private integer MountOwningPlayer = PLAYER_NEUTRAL_PASSIVE
private string AttachmentPoint = "chest mount"
endglobals
//
//==============================================================================
//========================== MountSystem ====================================
//==============================================================================
struct MountSystem extends array
private static hashtable table
readonly static integer MountedUnits
static method IsRegistered takes integer typ returns boolean
return LoadBoolean(.table, 0, typ)
endmethod
static method AddMount takes integer typ returns nothing
call SaveBoolean(.table, 0, typ, true)
endmethod
static method IsAnyUnitMounted takes nothing returns boolean
return .MountedUnits > 0
endmethod
static method IsUnitMounted takes unit u returns boolean
return HaveSavedHandle(.table, GetHandleId(u), 0)
endmethod
static method HowManyUnitsMounted takes nothing returns integer
return .MountedUnits
endmethod
static method MountUnit takes unit u, unit target, string mdl returns nothing
local player p = GetOwningPlayer(u)
local integer i = GetHandleId(target)
if .IsRegistered(GetUnitTypeId(target)) then
//If the unit is already mounted then dismount first.
if .IsUnitMounted(u) then
call .DismountUnit(u)
endif
//Store new rider information and apply effects.
call SaveUnitHandle(.table, i, 0, u)
call ShowUnit(u, false)
call SaveEffectHandle(.table, i, 1, AddSpecialEffectTarget(mdl, target, AttachmentPoint))
call SetUnitOwner(target, p, true)
//Increase number of total riders.
set .MountedUnits = .MountedUnits + 1
else
call BJDebugMsg("This unit is not registered")
endif
set p = null
endmethod
static method DismountUnit takes unit u returns nothing
local player p = GetOwningPlayer(u)
local integer i = GetHandleId(u)
local unit ou = LoadUnitHandle(.table, i, 0)
if .IsUnitMounted(u) then
//Remove effect and unhide the unit.
call DestroyEffect(LoadEffectHandle(.table, i, 1))
call SetUnitPosition(ou, GetUnitX(u), GetUnitY(u))
call SetUnitFacing(ou, GetUnitFacing(u))
call ShowUnit(ou, true)
call SetUnitOwner(u, Player(MountOwningPlayer), true)
//Clean up the hashtable data.
call FlushChildHashtable(.table, i)
//Decrease number of total riders.
set .MountedUnits = .MountedUnits - 1
else
call BJDebugMsg("This unit is not mounted")
endif
set p = null
set ou = null
endmethod
private static method onInit takes nothing returns nothing
//onInit method gets executed on loading screen.
set .table = InitHashtable()
set .MountedUnits = 0
endmethod
endstruct
endlibrary
as you can see its already a lot cleaner than the previous system just need a little more help
heres link to bribes NewTable: http://www.hiveworkshop.com/forums/jass-resources-412/snippet-new-table-188084/
Last edited: