Login
Register
Menu
Home
Forum
JassDoc
Types
Functions
Variables
Help
Chat
Media
Search
Search posts
WC3 JASS.com
"The Jass Vault" plus vJASS and Zinc
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
InjuryEffectScript
Warcraft III:
Maps
Models
Skins
Icons
Spells / Systems
Tools
Tutorials
Snippets
JASS vJASS Spells and Systems
Tutorials
Chat @Discord
vJASS & Zinc Documentation
For the latest documentation about how it works vJASS and Zinc language layers for Warcraft III, please follow these links:
Jasshelper documentation
-
Zinc documentation
-
WC3 Optimizer documentation
InjuryEffectScript
Codes & Snippets
Started by
moyack
Views
1609
Replies
0
Users
1
1
Pages:
1
Go Down
0 Members and 1 Guest are viewing this topic.
moyack
Site Owner
Administrator
Posts:
971
WC3 Models: 20
WC3 Tutorials: 17
WC3 Tools: 19
WC3 Maps: 12
WC3 Skins: 0
WC3 Icons: 1
WC3 Spells: 16
Reputation:
1153
Site Admin - I love fix things
InjuryEffectScript
on:
December 28, 2011, 08:24:44 AM
Category:
Effect
Language:
vJASS
Related Topics or Resources
[Snippet] New Table
by
Bribe
The Jass NewGen Pack (JNGP) 2.0
by
moyack
Injury Effect Script
By moyack. 2009
Ok, after revising this
old resource
, I took the freedom to develop something much more stable, configurable, clean and effective.
This script requires Jass New Gen Pack, and Table (Check related resources) to work properly.
Installation:
Create a new Trigger
Call it properly. like "Injury Effect Script"
Convert it to custom text
Remove the code posted.
Paste the code above
Save the map.
Voila!!! now it works.
As is, it only will use a single effect per race. If you want to add more FXs to any race, you can use this function:
call
SetDamageEffectPath(YOUR_RACE,
"your
\\
effect
\\
path"
)
New feature!!
Now you set custom effects
per unit type
. To do that, these are the commands:
AddBloodType(
"FX
\\
Path"
,
"attach,point"
)
// returns an integer which will identify that Blood type
SetUnitTypeBlood('Unit_ID', BLOOD_TYPE_INDEX)
// sets the Blood type for the unit type
RemoveUnitTypeBlood('Unit_ID')
// removes the Blood type for the unit type
Library Code.
Code: jass
library
InjuryEffectScript
initializer
init
requires
Table
//* configuration part
globals
private
constant
real
dt = 0.5
// check & effect rate...
private
constant
real
Percentage = 0.3
// when unit reach 30% of its hitpoints, it will show blood
private
constant
string
AttachPoint =
"chest"
// defines where's the attachment point of the effects for units
private
constant
string
MechEffect =
"Abilities
\\
Weapons
\\
FlyingMachine
\\
FlyingMachineImpact.mdl"
// sets the "blood" model effect for mechanical units...
endglobals
//* End configuration part.
// Do NOT CHANGE THIS... unless you know what are you doing...
globals
//! textmacro SetGlobals takes Race
private
string
array
$Race$Blood
private
integer
$Race$Index = 0
//! endtextmacro
//! runtextmacro SetGlobals("HUMAN")
//! runtextmacro SetGlobals("ORC")
//! runtextmacro SetGlobals("UNDEAD")
//! runtextmacro SetGlobals("NIGHTELF")
//! runtextmacro SetGlobals("DEMON")
//! runtextmacro SetGlobals("OTHER")
private
group
G =
CreateGroup
()
private
rect
R =
null
endglobals
private
struct
BloodType
static
Table T
string
FX
string
AttPoint
static
method
Add
takes
string
FX,
string
AP
returns
integer
local
BloodType BT = BloodType.
allocate
()
set
BT.FX = FX
set
BT.AttPoint = AP
return
integer
(BT)
endmethod
static
method
SetBlood
takes
integer
id,
integer
BloodT
returns
nothing
set
BloodType.T[id] = BloodT
endmethod
static
method
RemoveBlood
takes
integer
id
returns
nothing
call
BloodType.T.flush(id)
endmethod
endstruct
private
function
DoEffect
takes
nothing
returns
boolean
local
unit
u =
GetFilterUnit
()
if
GetWidgetLife
(u) /
GetUnitState
(u,
UNIT_STATE_MAX_LIFE
) <= Percentage
and
GetWidgetLife
(u) > 0.405
then
if
IsUnitType
(u,
UNIT_TYPE_MECHANICAL
) ==
true
then
call
DestroyEffect
(
AddSpecialEffectTarget
(MechEffect, u,
"chest"
))
return
false
endif
if
BloodType.T.exists(
GetUnitTypeId
(u))
then
call
DestroyEffect
(
AddSpecialEffectTarget
(BloodType(BloodType.T[
GetUnitTypeId
(u)]).FX, u, BloodType(BloodType.T[
GetUnitTypeId
(u)]).AttPoint))
return
false
endif
//! textmacro DoConds takes Race
if
GetUnitRace
(u) == RACE_$Race$
then
call
DestroyEffect
(
AddSpecialEffectTarget
($Race$Blood[
GetRandomInt
(0,$Race$Index)], u, AttachPoint))
return
false
endif
//! endtextmacro
//! runtextmacro DoConds("HUMAN")
//! runtextmacro DoConds("ORC")
//! runtextmacro DoConds("UNDEAD")
//! runtextmacro DoConds("NIGHTELF")
//! runtextmacro DoConds("DEMON")
//! runtextmacro DoConds("OTHER")
endif
return
false
endfunction
private
function
Check
takes
nothing
returns
nothing
call
GroupEnumUnitsInRect
(G, R,
Condition
(
function
DoEffect))
endfunction
//* Public functions
//* Sets the damage effect for a specific race
function
SetDamageEffectPath
takes
race
r,
string
path
returns
nothing
//! textmacro DoCond takes Race
if
r == RACE_$Race$
then
set
$Race$Index = $Race$Index + 1
set
$Race$Blood[$Race$Index] = path
return
endif
//! endtextmacro
//! runtextmacro DoCond("HUMAN")
//! runtextmacro DoCond("ORC")
//! runtextmacro DoCond("UNDEAD")
//! runtextmacro DoCond("NIGHTELF")
//! runtextmacro DoCond("DEMON")
//! runtextmacro DoCond("OTHER")
endfunction
//* Adds a new and custom Blood type effect to the database... it returns the Blood Type index
function
AddBloodType
takes
string
fx,
string
attachpoint
returns
integer
return
BloodType.Add(fx, attachpoint)
endfunction
//* Sets a custom blood effect for a specific unit type...
function
SetUnitTypeBlood
takes
integer
uid,
integer
bloodtype
returns
nothing
call
BloodType.SetBlood(uid, bloodtype)
endfunction
//* Removes to an specific unit type the custom Blood types, it will use instead the ones defined by race...
function
RemoveUnitTypeBlood
takes
integer
uid
returns
nothing
call
BloodType.RemoveBlood(uid)
endfunction
//* End public functions
private
function
init
takes
nothing
returns
nothing
set
BloodType.T = Table.
create
()
set
R =
GetWorldBounds
()
call
SetDamageEffectPath(
RACE_HUMAN
,
"Objects
\\
Spawnmodels
\\
Other
\\
HumanBloodCinematicEffect
\\
HumanBloodCinematicEffect.mdl"
)
call
SetDamageEffectPath(
RACE_ORC
,
"Objects
\\
Spawnmodels
\\
Other
\\
OrcBloodCinematicEffect
\\
OrcBloodCinematicEffect.mdl"
)
call
SetDamageEffectPath(
RACE_UNDEAD
,
"Objects
\\
Spawnmodels
\\
Undead
\\
UndeadBlood
\\
UndeadBloodAbomination.mdl"
)
call
SetDamageEffectPath(
RACE_NIGHTELF
,
"Objects
\\
Spawnmodels
\\
NightElf
\\
NightElfBlood
\\
NightElfBloodArcher.mdl"
)
call
SetDamageEffectPath(
RACE_DEMON
,
"Abilities
\\
Spells
\\
NightElf
\\
Immolation
\\
ImmolationDamage.mdl"
)
call
SetDamageEffectPath(
RACE_OTHER
,
"Objects
\\
Spawnmodels
\\
Undead
\\
UndeadBlood
\\
UndeadBloodNecromancer.mdl"
)
call
TimerStart
(
CreateTimer
(), dt,
true
,
function
Check)
endfunction
endlibrary
Usage example for custom blood types:
Code: jass
scope
TestingTime
initializer
init
globals
private
integer
BLOOD_TYPE_NAGA
// this global variable will store the index of this type of blood
endglobals
//===========================================================================
private
function
init
takes
nothing
returns
nothing
//* Creates a custom blood type, in this case one for nagas
set
BLOOD_TYPE_NAGA = AddBloodType(
"Objects
\\
Spawnmodels
\\
Demon
\\
DemonBlood
\\
DemonBloodPitlord.mdl"
,
"origin"
)
call
SetUnitTypeBlood(
'nwgs'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'nnmg'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'nnsw'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'nsnp'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'nmyr'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'nnrg'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'nhyc'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'nmpe'
, BLOOD_TYPE_NAGA)
call
SetUnitTypeBlood(
'Hvsh'
, BLOOD_TYPE_NAGA)
endfunction
endscope
Changelog:
(23/03/2009): First Release
(24/03/2009): now it works with all the races defined by the WC3 engine. Added a function to add more effects to any race. simplified the code and now it doesn't requires additional libraries.
(05/04/2009): Added the possibility to set a custom blood type per unit type, check the new functions you can use here. Now it requires Table.
«
Last Edit: December 21, 2017, 10:16:45 AM by moyack
»
WC3 Modding Information Center
Print
Pages:
1
Go Up
« previous
next »
WC3 Modding Information Center
Forum
Warcraft (WC3) Modding
Warcraft III Resources
Warcraft III Spells and Systems
Codes & Snippets
InjuryEffectScript
PortaMx-SEF 1.54
|
PortaMx © 2008-2015
,
PortaMx corp.
Search
Username
Password
Always stay logged in
Forgot your password?