(Keeps Hive Alive)
Go Back   The Hive Workshop - A Warcraft III Modding Site > Warcraft III Modding > Requests

Requests Need a resource done for your project? Post your request here, however we cannot guarantee that your request may be answered.

Closed Thread
 
LinkBack Thread Tools Display Modes
Old 12-09-2007, 12:09 AM   #1 (permalink)

Shame on me
 
Join Date: Oct 2006
Posts: 323

Cheeder has little to show at this moment (50)


Need EXPERT help for creep revival system

***PLEASE MOVE THIS TO REQUESTS SECTION***
Thanks


Hello. I need a revival system for Neutral units that's a bit more complex than any revival system out there..

***At the beginning of the map i need to place 48 random Neutral units in random spots within a rect.
There can be no more than 48 Neutral units on the map at a time.
Every 20 seconds, how ever many Neutral units are missing from the 48, a random number of random creeps is generated and placed randomly within the rect to eqal 48 creeps.

Not only that.. haha.. but every 40 seconds a random number between 5 and 20 of a random selection of the Neutral units needs to be "displaced" - by removing them from the rect/game, and allow the 20-second revival timer to replenish the map.


This may be a crucial factor so i am adding it.. Acturally, i know it is a crucial factor..

The neutral units will all be using the same name, and will look the same, but they serve as ability gains. If a user character comes within a very short range of these nuetral units, they gain modifications (spped, turn-rate, etc) or abilities. Once they come within the range of the neutral unit, the neutral unit will be "collected" - by removing the unit and then adding a mod/ability.

*** The units may not have to be different if the following is doable.

So i guess the only real way to do this is by having a bunch of Action triggers for the mods/abilities. Then if a player-character comes within range, remove neutral unit from game and somehow apply/"run" random trigger from 'trigger-group?' (using variables) for triggering unit?


I could not finish my map without this. So, please, dedicated scripters!

EDIT: Yar, no experts here, me matey!?!

(PLEASSSSSSEE!)

Last edited by Cheeder; 12-09-2007 at 11:05 PM..
Cheeder is offline  
Old 12-12-2007, 05:27 PM   #2 (permalink)
 
Silvenon's Avatar

BBoy Silv
 
Join Date: Nov 2006
Posts: 866

Silvenon is on a distinguished road (81)Silvenon is on a distinguished road (81)


I will see what I can do. Is Jass allowed?

Don't go crazy now, I'm not promising anything.
__________________
PurgeandFire111: Then you can delete the sound and whala... You have the label,filepath, and other parameters.
Silvenon: It's voila, not whala, you... stupidhead :)
PurgeandFire111: Yeah, I was in a rush. =( *cry*
Herman: Voila is an instrument that I quit playing in 6th grade, whala works just fine if not better
PurgeandFire111: No, viola is an instrument. Stupidhead... =D
Silvenon is offline  
Old 12-13-2007, 02:18 AM   #3 (permalink)

User
 
Join Date: Feb 2006
Posts: 261

aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)


I have a script for you. If it looks complicated, that's cuz it is. The problem is that blizz made the "TriggerRegisterUnitInRange" ("Unit comes Within Range of Unit" in GUI) only able to take single units, and the parameter only accepts either pre-existing units on the map (gg_unit_...) or units returned by functions. So basically for every creep unit you add to your map you have to add another trigger SPECIFICALLY for that creep. (Can't just add events to one trigger, mainly because there's no way to remove/destroy events and after too many events get added the game lags.)

The following script makes several assumptions:

1. You only have ONE type of creep unit
2. Creeps all belong to ONE player
3. Bonuses are in the forms of abilities
4. Creeps respawn in one continuous rectangular area (otherwise known as a rect)

If any of these assumptions are wrong, make a reply and I'll do my best to fix the script.

IMPORTANT: The script requires you to have the vJass preprocessor to compile it. If you don't have vJass when you save your map it will give you a bunch of syntax errors and it might crash WE. If you don't have vJass, get it by dling the Jass NewGen pack by Vexorian from wc3campaigns.net. If you don't want to use vJass, reply and I'll make the script old-fashioned WE-friendly.

library CreepSystem

struct creepsystemdata
    unit creep
    triggeraction action
endstruct

globals
    creepsystemdata creepdata = 0
    rect respawnrect = null
    timer creeptimer = CreateTimer()
    player creepplayer = Player(16) //Change this player to the player you want controlling the creeps
    integer creepcount = 0
    integer creepid = 0 //Change this to the custom data code of your creep unit
    real creeprange = 0 //Change this to the range at which you want the Addbonus trigger to fire
//(the range the player-controlled chars need to be within a creep unit for the creep to be removed and the chars given the bonuses)
    integer array creepbonusid = 0
    integer creepbonustotal = 0
    integer array playerunitid = 0
    integer playerunittotal = 0
endglobals

private function H2I takes handle h returns integer
    return h
    return 0
endfunction

function CreepSystem_Create takes player p, integer id, real x, real y returns unit
    set bj_lastCreatedUnit = CreateUnit( p, id, x, y, GetRandomReal( 1, 360 ) )
    return bj_lastCreatedUnit
endfunction

function CreepSystem_CheckPlayerId takes integer id returns boolean
    local integer counter = 0
    loop
        exitwhen ( counter > playerunittotal )
        if ( id == playerunitid[counter] ) then
            return true
        endif
        set counter = counter + 1
    endloop
    return false
endfunction

function CreepSystem_AddBonus takes nothing returns nothing
    local trigger t = GetTriggeringTrigger()
    local unit u = GetTriggerUnit()
local integer id = GetUnitTypeId( u )
    local creepsystemdata temp = GetStoredInteger( udg_CreepVars, I2S(H2I(t)), "temp" )
    if ( CreepSystem_CheckPlayerId( id ) ) then
        call RemoveUnit( temp.creep )
        call UnitAddAbility( u, creepbonusid[ GetRandomInt( 0, creepbonustotal - 1 ) ] )
        call TriggerRemoveAction( t, temp.action )
        call temp.destroy()
        call DestroyTrigger( t )
    endif
    set t = null
endfunction

function CreepSystem_Respawn takes nothing returns nothing
    local trigger t
    local real x = GetRandomReal( GetRectMinX( respawnrect ), GetRectMaxX( respawnrect ) )
local real y = GetRandomReal( GetRectMinY( respawnrect ), GetRectMaxY( respawnrect ) )
    if ( creepcount < 48 ) then
        set t = CreateTrigger()
        call TriggerRegisterUnitInRange( t, CreepSystem_Create( creepplayer, creepid, x, y ), creeprange, null )
        set temp.action = TriggerAddAction( t, function CreepSystem_AddBonus )
        set temp.creep = bj_lastCreatedUnit
        call StoreInteger( udg_CreepVars, I2S(H2I(t)), "temp", temp )
        set creepcount = creepcount + 1
set t = null
    endif
endfunction

function CreepSystem_BonusInit takes nothing returns nothing
    set creepbonusid[0] = 'A000' //Change these to the custom data codes that match the bonus abils in your map
    set creepbonusid[1] - 'A001'
set creepbonusid[2] = 'A002'
    //Add more abilities if you wish
    set creepbonustotal = 3 //Set this to the total number of abilities defined above
endfunction

function CreepSystem_PlayerInit takes nothing returns nothing
    set playerunitid[0] = 'H000' //Change these to the custom data codes that match the player-controlled units that you want to be able to get bonuses
    set playerunitid[1] = 'H001'
    set playerunitid[2] = 'H002'
    set playerunittotal = 3 //Set this to the total number of units defined above
endfunction

function CreepSystem_Init takes nothing returns nothing
    local trigger t
    local real x = GetRandomReal( GetRectMinX( respawnrect ), GetRectMaxX( respawnrect ) )
    local real y = GetRandomReal( GetRectMinY( respawnrect ), GetRectMaxY( respawnrect ) )
    local creepsystemdata temp = creepsystemdata.create()
    call SetRect( respawnrect, 0, 0, 0, 0 ) //Change the values here to match the region in which you want your creeps to respawn
    call CreepSystem_BonusInit()
    call CreepSystem_PlayerInit()
    loop
        exitwhen ( creepcount > 47 )
        set t = CreateTrigger()
        call TriggerRegisterUnitInRange( t, CreepSystem_Create( creepplayer, creepid, x, y ), creeprange, null )
        set temp.action = TriggerAddAction( t, function CreepSystem_AddBonus )
        set temp.creep = bj_lastCreatedUnit
        call StoreInteger( udg_CreepVars, I2S(H2I(t)), "temp", temp )
        set creepcount = creepcount + 1
        set t = null
    endloop
    call TimerStart( creeptimer, 20, true, function CreepSystem_Respawn )
endfunction

endlibrary

either copy/paste this into your custom script section or copy/paste into a trigger, doesn't matter.

You will need to call the CreepSystem_Init function at Map Initialization. Just make a trigger with event: Map Initialization, change to Custom Script, and type in "call CreepSystem_Init()" in the Trigger Actions function.

Last edited by aznricepuff; 12-13-2007 at 05:11 AM.. Reason: EDIT: Forgot to patch up some minor leaks...it's the little things in life...
aznricepuff is offline  
Old 12-13-2007, 01:51 PM   #4 (permalink)
 
Silvenon's Avatar

BBoy Silv
 
Join Date: Nov 2006
Posts: 866

Silvenon is on a distinguished road (81)Silvenon is on a distinguished road (81)


Nice job! +rep

With vJass he doesn't even have to create a map initialization trigger, he doesn't have to call CreepSystem_Init, because of one library feature you forgot about: initializers.

Just change that top line into:

library CreepSystem initializer CreepSystem_Init
__________________
PurgeandFire111: Then you can delete the sound and whala... You have the label,filepath, and other parameters.
Silvenon: It's voila, not whala, you... stupidhead :)
PurgeandFire111: Yeah, I was in a rush. =( *cry*
Herman: Voila is an instrument that I quit playing in 6th grade, whala works just fine if not better
PurgeandFire111: No, viola is an instrument. Stupidhead... =D
Silvenon is offline  
Old 12-14-2007, 12:24 AM   #5 (permalink)

User
 
Join Date: Feb 2006
Posts: 261

aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)aznricepuff has little to show at this moment (46)


lol thx. completely forgot about those. Prolly shouldn't be writing code and watching TV at the same time.
__________________
  1. Reign of War v1.6
  2. Reign of War II v0.1 (Alpha) - Terrain: 90% Units: 95% Triggers: 95%
aznricepuff is offline  
Old 12-15-2007, 12:01 AM   #6 (permalink)

iRawr
 
Join Date: Dec 2005
Posts: 8,349

PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)PurplePoot is a splendid one to behold (807)

Paired Mapping Contest #4 Winner: Fallen Angel - Lucifer's Keep Respected User: This user has been given the respected user award. Map Development Mini-Contest #1 Winner: Stand of the Elements 

~Moved to requests section.
PurplePoot is online now  
Closed Thread

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[GUI] Tree Revival System [Reviewed: Ralle] underscore Tutorial Submission 13 08-15-2008 12:27 PM
Creep System Pack paskovich Triggers & Scripts 22 01-18-2008 08:00 PM
[Trigger] Creep Revive System & Creep Drops Hawk07 Triggers & Scripts 14 10-16-2007 12:00 PM
Tree Revival System Hero12341234 JASS/AI Scripts Tutorials 0 03-24-2007 02:43 AM

All times are GMT. The time now is 06:59 PM.






Your link here 
Banruptcy | Buy Anything On eBay | Computer Programming Tutorials | Internet Advertising | Mortgage Calculator
Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
Copyright©Ralle