• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

ObjectEditing Packages

Status
Not open for further replies.
Level 23
Joined
Jan 1, 2009
Messages
1,610
So as you may or may not know, WurstScript does/will support creating Object-Editor Objects via code.
I started making some very small prototypes of how it will look and you can comment on the design.

JASS:
package SpellPreset
import public AbilityObjEditing


public class SpellPreset extends AbilityDefinition
	int lvl
	
	construct(string newAbilityId, string origAbilityId, int lvls)
		super(newAbilityId, origAbilityId)
		setLevels(lvls)
		this.lvl = lvls
		
	function setIcon(string name)
		string s = "ReplaceableTextures\\CommandButtons\\" + name
		if not name.endsWith(".blp")
			s += ".blp"

		setIconResearch(s)
		setIconNormal(s)

JASS:
package ChannelSpellPreset
import public SpellPreset

constant string CHANNEL_ID = "ANcl"

public enum Option
	VISIBLE
	TARGETIMAGE
	PHYSICALSPELL
	UNIVERSALSPELL
	UNIQUECAST
	
public enum Targettype
	//instant == standard
	PTARGET
	UTARGET
	PUTARGET
	
constant int visibleval = 1
constant int targetimageval = 2
constant int physicalspellval = 4
constant int universalspellval = 8
constant int uniquecastval = 16
	

	
public function Targettype.toString() returns string
	switch this
		case Targettype.PTARGET
			return "Point Target"
		case Targettype.UTARGET
			return "Unit Target"
		case Targettype.PUTARGET
			return "Point & Unit Target"
	return ""

public class ChannelSpellPreset extends SpellPreset
	boolean VISIBLE
	boolean TARGETIMAGE
	boolean PHYSICALSPELL
	boolean UNIVERSALSPELL
	boolean UNIQUECAST
	int optionval = 0
	

	
	construct(string newId, int lvls)
		super(newId, CHANNEL_ID, lvls)
		
	function setDisablesOther(boolean flag)
		int v = 0
		if flag
			v = 1 
		for i = 1 to lvl
			def.setLvlDataInt("Ncl5", i, 5, v)

			
	function setOption(Option opt, boolean flag)
		switch opt
			case Option.VISIBLE
				VISIBLE = flag
				if VISIBLE
					optionval+=visibleval
				else
					optionval-=visibleval
			case Option.TARGETIMAGE
				TARGETIMAGE = flag
				if VISIBLE
					optionval+=targetimageval
				else
					optionval-=targetimageval
			case Option.PHYSICALSPELL
				PHYSICALSPELL = flag
				if VISIBLE
					optionval+=physicalspellval
				else
					optionval-=physicalspellval
			case Option.UNIVERSALSPELL
				UNIVERSALSPELL = flag
				if VISIBLE
					optionval+=universalspellval
				else
					optionval-=universalspellval
			case Option.UNIQUECAST
				UNIQUECAST = flag
				if VISIBLE
					optionval+=uniquecastval
				else
					optionval-=uniquecastval

		for i = 1 to lvl
			def.setLvlDataInt("Ncl3", i, 3, optionval)

			
		
	function setTargetType(Targettype ttype)
		int typ = 0
		switch ttype
			case Targettype.PTARGET
				typ = 1
			case Targettype.UTARGET
				typ = 2
			case Targettype.PUTARGET
				typ = 3
				
		for i = 1 to lvl
			def.setLvlDataInt("Ncl2", i, 2, typ)
			
	function setFollowThroughTime(real time)
		for i = 1 to lvl
			def.setLvlDataUnreal("Ncl1", lvl, 1, 0.0)

As you can see it follows the Object Oriented approach. Of course these classes will not be instantiated in the game-code, but only used at compiletime.

Another nifty thing that follows up on the objects-in-code stuff is generating tooltips (for all you lazy donkeys) from the data of the spell-class
JASS:
package SpellDesignConfig
import ChannelSpellPreset

var TITLECOLOR = "|cff3B97D3"
var TITLE_COOLDOWN = "Cooldown:"
var TITLE_TTYPE = "Target Type:"
var TITLE_EFFECT = "Effect:"

public function generateTooltipNormal(string spellName, string hotkey, int lvl) returns string
	return spellName + " - Level " + lvl.toString() + " [|cffFFCC00" + hotkey + "|r]"
	
public function generateTooltipExtended(int cooldown, Targettype ttype, real aoe, string description ) returns string
	var s = ""
	if cooldown > 0
		s += TITLECOLOR + TITLE_COOLDOWN + "|r " + cooldown.toString() + "|n"
	
	if aoe > 0
		if ttype == Targettype.PTARGET
			s += TITLECOLOR + TITLE_TTYPE + "|r " + ttype.toString()
	else
		s += TITLECOLOR + TITLE_TTYPE + "|r " + ttype.toString()
		
	

	return s

So example usage would be
JASS:
	var spell = new ChannelSpellPreset("test", 4)
	spell.setName("Flame Fist")
	spell.setIcon("Fist.blp")
	for i = 0 to 3
		spell.setCooldown(i, 8.-i)
	spell.setCastRange(450)
	// Generating tooltips from input data (cooldown, targettype, etc.) and adding it to the object
	spell.generateTooltips()
 
Level 23
Joined
Jan 1, 2009
Messages
1,610
Looks excellent.

Some q's:
  • Can you read data from an existing object? (e.g. icon of abili
    ty 'Arav')
  • Can you write code as wurst through the object editing code? (e.g. write a global that is assigned to an object's level count, or writing some field to a hashtable for easy databasing)

The code of existing objects is generated And objects can be based on custom objects.
All operations that are supported ( implemented in java ) ccan be used at compiletime
 
Status
Not open for further replies.
Top